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
  • Hi,

    Thanks for your prompt reply. 

    I mean that the CPU is not responding at all. Please have a look at the attached call stack. It's got stocked in the highlighted line which is:

    HardFault_Handler:
    0x34bae: 0xe7fe B.N HardFault_Handler ; 0x34bae

    Once I receive a command (our own command) from the peripheral to drop, I start a timer to drop the connection on the timer timeout. But I never get any other event (not even the disconnect event) and the CPU is stopped. 

    If I just comment out the  sd_ble_gap_disconnect line, the app works fine. That's why I think the problem is with dropping the connection.

    Thanks

  • HSh said:
    Thanks for your prompt reply. 

    No problem at all, I am happy to help!

    HSh said:
    I mean that the CPU is not responding at all. Please have a look at the attached call stack.

    I do not see any attachments, sorry. Did you mean to attach a full callstack for me to see?

    HSh said:
    It's got stocked in the highlighted line which is:

    It would be interesting to see the callstack leading up to this hardfault line.

    HSh said:
    But I never get any other event (not even the disconnect event) and the CPU is stopped. 
    HSh said:
    If I just comment out the  sd_ble_gap_disconnect line, the app works fine. That's why I think the problem is with dropping the connection.

    This sounds very strange indeed. The sd_ble_gap_disconnect should generate a DISCONNECTED event upon succeeding. What else happens when this timer expires?
    Do you intend for anything else to happen when this timer expires? And, which timer are you using for this?

    Looking forward to resolve this issue together,

    Best regards,
    Karl

Reply
  • HSh said:
    Thanks for your prompt reply. 

    No problem at all, I am happy to help!

    HSh said:
    I mean that the CPU is not responding at all. Please have a look at the attached call stack.

    I do not see any attachments, sorry. Did you mean to attach a full callstack for me to see?

    HSh said:
    It's got stocked in the highlighted line which is:

    It would be interesting to see the callstack leading up to this hardfault line.

    HSh said:
    But I never get any other event (not even the disconnect event) and the CPU is stopped. 
    HSh said:
    If I just comment out the  sd_ble_gap_disconnect line, the app works fine. That's why I think the problem is with dropping the connection.

    This sounds very strange indeed. The sd_ble_gap_disconnect should generate a DISCONNECTED event upon succeeding. What else happens when this timer expires?
    Do you intend for anything else to happen when this timer expires? And, which timer are you using for this?

    Looking forward to resolve this issue together,

    Best regards,
    Karl

Children
No Data
Related