Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

CLI buffer problem

Hi everyone,

I'm using ble_app_interactive (SDK17.0.2) as a starting point for my application, which consists in sending commands from my PC to my nRF52DK, which is in charge to perform several BLE operations. I send the following commands to read some data from my BLE commercial device:

scan on

gatt services XX:XX:XX:XX:XX:XX

gatt characteristics XX:XX:XX:XX:XX:XX YYYY

gatt notification on XX:XX:XX:XX:XX:XX YYYY

It is all good until occur some problems with the buffering of the command that I sent. As echo messages, I sometimes get things such as:

gatt read D1:97:3C:2F:2F:C4 6f87:BF

where "87:BF" is a part of a previous command that I sent several seconds before the current command. 

It seems there is a problem of buffering the command, so when this buffer is full, some parts of previous command appears concatenated with the current command. If I well understand, there is a ring buffer that implement the buffer for this commands, which seems to be initialized with:

NRF_CLI_UART_DEF(m_cli_uart_transport, 0, 256, 256);

in the main file of the ble_app_interactive example. If it is responsible for this buffering, is there a way to reset it whenever I need, in order to avoid the above problem?

 

Parents
  • Hi,

    It looks like the example uses the following define by default:

    NRF_CLI_UART_DEF(m_cli_uart_transport, 0, 64, 16);

    Did you modify the buffer sizes? Have you seen the same issue with default settings?

    Are you using Putty with the recommended Terminal settings to test this?

    Best regards,
    Jørgen

  • Hi Jorgen,

    I modified the example because that configuration sometimes determined error in the communication when I received too much data (in particular with the characteristic list). I solved that problem changing from:

    NRF_CLI_UART_DEF(m_cli_uart_transport, 0, 64, 16);

    to:

    NRF_CLI_UART_DEF(m_cli_uart_transport, 0, 256, 256);

    I want to obtain a simple communication with the PC (mantaining BLE connection capabilities) with the goal of developing a simple GUI that will send command to che nrf52DK and receive responses (about BLE data of other nearby devices: for this purpose, i simplified as much as possibile the CLI by removing logs and colors functionality and other configurations in the sdk_config.h, as follows:

    // <o> GATT_DATA_WRITE_SIZE - Maximum size of GATT data to write. 
    #ifndef GATT_DATA_WRITE_SIZE
    #define GATT_DATA_WRITE_SIZE 64
    #endif
    
    // <o> MAX_CHARACTERISTIC_COUNT - Maximum count of characteristics to find. 
    #ifndef MAX_CHARACTERISTIC_COUNT
    #define MAX_CHARACTERISTIC_COUNT 20
    #endif
    
    #ifndef UART_DEFAULT_CONFIG_IRQ_PRIORITY
    #define UART_DEFAULT_CONFIG_IRQ_PRIORITY 2
    #endif
    
    #ifndef NRF_CLI_BUILD_IN_CMDS_ENABLED
    #define NRF_CLI_BUILD_IN_CMDS_ENABLED 0
    #endif
    
    // <o> NRF_CLI_CMD_BUFF_SIZE - Maximum buffer size for a single command. 
    #ifndef NRF_CLI_CMD_BUFF_SIZE
    #define NRF_CLI_CMD_BUFF_SIZE 512
    #endif
    
    // <o> NRF_CLI_PRINTF_BUFF_SIZE - Maximum print buffer size. 
    #ifndef NRF_CLI_PRINTF_BUFF_SIZE
    #define NRF_CLI_PRINTF_BUFF_SIZE 1024
    #endif
    
    #ifndef NRF_CLI_VT100_COLORS_ENABLED
    #define NRF_CLI_VT100_COLORS_ENABLED 0
    #endif
    
    #ifndef NRF_CLI_STATISTICS_ENABLED
    #define NRF_CLI_STATISTICS_ENABLED 0
    #endif
    
    #ifndef NRF_CLI_LOG_BACKEND
    #define NRF_CLI_LOG_BACKEND 0
    #endif
    #ifndef NRF_LOG_ENABLED
    #define NRF_LOG_ENABLED 0
    #endif
    
    #ifndef NRF_LOG_STR_PUSH_BUFFER_SIZE
    #define NRF_LOG_STR_PUSH_BUFFER_SIZE 256
    #endif

    So, I don't use anymore putty (which I tested in the first phase of the development), but I use an application written for the purpose above, which read/send data from/to serial port.

    Best regards and thanks for your help!

    Antonino

Reply
  • Hi Jorgen,

    I modified the example because that configuration sometimes determined error in the communication when I received too much data (in particular with the characteristic list). I solved that problem changing from:

    NRF_CLI_UART_DEF(m_cli_uart_transport, 0, 64, 16);

    to:

    NRF_CLI_UART_DEF(m_cli_uart_transport, 0, 256, 256);

    I want to obtain a simple communication with the PC (mantaining BLE connection capabilities) with the goal of developing a simple GUI that will send command to che nrf52DK and receive responses (about BLE data of other nearby devices: for this purpose, i simplified as much as possibile the CLI by removing logs and colors functionality and other configurations in the sdk_config.h, as follows:

    // <o> GATT_DATA_WRITE_SIZE - Maximum size of GATT data to write. 
    #ifndef GATT_DATA_WRITE_SIZE
    #define GATT_DATA_WRITE_SIZE 64
    #endif
    
    // <o> MAX_CHARACTERISTIC_COUNT - Maximum count of characteristics to find. 
    #ifndef MAX_CHARACTERISTIC_COUNT
    #define MAX_CHARACTERISTIC_COUNT 20
    #endif
    
    #ifndef UART_DEFAULT_CONFIG_IRQ_PRIORITY
    #define UART_DEFAULT_CONFIG_IRQ_PRIORITY 2
    #endif
    
    #ifndef NRF_CLI_BUILD_IN_CMDS_ENABLED
    #define NRF_CLI_BUILD_IN_CMDS_ENABLED 0
    #endif
    
    // <o> NRF_CLI_CMD_BUFF_SIZE - Maximum buffer size for a single command. 
    #ifndef NRF_CLI_CMD_BUFF_SIZE
    #define NRF_CLI_CMD_BUFF_SIZE 512
    #endif
    
    // <o> NRF_CLI_PRINTF_BUFF_SIZE - Maximum print buffer size. 
    #ifndef NRF_CLI_PRINTF_BUFF_SIZE
    #define NRF_CLI_PRINTF_BUFF_SIZE 1024
    #endif
    
    #ifndef NRF_CLI_VT100_COLORS_ENABLED
    #define NRF_CLI_VT100_COLORS_ENABLED 0
    #endif
    
    #ifndef NRF_CLI_STATISTICS_ENABLED
    #define NRF_CLI_STATISTICS_ENABLED 0
    #endif
    
    #ifndef NRF_CLI_LOG_BACKEND
    #define NRF_CLI_LOG_BACKEND 0
    #endif
    #ifndef NRF_LOG_ENABLED
    #define NRF_LOG_ENABLED 0
    #endif
    
    #ifndef NRF_LOG_STR_PUSH_BUFFER_SIZE
    #define NRF_LOG_STR_PUSH_BUFFER_SIZE 256
    #endif

    So, I don't use anymore putty (which I tested in the first phase of the development), but I use an application written for the purpose above, which read/send data from/to serial port.

    Best regards and thanks for your help!

    Antonino

Children
No Data
Related