Web Bluetooth Samples

Available in Chrome 45+ | View on GitHub | Browse Samples

The following samples show you some of the ways that you can use the Web Bluetooth API.

Beginner

Device Info (Promises) / Device Info (Async Await) - retrieve basic device information from a BLE Device.

Battery Level (Promises) / Battery Level (Async Await) - retrieve battery information from a BLE Device advertising Battery information (readValue).

Reset Energy (Promises) / Reset Energy (Async Await) - reset energy expended from a BLE Device advertising Heart Rate (writeValue).

Characteristic Properties (Promises) / Characteristic Properties (Async Await) - display all properties of a specific characteristic from a BLE Device.

Notifications (Promises) / Notifications (Async Await) - start and stop characteristic notifications from a BLE Device.

Device Disconnect (Promises) / Device Disconnect (Async Await) - disconnect and get notified from a disconnection of a BLE Device after connecting to it.

Get Characteristics (Promises) - / Get Characteristics (Async Await) - get all characteristics of an advertised service from a BLE Device.

Get Descriptors (Promises) - / Get Descriptors (Async Await) - get all characteristic's descriptors of an advertised service from a BLE Device.

Combining multiple operations

GAP Characteristics (Promises) / GAP Characteristics (Async Await) - get all GAP characteristics of a BLE Device.

Device Information Characteristics (Promises) / Device Information Characteristics (Async Await) - get all Device Information characteristics of a BLE Device.

Link Loss (Promises) / Link Loss (Async Await) - set the Alert Level characteristic of a BLE Device (readValue & writeValue).

Discover Services & Characteristics (Promises) / Discover Services & Characteristics (Async Await) - discover all accessible primary services and their characteristics from a BLE Device.

Automatic Reconnect (Promises) / Automatic Reconnect (Async Await) - Reconnect to a disconnected BLE device using an exponential backoff algorithm.

Read Characteristic Value Changed (Promises) / Read Characteristic Value Changed (Async Await) - read battery level and be notified of changes from a BLE Device.

Read Descriptors (Promises) / Read Descriptors (Async Await) - read all characteristic's descriptors of a service from a BLE Device.

Write Descriptor (Promises) / Write Descriptor (Async Await) - write to the descriptor "Characteristic User Description" on a BLE Device.