Comments (5)
It looks like the «Service Changed» characteristic, defined in BT4.1 3.G.7.1 provides Indications to bonded devices when there's a change to the set of services a device provides. The spec draft exposes these updates through the servicechanged
event.
Given the requirement in BT that
If the list of GATT based services and the service definitions cannot change for the lifetime of the device then this characteristic shall not exist, otherwise this characteristic shall exist.
is there a need to provide a polling-based interface?
from web-bluetooth.
There certainly should not be a polling-based interface. Service caching on the client-side inherently requires bonding and the presence of the "Service Changed" characteristic. The client is required to initiate service, characteristic, and descriptor discovery within the handle range that is contained in the indication PDU, if such an event is received from the peripheral.
The onServiceAdded, onServiceRemoved, and onServiceChanged events should be called as a result of the an indication from the "Service Changed" characteristic. So, as far as the API behavior goes, when such an indication is received, rediscovery should be automatically handled and the onService* events should be called accordingly.
from web-bluetooth.
Looking at the spec (which may not match the actual devices), it looks like
- For non-bonded devices, the "Service Changed" characteristic is still indicated and allows caching within a single connection. For bonded devices, it allows caching across connections. That's "For clients that do not have a trusted relationship with the server, the attribute cache is valid only during the connection. Clients without a trusted relationship shall receive an indication when the service change occurs only during the current connection." in 3.G.2.5.3.
- If the "Service Changed" characteristic is missing, that means the set of service definitions can't change, so caching always works. "If the list of GATT based services and the service definitions cannot change for the lifetime of the device then this characteristic shall not exist, otherwise this characteristic shall exist."
The one thing that worries me about this is that it doesn't seem compatible with an optimization described in 3.G.4.4.2, "Discover Primary Service by Service UUID". If a client finds all current services with UUID 1234, and then a new instance of the 1234 service is added, they'll get a ServiceChanged indication for the new range, but no indication that it's the service they care about. But maybe that's just a requirement to run "Discover All Primary Services" on any range mentioned in the ServiceChanged indication that's not strictly inside a known service.
I'll close this with the conclusion that we don't need a way to explicitly re-discover services, and that the UA just needs to keep its cache up to date. Feel free to reopen with more discussion though.
from web-bluetooth.
I think for the purposes of this web API, I don't think that "Discover Primary Service by UUID" is necessary: the underlying implementation should just discover all services and cache them.
In the case you're describing, the central can run the "Discover Primary Service by UUID" procedure inside the handle range that it receives in the indication from the Service Changed characteristic. This way it can find out if a new service with the desired UUID has been added.
But overall, I agree with your conclusion.
from web-bluetooth.
I agree with your conclusion, thanks.
from web-bluetooth.
Related Issues (20)
- Web Bluetooth Manufacturer Specific Data Map empty HOT 7
- requestDevice filters to exclude devices. HOT 1
- Would be nice to enable the Discussions on this repo, not everything is an issue HOT 1
- [watchAdvertisements] Support Extended Advertising HOT 8
- can't access services list on some devices HOT 2
- Kerem
- Services not found (Primary detected as Secondary?) HOT 3
- Using Bluetooth from WebExtension HOT 1
- Permissions API Extension HOT 3
- Not working with MacOS Sonoma + Intel HOT 1
- Add requestDevice User Prompt BiDi Extension Section to Bluetooth Spec
- p2p connection options HOT 3
- Filter on or prefer paired devices HOT 1
- Spec vs Chromium implementation. HOT 4
- Proposal does not reflect Chromium's dynamic device selection HOT 1
- Proposal: active scanning with scan response HOT 7
- navigator.bluetooth.requestDevice (opt) same filter but ios browser bluefy doesn't work HOT 2
- Unable to connect to the device, the error message is as follows HOT 1
- Broken references in Web Bluetooth
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from web-bluetooth.