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

i want to read data_id of the advertising data.

I'm using ble_app_uart_c example with NRF52840.

And i want to read the beacon device id( 8 byte ) at Central(nrf52840).

The ADDR value could be verified through the questions here.

Below is an example code i used.

it work in case BLE_GAP_EVT_ADV_REPORT:

const ble_gap_evt_adv_report_t * p_adv_report = &p_gap_evt->params.adv_report;

const ble_gap_addr_t peer_addr = p_adv_report->peer_addr;
const uint16_t deviceID = p_adv_report->data_id;

But the result  " printf("ID %08x\r\n",deviceID); " is  " ID 00000000 "

Can someone help me read the ID? thank you..

Parents
  • Hi,

    A const variable cannot change, e.g. "const uint16_t deviceID = p_adv_report->data_id;" means deviceID will get whatever value it gets initialized with and never change. Remove "const" from the declaration. You probably want to do that for the other variables from your listing as well, in particular for peer_addr.

    Regards,
    Terje

  • thank you Terje,

    I tried to remove it, but the result is the same.
    Is the "data_id" in the function referring to the device name? If so, it is understood that 0 is result.
    I want to read the FICR ID at the Central.. Do you know how to do it?

  • Hi,

    No, the data_id field is not the device name. Rather it is used to distinguish between different advertising sets transmitted by the device. It is not used if ble_gap_evt_adv_report_t::set_id is set to BLE_GAP_ADV_REPORT_SET_ID_NOT_AVAILABLE, see the documentation for ble_gap_evt_adv_report_t.

    Can you please explain what you mean by "FICR ID"? If you are looking for the address of the peer (or identity address in case of resolvable address) then you should use ble_gap_evt_adv_report_t::peer_addr, which is of type ble_gap_addr_t.

    Regards,
    Terje

  • I wanted to read the beacon ID and ADDR from the center to distinguish the data of several beacons.

    And,

    FICR VALUE means ID and ADDR to distinguish the chip, that is, DEVICEID [0], [1] and DEVICEADDR [0], [1].

    ADDR was able to identify, but I wanted to identify IDs to lower the probability of duplication...

    But I could not read the DATA_ID.

    Also, the result is the same even if  I delete the part you mentioned(But I could not read the DATA_ID. The result is the same even if you delete the part you mentioned and run it.) and run it.

Reply
  • I wanted to read the beacon ID and ADDR from the center to distinguish the data of several beacons.

    And,

    FICR VALUE means ID and ADDR to distinguish the chip, that is, DEVICEID [0], [1] and DEVICEADDR [0], [1].

    ADDR was able to identify, but I wanted to identify IDs to lower the probability of duplication...

    But I could not read the DATA_ID.

    Also, the result is the same even if  I delete the part you mentioned(But I could not read the DATA_ID. The result is the same even if you delete the part you mentioned and run it.) and run it.

Children
Related