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

CLI UART + NUS

Hello,

I'm trying to make CLI working with UART and BLE (NUS) backend simultaneously. Starting point is CLI example from SDK 14. What should I enable in sdk_config.h and how shuould I intialize CLI with UART and NUS in my app? In ble_app_cli CLI NUS is working alongside with RTT backend. How can I use UART instead of RTT?

  • I think you can modify this example:

    examples\ble_peripheral\experimental\ble_app_cli

    Baically you need to change RTT to UART (you can base on this example: \examples\peripheral\cli as it uses both RTT and UART)

  • For now I have Logger module + CLI + UART (as transport layer). I would like to add NUS, and make it working simultaneously.

    This is what I added to makefile:

    $(SDK_ROOT)/components/libraries/experimental_cli/ble_uart/nrf_cli_ble_uart.c \
    $(SDK_ROOT)/components/ble/ble_services/ble_nus/ble_nus.c \
    $(SDK_ROOT)/components/libraries/experimental_cli/ble_uart \
    

    This is what I changed/added to sdk_config.h:

    #define BLE_NUS_ENABLED 1
    #define NRF_CLI_BLE_UART_ENABLED 1
    
  • This is CLI part of my app:

    #define CLI_EXAMPLE_LOG_QUEUE_SIZE (4)
    NRF_CLI_UART_DEF(m_cli_uart_transport, 0, 64, 16);
    NRF_CLI_BLE_UART_DEF(cli_ble_uart, &m_gatt, 64, 32);
    NRF_CLI_DEF(m_cli_uart, "ub_dongle:~$ ", &m_cli_uart_transport.transport, '\r', CLI_EXAMPLE_LOG_QUEUE_SIZE);
    NRF_CLI_DEF(m_ble_cli, "cli_ble:~$ ", &cli_ble_uart.transport,, '\r', CLI_EXAMPLE_LOG_QUEUE_SIZE);
    

    On ble connection:

    nrf_cli_ble_uart_config_t config = { .conn_handle = m_conn_handle };
    err_code = nrf_cli_init(&m_ble_cli, &config, true, true, NRF_LOG_SEVERITY_NONE);
    APP_ERROR_CHECK(err_code);
    APP_ERROR_CHECK(nrf_cli_task_create(&m_ble_cli));
    

    On ble disconnection:

    (void)nrf_cli_uninit(&m_ble_cli);
    
  • CLI UART init:

    nrf_drv_uart_config_t uart_config = NRF_DRV_UART_DEFAULT_CONFIG;
    uart_config.pseltxd = TX_PIN_NUMBER;
    uart_config.pselrxd = RX_PIN_NUMBER;
    uart_config.hwfc    = NRF_UART_HWFC_DISABLED;
    ret                 = nrf_cli_init(&m_cli_uart, &uart_config, true, true, NRF_LOG_SEVERITY_INFO);
    APP_ERROR_CHECK(ret);
    

    Where should I put this:

    APP_ERROR_CHECK(nrf_cli_ble_uart_service_init());
    

    And this:

    ret_code_t ret;
    
    ret = nrf_cli_start(&m_cli_uart);
    APP_ERROR_CHECK(ret);
    

    I always getting fatal error on nrf_cli_ble_uart_service_init().

  • Can you please edit your question and explain what you have done there? Not in comment to an answer? Please also consider including the complete project. And exactly which function that returns the error.

Related