Bluetooth (Beta)
Last updated
Last updated
BLE support is currently in Beta. Some functionality is not available yet, and it may require further stability updates.
TypeScript is recommended
The Bluetooth
functions in JourneyApps rely on async-await. While it may be possible to work around this in a JavaScript app with promises, we strongly recommend using TypeScript.
JourneyApps' Bluetooth Low Energy (BLE) support allows users to scan for and connect to nearby BLE devices in real-time. The simplest way to achieve this is using Bluetooth.requestDevice()
. For more advanced use cases, Bluetooth.requestLEScan()
is available. More information on both these methods can be found below.
Bluetooth.requestDevice()
requests a device according to filters.
On Web, a list of devices is returned to the user, from which the user can proceed to select one.
On Windows, Android and iOS, Bluetooth.requestDevice()
the first matching device is automatically selected. We recommend using Bluetooth.requestLEScan()
(see below) on these platforms should the user need to select a device.
Added the signal
parameter to cancel scanning.
Events do not include manufacturerData
, serviceData
, txPower
or appearance
.
Note that in this example the first device is being connected to. In a real app, you'd typically add these devices to a list (for example, you'd create LocalDB objects and display these in a suitable UI component) for the user to select one.
Bluetooth.requestLEScan()
should be used (instead of Bluetooth.requestDevice()
) where the app needs more control over the BLE scanning process. It is based on . Note the following differences from this spec: