From 5bc9d59646e661d72c8286e07248fa3385861502 Mon Sep 17 00:00:00 2001 From: h2zero Date: Sun, 21 Jun 2020 20:46:20 -0600 Subject: [PATCH] Just return a pointer for getServices(false) and getCharacteristics(false) If parameter 'refresh' equals 'false' do not retrieve services or characteristics, just return a pointer to the vector. --- src/NimBLEClient.cpp | 4 +--- src/NimBLERemoteService.cpp | 6 ++---- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/NimBLEClient.cpp b/src/NimBLEClient.cpp index 153b440..0589ed9 100644 --- a/src/NimBLEClient.cpp +++ b/src/NimBLEClient.cpp @@ -412,15 +412,13 @@ NimBLERemoteService* NimBLEClient::getService(const NimBLEUUID &uuid) { * @param [in] bool value to indicate if the current vector should be cleared and * subsequently all services retrieved from the peripheral. * If false the vector will be returned with the currently stored services, - * if vector is empty it will retrieve all services from the peripheral. + * If true it will retrieve all services from the peripheral and return the vector with all services * @return a pointer to the vector of available services. */ std::vector* NimBLEClient::getServices(bool refresh) { if(refresh) { deleteServices(); - } - if(m_servicesVector.empty()) { if (!retrieveServices()) { NIMBLE_LOGE(LOG_TAG, "Error: Failed to get services"); } diff --git a/src/NimBLERemoteService.cpp b/src/NimBLERemoteService.cpp index ea3a5b2..6a1031e 100644 --- a/src/NimBLERemoteService.cpp +++ b/src/NimBLERemoteService.cpp @@ -118,17 +118,15 @@ NimBLERemoteCharacteristic* NimBLERemoteService::getCharacteristic(const NimBLEU * @param [in] bool value to indicate if the current vector should be cleared and * subsequently all characteristics for this service retrieved from the peripheral. * If false the vector will be returned with the currently stored characteristics, - * if the vector is empty it will retrieve all characteristics of this service - * from the peripheral. + * If true it will retrieve all characteristics of this service from the peripheral + * and return the vector with all characteristics for this service. * @return a pointer to the vector of descriptors for this characteristic. */ std::vector* NimBLERemoteService::getCharacteristics(bool refresh) { if(refresh) { deleteCharacteristics(); - } - if(m_characteristicVector.empty()) { if (!retrieveCharacteristics()) { NIMBLE_LOGE(LOG_TAG, "Error: Failed to get characteristics"); }