Skip to main content
jampino
Associate III
August 16, 2017
Question

Write unique ID

  • August 16, 2017
  • 1 reply
  • 587 views
Posted on August 16, 2017 at 16:58

Hello everyone,

I have the BLUENRG-1 running and working ( advertising, creating connections, sleeping ).

Now I would like to write a unique ID in each bluenrg-1 and then read it when the application starts up but not really sure how I should do it.

Can anyone help me on this.

Thanks

    This topic has been closed for replies.

    1 reply

    Micha Valach
    Associate III
    October 24, 2017
    Posted on October 24, 2017 at 07:18

    Hi Jamp,

    You can use a random() function to create a random 6 bytes Mac Address, then save those 6 bytes in your Flash.

    Once power up, for the very 1'st time, those 6 bytes might be all 0xff - then you might apply the random() function and save those 6 bytes to the Flash, next Power up time if those bytes are different then 0xff , use those bytes from flash as Mac Address. or if your BLE client is a mobile app, you can have a small utility which sends any 6 bytes of Mac address and then the Server (advertiser) will save those to Flash and use those as defined Mac.

    Thanks, Micha  

    jampino
    jampinoAuthor
    Associate III
    October 24, 2017
    Posted on October 24, 2017 at 10:32

    Hello Micha,

    Thanks for your answer, we have got how to do it already but thank you.

    Kind regards

    Andrea Palmieri
    ST Employee
    October 25, 2017
    Posted on October 25, 2017 at 11:43

    Hi Jamp,

    each BlueNRG-1 device has natively a unique random static address that can be retrieved using the following ACI API:

    uint8_t address[6];

    uint8_t data_len_out;

    aci_hal_read_config_data(CONFIG_DATA_RANDOM_ADDRESS, &data_len_out, address);

    On the other hand, if you need to overwrite it, you can use:

    hci_le_set_random_address(random_address);

    Kind regards

    Andrea