Skip to content
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

Getting BLERemoteService from BLERemoteCharacteristic #3367

Closed
coogle opened this issue Oct 15, 2019 · 4 comments
Closed

Getting BLERemoteService from BLERemoteCharacteristic #3367

coogle opened this issue Oct 15, 2019 · 4 comments

Comments

@coogle
Copy link

coogle commented Oct 15, 2019

Sorry for not following the standard bug report template here..

What I'm trying to do is use an ESP32 to connect/get some notification data / disconnect / go on to next device for N number of identical BLE servers and I'm having problems because of accessors in the API being set to private.

What I want to do is this:

  1. Connect to a BLE Server, register for notifications for a characteristic provided
  2. Listen to the characteristic notifications (it's a data stream) until I've captured the data I need
    2a) Parse out the relevant data from the capture, store in a struct for that device ID
  3. Disconnect from the BLE Server
  4. Connect to the next, identical BLE server, and repeat.

The problem I'm running into is that the BLERemoteCharacteristic::registerForNotify callback is unnecessarily limited because not only does it not make room to pass in any sort of context void *, but what it does pass in doesn't let you figure it out which device this notification came from.

One easy solution here would be to make BLERemoteCharacteristic::getRemoteService() public instead of private. This way, from within the callback you could call characteristic->getRemoteService()->getClient()->getPeerAddress() and get the address of the device sending the notification.

At the end of the day what I'd like to do is be able to tell from within a characteristic callback what device sent the notification.

@coogle
Copy link
Author

coogle commented Oct 16, 2019

Note on this bug the real issue is that when you call registerForNotify() in BLERemoteCharacteristic you can't pass any context variables in. This could also be solved by allowing for a void * context variable to be passed.

@coogle
Copy link
Author

coogle commented Oct 17, 2019

I was able to fix this by first updating the library I was using to the most recent build from this repo (the ESP bundled one is out of date) and making some meaningful changes to the way I tried to jump from BLE device to BLE device. I'll update the repo I pointed to in this ticket with my new code.

@coogle coogle closed this as completed Oct 17, 2019
@kind3r
Copy link
Contributor

kind3r commented Jan 20, 2021

I'm having the same issue, trying to build a BLE gateway, any strategic reason I'm missing as to why BLERemoteCharacteristic::getRemoteService() is private ?
Maybe @me-no-dev or @chegewara can shed some light, if not I can try my luck with a PR.

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

No branches or pull requests

3 participants