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

What is the best solution of transfer data wirelessly between two nRF51822 when using uart(115200) in both sides?

Hello everybody,

I have two nRF51822. One of them is connected to MCU (STM32 Development Board Nucleo 32) via USART with 115200 baudrate. The other one is connected to USB TLL module via USART with 115200. I am trying to send 20 bytes from MCU to nRF51 then it sends the data via BLE to other nRF51 to send over USART then I read data from PC. I need to transfer data continuously regardless of power consumption.

I am using SDK 12.3.0 and S130 softdevice. I tried ble_app_uart_c and ble_app_uart examples. There is no hardware flow control.

MIN_CONNECTION_INTERVAL MSEC_TO_UNITS(7.5, UNIT_1_25_MS)
MAX_CONNECTION_INTERVAL MSEC_TO_UNITS(20, UNIT_1_25_MS)
SLAVE_LATENCY           0                              
SUPERVISION_TIMEOUT     MSEC_TO_UNITS(4000, UNIT_10_MS)

I achieved to send 20 bytes with 220 milisecond delay. I am trying to send data less delay time. When I reduce the delay, the connection is never established.

Maybe it isn't the right way to send data. Can you suggest me way to do it?

Parents
  • Hello,

     

    When I reduce the delay, the connection is never established.

     So you never get the connected event, BLE_GAP_EVT_CONNECTED?

    If you do, do you get the BLE_GAP_EVT_DISCONNECTED?

    If you don't get the connected event, are you sure that both of your applications are running? Maybe your peripheral is running into an app_error?

    How do you determine that the connection is never established?

    On your central, ble_app_uart_c, do you see the advertising reports from the peripheral? Look in on_ble_evt() case BLE_GAP_EVT_ADV_REPORT.

    Does is_uuid_present() return true?

    My suspicion is that you connect (because the timing you refer to shouldn't affect the advertisements or connection procedure). I guess that you get caught in an APP_ERROR_CHECK() on your peripheral, which will reset the application. Is that the case?

    Best regards,

    Edvin

  • So you never get the connected event, BLE_GAP_EVT_CONNECTED?

    I checked the connection from peripheral side. So, when the connection established, the peripherial side sends to computer "connected". When there is disconnection, it sends "disconnected". However, I cannot check the connection apart from this.

    I am checking the advertisements with leds toggles. 

    How do you determine that the connection is never established?

    I reverted the settings to as previous explanation. The connection is established again.

    static void ble_nus_c_evt_handler(ble_nus_c_t * p_ble_nus_c, const ble_nus_c_evt_t * p_ble_nus_evt)
    {
        uint32_t err_code;
        switch (p_ble_nus_evt->evt_type)
        {
            case BLE_NUS_C_EVT_DISCOVERY_COMPLETE:
                err_code = ble_nus_c_handles_assign(p_ble_nus_c, p_ble_nus_evt->conn_handle, &p_ble_nus_evt->handles);
                APP_ERROR_CHECK(err_code);
    
                err_code = ble_nus_c_rx_notif_enable(p_ble_nus_c);
                APP_ERROR_CHECK(err_code);
    						printf("c");
    //            printf("The device has the Nordic UART Service\r\n");
                break;
    
            case BLE_NUS_C_EVT_NUS_RX_EVT:
                for (uint32_t i = 0; i < p_ble_nus_evt->data_len; i++)
                {
                    while (app_uart_put( p_ble_nus_evt->p_data[i]) != NRF_SUCCESS);
                }
                break;
    
            case BLE_NUS_C_EVT_DISCONNECTED:
    						printf("d");
    //            printf("Disconnected\r\n");
                scan_start();
                break;
        }
    }

    When the central side is connected, it sends "c" to MCU. Then, MCU begins to send numbers over UART. 

    I guess that you get caught in an APP_ERROR_CHECK() on your peripheral, which will reset the application. Is that the case?

    How can I check which APP_ERROR_CHECK() causing problem without SEGGER Debugger? (Now, I am trying to printf all APP_ERROR_CHECK over other UART.)
    What is the reason of resetting application? When does the nRF51822 go into reset?
    Maybe, I can use RF examples for fast data transfer.
     

  • msariisik said:
    How can I check which APP_ERROR_CHECK() causing problem without SEGGER Debugger?

     Do you have a debugger at all? It is kind of difficult to do developing without. 

    So you can monitor your log, right. Do you ever see a line with "fatal" in the log? Note that your log is on RTT, and not the UART. Please check that 

    If you follow the definitions from APP_ERROR_CHECK() -> APP_ERROR_HANDLER().

    Depending on whether DEBUG is defined in the preprocessor defines or not. If it is defined:

    APP_ERROR_HANDLER() -> app_error_handler() which is implemented in app_error.c on line 68.

    If you have no way of debugging, you may try to alter this function. Try something like this in your app_error_handler:

    void app_error_handler(ret_code_t error_code, uint32_t line_num, const uint8_t * p_file_name)
    {
        error_info_t error_info =
        {
            .line_num    = line_num,
            .p_file_name = p_file_name,
            .err_code    = error_code,
        };
        //app_error_fault_handler(NRF_FAULT_ID_SDK_ERROR, 0, (uint32_t)(&error_info));
        NRF_LOG_ERORR("error %d at line %d, in file 0x%x", error_code, line_num, p_file_name);
        NRF_LOG_FINAL_FLUSH();
        while (1)
        {
            //do nothing
        };
    
        UNUSED_VARIABLE(error_info);
    }

    You will not be able to find the file name without a debugger. the file. It will just point to the address of the function, but you can check the files that you suspect that the error comes from. 

    It is really difficult to say what the issue is if you are not able to debug in your project. Do you have any nRF51 DKs or anything else that you can use for development purposes?

    Best regards,

    Edvin

Reply
  • msariisik said:
    How can I check which APP_ERROR_CHECK() causing problem without SEGGER Debugger?

     Do you have a debugger at all? It is kind of difficult to do developing without. 

    So you can monitor your log, right. Do you ever see a line with "fatal" in the log? Note that your log is on RTT, and not the UART. Please check that 

    If you follow the definitions from APP_ERROR_CHECK() -> APP_ERROR_HANDLER().

    Depending on whether DEBUG is defined in the preprocessor defines or not. If it is defined:

    APP_ERROR_HANDLER() -> app_error_handler() which is implemented in app_error.c on line 68.

    If you have no way of debugging, you may try to alter this function. Try something like this in your app_error_handler:

    void app_error_handler(ret_code_t error_code, uint32_t line_num, const uint8_t * p_file_name)
    {
        error_info_t error_info =
        {
            .line_num    = line_num,
            .p_file_name = p_file_name,
            .err_code    = error_code,
        };
        //app_error_fault_handler(NRF_FAULT_ID_SDK_ERROR, 0, (uint32_t)(&error_info));
        NRF_LOG_ERORR("error %d at line %d, in file 0x%x", error_code, line_num, p_file_name);
        NRF_LOG_FINAL_FLUSH();
        while (1)
        {
            //do nothing
        };
    
        UNUSED_VARIABLE(error_info);
    }

    You will not be able to find the file name without a debugger. the file. It will just point to the address of the function, but you can check the files that you suspect that the error comes from. 

    It is really difficult to say what the issue is if you are not able to debug in your project. Do you have any nRF51 DKs or anything else that you can use for development purposes?

    Best regards,

    Edvin

Children
No Data
Related