Skip to content

Commit 8b5cfb0

Browse files
committed
Add success/fail return value to disoverAttributes.
1 parent 42201d4 commit 8b5cfb0

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

src/NimBLEClient.cpp

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -703,13 +703,29 @@ std::vector<NimBLERemoteService*>* NimBLEClient::getServices(bool refresh) {
703703

704704
/**
705705
* @brief Retrieves the full database of attributes that the peripheral has available.
706+
* @return True if successful.
706707
*/
707-
void NimBLEClient::discoverAttributes() {
708-
for(auto svc: *getServices(true)) {
709-
for(auto chr: *svc->getCharacteristics(true)) {
710-
chr->getDescriptors(true);
708+
bool NimBLEClient::discoverAttributes() {
709+
deleteServices();
710+
711+
if (!retrieveServices()){
712+
return false;
713+
}
714+
715+
716+
for(auto svc: m_servicesVector) {
717+
if (!svc->retrieveCharacteristics()) {
718+
return false;
719+
}
720+
721+
for(auto chr: svc->m_characteristicVector) {
722+
if (!chr->retrieveDescriptors()) {
723+
return false;
724+
}
711725
}
712726
}
727+
728+
return true;
713729
} // discoverAttributes
714730

715731

src/NimBLEClient.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class NimBLEClient {
7070
void updateConnParams(uint16_t minInterval, uint16_t maxInterval,
7171
uint16_t latency, uint16_t timeout);
7272
void setDataLen(uint16_t tx_octets);
73-
void discoverAttributes();
73+
bool discoverAttributes();
7474
NimBLEConnInfo getConnInfo();
7575
int getLastError();
7676
#if CONFIG_BT_NIMBLE_EXT_ADV

0 commit comments

Comments
 (0)