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

Unknown error when BLE peripheral tries to disconnect the central

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
if(deallocate_flag)
{
uint32_t periph_link_cnt=0;
deallocate_flag = 0;
periph_link_cnt = ble_conn_state_peripheral_conn_count();
#ifdef DEBUG
printf("total links :%d\n",periph_link_cnt);
#endif
if(periph_link_cnt)
{
for( ;periph_link_cnt>0;periph_link_cnt--)
{
err_code = sd_ble_gap_disconnect(periph_link_cnt-1,BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
#ifdef DEBUG
printf("error value is %x\n",err_code);
#endif
APP_ERROR_CHECK(err_code);
#ifdef DEBUG
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Hello,

  Please check this code for BLE disconnection.When peripheral tries to disconnect from the central , it is disconnect successfully the first time but second time it gives an unknown error and   the  whole controller resets.Please do reply to this.

Thanks & Regards,

  Suman