nRF5 SDK is not maintained anymore
More Info: Consider nRF Connect SDK for new designs

BLE disconnected while using virtual UART and HW_UART

Hello,

In my project i am using nrf52840 and i have change the default UART pins to P1.3 (TX) and P1.4(RX) and while using virtual UART like BLE UART  i mean in the sense sending data from the APP TO MCU and vice versa here at the same time if  i am trying to use the HW_UART BLE gets disconnected.

1. why its happening like this.??

2. Please suggest me to resolve this.

thank you.

Parents
  • Hi,

    It is not possible to guess the disconnect reasons based on your information.

    • It would be nice to get the disconnect reason. Based on that you can see which side of the connection initiated a disconnect and why. If it is a supervision time out disconnect then you can debug to see which device did not respond in the connection.
    • check to see if there are any app_error_check faults in your application.

  • Hello,

    thanks for the reply, i will explain the whole application then it will be easy for me to give a debug information so the actual application is i want to control the stepper motor with nrf52840 over BLE like sending some commands over BLE to MCU  and receiving the data's from the MCU this is only over a BLE the another way of communication is sending data over HW_UART like using RS232 which is connected to the MCU  and sensor board. when sensor board sending a data over RS232 to MCU it should accept the data and receive the data.

    so overall the virtual UART communication(BLE UART) as well as HW_UART (RS232) communication should happen at a time without any BLE disconnection and its working fine for some time and some time BLE gets disconnected.

    thank you.

  • Hi,

    It will still be nice to get a sniffer trace and/or disconnect reason to see why BLE is getting disconnected. BLE can get disconnected due to many reasons and the reason is given in the disconnect event to the application.

    Assuming that you are using nRF5SDK with a softdevice, the disconnect reason can be extracted from the event to the application like below

    static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context)
    {
       ...
       ...
            case BLE_GAP_EVT_DISCONNECTED:
            {
                NRF_LOG_INFO("Disconnected, reason 0x%x.",
                             p_gap_evt->params.disconnected.reason);
                             
    ...
    ...

  • Hello Susheel,

    thanks for your reply, if i mentioned the p_gap_evt-> params.disconnected.reason  but it gives me error like its undeclared and i don't have an idea how to declare it and where. sorry if its very silly question i am new to nordic and i don't have enough knowledge to do that so please help me to resolve this.

    thank you.

  • There are lot of examples in the SDK that extract the disconnect reason in the event and print it to the chosed log channel.

    For example in nRF5_SDK_17.1.0_ddde560\examples\ble_central\ble_app_gatts\main.c: Line 255.

    You can also know the disconnect reason from the air sniffer trace

Reply Children
  • Hello,

    Thanks for the reply, after i have change the code as you said i got this error

    <error> app: ERROR 1 [NRF_ERROR_SVC_HANDLER_MISSING] at C:\A\DeviceDownload\nRF5SDK1702d674dde\nRF5_SDK_17.0.2_d674dde\examples\ble_peripheral\ble_app_uart -3085\main.c:752
    PC at: 0x0002C0C9
    <error> app: End of error report
    

    so any issue in the hardware side.??

    thank you.

  • There is a logging bug in the uart error handler passing on the uart error as  NRF_ERROR_SVC_HANDLER_MISSING. I thought it was fixed in the latest nRF5 SDKs but I might be mistaken.

    You need to check how you are handling this error from the uart. If this is an overrun error, then it happens more frequently when you are not using any HW flow control.

  • Hello Susheel,

    thanks for the reply, 

    You need to check how you are handling this error from the uart. If this is an overrun error, then it happens more frequently when you are not using any HW flow control.

    In the uart_init() i have enabled the HW_flow_control aslo but no use still its happening like this.

    i think in the uart_event_handler() i am trying to receive sensor data sometimes uart_communication error will raised so what exactly happening and receiving a sensor data is a problem or any other issues.??

    thank you.

  • depends on what error it is.
    You can check the source of the error when using app_uart like below in the uart callback handler

            case APP_UART_COMMUNICATION_ERROR:
                APP_ERROR_HANDLER(p_event->data.error_communication);

    If using nrfx drivers, you can directly get and clear the errorsrc usingnrfx_uarte_errorsrc_get. Based on the type of error you get, you can handle that error as per the application need (for example, flush the RX FIFO or restart the uart communication etc)

    .

Related