BT NUS logging blocked

In our development using NCS-2.6.1 it is desirable to have logs using BT NUS. 

"Serial Bluetooth Terminal" android application is used.

For testing purposes NCS\v3.0.2\nrf\samples\bluetooth\central_and_peripheral_hr been used with modification to support ble logging with next lines added to prj.conf

CONFIG_LOG_BACKEND_BLE=y
CONFIG_LOG=y
CONFIG_LOG_PROCESS_THREAD_STACK_SIZE=2048
# Uncomment to use the maximum buffer size
CONFIG_BT_L2CAP_TX_MTU=600
CONFIG_BT_BUF_ACL_RX_SIZE=600
CONFIG_BT_NUS_LOG_LEVEL_DEFAULT=y

CONFIG_LOG_MODE_DEFERRED=y
CONFIG_LOG_BACKEND_UART=y

PCA10056 boards been used for testing with central_and_peripheral_hr and peripheral_hr.

Logs are blocked in case when phone app connected to firmware app implementing central and peripheral and peripheral device connects. Logs filled with "<wrn> bt_gatt: Device is not subscribed to characteristic." messages. Disconnecting peripheral does not recover logging.

Same happens if nRF Toolbox is used

Note that in case when firmware app implementing central and peripheral and peripheral device connected first and after that phone app connects then logging is OK.

Parents
  • Hi Ivan,

    It seems the problem is not related to Nordic UART Service (NUS), it is related to Bluetooth logging backend (log backend BLE). As we unrested you need to customize the connections control mechanism for this service if you are having multiple connections. Below is a simple solution that can solve the problem you have. With this modification, if you connect the mobile phone to central_peripheral_hr first and then connect peripheral_hr board, it will work fine. While this is a simple workaround, it is recommended to implement your own mechanism while considering all connection scenarios. 
    In below screenshot you can see the minor modification to "log_backend_ble_connect" and "log_backend_ble_disconnect". Just make sure to include "conn_internal.h" to the "log_backend_ble.c" file. 
     





  • Hi Ressa,

    This modes do fix one issue but issue remains in case when phone app is connected while peripheral_hr application is restarted. In our architecture design NRF52840 central and peripheral app periodically connects to NRF52840 peripheral and phone app could connect to central and peripheral app supporting ble backend logging at any time. So there are 2 test scenarios.

    1. NRF52840 devices are connected while phone app connects-disconnects few times.

    2. phone app connected to nfr52840 central and peripheral app while nrf52840 peripheral connects-disconnects few times.

    Second test scenario has issues that easy reproduceable. Basically it freezes nrf52840 central and peripheral app. Logs stopped and sometime one could see logs like

    [00:00:41.098,541] <wrn> bt_gatt: Device is not subscribed to characteristic
    ] --- 9999 messages dropped ---

    Kind Regards

Reply
  • Hi Ressa,

    This modes do fix one issue but issue remains in case when phone app is connected while peripheral_hr application is restarted. In our architecture design NRF52840 central and peripheral app periodically connects to NRF52840 peripheral and phone app could connect to central and peripheral app supporting ble backend logging at any time. So there are 2 test scenarios.

    1. NRF52840 devices are connected while phone app connects-disconnects few times.

    2. phone app connected to nfr52840 central and peripheral app while nrf52840 peripheral connects-disconnects few times.

    Second test scenario has issues that easy reproduceable. Basically it freezes nrf52840 central and peripheral app. Logs stopped and sometime one could see logs like

    [00:00:41.098,541] <wrn> bt_gatt: Device is not subscribed to characteristic
    ] --- 9999 messages dropped ---

    Kind Regards

Children
No Data
Related