Skip to content

Commit 7081b65

Browse files
committed
Add success/fail return value to disoverAttributes.
1 parent 8163d5a commit 7081b65

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
@@ -646,13 +646,29 @@ std::vector<NimBLERemoteService*>* NimBLEClient::getServices(bool refresh) {
646646

647647
/**
648648
* @brief Retrieves the full database of attributes that the peripheral has available.
649+
* @return True if successful.
649650
*/
650-
void NimBLEClient::discoverAttributes() {
651-
for(auto svc: *getServices(true)) {
652-
for(auto chr: *svc->getCharacteristics(true)) {
653-
chr->getDescriptors(true);
651+
bool NimBLEClient::discoverAttributes() {
652+
deleteServices();
653+
654+
if (!retrieveServices()){
655+
return false;
656+
}
657+
658+
659+
for(auto svc: m_servicesVector) {
660+
if (!svc->retrieveCharacteristics()) {
661+
return false;
662+
}
663+
664+
for(auto chr: svc->m_characteristicVector) {
665+
if (!chr->retrieveDescriptors()) {
666+
return false;
667+
}
654668
}
655669
}
670+
671+
return true;
656672
} // discoverAttributes
657673

658674

src/NimBLEClient.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class NimBLEClient {
7171
uint16_t scanInterval=16, uint16_t scanWindow=16);
7272
void updateConnParams(uint16_t minInterval, uint16_t maxInterval,
7373
uint16_t latency, uint16_t timeout);
74-
void discoverAttributes();
74+
bool discoverAttributes();
7575
NimBLEConnInfo getConnInfo();
7676
int getLastError();
7777

0 commit comments

Comments
 (0)