I want to change the MAC before doing some advertising, they recommended using the ble_gap_addr_set function, but whenever I call the function I get an error and the application stops.
I've tried with several approaches, including the approaches mentioned in the link below, in this approach I get error code 8.
In the approach I'm going to attach here, I get error code 3202. I've already tried to stop advertising before executing the function, I've also tried to only start advertising after calling the function, but even before starting advertising, always when I call the sd_ble_gap_addr_set function I get the error.
I use nRF5 SDK 17.0.2, and Softdevice S140, based on blinky's central example!
The most relevant part of the code is below, could someone help me to solve this problem?
if(newdisp && advertising[7] == 0x01 && advertising[8] != 0x00){
ble_gap_addr_t my_addr;
ret_code_t err_code;
err_code = sd_ble_gap_adv_stop(m_adv_handle);
memcpy(enderecoatual,endereco,sizeof(endereco));
newdisp = 0;
msg = 1;
err_code = sd_ble_gap_addr_get(&my_addr);
APP_ERROR_CHECK(err_code);
my_addr.addr_type = BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_NON_RESOLVABLE;
my_addr.addr[0] = p_scan_evt->params.p_not_found->peer_addr.addr[5];
my_addr.addr[1] = p_scan_evt->params.p_not_found->peer_addr.addr[4];
my_addr.addr[2] = p_scan_evt->params.p_not_found->peer_addr.addr[3];
my_addr.addr[3] = p_scan_evt->params.p_not_found->peer_addr.addr[2];
my_addr.addr[4] = p_scan_evt->params.p_not_found->peer_addr.addr[1];
my_addr.addr[5] = p_scan_evt->params.p_not_found->peer_addr.addr[0];
err_code = sd_ble_gap_addr_set(&my_addr);
NRF_LOG_INFO("Erro: %x", err_code);
APP_ERROR_CHECK(err_code);
advertising_start();
}
I tried to change the type of address, I tried to manually put a standardized address, anyway I've tried all the approaches I found on the forum, mostly always solved in previous SDK, but for this SDK 17.0.2 I'm not able to get around this error in the call sd_ble_gap_addr_set function.
Please, if you can take the time to apply solutions that really solve the code problem, I would be very grateful.