mirror of
https://github.com/h2zero/esp-nimble-cpp.git
synced 2024-11-23 21:50:55 +01:00
Remove recursive calling when fetching remote attributes.
This commit is contained in:
parent
aeaa432553
commit
11e705f487
3 changed files with 30 additions and 6 deletions
|
@ -618,7 +618,11 @@ NimBLERemoteService* NimBLEClient::getService(const NimBLEUUID &uuid) {
|
||||||
{
|
{
|
||||||
NimBLEUUID uuid128(uuid);
|
NimBLEUUID uuid128(uuid);
|
||||||
uuid128.to128();
|
uuid128.to128();
|
||||||
return getService(uuid128);
|
if(retrieveServices(&uuid128)) {
|
||||||
|
if(m_servicesVector.size() > prev_size) {
|
||||||
|
return m_servicesVector.back();
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// If the request was successful but the 128 bit uuid not found
|
// If the request was successful but the 128 bit uuid not found
|
||||||
// try again with the 16 bit uuid.
|
// try again with the 16 bit uuid.
|
||||||
|
@ -626,7 +630,11 @@ NimBLERemoteService* NimBLEClient::getService(const NimBLEUUID &uuid) {
|
||||||
uuid16.to16();
|
uuid16.to16();
|
||||||
// if the uuid was 128 bit but not of the BLE base type this check will fail
|
// if the uuid was 128 bit but not of the BLE base type this check will fail
|
||||||
if (uuid16.bitSize() == BLE_UUID_TYPE_16) {
|
if (uuid16.bitSize() == BLE_UUID_TYPE_16) {
|
||||||
return getService(uuid16);
|
if(retrieveServices(&uuid16)) {
|
||||||
|
if(m_servicesVector.size() > prev_size) {
|
||||||
|
return m_servicesVector.back();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -324,7 +324,11 @@ NimBLERemoteDescriptor* NimBLERemoteCharacteristic::getDescriptor(const NimBLEUU
|
||||||
{
|
{
|
||||||
NimBLEUUID uuid128(uuid);
|
NimBLEUUID uuid128(uuid);
|
||||||
uuid128.to128();
|
uuid128.to128();
|
||||||
return getDescriptor(uuid128);
|
if(retrieveDescriptors(&uuid128)) {
|
||||||
|
if(m_descriptorVector.size() > prev_size) {
|
||||||
|
return m_descriptorVector.back();
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// If the request was successful but the 128 bit uuid not found
|
// If the request was successful but the 128 bit uuid not found
|
||||||
// try again with the 16 bit uuid.
|
// try again with the 16 bit uuid.
|
||||||
|
@ -332,7 +336,11 @@ NimBLERemoteDescriptor* NimBLERemoteCharacteristic::getDescriptor(const NimBLEUU
|
||||||
uuid16.to16();
|
uuid16.to16();
|
||||||
// if the uuid was 128 bit but not of the BLE base type this check will fail
|
// if the uuid was 128 bit but not of the BLE base type this check will fail
|
||||||
if (uuid16.bitSize() == BLE_UUID_TYPE_16) {
|
if (uuid16.bitSize() == BLE_UUID_TYPE_16) {
|
||||||
return getDescriptor(uuid16);
|
if(retrieveDescriptors(&uuid16)) {
|
||||||
|
if(m_descriptorVector.size() > prev_size) {
|
||||||
|
return m_descriptorVector.back();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,7 +116,11 @@ NimBLERemoteCharacteristic* NimBLERemoteService::getCharacteristic(const NimBLEU
|
||||||
{
|
{
|
||||||
NimBLEUUID uuid128(uuid);
|
NimBLEUUID uuid128(uuid);
|
||||||
uuid128.to128();
|
uuid128.to128();
|
||||||
return getCharacteristic(uuid128);
|
if (retrieveCharacteristics(&uuid128)) {
|
||||||
|
if(m_characteristicVector.size() > prev_size) {
|
||||||
|
return m_characteristicVector.back();
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// If the request was successful but the 128 bit uuid not found
|
// If the request was successful but the 128 bit uuid not found
|
||||||
// try again with the 16 bit uuid.
|
// try again with the 16 bit uuid.
|
||||||
|
@ -124,7 +128,11 @@ NimBLERemoteCharacteristic* NimBLERemoteService::getCharacteristic(const NimBLEU
|
||||||
uuid16.to16();
|
uuid16.to16();
|
||||||
// if the uuid was 128 bit but not of the BLE base type this check will fail
|
// if the uuid was 128 bit but not of the BLE base type this check will fail
|
||||||
if (uuid16.bitSize() == BLE_UUID_TYPE_16) {
|
if (uuid16.bitSize() == BLE_UUID_TYPE_16) {
|
||||||
return getCharacteristic(uuid16);
|
if(retrieveCharacteristics(&uuid16)) {
|
||||||
|
if(m_characteristicVector.size() > prev_size) {
|
||||||
|
return m_characteristicVector.back();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue