This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

How to get advertising data and scan response data during device discovery

Other Parts Discussed in Thread: CC2541

Hi,

I want to receive advertising data and scan response data of slave device during device discovery from central?

I am using CC2541 chips for master and slave and BLE 1.4 stack for development. I am using SimpleBLECetral project for master design reference.

I  want to read advertisement and scan response data of my slave device in Master device during active device discovery using SimpleBLECetral project.

-

Dhvanil Patel

  • Hey Dhvanil,

    Looking at simpleBLECentral as a sample project to start from. When you receive an advertisment packet or a scan response that will produce a GAP_DEVICE_INFO_EVENT which will be processed within simpleBLECentralEventCB(). The argument that is passed, pEvent, is an enum so it has the type of gapDeviceInfoEvent_t for GAP_DEVICE_INFO_EVENTs. Within that struct is an array pointer pEvtData which will be a pointer to the scan response data or adv data. The var dataLen will give you the total length of the data that pEvtData is pointing to.

    -Matt

  • Thanks Matthew,

    I have tried to receive advertisement data and scan response data in  GAP_DEVICE_INFO_EVENT in simpleBLECentralEventCB(). But i am getting only advertisement packet. I am not able to receive scan response packet. I am able capture the advertisement packet, scan request and scan response packet in BLE sniffer but not able to receive GAP_DEVICE_INFO_EVENT in simpleBLECentralEventCB() for scan response packet.

    Please can you check and let me know more information about how to receive scan response in simpleBLECentral application.

    Also note that I have also tried using disables filtering of duplicate reports using GAP_SetParamValue(TGAP_FILTER_ADV_REPORTS, FALSE) and setting MAX_SCAN_RES to 20 but still i am not getting scan response data.

    Thanks in Advance,

    Best Regards,

    Dhvanil Patel

  • Hey Dhvanil,

    What are you running on your peripheral devices? SimpleBLEPeripheral?

    Within the "case GAP_DEVICE_INFO_EVENT:" are you checking the packets outside of the UUID check? If not and you are running the SimpleBLEPeriphal projects on your periphal then that is why you are only seeing the advertising packets (it's filtering through the adv data for the SIMPLEPROFILE_SERV_UUID). Try putting a check in that case statement for

    if(pEvent->deviceInfo.eventType == GAP_ADRPT_SCAN_RSP){

    blink an LED or something;

    }

    outside of the check for DEFAULT_DEV_DISC_BY_SVC_UUID. If you get a scan rsp passed to the application task it will for sure enter the if segment.

    I would keep the max scan response as default. You may run into issues with trying to allocate enough memory to handle the large amounts of responses. If you look into GAP_DeviceInit(), there is a call to GAP_CentDevMgrInit() which allocates memory for scan responses. It might be worth checking the return value to make sure it is a success if you need to handle a greater amount of scan responses than default.

    One last thing I would look into would be the return value of GapCentralRole_StartDevice(). Make sure it is returning  success (in the stock code there is no error check).
     
    -Matt

  • Thanks Matthew.

    I was working on older version 1.2.1 BLE stack and in this stack scan response packet is not coming at application callback and only the advertisement packet comes to the application callback.

    Now I switch to BLE 1.4 stack and in this stack advertisement packet and scan response packet comes to application callback SimpleBLECentralCB().

    Thanks you very much Matthew.

    -

    Dhvanil Patel

  • Ah ok that makes a lot of sense. Probably should have asked you the stack version first :) but I'm glad you got it working.

    -Matt