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

Send a string from nrf52840 to Android

Hello,

I really need your help with my problem.

I have a sparkfun nrf52840 mini which is the peripheral, using the code ble_app_uart, and a smartphone with a custom Android app, which is the central.

I tried to send a string from peripheral to nrf Connect app with ble_nus_data_string(), but I have received no string in the application. 

I have also enabled TX Characteristic from application, but the only message is: "Notifications enabled sent".

The code that transmits is:

static uint16_t m_conn_handle=BLE_CONN_HANDLE_ALL;
in  ble_evt_handler() function:
case BLE_GAP_EVT_CONNECTED:
    NRF_LOG_INFO("Connected");
    err_code=bsp_indication_set(BSP_INDICATE_CONNECTED);
    APP_ERROR_CHECK(err_code);
    m_conn_handle=p_ble_evt->evt.gap_evt.conn_handle;
    err_code=nrf_ble_qwr_conn_handle_assign(&m_qwr,m_conn_handle);
    APP_ERROR_CHECK(err_code);


    if(m_conn_handle!=BLE_CONN_HANDLE_INVALID)
    {
        uint8_t data_array[2]={'A','\n'};
        uint16_t length=4;

        err_code = ble_nus_data_send(&m_nus, data_array, &length, m_conn_handle);

        for(int i=0;i<3;i++)
        {
            bsp_board_led_on(ADVERTISING_LED);
            nrf_delay_ms(2000);
            bsp_board_led_off(ADVERTISING_LED);
            nrf_delay_ms(2000);
        }
    }
I receive NRF_ERROR_INVALID_STATE in the err_code

Is anything not correct?

How can I see the string in the app?

Thank you!

Parents Reply Children
No Data
Related