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

Logging Data over BLE UART from nRF Device to Laptop

Hi,

I am currently using the nRF logging module to log data from a nRF52832-DK to my laptop via a serial connection. However, I would like to move over to BLE logging for the sake of convenience. I've been looking at the ble_app_uart example for a while, but I'm having trouble applying it to my specific use case.

Instead of calling NRF_LOG_INFO() to send data to my laptop over a serial connection, how can I implement a similar function to send data to my laptop over BLE?

Thanks!

Parents Reply
  • Hi,

    So I should have been a bit more precise in my previous comment. The ble_nus_data_send() doesn't really convert the data to ASCII but instead threats the string as an array of bytes. What data types is buffer, and the 3 other parameters that you're passing to sprintf? Also, set a breakpoint after the call to sprintf and watch the buffer variable. How does it look in debug view? Is it correctly formatted? The phone that you use might also affect how the data is printed on the other side. 

    In addition, I just remembered that we actually have a better example for your use case. Namely using the CLI over BLE. See the example in the SDK and the documentation of CLI.  

    regards

    Jared 

Children
  • Hi Jared,

    The data type of buffer is a string, with 2 ints and a string variable being substituted into the string using sprintf(). I will take a look at the buffer variable in debug view, thanks. I am using an iPhone with nRF Toolbox to view the messages sent by my device. 

    Thanks for linking that example, I'll take a look!

  • Hi Jared,

    When I try to build and run ble_app_cli_pca10040_s132 on my nRF52-DK using SDK 16, I get these messages repeatedly over my serial connection:

    [00:00:00.000,000] <info> app_timer: RTC: initialized.

    [00:00:00.000,000] <info> stack_guard: Stack Guard (128 bytes): 0x2000E000-0x2000E07F (total stack size: 8192 bytes, usable stack area: 8064 bytes)

    [00:00:00.000,000] <info> pwr_mgmt: Init

    [00:00:00.000,000] <info> task_manager: Task 0 created (name: 'uart_cli:~$ ', stack: 0x20003B00-0x20003EFF).

    [00:00:00.000,000] <error> peer_manager_pds: Could not initialize flash storage. fds_init() returned 0x860A.

    [00:00:00.000,000] <error> peer_manager: pm_init failed because pds_init() returned NRF_ERROR_STORAGE_FULL.

    [00:00:00.000,000] <error> app: Fatal error

    [00:00:00.000,000] <warning> app: System reset

    This seems to indicate something is going wrong with the example itself, so I don't think I can move forward with integrating it with my project. Do you have any recommendations? Is this something that may have been fixed in the latest SDK? My original project is built on SDK 16 so I don't know if I can safely use SDK 17 example files in it.

    Thanks!

    Kyle

    EDIT: I tried ble_app_cli on SDK 17.0.2 and I get the same error message in the serial terminal. It seems like storage is full upon initialization even though the board is being newly programmed. This shouldn't be happening, right?

    EDIT 2: Clicking Target>Erase All in SES did the trick for me! Issues with FDS carrying over from previous programs.

  • Hi,

    I saw that you made a new ticket, did you solve this already?

    regards

    Jared 

  • I am trying to use the BLE over CLI example, so I decided to make a new ticket for it. I will close this one. Thanks Jared!

Related