stbBluetoothDevice

stbBluetoothDevice

Internal object provides API to work with Bluetooth devices.

Not accessible in global scope.
Can't be manually created but can be received in stbBluetooth global object.

Members

(static) address :string

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

Type:
  • string

(static) name :string

Bluetooth device discoverable name.

Type:
  • string

(static) type :string

Bluetooth device type.

Available types:

  • BR/EDR
  • BLE
Type:
  • string

(static) vendorId :number

Bluetooth device vendor identifier.

Type:
  • number

(static) productId :number

Bluetooth device product identifier.

Type:
  • number

(static) active :boolean

Bluetooth device connection state.
Has true value in case at least one profile is connected.

Type:
  • boolean

(static) paired :boolean

Bluetooth device paired state.

Type:
  • boolean

(static) profiles :Object

Properties:
Name Type Attributes Description
HID stbBluetoothProfile <optional>

Human Interface Device profile

A2DP stbBluetoothProfile <optional>

Advanced Audio Distribution Profile

Bluetooth device available profiles.

Type:
  • Object

(static) onPinProvide :stbBluetoothDevice~onPinProvideCallback

Default Value:
  • null

Event handler to be used when pin is available.
Alternative event name to use with stbBluetoothDevice.addEventListener: pinProvide.

Type:

(static) onAuthentication :stbBluetoothDevice~onAuthenticationCallback

Default Value:
  • null

Event handler to be used when authentication is completed.
Alternative event name to use with stbBluetoothDevice.addEventListener: authentication.
This event fires on each first connection.

Type:

(static) onChange :stbBluetoothDevice~onChangeCallback

Default Value:
  • null

Event handler to be used when a device property is changed.
Alternative event name to use with stbBluetoothDevice.addEventListener: change.

Type:

Methods

(static) addEventListener(name, callback)

See:

Registers the specified listener.

Available events:

  • pinProvide
  • authentication
  • change
Parameters:
Name Type Description
name string

event name

callback function

event callback function

(static) removeEventListener(callback)

See:

Removes the event listener previously registered.

Parameters:
Name Type Description
callback function

event callback function

(static) forget() → {boolean}

Disconnect and unpair the given Bluetooth device and remove it from the paired devices list.

Returns:

operation status

Type
boolean

Type Definitions

onPinProvideCallback(pin)

See:

Event handler callback.

Examples
stbBluetoothDevice.onPinProvide = function ( pin ) {
    console.log('onPinProvide event');
    console.log(pin);
};
stbBluetoothDevice.addEventListener('pinProvide', function ( pin ) {
    console.log('pinProvide listener');
    console.log(pin);
});
Parameters:
Name Type Description
pin string

provided pin

onAuthenticationCallback(status)

See:

Event handler callback.

Examples
stbBluetoothDevice.onAuthentication = function ( status ) {
    console.log('onAuthentication event');
    console.log(status);
};
stbBluetoothDevice.addEventListener('authentication', function ( status ) {
    console.log('authentication listener');
    console.log(status);
});
Parameters:
Name Type Description
status boolean

authentication status

onChangeCallback(name, value)

See:

Event handler callback.

Examples
stbBluetoothDevice.onChange = function ( name, value ) {
    console.log('onChange event');
    console.log(name, value);
};
stbBluetoothDevice.addEventListener('change', function ( name, value ) {
    console.log('change listener');
    console.log(name, value);
});
Parameters:
Name Type Description
name string

changed property name

value string

changed property value