implement Central Characteristic Descriptor Discovery

This commit is contained in:
hathach committed 2017-03-22 21:36:55 +07:00
1 parent 65f86005c3
commit 1e15b3884e
4 files changed
+43 -16

No files matched your search

@@ -36,19 +36,42 @@
#include "bluefruit.h"
#define MAX_DESCIRPTORS 8
BLECentralCharacteristic::BLECentralCharacteristic(void)
: uuid()
{
varclr(&_chr);
_cccd_handle = 0;
}
BLECentralCharacteristic::BLECentralCharacteristic(ble_gattc_char_t* gattc_char)
: uuid(gattc_char->uuid)
{
_chr = (*gattc_char);
_cccd_handle = 0;
}
uint16_t BLECentralCharacteristic::valueHandle()
{
return _chr.handle_value;
}
bool BLECentralCharacteristic::discoverDescriptor(void)
{
ble_gattc_desc_t desc_arr[MAX_DESCIRPTORS];
uint16_t count = Bluefruit.Central.discoverDescriptor(desc_arr, arrcount(desc_arr));
// only care CCCD for now
for(uint16_t i=0; i<count; i++)
{
if ( desc_arr[i].uuid.type == BLE_UUID_TYPE_BLE &&
desc_arr[i].uuid.uuid == BLE_UUID_DESCRIPTOR_CLIENT_CHAR_CONFIG )
{
LOG_LV1(BLECentralUart, "Found CCDD: handle = %d", desc_arr[i].handle);
_cccd_handle = desc_arr[i].handle;
}
}
return true;
}