This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Identify peripheral based on advertised data

For my application I need to identify the peripheral source advertising packets are coming from. How is this best done with BLE and SDK 7.1? I would prefer not to set a a different device name for every source.

  • After turning on scanning on your central device, you will receive an BLE_GAP_EVT_ADV_REPORT event for each received advertising packet.

    This event contains the following information:

    /**@brief Event data for advertising report event. */
    typedef struct
    {
      ble_gap_addr_t peer_addr;                     /**< Bluetooth address of the peer device. */
      int8_t         rssi;                          /**< Received Signal Strength Indication in dBm. */
      uint8_t        scan_rsp : 1;                  /**< If 1, the report corresponds to a scan response and          the type field may be ignored. */
      uint8_t        type     : 2;                  /**< See @ref BLE_GAP_ADV_TYPES. Only valid if the    scan_rsp field is 0. */
      uint8_t        dlen     : 5;                  /**< Advertising or scan response data length. */
      uint8_t        data[BLE_GAP_ADV_MAX_SIZE];    /**< Advertising or scan response data. */
    } ble_gap_evt_adv_report_t;
    

    The simplest way would be to use the peer_addr field. This will most likely (VERY likely if set randomly) be unique for each device, and not change on reboot (you cannot rely on this in a real life implementation however).

Related