AllJoyn/Samples/BACnetAdapter/bacnet-stack-0.8.2/demo/handler/h_cov.c
static int cov_address_add(
    BACNET_ADDRESS * dest)
{
    int index = -1;
    unsigned i = 0;
    bool found = false;
    bool valid = false;
    BACNET_ADDRESS *cov_dest = NULL;

    if (dest) {
        for (i = 0; i < MAX_COV_ADDRESSES; i++) {
            valid = COV_Addresses[i].valid;
            if (valid) {
                cov_dest = &COV_Addresses[i].dest;
                found = bacnet_address_same(dest, cov_dest);
                if (found) {
                    index = i;
                    break;
                }
            }
        }
        if (!found) {
            /* find a free place to add a new address */
            for (i = 0; i < MAX_COV_ADDRESSES; i++) {
                valid = COV_Addresses[i].valid;
                if (!valid) {
                    index = i;
                    cov_dest = &COV_Addresses[i].dest;
                    bacnet_address_copy(cov_dest, dest);
                    COV_Addresses[i].valid = true;
                    break;
                }
            }
        }
    }

    return index;
}
/**
* Adds the address to the list of COV addresses
*
* @param  dest - address to be added if there is room in the list
*
* @return index number 0..N, or -1 if unable to add
*/
Adds the address to the list of COV addresses
Adds the address to the list of COV addresses
static int cov_address_add(
    BACNET_ADDRESS * dest)
{
    int index = -1;
    unsigned i = 0;
    bool found = false;
    bool valid = false;
    BACNET_ADDRESS *cov_dest = NULL;
    if (dest) {
        for (i = 0; i < MAX_COV_ADDRESSES; i++) {
            valid = COV_Addresses[i].valid;
            if (valid) {
                cov_dest = &COV_Addresses[i].dest;
                found = bacnet_address_same(dest, cov_dest);
                if (found) {
                    index = i;
                    break;
                }
            }
        }
        if (!found) {
            for (i = 0; i < MAX_COV_ADDRESSES; i++) {
                valid = COV_Addresses[i].valid;
                if (!valid) {
                    index = i;
                    cov_dest = &COV_Addresses[i].dest;
                    bacnet_address_copy(cov_dest, dest);
                    COV_Addresses[i].valid = true;
                    break;
                }
            }
        }
    }
    return index;
}
static int cov_address_add ( BACNET_ADDRESS * dest ) { int index = -1 ; unsigned i = 0 ; bool found = false ; bool valid = false ; BACNET_ADDRESS * cov_dest = NULL ; if ( dest ) { for ( i = 0 ; i < MAX_COV_ADDRESSES ; i ++ ) { valid = COV_Addresses [ i ] . valid ; if ( valid ) { cov_dest = & COV_Addresses [ i ] . dest ; found = bacnet_address_same ( dest , cov_dest ) ; if ( found ) { index = i ; break ; } } } if ( ! found ) { for ( i = 0 ; i < MAX_COV_ADDRESSES ; i ++ ) { valid = COV_Addresses [ i ] . valid ; if ( ! valid ) { index = i ; cov_dest = & COV_Addresses [ i ] . dest ; bacnet_address_copy ( cov_dest , dest ) ; COV_Addresses [ i ] . valid = true ; break ; } } } } return index ; }
Adds the address to the list of COV addresses
Adds the address to the list of COV addresses
/* find a free place to add a new address */