cancel
Showing results for 
Search instead for 
Did you mean: 

ble scanner GAP_CENTRAL_ROLE to receive Beacon data but data length is zero?

IPang
Associate II

I trying to read iBeacon adv data for uuid, major and minor. But I notice I only able to get the address. I tried to print out the AD data, but it always tell me its empty when iBeacon is detected. Please help.

/*******************************************************************************

* Function Name : Master_DeviceDiscovery_CB

* Description  : Device discovery callback from master basic profile library

* Input     : 

* Return     : 

*******************************************************************************/

void Master_DeviceDiscovery_CB(uint8_t *status, uint8_t *addr_type, uint8_t *addr, 

    uint8_t *data_length, uint8_t *data,

    int8_t *RSSI)

{

 uint8_t i;

 uint8_t j;

 if (*status == DEVICE_DISCOVERED) {

  PRINTF("ADDR Type = %d\r\n", *addr_type);

  PRINTF("ADDR = 0x");

  for (i=0; i<6; i++)

   PRINTF("%02x", addr[i]);

  PRINTF("\r\n");

  PRINTF("ADDR_TYPE = 0x");

  for (i=0; i<10; i++)

   PRINTF("%02x", addr_type[i]);

  PRINTF("\r\n");

  PRINTF("AD DATA (Length=%d):\r\n", *data_length);

  for (i=0; i<*data_length; i++)

   PRINTF("%02x ", data[i]);

  PRINTF("\r\n");

  PRINTF("RSSI = 0x%02x\r\n", *RSSI);

  /* If the device found is a BlueNRG try to connect */

  if (!memcmp(&data[5], "BlueNRG", 6)) { 

   PRINTF("BlueNRG device found\r\n");

   masterContext.peer_addr_type = *addr_type;

   memcpy(masterContext.peer_addr, addr, 6);

   if (deviceConnection() != BLE_STATUS_SUCCESS)

PRINTF("Error during the device connection procedure\r\n");

  }else if(!memcmp(&data[5], "SlaveSec", 8)) {

   PRINTF("SlaveSec_A0 device found\r\n");

   masterContext.peer_addr_type = *addr_type;

   memcpy(masterContext.peer_addr, addr, 6);

   if (deviceConnection() != BLE_STATUS_SUCCESS)

PRINTF("Error during the device connection procedure\r\n");

}

 }

 if (*status == DEVICE_DISCOVERY_PROCEDURE_ENDED)

  PRINTF("***Device Discovery Procedure ended from the application\r\n");

 if (*status == DEVICE_DISCOVERY_PROCEDURE_TIMEOUT) {

  PRINTF("***Device Discovery Procedure Timeout\r\n");

  if (deviceDiscovery() != BLE_STATUS_SUCCESS) {

   PRINTF("Error during the device discovery procedure\r\n");

  }

 }   

}

0 REPLIES 0