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

Gatt connection writing via nrf_connect app only receiving a single byte

Hi,

I have a modified template of the ble_app_template example from sdk 15 NRF58240-dk pca 10056 s140.

I have written a custom function as per this tutorial : https://github.com/bjornspockeli/custom_ble_service_example

I am using the onwrite function to read data that I send via a NRF connect app. However, I wish to have a longer amount of data sent than a byte. But when I change my variable from a uint8 to anything bigger it does not read the data. Regardless of if I use the NRF connect app to send a byte, uint8 or uint16.

What could be my issue thanks,

Here is my on_write code. Works when using found_data(uint8) and sending a byte or uint8 via nrf connect.

void on_write(ble_cus_t * p_cus, ble_evt_t const * p_ble_evt)
{
    ble_gatts_evt_write_t * p_evt_write = &p_ble_evt->evt.gatts_evt.params.write;
    uint8_t found_data;
    //uint16_t found_data;
    
    // Check if the handle passed with the event matches the Custom Value Characteristic handle.
    if (p_evt_write->handle == p_cus->custom_value_handles.value_handle)
    {
        memcpy(&found_data, p_ble_evt->evt.gatts_evt.params.write.data, p_ble_evt->evt.gatts_evt.params.write.len);
        nrf_gpio_pin_toggle(LED_4); 
        NRF_LOG_INFO("data is: %d",found_data);
        if(found_data == 77){
            NRF_LOG_INFO("Dummy test passed");
        }
    }
}

Note I put a little test in if the value is 77 which passes when a 77 uint is passed in.

Parents Reply Children
Related