complete BLEClientDis
This commit is contained in:
1 parent
fcddca77c5
commit
bd96f7df90
4 files changed
+45
-5
No files matched your search
@@ -76,6 +76,8 @@ bool BLEDiscovery::_discoverService(uint16_t conn_handle, BLEClientService& svc,
|
||||
_evt_buf = &disc_svc;
|
||||
_evt_bufsize = sizeof(disc_svc);
|
||||
|
||||
LOG_LV2(Discover, "[SVC] Handle start = %d", start_handle);
|
||||
|
||||
VERIFY_STATUS( sd_ble_gattc_primary_services_discover(conn_handle, start_handle, &svc.uuid._uuid), false );
|
||||
|
||||
// wait for discovery event: timeout or has no data
|
||||
@@ -100,6 +102,7 @@ uint8_t BLEDiscovery::discoverCharacteristic(uint16_t conn_handle, BLEClientChar
|
||||
{
|
||||
uint8_t found = 0;
|
||||
|
||||
|
||||
while( found < count )
|
||||
{
|
||||
ble_gattc_evt_char_disc_rsp_t disc_chr;
|
||||
@@ -107,8 +110,7 @@ uint8_t BLEDiscovery::discoverCharacteristic(uint16_t conn_handle, BLEClientChar
|
||||
_evt_buf = &disc_chr;
|
||||
_evt_bufsize = sizeof(disc_chr);
|
||||
|
||||
// LOG_LV2(Discover, "[CHR] Handle start = %d, end = %d", _hdl_range.start_handle, _hdl_range.end_handle);
|
||||
|
||||
LOG_LV2(Discover, "[CHR] Handle start = %d, end = %d", _hdl_range.start_handle, _hdl_range.end_handle);
|
||||
VERIFY_STATUS( sd_ble_gattc_characteristics_discover(conn_handle, &_hdl_range), found );
|
||||
|
||||
// wait for discovery event: timeout or has no data
|
||||
|
||||
@@ -60,7 +60,25 @@ bool BLEClientDis::discover(uint16_t conn_handle)
|
||||
|
||||
uint16_t BLEClientDis::getChars(uint16_t uuid, char* buffer, uint16_t bufsize)
|
||||
{
|
||||
uint16_t count = 0;
|
||||
ble_gattc_handle_range_t bck_range = Bluefruit.Discovery.getHandleRange();
|
||||
|
||||
// Set discovery handle to DIS service
|
||||
Bluefruit.Discovery.setHandleRange(_hdl_range);
|
||||
|
||||
BLEClientCharacteristic chr(uuid);
|
||||
chr.begin(this);
|
||||
|
||||
if ( Bluefruit.Discovery.discoverCharacteristic(_conn_hdl, chr) )
|
||||
{
|
||||
count = chr.read(buffer, bufsize);
|
||||
PRINT_INT(count);
|
||||
}
|
||||
|
||||
// Set back
|
||||
Bluefruit.Discovery.setHandleRange(bck_range);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
uint16_t BLEClientDis::getModel(char* buffer, uint16_t bufsize)
|
||||
|
||||
@@ -58,6 +58,8 @@ class BLEClientDis : public BLEClientService
|
||||
private:
|
||||
uint16_t getChars(uint16_t uuid, char* buffer, uint16_t bufsize);
|
||||
|
||||
// BLE DIS has several characteristics but is often used one or two times
|
||||
// It is better to implement get() with on-the-fly BLEClientCharacteristic
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user