Hi!
So I have my GATT value of a service that I would like to update. Sadly that value always stays at the initial value. Below you can find my update function.
uint32_t ble_pwr_data_update(ble_pwr_t* p_pwr, pwr_data_t pwr_data){
if (p_pwr == NULL){
return NRF_ERROR_NULL;
}
uint32_t err_code = NRF_SUCCESS;
ble_gatts_value_t gatts_value;
// Initialize value struct.
memset(&gatts_value, 0, sizeof(gatts_value));
gatts_value.len = sizeof(uint8_t);
gatts_value.offset = 0;
gatts_value.p_value = (uint8_t*)&pwr_data;
// Update databasee.
err_code = sd_ble_gatts_value_set(p_pwr->conn_handle,
p_pwr->pwr_handles.value_handle,
&gatts_value);
if (err_code == NRF_SUCCESS){
// Save new Voltage value.
p_pwr->pwr_data = pwr_data;
}else{
return err_code;
}
// Send value if connected and notifying.
if ((p_pwr->conn_handle != BLE_CONN_HANDLE_INVALID) && p_pwr->is_notification_supported){
ble_gatts_hvx_params_t hvx_params;
memset(&hvx_params, 0, sizeof(hvx_params));
hvx_params.handle = p_pwr->pwr_handles.value_handle;
hvx_params.type = BLE_GATT_HVX_NOTIFICATION;
hvx_params.offset = gatts_value.offset;
hvx_params.p_len = &gatts_value.len;
hvx_params.p_data = gatts_value.p_value;
err_code = sd_ble_gatts_hvx(p_pwr->conn_handle, &hvx_params);
}
else{
err_code = NRF_ERROR_INVALID_STATE;
}
return err_code;
}
Do I do this in improper fashion?
(p_pwr->conn_handle != BLE_CONN_HANDLE_INVALID) && p_pwr->is_notification_supported
returns true, so it should also notify. I pulled the value manually tho to be sure. No change.
Thanks for any advice Best wishes Noah