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

How to get the value from a WRITE_EVT into a variable.

I am trying to modify the ble_app_hrs so that i can write a value to the board and save it as a new heart rate value. So far i have added a BLE_GATTS_EVT_WRITE case to the event manager, as well as adding the specific handle i want the write value from.

How can i write the value given in the write event into the heart rate variable?

Parents
  • Hi Mathias,

    if I understand you correct, you just need to copy the value of the event/data.

    
    if (p_ble_evt->evt.gatts_evt.params.write.handle == my_handle)
    {
        memcpy(&destination, p_ble_evt->evt.gatts_evt.params.write.data, p_ble_evt->evt.gatts_evt.params.write.len);
    }
    
    

    if you would like to write to the server database, and store the value of the write there, then the best way to do that is to:

    
    uint16_t len = p_ble_evt->evt.gatts_evt.params.write.len;
    sd_ble_gatts_value_set(handle, 
                                           p_ble_evt->evt.gatts_evt.params.write.offset,
                                           &len,
                                           p_ble_evt->evt.gatts_evt.params.write.data);
    
    

    Hope this helps, BR Pål

  • Hi Mathias,

    If I write 123456 to device from Master Control Panel and want to get it ,then store it and display on the LCD .How can i achieve it?

    Thanks!

Reply Children
No Data
Related