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.

CC2640R2F: How to get raw data in scanning

Part Number: CC2640R2F

Hi,

I had modified project zero example as per my application and now my application need to scan actively and receive raw data. I had created a task specially for scanning raw data based on observer example i'm using GAPObserverRole_StartDiscovery() API for scanning but i can't able to find the how can receive the raw data. Can anyone suggest me how get a raw data. (My application able get raw data & advertise even in connection with other device ) 

Regards,

Vijay Rakesh.

  • Hi Vijay,

    If you are trying to do both Advertising/Peripheral role and Observer role on the same device, it would probably be a good idea to start with the multi-role example included in the SDK rather than project zero: That is better set up to handle multiple connections.

    You would likely still need to make some modifications.

    When you say you want to get the "raw data" are you saying that you want to get the Scan Response data from the advertising device (not doing a connection and doing a GATT read) correct? See how in the simple_observer example that you mentioned, in the file simple_observer.c in SimpleBLEObserver_processRoleEvent, there is a case for handling GAP_DEVICE_INFO_EVENT? See how deviceInfo struct is used, which is of the type gapDeviceInfoEvent_t (the gapDeviceInfoEvent_t can be found in gap.h). Looking at the gapDeviceInfoEvent_t struct, you can see that the type includes information on whether the advertising report was a scan response or a different kind of advertisement in the eventType field. Further, it includes a pointer *pEvtData and a dataLen that could be used to get the raw data.

    /**
     * @brief @ref GAP_DEVICE_INFO_EVENT message format.
     *
     * This message is sent to the
     * app during a Device Discovery Request, when a new advertisement or scan
     * response is received.
     */
    typedef struct
    {
      osal_event_hdr_t  hdr;    //!< @ref GAP_MSG_EVENT and status
      uint8 opcode;             //!< @ref GAP_DEVICE_INFO_EVENT
      uint8 eventType;          //!< Advertisement Type: @ref GAP_Adv_Report_Types
      uint8 addrType;           //!< address type: @ref GAP_Addr_Types
      uint8 addr[B_ADDR_LEN];   //!< Address of the advertisement or SCAN_RSP
      int8 rssi;                //!< Advertisement or SCAN_RSP RSSI
      uint8 dataLen;            //!< Length (in bytes) of the data field (evtData)
      uint8 *pEvtData;          //!< Data field of advertisement or SCAN_RSP
    } gapDeviceInfoEvent_t;

    So, when you get a GAP_DEVICE_INFO_EVENT event you would want to get the data from deviceInfo by first checking if the event was a scan response by checking the eventType field, and then if it is you could copy the data to wherever you are wanting it, e.g. to be stored in a list of results like the discovered device addresses, or to print out, etc.

    Regards,

    Katie

  • Hi Katie,

    Thanks for the reply. Yes i need the scan response data & manufacture data from the advertising device (not doing a connection and doing a GATT read) and I'm able to read advertisement data at Case GAP_DEVICE_INFO_EVENT but not scan response data and how to set a callback event for SimpleBLEObserver_processRoleEvent()? 

    Regards,

    Vijay Rakesh

  • Hi Vijay,

    Do you have code checking eventType for the gapDeviceInfoEvent - if so is it always showing only advertising events and never scan response events?

    Regards,
    Katie
  • Hi Katie,

     Yeah, I had written code to check whether the event type is scan response or advertising data and every time it's goes in to advertising data and prints advertisement data but never prints scanresponse.

    Regrads,

    Vijay Rakesh.

  • Vijay,

    Scanning Task 2 of this SimpleLink Academy I think will be a great help to you for this:
    dev.ti.com/.../ble_scan_adv_basic.html
  • Hi Evan,

     I had gone through it before and made changes in my code to get scan response data but every it's printing advertising data and not getting event type as GAP_ADRPT_SCAN_RSP.

    Regards,

    Vijay Rakesh.

  • Vijay,

    Did you do this to the simple_central project or another example project or your own project?

    What i'd recommend if you haven't, is to try the SimpleLink Academy lab in simple_central and try to observe it working. If this works, then start migrating the code over to your own project.

    Do you have a sniffer to acknowledge that a scan response is even being sent over the air/received by your device?
  • Hi Evan Wakefield,

    I did this on simple_observer example and i can see the scan response in my BLE Scanner app(phone) but i can't able get same data on simple observer example. Does simple observer doesn't support do i need to check in simple_central ?

    Regards,
    Vijay Rakesh
  • Vijay,

    Simple_observer by default is a passive scanner which means it only ever listens for advertising packets. I never sends any information and therefore, never sends a scan_req packet to receive a scan_rsp packet. Look at BLE 4.2 Spec Vol 6, part B section 4.4.3.1 and 4.4.3.2 for more information.

    In Simple_Observer you can probably just change the following #define and it will work.
    // TRUE to use active scan
    #define DEFAULT_DISCOVERY_ACTIVE_SCAN FALSE