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

How to read public MAC using the nrfjprog.exe tool?

How to read public MAC using the nrfjprog.exe tool?

Parents
  • If you look at the "help", you will not see the direct command "Give a Mac"

    but you can read the values of the two registers with the factory settings and build the MAC address of the device yourself. It is worth remembering that the two bits of the address (46 and 47) should be one, because the address is random and public.

    I think that implementing it in a script language (e.g. batch) is not a difficult task.

    Best regards, Max

  • Hi

    To add to CheMax's reply, you can read DEVICEADDR[0] and DEVICEADDR[1] with the following command:

    nrfjprog --memrd 0x100000A4 --n 8

    The first register returned will be DEVICEADDR[0], containing bits 31-0 of the BLE address. 

    The second register is DEVICEADDR[1], from which the higher order bits are copied. 

    Keep in mind that to get a proper public MAC address you have to register it yourself with the IEEE. 
    The address provided by DEVICEADDR is a random static address only, and not guaranteed to be unique. 

    Best regards
    Torbjørn

  • Hi CheMax

    You can set the BLE address to whatever you like using the sd_ble_gap_address_set(..) function, there is no need to change the DEVICEADDR registers. 

    In other words you have full flexibility in the app to control the address assignment. 

    Best regards
    Torbjørn

  • Thank you, for myself, I learned and understood everything.

    I hope the author of this issue will also find a solution for himself.

  • 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
    

  • 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

Reply Children
No Data
Related