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

Adding Logging information to beacon example

I am studying the beacon example provided in the SDK (The project is found in following directory C:\Nordic_semi\nRF5SDK160098a08e2\examples\ble_peripheral\ble_app_beacon\pca10056\s140\ses on my computer. It is mentioned here to show the relative path). The SDK being nRF5SDK160098a08e2, the IDE being Segger Embedded Studio. I downloaded the softdevice using ‘Programmer’ in the nRF desktop connect app. The nRF connect is downloaded on smartphone (Samsung S7) and I used this app to ascertain the beacon working. I am using nRF 52840 DK.

Out of curiosity, I wanted to add some logging information in the code.

The main loop, i.e. the 'for' loop has a function

idle_state_handle();

I commented it out and instead replaced it with following lines of code

NRF_LOG_INFO("Beacon example executing");

               nrf_delay_ms(500);

               NRF_LOG_FLUSH();

The header file nrf_delay.h was included to support the nrf_delay_ms function.

With the above changes done, the program was build and downloaded into the nRF 52840 DK. I could see the beacon work but the logging information did not work ( I used JLinkRTTViewer.exe to examine the logging information).

On debugging, the program is stuck in app_error_weak.c file at line number 100 that reads NRF_BREAKPOINT_COND;

Can someone help me with this? I hope I have included the necessary information.

  • Hi,

    Logging is enabled in the example by default, but only on the UART backend. To enable RTT backend, you need to set this config in your sdk_config.h file:

    //==========================================================
    // <e> NRF_LOG_BACKEND_RTT_ENABLED - nrf_log_backend_rtt - Log RTT backend
    //==========================================================
    #ifndef NRF_LOG_BACKEND_RTT_ENABLED
    #define NRF_LOG_BACKEND_RTT_ENABLED 1
    #endif

    Best regards,
    Jørgen

Related