How to read public MAC using the nrfjprog.exe tool?
How to read public MAC using the nrfjprog.exe tool?
Hi Torbjørn
For another user on this forum asking a question on the BLE address I tried using the sd_ble_gap_address_set() but found the address did not change even though the return code rcode below was NRF_SUCCESS:
ble_gap_conn_sec_mode_t myMode = {.sm = 0, .lv = 0}; uint8_t myName[6] = {0x01,0x02,0x03,0x04,0x05,0xC6}; // Doesn't allow set if BLE name is in FLASH - maybe see ref sd_ble_cfg_set() uint32_t rcode = sd_ble_gap_device_name_set(&myMode, myName, sizeof(myName));
I'm curious as to why the actual BLE address reported remained unchanged. I tried both immediately after ble_stack_init() and later with the same result (success but same ble address). It's not clear where the original ble address variable is located: RAM or Flash? If the latter the return code would have indicated other than success
db_discovery_init(); ble_stack_init(); ReportSignOnString(); // <- Test here gatt_init(); nus_c_init(); db_discovery_init(); ble_stack_init(); gatt_init(); nus_c_init(); ReportSignOnString(); // <- Test here
Thank you.
Now I can read the public MAC.
I am glad to hear you figured it out Bon!
As for your question Hugh it would be better to open a new case.
A quick comment though, why is the code snippet using the sd_ble_gap_device_name_set(..) function, while you refer to sd_ble_gap_address_set() in the text?
Best regards
Torbjørn
Hi,
When I used the same command, I was only able to read the 5 bytes correctly. The Most higher byte does not match.
C:\Program Files\Nordic Semiconductor\nrf-command-line-tools\bin>nrfjprog --memrd 0x100000A4 --n 8
0x100000A4: 121DCF55 7C1D8BD6 |U......||
From Nrfconnect, I noticed a different mac address.
Am I missing anything?
Hi Daniel
The device address bytes stored in the flash are random numbers, and won't necessarily follow the Bluetooth specification requirements for a valid BLE address.
When using a static random BLE address the two most significant bits shall both be 1, which is why 0x8B is changed to 0xCB by the SoftDevice before setting the address.
For more information please refer to the Device Address chapter in the Bluetooth specification (Vol 6, Part B, chapter 1.3 in v5.0 of the specification).
Best regards
Torbjørn