WebBluetooth in Servo
Servo is a modern, high-performance browser engine designed for both application and embedded use.
Sponsored by Mozilla and written in the new language Rust, the Servo project aims to achieve better parallelism, security, modularity, and performance.
Bluetooth is a standard for short-range wireless communication between devices. The Web Bluetooth Community Group is developing a specification for Bluetooth APIs to allow websites to communicate with devices in a secure and privacy-preserving way. In particular, the Web Bluetooth API focuses on minimizing the device attack surface exposed to malicious websites, possibly by removing access to some existing Bluetooth features that are hard to implement securely. Further, the API takes the approach of a user interface to select and approve access to devices as opposed to using certification and installation.
Platform | Prerequisites | Status | Crate |
---|---|---|---|
Linux |
Requires Kernel 3.19+ and BlueZ 5.39+ installed. You can read more about here. |
Supported | blurz |
Android | Android 4.3 (Jelly Bean) | Supported* | blurdroid |
macOS | macOS 10.10+ | Supported | blurmac |
Windows | Requires Windows 8.1 | No progress | |
- | Mocking framework for testing | Supported | blurmock |
Feature | Status |
---|---|
getAvailability() | Done |
Referring Device (Physical Web) | No progress |
Discovery | Done |
└ Service list | Done |
└ Name or prefix | Done |
└ Manufacturer/Service data | Done |
└ acceptAllDevices | Done |
Chooser UI | Done |
Permission API integration | Done |
└ permissions.request() | Done |
└ permissions.query() | Done |
└ permissions.revoke() | Done |
watchAdvertisements() | Partial |
Persistent Device IDs | No progress |
GATT Server Connect | Done |
GATT Server Disconnect | Done |
Hanging connect() abortable by disconnect() | No progress |
GATT Advertising event | Partial |
getPrimaryService*() | Done |
getIncludedService*() | Done |
getCharacteristic*() | Done |
Characteristic Properties | Done |
Read Characteristic | Done |
Write Characteristic | Done |
Start GATT Notifications | Partial |
Stop GATT Notifications | Partial |
{start,stop}Notifications returns `this` | Done |
getDescriptor*() | Done |
Read Descriptor | Done |
Write Descriptor | Done |
Event bubbling | Partial |
Device Disconnected Event | No progress |
Service Changed Event | No progress |
BluetoothUUID | Done |
TypeError for bad UUIDs | Done |
Invalidate GATT attributes upon disconnect | Done |
GATT Blocklist | Done |
Low-latency Blocklist Updates | No progress |
First of all you have to install the bluetooth support on your OS. Check out our guide how to setup the basic environment.
There is no special build flag or option which is required to build Servo with Web Bluetooth support. All information how to compile Servo can be found at Servo's GitHub page.
The support of Web Bluetooth is behind a pref option. So, in order to use a bluetooth device you should add only one extra parameter to the command line: --pref=dom.bluetooth.enabled
. For example:
./mach run --release --pref=dom.bluetooth.enabled
If you are about to test the Web Bluetooth implementation in Servo, you can use the Web Platform Tests. For example:
./mach test-wpt tests/wpt/mozilla/tests/mozilla/bluetooth/ --pref=dom.bluetooth.enabled --pref=dom.bluetooth.testing.enabled --pref=dom.permissions.enabled