From fba7e0fd6873e5edca3e20a9134ab0d0734dcc3f Mon Sep 17 00:00:00 2001 From: h2zero Date: Thu, 7 May 2020 22:30:58 -0600 Subject: [PATCH] NimBLEAdvertisedDevice: Prevent adding dupicate service uuid's. --- src/NimBLEAdvertisedDevice.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/NimBLEAdvertisedDevice.cpp b/src/NimBLEAdvertisedDevice.cpp index ff0097a..1bcdc62 100644 --- a/src/NimBLEAdvertisedDevice.cpp +++ b/src/NimBLEAdvertisedDevice.cpp @@ -441,6 +441,12 @@ void NimBLEAdvertisedDevice::setServiceUUID(const char* serviceUUID) { * @param [in] serviceUUID The discovered serviceUUID */ void NimBLEAdvertisedDevice::setServiceUUID(NimBLEUUID serviceUUID) { + // Don't add duplicates + for (int i = 0; i < m_serviceUUIDs.size(); i++) { + if (m_serviceUUIDs[i].equals(serviceUUID)) { + return; + } + } m_serviceUUIDs.push_back(serviceUUID); m_haveServiceUUID = true; NIMBLE_LOGD(LOG_TAG,"- addServiceUUID(): serviceUUID: %s", serviceUUID.toString().c_str());