add discover() to client characteristic
- add getHandleRange to client service
This commit is contained in:
1 parent
78b3906ec1
commit
0133b05fd7
4 files changed
+30
-10
No files matched your search
@@ -91,6 +91,27 @@ void BLEClientCharacteristic::disconnect(void)
|
||||
_chr.handle_value = BLE_GATT_HANDLE_INVALID;
|
||||
}
|
||||
|
||||
|
||||
bool BLEClientCharacteristic::discover(void)
|
||||
{
|
||||
ble_gattc_handle_range_t bck_range = Bluefruit.Discovery.getHandleRange();
|
||||
|
||||
// Set discovery handle to parent's service
|
||||
Bluefruit.Discovery.setHandleRange( _service->getHandleRange() );
|
||||
|
||||
bool result = Bluefruit.Discovery.discoverCharacteristic( _service->connHandle(), *this) > 0;
|
||||
|
||||
// Set back to previous
|
||||
Bluefruit.Discovery.setHandleRange(bck_range);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool BLEClientCharacteristic::discovered(void)
|
||||
{
|
||||
return _chr.handle_value != BLE_GATT_HANDLE_INVALID;
|
||||
}
|
||||
|
||||
void BLEClientCharacteristic::useAdaCallback(bool enabled)
|
||||
{
|
||||
_use_AdaCallback = enabled;
|
||||
@@ -106,10 +127,7 @@ uint16_t BLEClientCharacteristic::valueHandle(void)
|
||||
return _chr.handle_value;
|
||||
}
|
||||
|
||||
bool BLEClientCharacteristic::discovered(void)
|
||||
{
|
||||
return _chr.handle_value != BLE_GATT_HANDLE_INVALID;
|
||||
}
|
||||
|
||||
|
||||
uint8_t BLEClientCharacteristic::properties(void)
|
||||
{
|
||||
|
||||
@@ -64,9 +64,11 @@ class BLEClientCharacteristic
|
||||
|
||||
void begin(BLEClientService* parent_svc = NULL);
|
||||
|
||||
bool discover(void);
|
||||
bool discovered(void);
|
||||
|
||||
uint16_t connHandle(void);
|
||||
uint16_t valueHandle(void);
|
||||
bool discovered(void);
|
||||
uint8_t properties(void);
|
||||
|
||||
|
||||
|
||||
@@ -96,10 +96,9 @@ void BLEClientService::setHandleRange(ble_gattc_handle_range_t handle_range)
|
||||
_hdl_range = handle_range;
|
||||
}
|
||||
|
||||
void BLEClientService::setHandleRange(uint16_t start_hdl, uint16_t end_hdl)
|
||||
ble_gattc_handle_range_t BLEClientService::getHandleRange(void)
|
||||
{
|
||||
_hdl_range.start_handle = start_hdl;
|
||||
_hdl_range.end_handle = end_hdl;
|
||||
return _hdl_range;
|
||||
}
|
||||
|
||||
void BLEClientService::disconnect(void)
|
||||
|
||||
@@ -62,8 +62,9 @@ class BLEClientService
|
||||
bool discovered(void);
|
||||
|
||||
uint16_t connHandle(void);
|
||||
void setHandleRange(uint16_t start_hdl, uint16_t end_hdl);
|
||||
void setHandleRange(ble_gattc_handle_range_t handle_range);
|
||||
|
||||
void setHandleRange(ble_gattc_handle_range_t handle_range);
|
||||
ble_gattc_handle_range_t getHandleRange(void);
|
||||
|
||||
friend class BLEGatt;
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user