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

Stop ble_app_uart connection with ble_app_uart_c

I am using: \examples\ble_peripheral\ble_app_uart  and  \examples\ble_central\ble_app_uart_c  .

In Nordic infocenter it says: The application scans peripheral devices and connects to a device that advertises with the NUS UUID in its advertisement report.

The questions are: 

1- Is this type of connection similar to a pairing where a key exchange occurs and connection is encrypted between peripheral and central?

2- How can I modify \examples\ble_peripheral\ble_app_uart code to drop the connection and reconnect periodically (for power saving) .

  • I have modified ble_app_uart and ble_app_uart_c codes by adding peer manager modules to it and compiles successfully. But it does not seem my devices connect any more after adding peer manager and send and receive serial data from one to the other. Can you give me any idea what could be wrong here. 

  • You need to remove the event handling for BLE_GATTS_EVT_SYS_ATTR_MISSING and BLE_GAP_EVT_SEC_PARAMS_REQUEST from your ble_evt_handlers as these are being handled by the peer manager. Apart from that it looks good.

    Do you have any debug logs from the central? Is it able to discover the NUS peripheral at all?

  •  removed BLE_GATTS_EVT_SYS_ATTR_MISSING and BLE_GAP_EVT_SEC_PARAMS_REQUEST from both central and peripheral codes in ble_evt_handlers. 

    My central keeps resetting and prints this in COM port:

    <info> app_timer: RTC: initialized.
    <error> app: Fatal error
    <warning> app: System reset

    This is what appears in central code Debug terminal:

    <info> app_timer: RTC: initialized.
    <error> app: ERROR 8 [NRF_ERROR_INVALID_STATE] 
    PC at: 0x00035A03
    <error> app: End of error report

    My peripheral does not print anything to the COM port. It is expected to print:

    Peripheral UART Started. 

    For peripheral this appears in the debug terminal:

    <error> app: Fatal error

    For both peripheral and central, debugger stops at: NRF_BREAKPOINT_COND in app_error_weak.c

  • Please select the "Debug" build configuration when debugging your project. This configuration includes the DEBUG flag which will make the error handler in app_error_weak.c print a more detailed error message.

  • Thanks Vidar. 

    For peripheral I get this in the debug terminal:

    <error> app: ERROR 8 [NRF_ERROR_INVALID_STATE] at ...\nRF5_SDK_17.0.2_d674dde\components\libraries\log\src\nrf_log_backend_uart.c:67
    PC at: 0x000314CF
    <error> app: End of error report

    I set NRF_LOG_BACKEND_UART_ENABLED=0 in sdk_config and that seems to fix the issue. Now my peripheral device is blinking normal in scan mode. Please confirm.

    For central I get this in the debug terminal: 

    <info> app_timer: RTC: initialized.
    <error> app: ERROR 8 [NRF_ERROR_INVALID_STATE] at ...\nRF5_SDK_17.0.2_d674dde\examples\My Projects\uart_central_wpmg_3\main.c:956
    PC at: 0x00035A03
    <error> app: End of error report

Related