Version: 1.0
Status: ⚫⚪⚪
BluetoothRemoteControl plugin for Thunder framework.
This document describes purpose and functionality of the BluetoothRemoteControl plugin. It includes detailed specification about its configuration, methods and properties as well as sent notifications.
All identifiers of the interfaces described in this document are case-sensitive. Thus, unless stated otherwise, all keywords, entities, properties, relations and actions should be treated as such.
The table below provides and overview of acronyms used in this document and their definitions.
Acronym | Description |
---|---|
ADPCM | Adaptive Pulse-code Modulation |
API | Application Programming Interface |
BLE | Bluetooth Low Energy |
GATT | Generic Attribute Profile |
HTTP | Hypertext Transfer Protocol |
JSON | JavaScript Object Notation; a data interchange format |
JSON-RPC | A remote procedure call protocol encoded in JSON |
PCM | Pulse-code Modulation |
UUID | Universally Unique Identifier |
WAV | Waveform Audio File Format |
The table below provides and overview of terms and abbreviations used in this document and their definitions.
Term | Description |
---|---|
callsign | The name given to an instance of a plugin. One plugin can be instantiated multiple times, but each instance the instance name, callsign, must be unique. |
Ref ID | Description |
---|---|
HTTP | HTTP specification |
JSON-RPC | JSON-RPC 2.0 specification |
JSON | JSON specification |
Thunder | Thunder API Reference |
The Bluetooth Remote Control plugin allows configuring and enabling Bluetooth LE remote control units.
The plugin is designed to be loaded and executed within the Thunder framework. For more information about the framework refer to [Thunder].
The table below lists configuration options of the plugin.
Name | Type | M/O | Description |
---|---|---|---|
callsign | string | mandatory | Plugin instance name (default: BluetoothRemoteControl) |
classname | string | mandatory | Class name: BluetoothRemoteControl |
locator | string | mandatory | Library name: libThunderBluetoothRemoteControl.so |
startmode | string | mandatory | Determines in which state the plugin should be moved to at startup of the framework |
configuration | object | optional | ... |
configuration?.controller | string | optional | Name of the Bluetooth controller service (default: BluetoothControl) |
configuration?.keymap | string | optional | Keymap name |
configuration?.keyingest | boolean | optional | Enable key ingestion |
configuration?.serviceuuid | string | optional | UUID of the voice control GATT service |
configuration?.commanduuid | string | optional | UUID of the voice control command GATT characteristic |
configuration?.datauuid | string | optional | UUID of the voice control data GATT characteristic |
configuration?.recorder | string | optional | Enable voice data recording (debug purposes) to WAV file (must be one of the following: off, sequenced, sequenced_persist, single, single_persist) |
configuration?.audiobuffersize | integer | optional | Size of the audio buffer in miliseconds (if not set then determined automatically) |
configuration?.firstaudiochunksize | integer | optional | Size of the first audio transmission notification in miliseconds |
configuration?.audiochunksize | integer | optional | Size of the audio transmission notifications in miliseconds (if not set then audio data is not buffered) |
configuration?.audioprofile | object | optional | ... |
configuration?.audioprofile?.samplerate | integer | optional | Audio data sample rate in Hz (e.g. 16000) |
configuration?.audioprofile?.channels | integer | optional | Number of audio channels (e.g. 1 for mono stream) |
configuration?.audioprofile?.resolution | integer | optional | Audio samples resolution in bits (e.g. 16) |
This plugin implements the following interfaces:
- IBluetoothRemoteControl (IBluetoothRemoteControl.h) (version 1.0.0) (compliant format)
- IAudioStream (IAudioStream.h) (version 1.0.0) (compliant format)
The following methods are provided by the BluetoothRemoteControl plugin:
BluetoothRemoteControl interface methods:
Method | Description |
---|---|
assign | Assigns a Bluetooth device as a RCU |
revoke | Revokes a Bluetooth device from RCU operation |
assign method
Assigns a Bluetooth device as a RCU.
Name | Type | M/O | Description |
---|---|---|---|
params | object | mandatory | ... |
params.address | string | mandatory | Address of the Bluetooth device to assign |
Name | Type | M/O | Description |
---|---|---|---|
result | null | mandatory | Always null |
Message | Description |
---|---|
ERROR_UNKNOWN_KEY |
Device address value is invalid |
ERROR_ALREADY_CONNECTED |
A RCU device is already assigned |
{
"jsonrpc": "2.0",
"id": 42,
"method": "BluetoothRemoteControl.1.assign",
"params": {
"address": "..."
}
}
{
"jsonrpc": "2.0",
"id": 42,
"result": null
}
revoke method
Revokes a Bluetooth device from RCU operation.
This method takes no parameters.
Name | Type | M/O | Description |
---|---|---|---|
result | null | mandatory | Always null |
Message | Description |
---|---|
ERROR_ALREADY_RELEASED |
No device is currently assigned as RCU |
{
"jsonrpc": "2.0",
"id": 42,
"method": "BluetoothRemoteControl.1.revoke"
}
{
"jsonrpc": "2.0",
"id": 42,
"result": null
}
The following properties are provided by the BluetoothRemoteControl plugin:
BluetoothRemoteControl interface properties:
Property | R/W | Description |
---|---|---|
device / address | read-only | Bluetooth address |
metadata / info | read-only | Device metadata |
batterylevel | read-only | Battery level |
voicecontrol | read/write | Toggle voice control |
AudioStream interface properties:
Property | R/W | Description |
---|---|---|
name | read-only | Name of the stream |
state | read-only | Current state of the stream |
capabilities | read-only | List of codecs supported by the stream |
audioprofile | read/write | Preferred profile of the stream |
time | read-only | Stream position |
speed | read/write | Stream speed |
device property
Provides access to the bluetooth address.
This property is read-only.
address
is an alternative name for this property. This name is deprecated and may be removed in the future. It is not recommended for use in new implementations.
Name | Type | M/O | Description |
---|---|---|---|
result | string | mandatory | Bluetooth address |
Message | Description |
---|---|
ERROR_ILLEGAL_STATE |
The RCU device currently is not assigned |
{
"jsonrpc": "2.0",
"id": 42,
"method": "BluetoothRemoteControl.1.device"
}
{
"jsonrpc": "2.0",
"id": 42,
"result": "..."
}
metadata property
Provides access to the device metadata.
This property is read-only.
info
is an alternative name for this property. This name is deprecated and may be removed in the future. It is not recommended for use in new implementations.
Name | Type | M/O | Description |
---|---|---|---|
result | object | mandatory | Device metadata |
result.name | string | mandatory | Name of the unit |
result?.model | string | optional | Model name |
result?.serial | string | optional | Serial number |
result?.firmware | string | optional | Firmware version |
result?.software | string | optional | Software version |
result?.manufacturer | string | optional | Vendor/manufacturer name |
Message | Description |
---|---|
ERROR_ILLEGAL_STATE |
The RCU device currently is not assigned |
{
"jsonrpc": "2.0",
"id": 42,
"method": "BluetoothRemoteControl.1.metadata"
}
{
"jsonrpc": "2.0",
"id": 42,
"result": {
"name": "...",
"model": "...",
"serial": "...",
"firmware": "...",
"software": "...",
"manufacturer": "..."
}
}
batterylevel property
Provides access to the battery level.
This property is read-only.
Name | Type | M/O | Description |
---|---|---|---|
result | integer | mandatory | Battery level |
Message | Description |
---|---|
ERROR_UNAVAILABLE |
The device is not connected or does not support battery information |
ERROR_ILLEGAL_STATE |
The RCU device currently is not assigned |
{
"jsonrpc": "2.0",
"id": 42,
"method": "BluetoothRemoteControl.1.batterylevel"
}
{
"jsonrpc": "2.0",
"id": 42,
"result": 75
}
voicecontrol property
Provides access to the toggle voice control.
Name | Type | M/O | Description |
---|---|---|---|
(property) | object | mandatory | Toggle voice control |
(property).value | boolean | mandatory | ... |
Name | Type | M/O | Description |
---|---|---|---|
result | boolean | mandatory | Toggle voice control |
Message | Description |
---|---|
ERROR_NOT_SUPPORTED |
The device does not support voice input |
ERROR_ILLEGAL_STATE |
The RCU device currently is not assigned |
{
"jsonrpc": "2.0",
"id": 42,
"method": "BluetoothRemoteControl.1.voicecontrol"
}
{
"jsonrpc": "2.0",
"id": 42,
"result": false
}
{
"jsonrpc": "2.0",
"id": 42,
"method": "BluetoothRemoteControl.1.voicecontrol",
"params": {
"value": false
}
}
{
"jsonrpc": "2.0",
"id": 42,
"result": "null"
}
name property
Provides access to the name of the stream.
This property is read-only.
Name | Type | M/O | Description |
---|---|---|---|
result | string | mandatory | Name of the stream |
Message | Description |
---|---|
ERROR_ILLEGAL_STATE |
The stream is not ready for this operation |
{
"jsonrpc": "2.0",
"id": 42,
"method": "BluetoothRemoteControl.1.name"
}
{
"jsonrpc": "2.0",
"id": 42,
"result": "..."
}
state property
Provides access to the current state of the stream.
This property is read-only.
Name | Type | M/O | Description |
---|---|---|---|
result | string | mandatory | Current state of the stream (must be one of the following: Idle, Started, Unavailable) |
{
"jsonrpc": "2.0",
"id": 42,
"method": "BluetoothRemoteControl.1.state"
}
{
"jsonrpc": "2.0",
"id": 42,
"result": "Unavailable"
}
capabilities property
Provides access to the list of codecs supported by the stream.
This property is read-only.
Name | Type | M/O | Description |
---|---|---|---|
result | array | mandatory | List of codecs supported by the stream |
result[#] | string | mandatory | ... (must be one of the following: IMA-ADPCM, PCM) |
Message | Description |
---|---|
ERROR_ILLEGAL_STATE |
The stream is not ready for this operation |
{
"jsonrpc": "2.0",
"id": 42,
"method": "BluetoothRemoteControl.1.capabilities"
}
{
"jsonrpc": "2.0",
"id": 42,
"result": [
"PCM"
]
}
audioprofile property
Provides access to the preferred profile of the stream.
Name | Type | M/O | Description |
---|---|---|---|
(property) | object | mandatory | Preferred profile of the stream |
(property).value | object | mandatory | ... |
(property).value.codec | string | mandatory | Compression method (PCM: uncompressed) (must be one of the following: IMA-ADPCM, PCM) |
(property).value?.codecparams | opaque object | optional | Additional parameters for codec |
(property).value.channels | integer | mandatory | Number of audio channels |
(property).value.resolution | integer | mandatory | Sample resultion in bits |
(property).value.samplerate | integer | mandatory | Sample rate in hertz |
(property).value?.bitrate | integer | optional | Data rate of the compressed stream in bits per second |
Name | Type | M/O | Description |
---|---|---|---|
result | object | mandatory | Preferred profile of the stream |
result.codec | string | mandatory | Compression method (PCM: uncompressed) (must be one of the following: IMA-ADPCM, PCM) |
result?.codecparams | opaque object | optional | Additional parameters for codec |
result.channels | integer | mandatory | Number of audio channels |
result.resolution | integer | mandatory | Sample resultion in bits |
result.samplerate | integer | mandatory | Sample rate in hertz |
result?.bitrate | integer | optional | Data rate of the compressed stream in bits per second |
Message | Description |
---|---|
ERROR_NOT_SUPPORTED |
Profile change is not supported by this stream |
ERROR_ILLEGAL_STATE |
The stream is not ready for this operation |
ERROR_BAD_REQUEST |
The profile specified is invalid |
ERROR_INPROGRESS |
Stream is started, profile will be changed for the next streaming |
{
"jsonrpc": "2.0",
"id": 42,
"method": "BluetoothRemoteControl.1.audioprofile"
}
{
"jsonrpc": "2.0",
"id": 42,
"result": {
"codec": "PCM",
"codecparams": {},
"channels": 1,
"resolution": 16,
"samplerate": 16000,
"bitrate": 64000
}
}
{
"jsonrpc": "2.0",
"id": 42,
"method": "BluetoothRemoteControl.1.audioprofile",
"params": {
"value": {
"codec": "PCM",
"codecparams": {},
"channels": 1,
"resolution": 16,
"samplerate": 16000,
"bitrate": 64000
}
}
}
{
"jsonrpc": "2.0",
"id": 42,
"result": "null"
}
time property
Provides access to the stream position.
This property is read-only.
Name | Type | M/O | Description |
---|---|---|---|
result | integer | mandatory | Stream position |
Message | Description |
---|---|
ERROR_NOT_SUPPORTED |
Time reporting is not supported by this stream |
ERROR_ILLEGAL_STATE |
The stream is not ready for this operation |
{
"jsonrpc": "2.0",
"id": 42,
"method": "BluetoothRemoteControl.1.time"
}
{
"jsonrpc": "2.0",
"id": 42,
"result": 0
}
speed property
Provides access to the stream speed.
Name | Type | M/O | Description |
---|---|---|---|
(property) | object | mandatory | Stream speed |
(property).value | integer | mandatory | ... |
Name | Type | M/O | Description |
---|---|---|---|
result | integer | mandatory | Stream speed |
Message | Description |
---|---|
ERROR_NOT_SUPPORTED |
Speed setting is not supported by this stream |
ERROR_ILLEGAL_STATE |
The stream is not ready for this operation |
{
"jsonrpc": "2.0",
"id": 42,
"method": "BluetoothRemoteControl.1.speed"
}
{
"jsonrpc": "2.0",
"id": 42,
"result": 0
}
{
"jsonrpc": "2.0",
"id": 42,
"method": "BluetoothRemoteControl.1.speed",
"params": {
"value": 0
}
}
{
"jsonrpc": "2.0",
"id": 42,
"result": "null"
}
Notifications are autonomous events triggered by the internals of the implementation and broadcasted via JSON-RPC to all registered observers. Refer to [Thunder] for information on how to register for a notification.
The following events are provided by the BluetoothRemoteControl plugin:
BluetoothRemoteControl interface events:
Notification | Description |
---|---|
batterylevelchange | Signals battery level change |
AudioStream interface events:
Notification | Description |
---|---|
audioframe | Provides audio data |
audiotransmission | Signals state of the stream |
batterylevelchange notification
Signals battery level change.
If applicable, this notification may be sent out during registration, reflecting the current status.
Name | Type | M/O | Description |
---|---|---|---|
params | object | mandatory | ... |
params.level | integer | mandatory | Battery level in percent |
{
"jsonrpc": "2.0",
"id": 42,
"method": "BluetoothRemoteControl.1.register",
"params": {
"event": "batterylevelchange",
"id": "client"
}
}
{
"jsonrpc": "2.0",
"method": "client.batterylevelchange",
"params": {
"level": 75
}
}
audioframe notification
Provides audio data.
Name | Type | M/O | Description |
---|---|---|---|
params | object | mandatory | ... |
params?.seq | integer | optional | Frame number in current transmission |
params?.timestamp | integer | optional | Timestamp of the frame |
params.length | integer | mandatory | Size of the raw data frame in bytes |
params.data | string (base64) | mandatory | Raw audio data, the format of the data is specified in the most recent audiotransmission notification |
{
"jsonrpc": "2.0",
"id": 42,
"method": "BluetoothRemoteControl.1.register",
"params": {
"event": "audioframe",
"id": "client"
}
}
{
"jsonrpc": "2.0",
"method": "client.audioframe",
"params": {
"seq": 1,
"timestamp": 0,
"length": 400,
"data": "..."
}
}
audiotransmission notification
Signals state of the stream.
If applicable, this notification may be sent out during registration, reflecting the current status.
Name | Type | M/O | Description |
---|---|---|---|
params | object | mandatory | ... |
params.state | string | mandatory | New state of the stream (must be one of the following: Idle, Started, Unavailable) |
params?.profile | object | optional | Details on the format used in the stream |
params?.profile.codec | string | mandatory | Compression method (PCM: uncompressed) (must be one of the following: IMA-ADPCM, PCM) |
params?.profile?.codecparams | opaque object | optional | Additional parameters for codec |
params?.profile.channels | integer | mandatory | Number of audio channels |
params?.profile.resolution | integer | mandatory | Sample resultion in bits |
params?.profile.samplerate | integer | mandatory | Sample rate in hertz |
params?.profile?.bitrate | integer | optional | Data rate of the compressed stream in bits per second |
{
"jsonrpc": "2.0",
"id": 42,
"method": "BluetoothRemoteControl.1.register",
"params": {
"event": "audiotransmission",
"id": "client"
}
}
{
"jsonrpc": "2.0",
"method": "client.audiotransmission",
"params": {
"state": "Unavailable",
"profile": {
"codec": "PCM",
"codecparams": {},
"channels": 1,
"resolution": 16,
"samplerate": 16000,
"bitrate": 64000
}
}
}