Unverified Commit c1417e9b authored by dpnebert's avatar dpnebert Committed by GitHub

Added methods to remove service UUID from BLEAdvertising (#8747)

* Modified 'BLEAdvertising.h' & 'BLEAdvertising.cpp'

Added three methods for removing service UUID from BLEAdvertised

* Update BLEAdvertising.cpp

Changed 'i' to 'index'

---------
Co-authored-by: default avatarJan Procházka <90197375+P-R-O-C-H-Y@users.noreply.github.com>
parent bd39fcfa
......@@ -79,6 +79,41 @@ void BLEAdvertising::addServiceUUID(const char* serviceUUID) {
} // addServiceUUID
/**
* @brief Remove a service uuid to exposed list of services.
* @param [in] index The index of the service to stop exposing.
*/
bool BLEAdvertising::removeServiceUUID(int index) {
// If index is larger than the size of the
// advertised services, return false
if(index > m_serviceUUIDs.size()) return false;
m_serviceUUIDs.erase(m_serviceUUIDs.begin() + index);
return true;
}
/**
* @brief Remove a service uuid to exposed list of services.
* @param [in] serviceUUID The BLEUUID of the service to stop exposing.
*/
bool BLEAdvertising::removeServiceUUID(BLEUUID serviceUUID) {
for(int i = 0; i < m_serviceUUIDs.size(); i++) {
if(m_serviceUUIDs.at(i).equals(serviceUUID)) {
return removeServiceUUID(i);
}
}
return false;
}
/**
* @brief Remove a service uuid to exposed list of services.
* @param [in] serviceUUID The string of the service to stop exposing.
*/
bool BLEAdvertising::removeServiceUUID(const char* serviceUUID) {
return removeServiceUUID(BLEUUID(serviceUUID));
}
/**
* @brief Set the device appearance in the advertising data.
* The appearance attribute is of type 0x19. The codes for distinct appearances can be found here:
......
......@@ -51,7 +51,10 @@ class BLEAdvertising {
public:
BLEAdvertising();
void addServiceUUID(BLEUUID serviceUUID);
void addServiceUUID(const char* serviceUUID);
void addServiceUUID(const char* serviceUUID);
bool removeServiceUUID(int index);
bool removeServiceUUID(BLEUUID serviceUUID);
bool removeServiceUUID(const char* serviceUUID);
void start();
void stop();
void setAppearance(uint16_t appearance);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment