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
Should requestDevice() find devices by service UUID? #124
Comments
Thanks for raising this @cwilling Can you confirm if your service UUID is advertised by your device (not just a primary service)? This library currently only matches service UUID filters against advertised services and I've just tested this works. e.g. https://webbluetoothcg.github.io/web-bluetooth/#scan-for-devices
and: https://webbluetoothcg.github.io/web-bluetooth/#matches-a-filter
@reillyeon What is the intent here? Should serviceuuid filters match advertised services and primary services? |
Thanks for looking into this. I can confirm the correct service UUID is being advertised (using Light Blue app on my phone). Because my peripheral devices offer multiple services of which different clients may use different subsets, I use a separate UUID just for advertising. That way a client finding a device with correct UUID will know what real services the device offers (or connect to confirm). This advertising UUID has no corresponding service - it's purely for advertising. However from your discussion above, it seems expected that the advertised UUID also corresponds to an actual service. To test whether that makes a difference, I have now added a primary service with the same UUID as the advertising UUID. Unfortunately it has made no difference. Other information:
They're all advertising using the same UUID and are successfully filtered by that UUID using the browser application. |
Can you run the select example: > node examples/selector.js This should display all devices in range and any services they advertise. e.g. I see:
|
I previously copied examples/selector.js into the directory from where I want to run things (when they're working). Therefore I changed the line
If I then select device 1, I see all the three primary services including the 9f9c635f-3321-4490-9bae-c58572125000 service which is UUID being advertised:
That all lines up with how the services have been setup for the peripherals. Interestingly (not sure whether related to the main problem), I just noticed that the Raspberry Pi devices isn't listed even though it's found OK by the browser app. |
Your selector output shows that the module can't see any services advertised by your device. I wonder if this is an issue in the SimpleBLE module for your OS? All my testing is done on MacOS, what host are you using? |
So far, I have been trying with Linux. I have access to a mac laptop which I've just tried. For all the esp32 & raspi devices, selector.js shows additional output "Advertising: " + the advertising UUID. Also, when I substitute that UUID into example/heartrate.js (replacing "heart_rate" filter), a relevant device is found i.e. filtering by UUID works as "advertised" on Mac but not Linux. If I now need to investigate SimpleBLE, do you have any tips as to where to start looking? |
OK, this sounds like an OS specific issue with SimpleBLE. @Symbitic can you support with investigating this shortcoming? |
@thegecko Yes, this is an issue with SimpleBLE. More specifically, a problem with SimpleBlueZ: OpenBluetoothToolbox/SimpleBLE#135 Edit: I finally made a PR in SimpleBLE to fix this. As soon as it's merged, should just need to update SimpleBLE used here. |
Thanks @Symbitic that's great news - can't wait to try it out! EDIT: in fact, I couldn't wait! To test the PR OpenBluetoothToolbox/SimpleBLE#275, I changed local webbluetooth's SimpleBLE submodule url to point to @Symbitic bluez-servicedata-fix branch and rebuilt webbluetooth. Running examples/selector.js now shows (with multiple uninteresting results removed):
i.e. each of the relevant devices is now shown with its Mission accomplished! Thanks again - I'll wait now until the PR is merged and a new webbluetooth npm module is published. |
A great example of people working together (and making my life easier)! thanks both. |
Will update webbluetooth when this is merged: OpenBluetoothToolbox/SimpleBLE#275 |
Great! Any chance you can take a look at my PR while we wait? |
@Symbitic's PR has been merged! |
The update run is here (it built): Perhaps use the artifacts on that to see if it fixes the issue? |
I was able to pull from your repo and checkout the advertised-uuids branch and build a new build/Release/simpleble.node that works. However I couldn't use the simpleble.node from the artifacts. Trying to use it complains about not finding a particular glibc version. I had the same problem with the previous version (before rebuilding) so since this isn't related to the original issue, I may raise a separate issue about it. |
Annoyingly I can't use the latest version of SimpleBLE with the advert fix due to this bug being introduced: |
I have some devices which advertise a service using a 128bit UUID generated at https://www.uuidgenerator.net/. The devices are successfully discovered in a browser using my own code based on webbluetooth samples at https://googlechrome.github.io/samples/web-bluetooth/index.html e.g.
(where options are:
{"filters":[{"services":["9f9c635f-3321-4490-9bae-c58572125000"]}]}
)However if I try the heartrate.js example here but change the 'heart_rate' filter to my 128bit uuid i.e. change
filters: [{ services: [ "heart_rate" ] }]
tofilters: [{ services: [ "9f9c635f-3321-4490-9bae-c58572125000" ] }]
, the devices are not discovered.Should I be able to use arbitrary 128bit service uuids to filter available devices?
P.S. the devices are all found, along with a bunch or other devices, using the list.js example. I just want to limit the listing to those devices with my own service uuid.
Thanks for any assistance.
The text was updated successfully, but these errors were encountered: