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

ble_app_blinky + usb cli + 2x uart

I'm working on a prototype currently using the nRF52840 dongle. I've used the ble_app_blinky as a basic, and added some custom code to it. The goal is to use BLE in the end, but I've edited main to not do any ble at this stage. I've added support for both uarts and integrated in some of the cli demo using the usb port. So far, everything is working. Since this is based on the ble_app_blinky, the app uses s140 softdevice.

However, I've modified the behavior of the timer_handle() function.

static void timer_handle(void * p_context)

{
    UNUSED_PARAMETER(p_context);

    if (m_counter_active)
    {
        char line[80];
        sprintf(line"~~ counter = %d\r\n"m_counter);
        nrf_libuarte_async_tx(&uart0, linestrlen(line));

        // nrf_cli_print(p_cli, "counter = %d\n", m_counter);
        NRF_LOG_RAW_INFO("~~ counter = %d\n"m_counter);

        m_counter++;
    }
}
When I use the cli to "counter start", I see the counter being updated via the uart interface, but unlike the non-softdevice cli program, I don't see the counter update in the cli display anymore. I've looked through the sdk_config.h, and things mostly match. There are very few small differences.
I've also added a number of my own commands to a cli_cmds.c file. I can enter a command and see data this way, but how do I get external code like the timer_handle() to get data to show on the usb cli?
  • On the code above, if I uncomment the nrf_cli_print() and comment out the other one, I do see data printing on the cli, but the output is not as nice as the original. As I type further commands, this adds to what's being output. The NRF_LOG_RAW_INFO() in the non s140 cli program just displays the output on it's own line, keeping the user prompt at the bottom.

  • Hi Justin, 

    Have you tried the ble_app_interactive in ble_central_and_peripherals examples ? or ble_app_cli in ble_peripheral examples ? They are CLI with softdevice. 

    Please note that when the softdevice is used the idle task is a little bit different. You may want to have a look at the idle_state_handler() function inside ble_app_interactive example. 

  • I've looked at the code for both of those. They both target the nrf52840 dk, which I don't have. I was able to use the cli one to add in a task which worked better for making the cli seem smooth when I had other things occurring periodically using a counter in the task.

    What I don't get is that in the original cli demo I was looking at the line:

    NRF_LOG_RAW_INFO("~~ counter = %d\n"m_counter);

    would then display info in the cli window. If the counter was active, the window would update at a set rate, but I could still type into the cli.

    In my app, this line doesn't print. This is likely a setup issue, but I can't see any obvious difference in the sdk_config.h files. Is the RTT logging necessary?

  • I would suggest to start your development on a DK. The dongle is not a development board, it's made as a hardware backend for our nRF Connect software. 

    Please check what I mentioned about inside idle_state_handler()

Related