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

How to change the mac address when the system boots up?

As said on the topic "GAP Address types", the random static address can be changed when system boots up. I can't find any content about how to make it. Could anyone offer any tips? best regards!

Parents
  • Check out the function "sd_ble_gap_address_set" in ble_gap.h. Here's an example:

    ble_gap_addr_t gap_addr;
    gap_addr.addr_type = BLE_GAP_ADDR_TYPE_RANDOM_STATIC;
    // "my_random_addr" must be random generated.
    memcpy(&gap_addr.addr, my_random_addr, sizeof(gap_addr.addr));
    gap_addr.addr[5] |= 0xc0; // 2 MSBit must be '11' for RANDOM_STATIC address, see v4.0, Vol 3, Part C, chapter 10.8
    err_code = sd_ble_gap_address_set(gap_addr);
    APP_ERROR_CHECK(err_code);
    
  • Where would be a good place to include this code if we are using the sample beacon project? I currently cannot find where in this sample project, the function sd_ble_gap_address_set() is being called. I'm quite new to nRF programming, so I would appreciate if you could give some basic instructions.

Reply Children
No Data
Related