Giter VIP home page Giter VIP logo

Comments (7)

dlech avatar dlech commented on August 11, 2024 1

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.

alvinjiooo avatar alvinjiooo commented on August 11, 2024

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.

dlech avatar dlech commented on August 11, 2024

"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.

alvinjiooo avatar alvinjiooo commented on August 11, 2024

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.

mikolajefento avatar mikolajefento commented on August 11, 2024

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.

reillyeon avatar reillyeon commented on August 11, 2024

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.

mikolajefento avatar mikolajefento commented on August 11, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.