From cdfb535f17f2f7104b9c3519df0bd91395f0eb26 Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 9 Oct 2017 20:58:26 +0700 Subject: [PATCH] only attemp to discover cccd --- libraries/Bluefruit52Lib/src/BLEDiscovery.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/libraries/Bluefruit52Lib/src/BLEDiscovery.cpp b/libraries/Bluefruit52Lib/src/BLEDiscovery.cpp index 0d22f948..55f2a54b 100644 --- a/libraries/Bluefruit52Lib/src/BLEDiscovery.cpp +++ b/libraries/Bluefruit52Lib/src/BLEDiscovery.cpp @@ -137,13 +137,16 @@ uint8_t BLEDiscovery::discoverCharacteristic(uint16_t conn_handle, BLEClientChar // characteristic assign overload chr[i]->assign(&disc_chr->chars[d]); - ble_gattc_handle_range_t range = { disc_chr->chars[d].handle_value + 1, _hdl_range.end_handle }; - - // Discovery All descriptors if possible - if ( range.start_handle <= range.end_handle ) + // only discover CCCD descriptor + if (disc_chr->chars[d].char_props.notify || disc_chr->chars[d].char_props.indicate ) { - // skip discovery descriptor - chr[i]->discoverDescriptor(conn_handle, range); + ble_gattc_handle_range_t range = { disc_chr->chars[d].handle_value + 1, _hdl_range.end_handle }; + + if ( range.start_handle <= range.end_handle ) + { + // skip if reaching end of range (last char has no descriptor)p + chr[i]->discoverDescriptor(conn_handle, range); + } } found++;