stbBluetooth

stbBluetooth

Since:
  • v343

Global object provides API to work with Bluetooth devices.
Exists only on supported devices.

Supported profiles: HID, A2DP.

Members

(static) devices :Array.<stbBluetoothDevice>

List of all devices.

Type:

(static) onDiscoveryStart :stbBluetooth~onDiscoveryStartCallback

Default Value:
  • null

Event handler to be used when discovery is started.
Alternative event name to use with stbBluetooth.addEventListener: discoveryStart.

Type:

(static) onDiscoveryStop :stbBluetooth~onDiscoveryStopCallback

Default Value:
  • null

Event handler to be used when discovery is completed.
Alternative event name to use with stbBluetooth.addEventListener: discoveryStop.

Type:

(static) onDeviceFound :stbBluetooth~onDeviceFoundCallback

Default Value:
  • null

Event handler to be used when a new device found.
Alternative event name to use with stbBluetooth.addEventListener: deviceFound.

Type:

(static) onDeviceRemoved :stbBluetooth~onDeviceRemovedCallback

Default Value:
  • null

Event handler to be used when a device removed.
Alternative event name to use with stbBluetooth.addEventListener: deviceRemoved.

Type:

(static) startDiscovery

See:

Start Bluetooth devices discovery.

Default duration of devices discovery - 10.24 seconds (1.28s * 8 intervals).

Examples
// default discovery options
if ( !stbBluetooth.startDiscovery() ) {
    console.log('discovery failure - already in progress!');
}
// custom discovery options
stbBluetooth.startDiscovery({duration: 20});

(static) stopDiscovery

See:

Stop Bluetooth devices discovery.

Example
if ( !stbBluetooth.stopDiscovery() ) {
    console.log('discovery stopping failure!');
}

(static) name :string

Bluetooth adapter discoverable name.
Can be changed at run-time.

To set this attribute permanently at boot time use the associated environment variable: bluetoothAdapterName.
Changing this property does not affect the associated environment variable.

Type:
  • string
Examples
// change in JavaScript
stbBluetooth.name = "John's STB";
# change in shell
fw_setenv bluetoothAdapterName "John's STB"

(static) visible :boolean

Default Value:
  • false

Set host device discoverable or not.
Can be changed at run-time.

To set this attribute permanently at boot time use the associated environment variable: bluetoothAdapterVisible.
Changing this property does not affect the associated environment variable.

Type:
  • boolean
Examples
// change in JavaScript
stbBluetooth.visible = true;
# change in shell
fw_setenv bluetoothAdapterVisible 1

(static) enable :boolean

Default Value:
  • true

Turn on/off host Bluetooth adapter.
Can be changed at run-time.

To set this attribute permanently at boot time use the associated environment variable: bluetoothAdapterEnable.
Changing this property does not affect the associated environment variable.

Type:
  • boolean
Examples
// change in JavaScript
stbBluetooth.enable = false;
# change in shell
fw_setenv bluetoothAdapterEnable 0

(static, readonly) address :string

Bluetooth device MAC address in the format: "AA:BB:CC:DD:EE:FF".

Type:
  • string

Type Definitions

onDiscoveryStartCallback(config)

See:

Event handler callback.

Examples
stbBluetooth.onDiscoveryStart = function ( config ) {
    console.log('onDiscoveryStart event');
    console.log(config);
};
stbBluetooth.addEventListener('discoveryStart', function ( config ) {
    console.log('discoveryStart listener');
    console.log(config);
});
Parameters:
Name Type Description
config stbBluetooth~discoveryConfig

discovery options

onDiscoveryStopCallback()

See:

Event handler callback.

Examples
stbBluetooth.onDiscoveryStop = function () {
    console.log('onDiscoveryStop event');
};
stbBluetooth.addEventListener('discoveryStop', function () {
    console.log('discoveryStop listener');
});

onDeviceFoundCallback(device)

See:

Event handler callback.

Examples
stbBluetooth.onDeviceFound = function ( device ) {
    console.log('onDeviceFound event');
    console.log(device);
};
stbBluetooth.addEventListener('deviceFound', function ( device ) {
    console.log('deviceFound listener');
    console.log(device);
});
Parameters:
Name Type Description
device stbBluetoothDevice

discovered device

onDeviceRemovedCallback(device)

See:

Event handler callback.

Examples
stbBluetooth.onDeviceRemoved = function ( device ) {
    console.log('onDeviceRemoved event');
    console.log(device);
};
stbBluetooth.addEventListener('deviceRemoved', function ( device ) {
    console.log('deviceRemoved listener');
    console.log(device);
});
Parameters:
Name Type Description
device stbBluetoothDevice

removed device

discoveryConfig

See:
Properties:
Name Type Attributes Default Description
duration Object <optional>
8

discovery process timeout (amount of 1.28s intervals) [1..48]

in case of wrong value default is used

Discovery configuration options.

Type:
  • Object
Example
{
    duration: 10
}