Comments (3)
- The GATT wireless protocol defines (BT4.1 3.G.4) both a way to discover all primary services/included services/characteristics/descriptors (3.G 4.4.1, 4.5.1, 4.6.1, 4.7.1) and a way to discover a single service or characteristic given its UUID (3.G 4.4.2, 4.6.2). Android and MacOS provide interface functions for looking entities up given a UUID. Mac accepts a list of interesting UUIDs, which may allow it to optimize the Bluetooth radio better than a series of 1-UUID calls. If we insist on fully populating the tree on instantiation, or even using a GetAllServices() method, we may unnecessarily hurt performance and battery life.
- The above also, I think, answers this point: yes, we should let developers access just the UUIDs they're interested in. For now, let's not provide
[]
access since [MapClass] appears to require a synchronous getter for all entries, so it would require us to fully populate the tree eagerly, and plain getter methods don't allow any type structure on their argument. Both would be somewhat ambiguous between forwarding togetCharacteristic
andgetIncludedService
, although UUIDs are unique enough to produce a clear answer. - No, 4.4.2 says "The specific primary service may exist multiple times on a server", and one library gave the example of a device with multiple batteries, each of which exposes a copy of the same service. We could provide functions similar to
querySelector
vsquerySelectorAll
to provide the first vs all instances of a service.
Maybe we should use:
Promise<GATTService> getService((DOMString or UUID))
Promise<sequence<GATTService>> getAllServices(optional (DOMString or UUID or sequence<(DOMString or UUID)>))
which incorporates @marcoscaceres' suggestion to allow names for the standardized UUIDs. getService((DOMString or UUID))
would follow Android in returning the "first" instance of the specified service.
from web-bluetooth.
@armansito, I'm curious about your thoughts on the optimization described in (1). Specifically, I'm thinking that if a website connects to a device and calls getService(a_uuid), the UA can avoid doing a full service discovery and instead use the 1-round-trip Discover Primary Service by Service UUID procedure.
from web-bluetooth.
To be honest, I think the Web API spec shouldn't care, though if the UA wants to optimize and only discover specific services on demand, then it should be free to do so. In Chrome (or Chrome OS specifically), we currently discover all services on initial connection and keep a cache.
So, in general, I agree with adding a getService(uuid) and leaving it up to implementation to decide how that service is obtained (that is OTA for the first time or from a cache).
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.