Web Bluetooth / Write and Read File Sample

Available in Chrome 58+ | View on GitHub | Browse Original Sambles by Chrome

The Web Bluetooth API lets websites discover and communicate with devices over the Bluetooth 4 wireless standard using the Generic Attribute Profile (GATT). It is currently partially implemented in Android M, Chrome OS, Mac, and Windows 10.

This is an example of writing and reading files over BLE. Be warned, the speed is roughly 5mb / minute! (Yes Minute!) This is because we are using the GATT protocol which is not designed for high speed transfers and we are limited to 512 bytes per write. Currently we do not expect a conformation for each write (writeValueWithoutResponse), which likely increases speed but might lead to package loss (I have not experienced this though). We also read the whole file into the process memory on both sides (Client and Server). Hence beware of large files. Best ist to create ZIPs and split them into junks before sending.

Connect to Service

This sample requires a Bluetooth device that supports the following service and characteristics:

Send File

Will automatically send the file once selected.

Receive File

Will automatically receive the file once clicked.

Live Output