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

Data sending of ble_app_uart question in ble_central

I example test ble_central and ble_peripheral of ble_app_uart. Radio TX and RX test is OK. It confirmed the data communications relating to uart_event_handler function.

if ((data_array[index - 1] == '\n') || (index >= (BLE_NUS_MAX_DATA_LEN)))
{
    err_code = ble_nus_string_send(&m_nus, data_array, index);
}   

when '\n' or length, should call the function ble_nus_string_send. But I have an arduino download wirelessly(nrf51822). arduino download data without the epilogue to '\n', length also is not fixed. I want to spend as data is coming. So, modified ble_app_uart. uart_event_handle function of ble_pripheral and ble_central as below.

switch (p_event->evt_type)
    {
        case APP_UART_DATA_READY:
            UNUSED_VARIABLE(app_uart_get(&data_array[index]));
            index++;
            ble_nus_string_send(&m_nus, data_array, index);
            index = 0;
       break;
....

ble_pripheral is OK. ble_central is not OK. ble_central When you send the data 10 received only one front. Where parts need to modify? Or is the source code for the modem type?

  • Hi,

    I think I do understand what is your goal and what you have done. Let me know if I am wrong:

    You want to transfer binary data over UART over BLE. You use the Nordic UART Service examples from the SDK (found in examples\ble_peripheral\ble_app_uart and examples\ble_central\ble_app_uart_c folders of the SDK). The problem is that the newline character \n is not handled correctly. This corresponds to hexadecimal value 0x0A, or 10 in decimal. You have changed the uart event handler to relay data at once, where the old behaviour was to wait for a string of maximal length or the newline character. Was this correctly understood?

    If I understand you correctly the problem arises when you send the newline character, and you experience that the data stream stops at that character, and anything beyond that character is lost. Is this a correct problem description?

    The Nordic UART Service examples can be used this way, when you are using both peripheral and central: [A]<--Regular UART--> [nRF peripheral] <--NUS--> [nRF central] <--Regular UART--> [B]. Is this the setup you are using, and what are the devices [A] and [B]? If not, where does the UART communication come from and where does it go to?

    Regards, Terje

  • thank you for your comment. you're right. I addition comment. [A] is Atmega328pa(robot education), [B] is computer(Arduino download program).

  • add a comment. receive at the same time 18050byte 115200baudrate, from arduino program(download program) to central nrf51822 . so. I want sending single byte after 18050byte storage. it is a possible?

  • add a comment. Is necessary handshake flow control to prevent loss of data. Is there a way to control the flow of a handshake?

  • The regular UART part of the NUS examples uses hardware flow control, as can be read in the documentation for the example, section Initializing UART: "Note that app_uart_comm_params_t configures the application to use hardware flow control. Therefore, RTS_PIN_NUMBER and CTS_PIN_NUMBER are used as Ready-to-Send and Clear-to-Send pins, respectively."

    The Nordic UART Service (NUS) should be reliable as long as the BLE connection is not lost, and I do not see why \n should be handled differently from other characters there. Have you located where in the transfer it breaks? (I.e. at which of the three links UART, NUS and UART.) Also, are you sure that the \n character is handled correctly by both [A] and [B]?

Related