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

HVX indication works only once

Hey, I got 2 beacons which I have connected via BLE successfully however I have some problems with BLE_GATTC_EVT_HVX event. Every time I get only one BLE_GATTC_EVT_HVX event on client side. I am sure that server side changes characteristic more times because I have set breakpoints and checked it. What is more indication works perfect when I connect mobile phone to GATT server.

This is the code I use to enable indication on CCCD of that characteristics:

uint32_t err;
ble_gattc_write_params_t write_params;

uint8_t cccd = BLE_GATT_HVX_INDICATION ;

write_params.write_op = BLE_GATT_OP_WRITE_REQ;
write_params.flags = BLE_GATT_EXEC_WRITE_FLAG_PREPARED_WRITE;
write_params.handle = rx_cccd_handle;
write_params.offset = 0;
write_params.len = 1;
write_params.p_value = &cccd;

err = sd_ble_gattc_write(fsm.conn_handle, &write_params);
APP_ERROR_CHECK(err);

I am sure that I do not lose this event somewhere in my code cause I have counter of BLE_GATTC_EVT_HVX events in ble_evt_dispatch(ble_evt_t *p_ble_evt) function that is registered directly to softdevice_ble_evt_handler_set(ble_evt_dispatch).

I got no idea what might be wrong.

EDIT: I have solved the issue. On beacon I have to call sd_ble_gattc_hv_confirm(uint16_t conn_handle, uint16_t handle) explicitly. On mobile phone it is somehow automatic.

Related