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

Error during disconnection with sd_ble_gap_disconnect( )

Hi, I'm creating a project on nRF51822 chip and I have a problem with disconnection. In my program I want to disconnect with master after some time e.g. 30 seconds. I'm using on_ble_evt(ble_evt_t * p_ble_evt) function to catch connection event from BLE stack and I'm starting new timer. In function which handling timeout of this timer I'm using: err_code = sd_ble_gap_disconnect(m_conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION) and APP_ERROR_HANDLER(err_code) orders, but it generates an error and chip is resetting. From Master Control Panel I'm getting that info: Lost connection to device. Reason: BTLE_CONNECTION_TIMEOUT SERVER: Received packet <HciEvent: eventCode=0x0A> - <HciEvent: eventCode=0x0A> SERVER: Received Link Loss When I delete APP_ERROR_HANDLER(err_code) function, everything is ok - there is diconnection without chip reset and the reason is correct: BTLE_REMOTE_USER_TERMINATED_CONNECTION. My questions are: what can cause this error and is there any way to eliminate it? P.S. I'm using SoftDevice 6.0.0 and SDK 5.1.0.

Parents
  • Hi

    The app_error_handler resets the system (NVIC_SystemReset(); ) when it receives an err_code that is not NRF_SUCCESS.

    If you delete APP_ERROR_HANDLER(err_code) you still have an error, you just don't react to it, but your system might still work. I would recommend to try to figure out why you get this error. You could try to debug, put a breakpoint at the function and see what the actual error code is. It may give you an idea of what causes the error.

    You can read more on debugging here and here.

Reply
  • Hi

    The app_error_handler resets the system (NVIC_SystemReset(); ) when it receives an err_code that is not NRF_SUCCESS.

    If you delete APP_ERROR_HANDLER(err_code) you still have an error, you just don't react to it, but your system might still work. I would recommend to try to figure out why you get this error. You could try to debug, put a breakpoint at the function and see what the actual error code is. It may give you an idea of what causes the error.

    You can read more on debugging here and here.

Children
No Data
Related