7 years, 6 months ago.

How to know when a GATT client characteristic is updated

I'm developing a BLE Client device, based on X-nucleo-IDB05A1. On my application, I want to be notified when the server device updates the characteristic.Once i get any kind of notification ,then only i will perform read operation.I am still unable to find any kind of example code where the client gets notified on characteristic update by the server.Can any one please guide me how to achieve this?

1 Answer

5 years, 10 months ago.

Im also struggling on this one. I managed to write to the cccd of the desired characterisitc using ble.gattClient().write(). it looked sth like this:

write cccd

void write_cccd(){
        uint8_t notification_enabled = 1;
        BLE &ble = BLE::Instance();
        ble_error_t err = ble.gattClient().write(

            GattClient::GATT_OP_WRITE_REQ,
            ledCharacteristic.getConnectionHandle(),
            _CCCD_handle,
            sizeof(notification_enabled),
            reinterpret_cast<const uint8_t*>(&notification_enabled)

        );
        if(err == 0){
            printf("cccd update successfull\n");
        }else{
            printf("error updating: error_code [%u]\n", err);
        }
}

i also receive read events from GattClient, but however, they seem to have the wrong value attribute handle, connection handle and data.

receive updates

void onUpdatesCallback(const GattHVXCallbackParams *updates){
        uint8_t p_data = 0;
        printf("updates recieved: connHandle[%u]    attrHandle[%u]  Data[%u] Type[%x]\n",
                updates->connHandle,
                updates->handle,
                p_data = updates->data[0] ^ 0x1,
                updates->type
        );

}

Im wondering if someone find a solution to this. Hope for the best, Philipp