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

sd_ble_gap_disconnect causes nRf52 freezes

Dear Nordic expert,

I'm using nRF52840 as central with SDK 16.0.0. 

I establish a connection with a peripheral (phone) and then I need to drop the connection. I set a timer to drop the connection after a certain time.Once I call sd_ble_gap_disconnect, it returns success but I never receive the disconnect event and the CPU gets frozen with absolutely no report. 

Here's my code. It actually prints out NRF_LOG_INFO("disconnect") and then gets frozen. I'd appreciate any help.

static void Disconnect_Timer_handler(void * p_context)
{
ret_code_t err_code;

if (mylist[new_id].conn_handle != BLE_CONN_HANDLE_INVALID)
{
err_code = sd_ble_gap_disconnect(mylist[new_id].conn_handle,
BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
APP_ERROR_CHECK(err_code);
}
pairing_in_progress = 0;
pairing_status = PAIRING_IDLE;
NRF_LOG_INFO("disconnect");
}

Thanks

Parents
  • Hello,

    Here's my code. It actually prints out NRF_LOG_INFO("disconnect") and then gets frozen. I'd appreciate any help.

    This is not a lot of code to go on. All this tells me is that the call to NRF_LOG_INFO completes, so we know that your program counter makes it out of the function.
    Are you using the deferred logging option?

    Could you elaborate what you mean when you say that the device 'freezes'? Is it unresponsive to button presses, or are you not seeing your expected stream of log statements?
    What where the device doing just prior to the timer expiring and the disconnect being triggered?

    If your program is stuck in a loop somewhere, it is not in the function you have included at least. It would have to be somewhere else in the program. If you use the debugger, and let the program run freely, how does your call stack look after the disconnect?

    Best regards,
    Karl

Reply
  • Hello,

    Here's my code. It actually prints out NRF_LOG_INFO("disconnect") and then gets frozen. I'd appreciate any help.

    This is not a lot of code to go on. All this tells me is that the call to NRF_LOG_INFO completes, so we know that your program counter makes it out of the function.
    Are you using the deferred logging option?

    Could you elaborate what you mean when you say that the device 'freezes'? Is it unresponsive to button presses, or are you not seeing your expected stream of log statements?
    What where the device doing just prior to the timer expiring and the disconnect being triggered?

    If your program is stuck in a loop somewhere, it is not in the function you have included at least. It would have to be somewhere else in the program. If you use the debugger, and let the program run freely, how does your call stack look after the disconnect?

    Best regards,
    Karl

Children
No Data
Related