This seems to have changed in recent SDKs, so that none of the examples or techniques mentioned in previous posts is relevant any more.
I am using the SDK v16.0.0 ble_app_blinky_c_pca10040_s132 example on a PC10040 board.
I have added code in the ble_evt_handler() in main.c to handle the BLE_GAP_EVT_ADV_REPORT event:
It should
- Log the device address from the Advertising Report;
- Log the entire Advertising Data;
- Extract the Device Name from the Advertising Data, and log it
Logging the Device Address works;
Logging the entire Advertising Data shows that the Device Name is present;
But Extracting the Device Name does not work.
eg, from a Thingy:52:
C6:1A:BD:D5:43:2E is, indeed, the address of the Thingy; and the "Thingy:5" text can clearly be seen in the 1st dump.
But why is it giving two BLE_GAP_EVT_ADV_REPORT events - where each one only seems to have part of the Advertising Data, and neither finds the Name properly?
Even in the old threads, it is never clearly explained how the "extracted" Name can be used. Some show it being printed (as above), but I don't think that can be right - as it does not seem to be a valid NUL-terminated 'C' string.