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

How can I set Characteristic value as zero while on transmission? (without notify)

I'd like to (re)set my characteristic's value to Zero. (after my services and characteristics are set)

I tried to search methods that can set value of characteristic when I'm not connected with any device, but I couldn't found any. (Actually, un-set my char and re-initialize will do, but I think this is pretty nasty solution..)

The only one method that I can set value is sd_ble_gatts_hvx and it needs to be called while I'm connected with other device.

My characteristic's properties are only have Read,Write.
I tried to set with BLE_GATT_HVX_INVALID, and it results NRF_ERROR_INVALID_PARAM
also I tried to set with BLE_GATT_HVX_INDICATION, and it results BLE_ERROR_GATTS_INVALID_ATTR_TYPE.

Q1. How can I set Characteristic value as zero while on transmission? (without notify)
(Actually I don't need to notify or indicate about this zero-filling work...)

Q2. Can I zero-fill when I'm not on connected sequence?
(Characteristics are on my side, so I don't really need to be connected to fill this with zero..)

  #define 	BLE_GATT_HVX_INVALID   0x00
  #define 	BLE_GATT_HVX_NOTIFICATION   0x01
  #define 	BLE_GATT_HVX_INDICATION   0x02

  param_type = BLE_GATT_HVX_*

  hvx_params.handle = data_handle->value_handle;
  hvx_params.offset = 0;
  hvx_params.p_len = &length; //sizeof(string)
  hvx_params.p_data = p_string; // which is zero-filled string.
  hvx_params.type = BLE_GATT_HVX_NOTIFICATION;
  hvx_params.type = param_type;

  return sd_ble_gatts_hvx(p_per->conn_handle, &hvx_params);
Parents Reply Children
No Data
Related