Add success/fail return value to disoverAttributes.

This commit is contained in:
h2zero 2022-04-16 20:32:01 -06:00
parent c285052f6d
commit a36655c105
2 changed files with 21 additions and 5 deletions

View file

@ -703,13 +703,29 @@ std::vector<NimBLERemoteService*>* NimBLEClient::getServices(bool refresh) {
/**
* @brief Retrieves the full database of attributes that the peripheral has available.
* @return True if successful.
*/
void NimBLEClient::discoverAttributes() {
for(auto svc: *getServices(true)) {
for(auto chr: *svc->getCharacteristics(true)) {
chr->getDescriptors(true);
bool NimBLEClient::discoverAttributes() {
deleteServices();
if (!retrieveServices()){
return false;
}
for(auto svc: m_servicesVector) {
if (!svc->retrieveCharacteristics()) {
return false;
}
for(auto chr: svc->m_characteristicVector) {
if (!chr->retrieveDescriptors()) {
return false;
}
}
}
return true;
} // discoverAttributes

View file

@ -70,7 +70,7 @@ public:
void updateConnParams(uint16_t minInterval, uint16_t maxInterval,
uint16_t latency, uint16_t timeout);
void setDataLen(uint16_t tx_octets);
void discoverAttributes();
bool discoverAttributes();
NimBLEConnInfo getConnInfo();
int getLastError();
#if CONFIG_BT_NIMBLE_EXT_ADV