Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Map to vector v2 (this was PR #37) #46

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 9 commits into from
May 18, 2020
Merged

Conversation

Jeroen88
Copy link

@Jeroen88 Jeroen88 commented May 17, 2020

Add NimBLEAdvertisedDevice *getDevice(const NimBLEAddress &address) to get a pointer to an advertised device by address.

This is useful for devices that send information in their service data. Now you can do:

NimBLEAdvertisedDevice *dev = pBLEScan->getResults().getDevice(NimBLEAddress("58:2d:34:39:22:58"));
if(dev != nullptr && dev->haveServiceData()) {
  const uint8_t * pData = (const uint8_t*)(dev->getServiceData().data());
  ... do something with the service data ...
}

This was PR #37, but since @h2zero merged master into this PR at May 15, 2020, I could not push my branch again. So I created a new branch by pulling from PR #37. So this branch includes the master merged by @h2zero. I am not aware if this leads to additional diffs from that master with PR #37 ...

@h2zero
Copy link
Owner

h2zero commented May 17, 2020

@Jeroen88 sorry about that, I thought you were done with the PR, I was fixing up conflicts. Will merge #37 soon.

@Jeroen88
Copy link
Author

Jeroen88 commented May 17, 2020

sorry about that

No problem!

If you merge #37, please take NimBLEAdvertisedDevice *getDevice(const NimBLEAddress &address) from this PR as well. Also I updated the text 'map' to 'vector', this isn't done everywhere in PR #37.

@Jeroen88
Copy link
Author

@h2zero I just realized that the getDevice() using an index currently in master is incorrect on an index out-of-bounds! I think it will crash if no devices are found yet while still calling getDevice(), otherwise it will always return the first device discovered if the index is out-of-bounds.

@h2zero h2zero merged commit 954f473 into h2zero:master May 18, 2020
@h2zero h2zero mentioned this pull request May 18, 2020
h2zero added a commit that referenced this pull request May 18, 2020
This small bug was introduced in PR #46, this PR corrects it.
@Jeroen88
Copy link
Author

@h2zero I updated all my open PR's except #42 to the latest master

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.

2 participants