File tree Expand file tree Collapse file tree 4 files changed +30
-10
lines changed
libraries/Bluefruit52Lib/src Expand file tree Collapse file tree 4 files changed +30
-10
lines changed Original file line number Diff line number Diff line change @@ -91,6 +91,27 @@ void BLEClientCharacteristic::disconnect(void)
9191 _chr.handle_value = BLE_GATT_HANDLE_INVALID;
9292}
9393
94+
95+ bool BLEClientCharacteristic::discover (void )
96+ {
97+ ble_gattc_handle_range_t bck_range = Bluefruit.Discovery .getHandleRange ();
98+
99+ // Set discovery handle to parent's service
100+ Bluefruit.Discovery .setHandleRange ( _service->getHandleRange () );
101+
102+ bool result = Bluefruit.Discovery .discoverCharacteristic ( _service->connHandle (), *this ) > 0 ;
103+
104+ // Set back to previous
105+ Bluefruit.Discovery .setHandleRange (bck_range);
106+
107+ return result;
108+ }
109+
110+ bool BLEClientCharacteristic::discovered (void )
111+ {
112+ return _chr.handle_value != BLE_GATT_HANDLE_INVALID;
113+ }
114+
94115void BLEClientCharacteristic::useAdaCallback (bool enabled)
95116{
96117 _use_AdaCallback = enabled;
@@ -106,10 +127,7 @@ uint16_t BLEClientCharacteristic::valueHandle(void)
106127 return _chr.handle_value ;
107128}
108129
109- bool BLEClientCharacteristic::discovered (void )
110- {
111- return _chr.handle_value != BLE_GATT_HANDLE_INVALID;
112- }
130+
113131
114132uint8_t BLEClientCharacteristic::properties (void )
115133{
Original file line number Diff line number Diff line change @@ -64,9 +64,11 @@ class BLEClientCharacteristic
6464
6565 void begin (BLEClientService* parent_svc = NULL );
6666
67+ bool discover (void );
68+ bool discovered (void );
69+
6770 uint16_t connHandle (void );
6871 uint16_t valueHandle (void );
69- bool discovered (void );
7072 uint8_t properties (void );
7173
7274
Original file line number Diff line number Diff line change @@ -96,10 +96,9 @@ void BLEClientService::setHandleRange(ble_gattc_handle_range_t handle_range)
9696 _hdl_range = handle_range;
9797}
9898
99- void BLEClientService::setHandleRange ( uint16_t start_hdl, uint16_t end_hdl )
99+ ble_gattc_handle_range_t BLEClientService::getHandleRange ( void )
100100{
101- _hdl_range.start_handle = start_hdl;
102- _hdl_range.end_handle = end_hdl;
101+ return _hdl_range;
103102}
104103
105104void BLEClientService::disconnect (void )
Original file line number Diff line number Diff line change @@ -62,8 +62,9 @@ class BLEClientService
6262 bool discovered (void );
6363
6464 uint16_t connHandle (void );
65- void setHandleRange (uint16_t start_hdl, uint16_t end_hdl);
66- void setHandleRange (ble_gattc_handle_range_t handle_range);
65+
66+ void setHandleRange (ble_gattc_handle_range_t handle_range);
67+ ble_gattc_handle_range_t getHandleRange (void );
6768
6869 friend class BLEGatt ;
6970};
You can’t perform that action at this time.
0 commit comments