mirror of
https://github.com/h2zero/esp-nimble-cpp.git
synced 2026-01-27 01:22:19 +01:00
Add feature: remove service (#17)
* Get service handles on server start * remove service + indicate service changed * Reset gatt services when no connections active and services changed. * NimBLEServer::createService can now be used any time and will send service changed indication if server was already active. * Add ability to remove advertised serviceUUIDS * Adds addService() method to server to be allow user to re-add a service previously removed * Add destructior to NimBLEServer, NimBLEService and NimBLECharacteristic to release allocated resources.
This commit is contained in:
@@ -63,6 +63,7 @@ NimBLEAdvertising::NimBLEAdvertising() {
|
||||
*/
|
||||
void NimBLEAdvertising::addServiceUUID(const NimBLEUUID &serviceUUID) {
|
||||
m_serviceUUIDs.push_back(serviceUUID);
|
||||
m_advDataSet = false;
|
||||
} // addServiceUUID
|
||||
|
||||
|
||||
@@ -75,6 +76,22 @@ void NimBLEAdvertising::addServiceUUID(const char* serviceUUID) {
|
||||
} // addServiceUUID
|
||||
|
||||
|
||||
/**
|
||||
* @brief Add a service uuid to exposed list of services.
|
||||
* @param [in] serviceUUID The UUID of the service to expose.
|
||||
*/
|
||||
void NimBLEAdvertising::removeServiceUUID(const NimBLEUUID &serviceUUID) {
|
||||
//m_serviceUUIDs.erase(std::remove_if(m_serviceUUIDs.begin(), m_serviceUUIDs.end(),[serviceUUID](const NimBLEUUID &s) {return serviceUUID == s;}), m_serviceUUIDs.end());
|
||||
for(auto it = m_serviceUUIDs.begin(); it != m_serviceUUIDs.end(); ++it) {
|
||||
if((*it) == serviceUUID) {
|
||||
m_serviceUUIDs.erase(it);
|
||||
break;
|
||||
}
|
||||
}
|
||||
m_advDataSet = false;
|
||||
} // addServiceUUID
|
||||
|
||||
|
||||
/**
|
||||
* @brief Set the device appearance in the advertising data.
|
||||
* The codes for distinct appearances can be found here:\n
|
||||
|
||||
Reference in New Issue
Block a user