2 months ago
Is there a way to read the peer address and store it to pair with later on?
Posted byHdhdh Ddjek20 points 5 replies我试图找到同伴address of my smartphone in order to store it for use later on, like reconnecting.
1 month ago
Ah thanks very much, I managed to get it working and can display the my phones random BT address to UART. This leads me to another question though, is there a method for the DA14531 to connect to the smart phone automatically once the address is stored in memory?
1 month ago
Hi Hdhdh Ddjek,
Glad that you are able to display your phones BDA to the UART.
This is not possible – a BLE connection is initiated only by the GAP Central device which is the phone in this use case.
Thanks, PM_Dialog
1 month ago
Thanks for clarifying, I thought so as well.
Unfortunely the BDA I received via UART was not the same as my smartphones BT Address. I may not have printed out the address correctly, could you please check the code below and feedback to me where I went wrong?
void user_app_connection(uint8_t conidx, struct gapc_connection_req_ind const *param) { if (app_env[conidx].conidx != GAP_INVALID_CONIDX) { app_connection_idx = conidx; // Stop the advertising data update timer app_easy_timer_cancel(app_adv_data_update_timer_used); // Check if the parameters of the established connection are the preferred ones. // If not then schedule a connection parameter update request. if ((param->con_interval < user_connection_param_conf.intv_min) || (param->con_interval > user_connection_param_conf.intv_max) || (param->con_latency != user_connection_param_conf.latency) || (param->sup_to != user_connection_param_conf.time_out)) { // Connection params are not these that we expect app_param_update_request_timer_used = app_easy_timer(APP_PARAM_UPDATE_REQUEST_TO, param_update_request_timer_cb); } #if defined (CFG_PRINTF) arch_printf("Contents of structure are %x, %02x:%02x:%02x:%02x:%02x:%02x\n", param->peer_addr_type, param->peer_addr.addr[5], param->peer_addr.addr[4], param->peer_addr.addr[3], param->peer_addr.addr[2], param->peer_addr.addr[1], param->peer_addr.addr[0]); #endif } else { // No connection has been established, restart advertising user_app_adv_start(); } default_app_on_connection(conidx, param); }
Thanks for you patience and continued help.
1 month ago
Hi There,
Apologies for the delay. The mobile phones are usually using random BD address, so is changing every time. This might be the most probable why you see different BD address in the serial terminal. You can use another DA14531 that is acting as GAP Central to check this too. You could use theDA14585/DA14586/DA14531 Central ImplementationSW Example, for configuring the DA14531 as a Central.
Thanks, PM_Dialog
1 month ago
Hi There,
Please check out the ble_app_security example from the SDK6.0.14.
Location : 6.0.14.1114\projects\target_apps\ble_examples\ble_app_ security
When the device is connected, the user_app_connection() callback is getting triggered. The gapc_connection_req_ind structures holds all the information related to the connection – it also contains the Peer address type (peer_addr_type) and Peer BT address (struct bd_addr peer_addr;).
So, upon the connection, you should read the Peer BT address and store it.
Thanks, PM_Dialog