Device.bluetoothGetPaired()

Overview

On an Android device, returns a list of paired Bluetooth devices.

Added in version 2.1.29

Format

var devices = Device.bluetoothGetPaired();

Parameter Description Type Required Notes
devices Returns a list of paired Bluetooth devices. Array of object Return value May return undefined or null if there is no Bluetooth adapter.

Paired Device Object

Value Description Type
name The friendly name of the Bluetooth device. String
address The MAC address of the Bluetooth device. String
class The device class of the Bluetooth device. See Bluetooth Class of device below. Integer
uuids An array of Bluetooth supported feature UUIDs reported for the device. See Bluetooth Supported Feature UUIDs below. Array of string

Bluetooth Class of Device

The Bluetooth class of device is a number identifier that helps to categorize devices. This information is broadcast when the device is in pairing mode and collected during discovery. If a device is connected without discovery, it may be set to Unknown (7936 (0x1F00)).

See "Class of Device" in the Assigned Numbers document at https://www.bluetooth.com/specifications/assigned-numbers/

Here are a few common classes:

Class Description
1028 (0x0404) Audio/Video - Headset
1048 (0x0418) Audio/Video - Headphones
1044 (0x0414) Audio/Video - Loudspeaker
1664 (0x0680) Imaging - Printer
7936 (0x1F00) Unknown

Bluetooth Supported Feature UUIDs

UUIDs specify services provided by a Bluetooth device.

See "SDP Service Class and Profile Identifiers" in the Assigned Numbers document at https://www.bluetooth.com/specifications/assigned-numbers/

Here are a few common UUIDs:

Class Description
00000000-0000-1000-8000-00805f9b34fb Bluetooth Base
00001108-0000-1000-8000-00805f9b34fb Headset Profile
0000111e-0000-1000-8000-00805f9b34fb Hands-Free Profile
00001101-0000-1000-8000-00805f9b34fb Serial Port Profile
0000110b-0000-1000-8000-00805f9b34fb Advanced Audio Distribution Profile

Example

Copy
/* Gets a list of devices and dumps it to the log when the 0 key is pressed.
 */

WLEvent.onKey(0x30, function(event) {
    var paired = Device.bluetoothGetPaired() || "Sorry cannot get list";
    Logger.debug(JSON.stringify(paired));
});