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

SDK12.2 nRF52832 Central Connect and Disconnect Device Question

Hi, I use nRF52832 and SDK12.2 The Project is ble_central_and_peripheral and the link define is like below #define CENTRAL_LINK_COUNT 4
Here will connect 1 HR device and 3 CSC devices

#define PERIPHERAL_LINK_COUNT 1 Here is waiting for cell phone app

Here is what my project works. When my project power on, MCU will scan 1 HR device and 3 CSC devices and make sure the ble MAC address is my target then connect those device. The result is work and I can got the datas by 4 devices notify handle.

When I press the button to disconnect 4 devices and I wait the on_ble_central_evt’s “p_ble_evt->header.evt_id” got the “BLE_GAP_EVT_DISCONNECTED” 4 times I make sure 4 devices is disconnect.

After I disconnect 4 devices and connect to those devices again. Sometimes the project will stuck on: err_code = ble_db_discovery_start(&m_ble_db_discovery[p_gap_evt->conn_handle], p_gap_evt->conn_handle); APP_ERROR_CHECK(err_code);

And I make sure the 4 devices is advertising because I use 4 nRF51 Dongle and their Led is shiny again.

And my question is: When I disconnect the 4 devices should do some more action or just call sd_ble_gap_disconnect(m_conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION); And wait on_ble_central_evt make sure device is disconnect then call sd_ble_gap_disconnect to next device and wait on_ble_central_evt again until 4 devices all in disconnect. Then I can connect those device again.

Thanks

Parents
  • Hi, I do try the memset(&m_ble_db_discovery,0,sizeof(m_ble_db_discovery)); before ble_db_discovery_start() and it work fine. I try many time like below: scan my target -> connect target -> disconnect target -> reconnect but I dont understand another suggestion about "In ble_db_discovery.c move p_db_discovery->curr_char_ind = 0; from line 237 to line 234."

    If each device I only discovery main service what should I do about p_db_discovery->curr_char_ind = 0; Keep that is 0 or just mask this line.

    Thanks

Reply
  • Hi, I do try the memset(&m_ble_db_discovery,0,sizeof(m_ble_db_discovery)); before ble_db_discovery_start() and it work fine. I try many time like below: scan my target -> connect target -> disconnect target -> reconnect but I dont understand another suggestion about "In ble_db_discovery.c move p_db_discovery->curr_char_ind = 0; from line 237 to line 234."

    If each device I only discovery main service what should I do about p_db_discovery->curr_char_ind = 0; Keep that is 0 or just mask this line.

    Thanks

Children
No Data
Related