Comments (7)
This sounds like platform-specific differences showing through.
On Windows, different events are received for each advertisement packet received so we get separate events for "regular" advertisement data and a separate event for the scan response. But on macOS, Android and Linux events only indicate that something in the advertisement data changed and there is no way to tell on those platforms which information was in the advertisement data and which data was in the scan response. So this one is probably more of an implementation issue where Windows needs to be made to work more like the other platforms under the hood so that web developers don't have to handle OS-specific differences in their apps.
Also, on macOS, passive scanning is not possible (also not an easy way to do it on Linux). So I think it only makes sense to have active scanning in WebBLE.
from web-bluetooth.
Just to clarify, does the "scan response" mean serviceData
in advertisementreceived
?
Both watchAdvertisements
and requestLEScan
induce advertisementreceived
so I assume if scan responses are available to one it should also be available to another?
from web-bluetooth.
"scan response" in this context means an advertisement data packet with a PDU Type of SCN_RSP
. What types of advertisement data it contains depends entirely on the peripheral device.
I would expect watchAdvertisements
and requestLEScan
to return the same info for the same device, so if it isn't, that sounds like a potential implementation bug to me.
from web-bluetooth.
Yes, I would assume watchAdvertisements
and requestLEScan
to see the same information if the advertisement event matched what filter defined. Although the complete filtering implementation is not finished yet.
In Chromium:
content/browser/bluetooth/advertisement_client.cc
// TODO(crbug.com/707635): Support manufacturerData and serviceData
// filters.
from web-bluetooth.
It seems that the teams implementing BLE scanning and advertising would need to unify how scan responses work across all platforms. However, with no clear instructions on how it should work, it could lead to different implementations on different browsers, resulting in an API that cannot be used in the real world, or at least is very difficult to use.
For example, on Android, scan response is integrated with advertising data (see: context), but from my experience on iOS, the data is split into two subsequent messages. I have found that it works similarly on Windows.
My proposal is to add a field in the scan event for the scanResponseData (similar to serviceData). This way, it would be clear to teams implementing the specification that they should include this data (or null if not present) inside the event, and therefore they must glue together incoming SCN_RSP data packets with ADV packets
from web-bluetooth.
From the conversation above it sounds like the issue is whether two advertisementreceived
events are fired, each with data from a single Bluetooth packet or one advertisementreceived
event is filed with the combined data from both packets. I'm trying to understand whether this difference matters to applications because there might be some data missing or incorrectly combined, or if all the data is present but applications need to consider the possibility it will be split across multiple events. The former would be a serious issue while the latter is annoying but workable.
from web-bluetooth.
@reillyeon, based on my experience with Chromium implementation, I've observed missing data when using requestLEScan
. This could be due to incomplete implementation, as pointed out earlier. On the other hand, with watchAdvertisements
, data arrives separately on Windows but combined on Android, which is indeed annoying but workable 😄.
Considering this, it's conceivable that different browsers may handle data combination differently, leading to potential debugging challenges. To streamline this process, a simple addition to the Web Bluetooth spec could be added. If the specification explicitly stated whether scan responses should be combined or split, browser developers could align their implementations accordingly facilitating long-term maintenance.
from web-bluetooth.
Related Issues (20)
- 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
- 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
- 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.