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)
91
91
_chr.handle_value = BLE_GATT_HANDLE_INVALID;
92
92
}
93
93
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
+
94
115
void BLEClientCharacteristic::useAdaCallback (bool enabled)
95
116
{
96
117
_use_AdaCallback = enabled;
@@ -106,10 +127,7 @@ uint16_t BLEClientCharacteristic::valueHandle(void)
106
127
return _chr.handle_value ;
107
128
}
108
129
109
- bool BLEClientCharacteristic::discovered (void )
110
- {
111
- return _chr.handle_value != BLE_GATT_HANDLE_INVALID;
112
- }
130
+
113
131
114
132
uint8_t BLEClientCharacteristic::properties (void )
115
133
{
Original file line number Diff line number Diff line change @@ -64,9 +64,11 @@ class BLEClientCharacteristic
64
64
65
65
void begin (BLEClientService* parent_svc = NULL );
66
66
67
+ bool discover (void );
68
+ bool discovered (void );
69
+
67
70
uint16_t connHandle (void );
68
71
uint16_t valueHandle (void );
69
- bool discovered (void );
70
72
uint8_t properties (void );
71
73
72
74
Original file line number Diff line number Diff line change @@ -96,10 +96,9 @@ void BLEClientService::setHandleRange(ble_gattc_handle_range_t handle_range)
96
96
_hdl_range = handle_range;
97
97
}
98
98
99
- void BLEClientService::setHandleRange ( uint16_t start_hdl, uint16_t end_hdl )
99
+ ble_gattc_handle_range_t BLEClientService::getHandleRange ( void )
100
100
{
101
- _hdl_range.start_handle = start_hdl;
102
- _hdl_range.end_handle = end_hdl;
101
+ return _hdl_range;
103
102
}
104
103
105
104
void BLEClientService::disconnect (void )
Original file line number Diff line number Diff line change @@ -62,8 +62,9 @@ class BLEClientService
62
62
bool discovered (void );
63
63
64
64
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 );
67
68
68
69
friend class BLEGatt ;
69
70
};
You can’t perform that action at this time.
0 commit comments