AllJoyn/Samples/BACnetAdapter/bacnet-stack-0.8.2/demo/object/gw_device.c
bool Routed_Device_Address_Lookup(
    int idx,
    uint8_t address_len,
    uint8_t * mac_adress)
{
    bool result = false;
    DEVICE_OBJECT_DATA *pDev = &Devices[idx];
    int i;

    if ((idx >= 0) && (idx < MAX_NUM_DEVICES)) {
        if (address_len == 0) {
            /* Automatic match */
            iCurrent_Device_Idx = idx;
            result = true;
        } else if (mac_adress != NULL) {
            for (i = 0; i < address_len; i++) {
                if (pDev->bacDevAddr.mac[i] != mac_adress[i])
                    break;
            }
            if (i == address_len) {     /* Success! */
                iCurrent_Device_Idx = idx;
                result = true;
            }
        }
    }
    return result;
}
/** See if the Gateway or Routed Device at the given idx matches
 * the given MAC address.
 * Has the desirable side-effect of setting iCurrent_Device_Idx to the
 * given idx if a match is found, for use in the subsequent routing handling
 * functions here.
 *
 * @param idx [in] Index into Devices[] array being requested.
 *                 0 is for the main, gateway Device entry.
 * @param address_len [in] Length of the mac_adress[] field.
 *         If 0, then this is a MAC broadcast.  Otherwise, size is determined
 *         by the DLL type (eg, 6 for BIP and 2 for MSTP).
 * @param mac_adress [in] The desired MAC address of a Device;
 *
 * @return True if the MAC addresses match (or the address_len is 0,
 *         meaning MAC broadcast, so it's an automatic match).
 *         Else False if no match or invalid idx is given.
 */
See if the Gateway or Routed Device at the given idx matches
the given MAC address.
Has the desirable side-effect of setting iCurrent_Device_Idx to the
given idx if a match is found, for use in the subsequent routing handling
functions here.

@param idx [in] Index into Devices[] array being requested.
0 is for the main, gateway Device entry.
@param address_len [in] Length of the mac_adress[] field.
If 0, then this is a MAC broadcast.  Otherwise, size is determined
by the DLL type .
@param mac_adress [in] The desired MAC address of a Device.

@return True if the MAC addresses match (or the address_len is 0,
meaning MAC broadcast, so it's an automatic match).
Else False if no match or invalid idx is given.
See if the Gateway or Routed Device at the given idx matches the given MAC address . Has the desirable side - effect of setting iCurrent_Device_Idx to the given idx if a match is found for use in the subsequent routing handling functions here . @param idx [ in ] Index into Devices [] array being requested . 0 is for the main gateway Device entry . @param address_len [ in ] Length of the mac_adress [] field . If 0 then this is a MAC broadcast . Otherwise size is determined by the DLL type . @param mac_adress [ in ] The desired MAC address of a Device . @return True if the MAC addresses match ( or the address_len is 0 meaning MAC broadcast so it ' s an automatic match ) . Else False if no match or invalid idx is given .
bool Routed_Device_Address_Lookup(
    int idx,
    uint8_t address_len,
    uint8_t * mac_adress)
{
    bool result = false;
    DEVICE_OBJECT_DATA *pDev = &Devices[idx];
    int i;
    if ((idx >= 0) && (idx < MAX_NUM_DEVICES)) {
        if (address_len == 0) {
            iCurrent_Device_Idx = idx;
            result = true;
        } else if (mac_adress != NULL) {
            for (i = 0; i < address_len; i++) {
                if (pDev->bacDevAddr.mac[i] != mac_adress[i])
                    break;
            }
            if (i == address_len) {     
                iCurrent_Device_Idx = idx;
                result = true;
            }
        }
    }
    return result;
}
bool Routed_Device_Address_Lookup ( int idx , uint8_t address_len , uint8_t * mac_adress ) { bool result = false ; DEVICE_OBJECT_DATA * pDev = & Devices [ idx ] ; int i ; if ( ( idx >= 0 ) && ( idx < MAX_NUM_DEVICES ) ) { if ( address_len == 0 ) { iCurrent_Device_Idx = idx ; result = true ; } else if ( mac_adress != NULL ) { for ( i = 0 ; i < address_len ; i ++ ) { if ( pDev -> bacDevAddr . mac [ i ] != mac_adress [ i ] ) break ; } if ( i == address_len ) { iCurrent_Device_Idx = idx ; result = true ; } } } return result ; }
See if the Gateway or Routed Device at the given idx matches
 the given MAC address.
See if the Gateway or Routed Device at the given idx matches the given MAC address .
/* Automatic match */ /* Success! */