8000 added getServiceCount() to BLEServer.cpp · exocode/esp32-snippets@5a97e68 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5a97e68

Browse files
committed
added getServiceCount() to BLEServer.cpp
1 parent a338ca1 commit 5a97e68

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

cpp_utils/BLEServer.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,21 @@ BLEService* BLEServer::getServiceByUUID(BLEUUID uuid) {
115115
}
116116

117117

118+
/**
119+
* @brief Returns the amount of services registered to this server
120+
* @return The amount of registered services
121+
*/
122+
int BLEServer::getServiceCount() {
123+
int count = 0;
124+
if(m_serviceMap.getFirst() == nullptr) return 0;
125+
while(m_serviceMap.getNext() != nullptr){
126+
count++;
127+
}
128+
129+
return count;
130+
}
131+
132+
118133
/**
119134
* @brief Retrieve the advertising object that can be used to advertise the existence of the server.
120135
*

cpp_utils/BLEServer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class BLEServiceMap {
4343
BLEService* getFirst();
4444
BLEService* getNext();
4545
void removeService(BLEService* service);
46+
int getServiceCount();
4647

4748
private:
4849
std::map<uint16_t, BLEService*> m_handleMap;

0 commit comments

Comments
 (0)
0