WebBluetooth in Servo

Servo » WebBluetooth » Demos »

Introduction

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.


Implementation Status

The platform dependent code can be found in the following crates.
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
Important: No support for notifications or events. You can subcribe for them, but there won't be any trigger.
* No popup support on Android
The following features are implemented in Servo's codebase.
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

How to use Web Bluetooth

Requirement

First of all you have to install the bluetooth support on your OS. Check out our guide how to setup the basic environment.

Building

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.

Running

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

Testing

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

Note: you have to enable the bluetooth test device and permissions features as well. Since the WPT testing works on an artificial hardware.

Servo Blog

Weekly news, status about Servo.


View details »

WBT Setup

How to setup WebBluetooth.


View details »

Testing

Testing WebBluetooh features.


View details »