8000 added getServiceCount() to BLEServer.cpp by Donderda · Pull Request #700 · nkolban/esp32-snippets · GitHub
[go: up one dir, main page]

Skip to content

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

Merged
merged 4 commits into from
Oct 17, 2018
Merged

Conversation

Donderda
Copy link
Contributor

No big change, just added a getter for the amount of services.

int BLEServer::getServiceCount() {
int count = 0;
if(m_serviceMap.getFirst() == nullptr) return 0;
while(m_serviceMap.getNext() != nullptr){
Copy link
Collaborator

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.

Copy link
Contributor Author

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...

Copy link
Contributor Author
@Donderda Donderda Oct 15, 2018

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...

Copy link
Collaborator

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

@@ -17,9 +17,9 @@
* @return The characteristic.
*/
BLEService* BLEServiceMap::getByUUID(const char* uuid) {
return getByUUID(BLEUUID(uuid));
return getByUUID(BLEUUID(uuid));
Copy link
Contributor

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()));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This edit is unnecessary.

< A920 td data-line-number="125" class="blob-num blob-num-context">
@@ -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){
Copy link
Contributor

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.

@nkolban nkolban merged commit e742546 into nkolban:master Oct 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0