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

Application of BLE UART Console on 51822

I have a nRF51822 custom board for BLE UART application. Connects this to serial port of an ARM SoC board. P0.09 is for UART_Tx and P0.11 is for UART_Rx. No RTS and CTS are used.

Build examples/ble_peripheral/ble_app_uart for PCA10001 based on nRF5_SDK_12.1.0_0d23e2a.

Flash hex file to custom board as following sequence:

  1. softdevice components/softdevice/s130/hex/s130_nrf51_2.0.1_softdevice.hex

  2. ble_app_uart examples/ble_peripheral/ble_app_uart/pca10028/s130/armgcc/_build/nrf51422_xxac.hex

Test:

Using nRF UART or nRF tools on Android phone to receive console messages

The problem is my nRF UART only receives console messages less than 20 bytes per line.

Does ble_app_uart application handle console message that is bigger than 20 bytes per line?

Thanks for help!

---henry

Parents
  • Sigurd,

    Look at main.c in ble_app_uart subdirectory in nRF5_SDK_12.1.0_0d23e2a

    void uart_event_handle(app_uart_evt_t * p_event) { static uint8_t data_array[BLE_NUS_MAX_DATA_LEN]; static uint8_t index = 0; uint32_t err_code;

    switch (p_event->evt_type)
    {
        case APP_UART_DATA_READY:
            UNUSED_VARIABLE(app_uart_get(&data_array[index]));
            index++;
    
            if ((data_array[index - 1] == '\n') || (index >= (BLE_NUS_MAX_DATA_LEN)))
            {
                err_code = ble_nus_string_send(&m_nus, data_array, index);
                if (err_code != NRF_ERROR_INVALID_STATE)
                {
                    APP_ERROR_CHECK(err_code);
                }
    
                index = 0;
            }
            break;
    

    Above does split 20 bytes and sends to UART.

    Some posts suggest to check BLE_EVT_TX_COMPLETE as:

    void on_ble_evt(ble_evt_t * p_ble_evt) { switch (p_ble_evt->header.evt_id){

                 case BLE_EVT_TX_COMPLETE: 
    

    Call is not hit at "case BLE_EVT_TX_COMPLETE" when text messages are sent from serial console to nRF51822. But does hit it when send message from Android phone to nRF51822.

    Is there any reference code around?

    Thanks.

  • The function uart_event_handle() receives the characters you send on the terminal, and then sends the characters as a string to the phone. The function splits the string into 20 bytes blocks, so you will have no problem sending a single string of more than 20 bytes to the phone, as long as you don’t send it too often (overflow the buffers). After you have sent the string to the phone, you will get the event BLE_EVT_TX_COMPLETE.

    The problem is when you try to send strings longer than 20 bytes from the phone to the nRF51, since the example does not use read long characteristic.

Reply
  • The function uart_event_handle() receives the characters you send on the terminal, and then sends the characters as a string to the phone. The function splits the string into 20 bytes blocks, so you will have no problem sending a single string of more than 20 bytes to the phone, as long as you don’t send it too often (overflow the buffers). After you have sent the string to the phone, you will get the event BLE_EVT_TX_COMPLETE.

    The problem is when you try to send strings longer than 20 bytes from the phone to the nRF51, since the example does not use read long characteristic.

Children
No Data
Related