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

Need help with understanding sd_ble_gattc_hv_confirm input parameters

Let us say we have a struct

typedef struct
{
    uint16_t                    conn_handle;    /**< Handle of the current connection (as provided by the BLE stack, is BLE_CONN_HANDLE_INVALID if not in a connection).*/
    uint16_t                    service_handle; /**< Handle of Our Service (as provided by the BLE stack). */
    // OUR_JOB: Step 2.D, Add handles for the characteristic attributes to our struct
    ble_gatts_char_handles_t    char_handles;
    // Done with step 2.D
}ble_os_t;

Using this struct I have initialized a variable as

ble_os_t *p_our_service

Next I call the SoftDevice function to update a characteristic value (It has both notify and indicate turned on)

    char_md.char_props.notify   = 1;
    char_md.char_props.indicate = 1;
   


ble_gatts_hvx_params_t hvx_params;
  memset(&hvx_params, 0, sizeof(hvx_params));

  hvx_params.handle = p_our_service->char_handles.value_handle;
  hvx_params.type   = BLE_GATT_HVX_NOTIFICATION;
  hvx_params.offset = 1;
  hvx_params.p_len  = &len;
  hvx_params.p_data = (uint16_t*)sensor_value;
  sd_ble_gatts_hvx(p_our_service->conn_handle, &hvx_params);
  err_code = sd_ble_gattc_hv_confirm(p_our_service->conn_handle, p_our_service->char_handles.value_handle);

I get a response that NRF_ERROR_INVALID_STATE for  sd_ble_gattc_hv_confirm.

Have I passed the parameters correctly or am I doing it wrong? Please help me out.

Parents Reply
  • Hello Vidar,

    Yes. I did the one with BLE_GATTS_EVT_HVC earlier but I noticed that this was causing a new issue of the value not being read by the app as I am entering the System off state a bit too soon.

    I guess that is because I usedNRF_POWER->SYSTEMOFF = 1; .

    sd_power_system_off() was not working for me and my system continued transmitting the characteristic.

    Yesterday I found a way to over come this issue.

    I have given a delay by reading the BLE_GATTS_EVT_HVC event twice and it worked fine.

Children
No Data
Related