diff --git a/src/NimBLEClient.cpp b/src/NimBLEClient.cpp index 3619b44..504fdb2 100644 --- a/src/NimBLEClient.cpp +++ b/src/NimBLEClient.cpp @@ -703,13 +703,29 @@ std::vector* 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 diff --git a/src/NimBLEClient.h b/src/NimBLEClient.h index 4aed02a..0061fd3 100644 --- a/src/NimBLEClient.h +++ b/src/NimBLEClient.h @@ -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