---
title: bt
slug: develop/bt
docTags: 
createdAt: 2025-03-11T07:07:19.526Z
---

The *bt* object allows you to check if Bluetooth is fitted; set, monitor, or retrieve the current BLE advertisements; scan for Bluetooth devices; and trigger connection to, and disconnection from, another device.

**bt IDL**

```javascript
enum BtCentralEventType {
    'advertising-report',
    'device-found',
    'device-lost'
};

interface BtCentralAdvertisingReportEvent {
    attribute String adapter_path;
    attribute String device_address;
    attribute int rssi;
    attribute Array<byte> data;
};

interface BtCentralDeviceFoundEvent {
    attribute String adapter_path;
    attribute String address;
    attribute String alias;
    [optional] attribute String name;
    [optional] attribute int rssi;
    [optional] attribute int tx_power;
    [optional] attribute Array<String> uuids;
    [optional] attribute Array<byte> advertising_flags;
    [optional] attribute Array<Array<int, Array<byte>>> manufacturer_data;
    [optional] attribute Map<String, Array<byte>> service_data;
};

interface BtCentralDeviceLostEvent {
    attribute String adapter_path;
    attribute String address;
};

typedef (BtCentralAdvertisingReportEvent | BtCentralDeviceFoundEvent | BtCentralDeviceLostEvent) BtCentralEvent;

callback BtCentralEventCallback = void (BtCentralEvent event);

interface BtCentral {
    Promise<Array<Adapter>> getAdapters();
    Promise<void> scan(optional ScanParameters);
    Promise<void> stopScan();

    void addEventListener(BtCentralEventType type, BtCentralEventCallback callback);
    void removeEventListener(BtCentralEventType type, BtCentralEventCallback callback);
};

interface Adapter {
    attribute String name;
    attribute bool powered;
};

interface ScanParameters {
    attribute bool advertisingReports;
};
```

## Object Creation

To create a *bt&#x20;*&#x6F;bject, first load the `brightsign/bt` module using the `require()` method. Then create an instance of the *bt&#x20;*&#x63;lass.

```javascript
var btClass = require("@brightsign/bt");
var bt = new btClass();
```

## BtCentralAdvertisingReportEvent

- `adapter_path` <font color="#704ae0">string</font> <font color="#01a0af">required</font>:  The adapter that the advertising device belongs to
- `device_address` <font color="#704ae0">string</font> <font color="#01a0af">required</font>: The identifier for a remote advertising device
- `rssi` <font color="#704ae0">int</font> <font color="#01a0af">required</font>: The signal strength of the device when an advertisement is reported
- `data` <font color="#704ae0">Array&lt;byte&gt;</font> <font color="#01a0af">required</font>: Advertisement data

## BtCentralDeviceFoundEvent

Indicates if a Bluetooth device is found during scanning

- `adapter_path` <font color="#704ae0">string</font> <font color="#01a0af">required</font>: The adapter that the advertising device belongs to
- `address` <font color="#704ae0">string</font> <font color="#01a0af">required</font>: The unique Bluetooth address of the device
- `alias` <font color="#704ae0">string</font> <font color="#01a0af">required</font>: An alternate name for the remote device
- `name` <font color="#704ae0">string</font> <font color="#01a0af">optional</font>: The name of the Bluetooth device
- `rssi` <font color="#704ae0">int</font> <font color="#01a0af">optional</font>: The signal strength of the device
- `tx_power` <font color="#704ae0">int</font> <font color="#01a0af">optional</font>: The transmitted power level of the device
- `uuids` <font color="#704ae0">Array&lt;String&gt;</font> <font color="#01a0af">optional</font>: UUID strings
- `advertising_flags` <font color="#704ae0">Array&lt;byte&gt;</font> <font color="#01a0af">optional</font>: The flags used for advertising
- `manufacturer_data` <font color="#704ae0">Array&lt;Array&lt;int, Array&lt;byte&gt;&gt;&gt;</font> <font color="#01a0af">optional</font>: The manufacturer specific advertisement data keyed by manufacturer id
- `service_data` <font color="#704ae0">Map&lt;String, Array&lt;byte&gt;&gt;</font> <font color="#01a0af">optional</font>: The service advertisement data keyed by UUID

## BtCentralDeviceLostEvent

This is used to report when a Bluetooth device is lost.

- `adapter_path` <font color="#704ae0">string</font> <font color="#01a0af">required</font>: The adapter that the advertising device belongs to
- `address` <font color="#704ae0">string</font> <font color="#01a0af">required</font>: The unique Bluetooth address of the device

## BtCentral

Use this interface to perform actions on Bluetooth streaming connections.

**getAdapters()**

:::BlockQuote
Promise\<Array\<Adapter>> getAdapters()
:::

Returns an array of adapter identity strings. The number of elements in the array is the number of Bluetooth adapters fitted.

**scan()**

:::BlockQuote
Promise\<void> scan(optional ScanParameters)
:::

Reports new Bluetooth devices as they are discovered. It is also possible to monitor raw advertising reports.

- `ScanParameters` <font color="#01a0af">optional</font>:

**stopScan()**

:::BlockQuote
Promise\<void> stopScan()
:::

Stops scanning and reporting new Bluetooth devices

**reset()**

:::BlockQuote
Promise\<void> reset()
:::

Will attempt to recover a Bluetooth stack if it becomes unresponsive&#x20;

**addEventListener**

:::BlockQuote
addEventListener(BtCentralEventType type, BtCentralEventCallback callback)
:::

This event is raised when the Bluetooth status changes. Use this method to listen for this event. See [JavaScript Event Handling](docId\:SurGnnHZ666sb1Wh6PbD9) for more information.

**removeEventListener**

:::BlockQuote
removeEventListener(BtCentralEventType type, BtCentralEventCallback callback)
:::

Use this method to remove an event listener. See [JavaScript Event Handling](docId\:SurGnnHZ666sb1Wh6PbD9) for more information.

## Adapter

In BOS versions below 9.1.21 and below 9.0.198, this returns an array of adapter identity strings. The number of elements in the array is the number of Bluetooth adapters fitted.

In BOS versions above 9.1.21 and 9.0.198, this returns an array of adapter objects.

- `name` <font color="#704ae0">string</font>:
- `powered` <font color="#704ae0">bool</font>: Whether or not the adapter is powered on

## ScanParameters

This interface contains information about a scanned Bluetooth streaming device: 

- `advertisingReports` <font color="#704ae0">bool</font>: Whether or not scanning for advertisements is active.

