-
Notifications
You must be signed in to change notification settings - Fork 716
added getServiceCount() to BLEServer.cpp #700
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
cpp_utils/BLEServer.cpp
Outdated
int BLEServer::getServiceCount() { | ||
int count = 0; | ||
if(m_serviceMap.getFirst() == nullptr) return 0; | ||
while(m_serviceMap.getNext() != nullptr){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
m_serviceMap is std::map and has size() function to get count of elements.
https://en.cppreference.com/w/cpp/container/map/size
Also it will only return services that we are storing, without 2 generic services.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, ok didn't know about that. Thank you for clarifying. I didn't know that there is are services which are not stored...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also it will only return services that we are storing, without 2 generic services.
Are there always two generic services? Or is it possible to check if these services exist? I will update my code then...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Always 2 generic services, it is bluetooth specs mandatory. Its 0x1800 and 0x1801
…l count of default services
@@ -17,9 +17,9 @@ | |||
* @return The characteristic. | |||
*/ | |||
BLEService* BLEServiceMap::getByUUID(const char* uuid) { | |||
return getByUUID(BLEUUID(uuid)); | |||
return getByUUID(BLEUUID(uuid)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use tabs instead of spaces
BLEService* service) { | ||
m_uuidMap.insert(std::pair<BLEService*, std::string>(service, uuid.toString())); | ||
BLEService *service) { | ||
m_uuidMap.insert(std::pair<BLEService *, std::string>(service, uuid.toString())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This edit is unnecessary.
@@ -120,9 +124,17 @@ BLEService* BLEServiceMap::getNext() { | |||
* @brief Removes service from maps. | |||
* @return N/A. | |||
*/ | |||
void BLEServiceMap::removeService(BLEService* service) { | |||
void BLEServiceMap::removeService(BLEService *service){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please refrain from applying auto-formatting to the whole document when you only add\edit couple of lines.
Or, even better, set your IDE rules to conform to project's.
No big change, just added a getter for the amount of services.