Hi Dialog,
Currently I am working on ble_barebone example with GAPM_GEN_STATIC_RND_ADDR configuration, I want to send the randomly generated Bd Address through uart to a co-processor once the advertisement starts, can you suggests any methods to read the random bd address??
我试着做以下几点:
void user_app_adv_start(void)
{
struct gapm_start_advertise_cmd* cmd;
cmd = app_easy_gap_undirected_advertise_get_active();
memcpy (bd_address cmd - > op.addr.addr, 6);
app_easy_gap_undirected_advertise_start();
}
但我always received all zeros .
谢谢,
Regards,
Dhiraj
Device:
Hi dhirajp15,
Since you have configured your device as GAPM_GEN_STATIC_RND_ADDR, you should generate static random BD address. It seems that you read the BD address with the correct way. I suggest you to debug your code and check if bd_address variable contains the BD address or zeros before print it through uart. You can add a breakpoint in the memcpy(bd_address,cmd->op.addr.addr,6) of your code and check if the bd address copied matches the bd address that you are using during advertising.
Thanks PM_dialog
Hi PM_Dialog,
I have added a breakpoint in the memcpy(bd_address,cmd->op.addr.addr,6) and checked the value its showing zeros. Also keeping a watch at cmd->op.addr.addr which holds the bluetooth address randomly generated, it shows zero while user_app_adv_start() function is executing and it shows the actual value after it gets executed.
Thanks,
Regards,
Dhiraj
Hi dhirajp15,
I have tested it in the the ble_app_barebone project of the SDK. I defined GAPM_GEN_STATIC_RND_ADDR into the addr_src member of the user_adv_conf structure and I am able to generate static random BD addresses. In which project are you working on? Does your code execute generate_static_random_address() function which is allocated into app_easy_gap_undirected_advertise_start_create_msg() function? As soon as you have configured your device as GAPM_GEN_STATIC_RND_ADDR, your application code should execute generate_static_random_address() function. I suggest you to add a break point into that place of your code and then check if the BD address is generated by using the “Call Stack Window” of the panel. Also, I suggest you to check if the optimization of your code is in Level-O0, if –O3 perhaps Keil optimizes the code and it won’t show you the actual value of the array. Click to the “Project” tab and the click to the “Options for target”. In the open windows, go to the “C/C++” tab and change the optimization option to Level0(-O0).
Thanks PM_dialog
Hi PM_Dialog ,
I dint find the function generate_static_random_address() in the project. I am working on sdk 5.0.2.1. Also checked using Call Stack Window the value of op.addr.addr is zero . Also sending you the screenshot of my keil window, i have set the optimization to O0 for debugging purpose.Please help to solve this issue ASAP.
PFA.
谢谢,
Regards,
Dhiraj
Hi dhirajp15,
The SDK5.0.2.1 that you are working on is an obsolete version. In this SDK, when you configure you device as GAPM_GEN_STATIC_RND_ADDR, the bd address is generated from the ble stack and it is changed every time the device advertises. So it is random bd address but not static. It’s expected to receive zeros in bd address with the code that you have posted, because as mentioned the bd address is generated from the stack and you will not be able to read it using the way that you ‘ve posted. It’s strongly recommended to use the latest version of the SDK (SDK5.0.4) in which the static random bd address generation is done by the SDK. This version of the SDK uses the generate_static_random_address() function to generate static random bd addresses if you configure your device as GAPM_GEN_STATIC_RND_ADDR. If it’s necessary to use the SDK5.0.2.1, I would suggest you to take the implementation of SDK5.0.4 and embedded it in your application code.
Thanks PM_dialog