17
17
* @return The characteristic.
18
18
*/
19
19
BLEService* BLEServiceMap::getByUUID (const char * uuid) {
20
- return getByUUID (BLEUUID (uuid));
20
+ return getByUUID (BLEUUID (uuid));
21
21
}
22
-
22
+
23
23
/* *
24
24
* @brief Return the service by UUID.
25
25
* @param [in] UUID The UUID to look up the service.
@@ -53,8 +53,8 @@ BLEService* BLEServiceMap::getByHandle(uint16_t handle) {
53
53
* @return N/A.
54
54
*/
55
55
void BLEServiceMap::setByUUID (BLEUUID uuid,
56
- BLEService* service) {
57
- m_uuidMap.insert (std::pair<BLEService*, std::string>(service, uuid.toString ()));
56
+ BLEService * service) {
57
+ m_uuidMap.insert (std::pair<BLEService *, std::string>(service, uuid.toString ()));
58
58
} // setByUUID
59
59
60
60
@@ -66,7 +66,7 @@ void BLEServiceMap::setByUUID(BLEUUID uuid,
66
66
*/
67
67
void BLEServiceMap::setByHandle (uint16_t handle,
68
68
BLEService* service) {
69
- m_handleMap.insert (std::pair<uint16_t , BLEService*>(handle, service));
69
+ m_handleMap.insert (std::pair<uint16_t , BLEService *>(handle, service));
70
70
} // setByHandle
71
71
72
72
@@ -86,7 +86,7 @@ std::string BLEServiceMap::toString() {
86
86
void BLEServiceMap::handleGATTServerEvent (
87
87
esp_gatts_cb_event_t event,
88
88
esp_gatt_if_t gatts_if,
89
- esp_ble_gatts_cb_param_t * param) {
89
+ esp_ble_gatts_cb_param_t * param) {
90
90
// Invoke the handler for every Service we have.
91
91
for (auto &myPair : m_uuidMap) {
92
92
myPair.first ->handleGATTServerEvent (event, gatts_if, param);
@@ -99,7 +99,9 @@ void BLEServiceMap::handleGATTServerEvent(
99
99
*/
100
100
BLEService* BLEServiceMap::getFirst () {
101
101
m_iterator = m_uuidMap.begin ();
102
- if (m_iterator == m_uuidMap.end ()) return nullptr ;
102
+ if (m_iterator == m_uuidMap.end ()) {
103
+ return nullptr ;
104
+ }
103
105
BLEService* pRet = m_iterator->first ;
104
106
m_iterator++;
105
107
return pRet;
@@ -110,7 +112,9 @@ BLEService* BLEServiceMap::getFirst() {
110
112
* @return The next service in the map.
111
113
*/
112
114
BLEService* BLEServiceMap::getNext () {
113
- if (m_iterator == m_uuidMap.end ()) return nullptr ;
115
+ if (m_iterator == m_uuidMap.end ()) {
116
+ return nullptr ;
117
+ }
114
118
BLEService* pRet = m_iterator->first ;
115
119
m_iterator++;
116
120
return pRet;
@@ -120,9 +124,17 @@ BLEService* BLEServiceMap::getNext() {
120
124
* @brief Removes service from maps.
121
125
* @return N/A.
122
126
*/
123
- void BLEServiceMap::removeService (BLEService* service) {
127
+ void BLEServiceMap::removeService (BLEService * service){
124
128
m_handleMap.erase (service->getHandle ());
125
129
m_uuidMap.erase (service);
126
130
} // removeService
127
131
132
+ /* *
133
+ * @brief Returns the amount of registered services
134
+ * @return amount of registered services
135
+ */
136
+ int BLEServiceMap::getRegisteredServiceCount (){
137
+ return m_handleMap.size ();
138
+ }
139
+
128
140
#endif /* CONFIG_BT_ENABLED */
0 commit comments