Fix attributes not found with 16/32bit UUIDs.

* Some peripherals will advertise 16/32bit UUIDs but when queried for their handles
they do not convert the UUID to 128 bit locally and will return attribute not found.

This patch will query the peripheral a second time with a 128bit converted UUID.
This commit is contained in:
h2zero
2020-12-28 15:40:01 -07:00
parent 27fc792952
commit 39a3a63f80
3 changed files with 36 additions and 1 deletions

View File

@@ -454,6 +454,16 @@ NimBLERemoteService* NimBLEClient::getService(const NimBLEUUID &uuid) {
if(m_servicesVector.size() > prev_size) {
return m_servicesVector.back();
}
// If the request was successful but 16/32 bit service not found
// try again with the 128 bit uuid.
if(uuid.bitSize() == BLE_UUID_TYPE_16 ||
uuid.bitSize() == BLE_UUID_TYPE_32)
{
NimBLEUUID uuid128(uuid);
uuid128.to128();
return getService(uuid128);
}
}
NIMBLE_LOGD(LOG_TAG, "<< getService: not found");