Accessory Module
Version 0.1.0-alpha.4
Overview
A module for assisting pairing and managing Firebolt compatible accessories.
OpenRPC
Firebolt APIs are maintained in the rdkcentral/firebolt-manage-sdk.git GitHub repository.
You can see this API in the accessory.json OpenRPC JSON-Schema document.
Table of Contents
Usage
To use the Accessory module, you can import it into your project from the Firebolt SDK:
import { Accessory } from '@firebolt-js/manage-sdk'
Methods
pair
Pair an accessory with the device.
function pair(type?: AccessoryType, protocol?: AccessoryProtocol, timeout?: AccessoryPairingTimeout): Promise<AccessoryInfo>
Parameters:
Param | Type | Required | Summary |
---|---|---|---|
type |
AccessoryType |
false | |
protocol |
AccessoryProtocol |
false | |
timeout |
AccessoryPairingTimeout |
false | minumum: 0 |
maximum: 9999 |
Promise resolution:
Type | Description |
---|---|
AccessoryInfo |
Properties of a paired accessory. |
Examples
Pair a Bluetooth Remote
JavaScript:
import { Accessory } from '@firebolt-js/manage-sdk'
Accessory.pair("Remote", "BluetoothLE", 180)
.then(pairedAccessory => {
console.log(pairedAccessory)
})
Value of pairedAccessory
:
{
"type": "Remote",
"make": "UEI",
"model": "PR1",
"protocol": "BluetoothLE"
}
JSON-RPC:
Request:
{
"jsonrpc": "2.0",
"id": 1,
"method": "accessory.pair",
"params": {
"type": "Remote",
"protocol": "BluetoothLE",
"timeout": 180
}
}
Response:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"type": "Remote",
"make": "UEI",
"model": "PR1",
"protocol": "BluetoothLE"
}
}
More examples…
Pair a Bluetooth SpeakerJavaScript:
import { Accessory } from '@firebolt-js/manage-sdk'
Accessory.pair("Speaker", "BluetoothLE", 180)
.then(pairedAccessory => {
console.log(pairedAccessory)
})
Value of pairedAccessory
:
{
"type": "Speaker",
"make": "Sonos",
"model": "V120",
"protocol": "BluetoothLE"
}
JSON-RPC:
Request:
{
"jsonrpc": "2.0",
"id": 1,
"method": "accessory.pair",
"params": {
"type": "Speaker",
"protocol": "BluetoothLE",
"timeout": 180
}
}
Response:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"type": "Speaker",
"make": "Sonos",
"model": "V120",
"protocol": "BluetoothLE"
}
}
Pair a RF Remote
JavaScript:
import { Accessory } from '@firebolt-js/manage-sdk'
Accessory.pair("Remote", "RF4CE", 180)
.then(pairedAccessory => {
console.log(pairedAccessory)
})
Value of pairedAccessory
:
{
"type": "Remote",
"make": "UEI",
"model": "15",
"protocol": "RF4CE"
}
JSON-RPC:
Request:
{
"jsonrpc": "2.0",
"id": 1,
"method": "accessory.pair",
"params": {
"type": "Remote",
"protocol": "RF4CE",
"timeout": 180
}
}
Response:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"type": "Remote",
"make": "UEI",
"model": "15",
"protocol": "RF4CE"
}
}
list
Provides a list of Accesories paired to the device.
function list(type?: AccessoryTypeListParam, protocol?: AccessoryProtocolListParam): Promise<AccessoryList>
Parameters:
Param | Type | Required | Summary |
---|---|---|---|
type |
AccessoryTypeListParam |
false | |
protocol |
AccessoryProtocolListParam |
false | Defines the mechanism by which accessory will connect to the device. |
Promise resolution:
Type | Description |
---|---|
AccessoryList |
Contains a list of Accessories paired to the device. |
Examples
List all Accessories.
JavaScript:
import { Accessory } from '@firebolt-js/manage-sdk'
Accessory.list("All", "All")
.then(list => {
console.log(list)
})
Value of list
:
{
"list": [
{
"type": "Remote",
"make": "uei",
"model": "PR1",
"protocol": "BluetoothLE"
},
{
"type": "Speaker",
"make": "Sonos",
"model": "V120",
"protocol": "BluetoothLE"
}
]
}
JSON-RPC:
Request:
{
"jsonrpc": "2.0",
"id": 1,
"method": "accessory.list",
"params": {
"type": "All",
"protocol": "All"
}
}
Response:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"list": [
{
"type": "Remote",
"make": "uei",
"model": "PR1",
"protocol": "BluetoothLE"
},
{
"type": "Speaker",
"make": "Sonos",
"model": "V120",
"protocol": "BluetoothLE"
}
]
}
}
More examples…
List Bluetooth accessoriesJavaScript:
import { Accessory } from '@firebolt-js/manage-sdk'
Accessory.list("All", "BluetoothLE")
.then(list => {
console.log(list)
})
Value of list
:
{
"list": [
{
"type": "Remote",
"make": "uei",
"model": "PR1",
"protocol": "BluetoothLE"
},
{
"type": "Speaker",
"make": "Sonos",
"model": "V120",
"protocol": "BluetoothLE"
}
]
}
JSON-RPC:
Request:
{
"jsonrpc": "2.0",
"id": 1,
"method": "accessory.list",
"params": {
"type": "All",
"protocol": "BluetoothLE"
}
}
Response:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"list": [
{
"type": "Remote",
"make": "uei",
"model": "PR1",
"protocol": "BluetoothLE"
},
{
"type": "Speaker",
"make": "Sonos",
"model": "V120",
"protocol": "BluetoothLE"
}
]
}
}
List only Bluetooth Remotes
JavaScript:
import { Accessory } from '@firebolt-js/manage-sdk'
Accessory.list("Remote", "BluetoothLE")
.then(list => {
console.log(list)
})
Value of list
:
{
"list": [
{
"type": "Remote",
"make": "uei",
"model": "PR1",
"protocol": "BluetoothLE"
}
]
}
JSON-RPC:
Request:
{
"jsonrpc": "2.0",
"id": 1,
"method": "accessory.list",
"params": {
"type": "Remote",
"protocol": "BluetoothLE"
}
}
Response:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"list": [
{
"type": "Remote",
"make": "uei",
"model": "PR1",
"protocol": "BluetoothLE"
}
]
}
}
List only Bluetooth Speakers
JavaScript:
import { Accessory } from '@firebolt-js/manage-sdk'
Accessory.list("Speaker", "BluetoothLE")
.then(list => {
console.log(list)
})
Value of list
:
{
"list": [
{
"type": "Speaker",
"make": "Sonos",
"model": "V120",
"protocol": "BluetoothLE"
}
]
}
JSON-RPC:
Request:
{
"jsonrpc": "2.0",
"id": 1,
"method": "accessory.list",
"params": {
"type": "Speaker",
"protocol": "BluetoothLE"
}
}
Response:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"list": [
{
"type": "Speaker",
"make": "Sonos",
"model": "V120",
"protocol": "BluetoothLE"
}
]
}
}
List only RF Remote
JavaScript:
import { Accessory } from '@firebolt-js/manage-sdk'
Accessory.list("Remote", "RF4CE")
.then(list => {
console.log(list)
})
Value of list
:
{
"list": [
{
"type": "Remote",
"make": "uei",
"model": "XR15",
"protocol": "RF4CE"
}
]
}
JSON-RPC:
Request:
{
"jsonrpc": "2.0",
"id": 1,
"method": "accessory.list",
"params": {
"type": "Remote",
"protocol": "RF4CE"
}
}
Response:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"list": [
{
"type": "Remote",
"make": "uei",
"model": "XR15",
"protocol": "RF4CE"
}
]
}
}
Schemas
AccessoryList
Contains a list of Accessories paired to the device.
type AccessoryList = {
list?: AccessoryInfo[]
}
AccessoryPairingTimeout
Defines the timeout in seconds. If the threshold for timeout is passed without a result it will throw an error.
type AccessoryPairingTimeout = number
AccessoryType
Type of the device Remote,Speaker or Other
type AccessoryType = 'Remote' | 'Speaker' | 'Other'
AccessoryTypeListParam
Type of the device Remote,Speaker or Other
type AccessoryTypeListParam = 'Remote' | 'Speaker' | 'All'
AccessoryProtocol
Mechanism to connect the accessory to the device
type AccessoryProtocol = 'BluetoothLE' | 'RF4CE'
AccessoryProtocolListParam
Mechanism to connect the accessory to the device
type AccessoryProtocolListParam = 'BluetoothLE' | 'RF4CE' | 'All'
AccessoryInfo
Properties of a paired accessory.
type AccessoryInfo = {
type?: AccessoryType // Type of the device Remote,Speaker or Other
make?: string // Name of the manufacturer of the accessory
model?: string // Model name of the accessory
protocol?: AccessoryProtocol // Mechanism to connect the accessory to the device
}