Version: 1.0
Status: ⚫⚪⚪
A BluetoothControl plugin for Thunder framework.
This document describes purpose and functionality of the BluetoothControl plugin. It includes detailed specification about its configuration, methods and properties provided, as well as notifications sent.
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 |
---|---|
API | Application Programming Interface |
HTTP | Hypertext Transfer Protocol |
JSON | JavaScript Object Notation; a data interchange format |
JSON-RPC | A remote procedure call protocol encoded in JSON |
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 Control plugin allows Bluetooth device administration.
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 | Description |
---|---|---|
callsign | string | Plugin instance name (default: BluetoothControl) |
classname | string | Class name: BluetoothControl |
locator | string | Library name: libWPEFrameworkBluetoothControl.so |
autostart | boolean | Determines if the plugin shall be started automatically along with the framework |
configuration | object | (optional) |
configuration?.interface | number | (optional) ID of interface |
configuration?.name | String | (optional) Name of interface |
configuration?.class | number | (optional) Number of Class |
configuration?.autopasskeyconfirm | boolean | (optional) Enable autopass confirm |
configuration?.persistmac | boolean | (optional) Enable persistent MAC |
This plugin implements the following interfaces:
The following methods are provided by the BluetoothControl plugin:
BluetoothControl interface methods:
Method | Description |
---|---|
scan | Starts active scanning for Bluetooth devices |
stopscanning | Stops scanning procedure |
connect | Connects to a Bluetooth device |
disconnect | Disconnects from a connected Bluetooth device |
pair | Pairs a Bluetooth device |
unpair | Unpairs a paired Bluetooth device |
abortpairing | Aborts the pairing process |
pincode | Specifies a PIN code for authentication during a legacy pairing process |
passkey | Specifies a passkey for authentication during a pairing process |
confirmpasskey | Confirms a passkey for authentication during a pairing process |
scan method
Starts active scanning for Bluetooth devices.
Also see: scanstarted, scancomplete
Name | Type | Description |
---|---|---|
params | object | |
params.type | string | Bluetooth device type (must be one of the following: Classic, LowEnergy) |
params?.timeout | number | (optional) Duration of the scan (in seconds); default: 10 seconds |
params?.duration | number | (optional) Duration of the scan (in seconds); default: 10 seconds |
Name | Type | Description |
---|---|---|
result | null | Always null |
Code | Message | Description |
---|---|---|
1 | ERROR_GENERAL |
Failed to scan |
12 | ERROR_INPROGRESS |
Scan already in progress |
{
"jsonrpc": "2.0",
"id": 42,
"method": "BluetoothControl.1.scan",
"params": {
"type": "LowEnergy",
"timeout": 60,
"duration": 60
}
}
{
"jsonrpc": "2.0",
"id": 42,
"result": null
}
stopscanning method
Stops scanning procedure.
Also see: scancomplete
This method takes no parameters.
Name | Type | Description |
---|---|---|
result | null | Always null |
Code | Message | Description |
---|---|---|
1 | ERROR_GENERAL |
Failed to top scanning |
5 | ERROR_ILLEGAL_STATE |
No scan is in progress |
{
"jsonrpc": "2.0",
"id": 42,
"method": "BluetoothControl.1.stopscanning"
}
{
"jsonrpc": "2.0",
"id": 42,
"result": null
}
connect method
Connects to a Bluetooth device.
If the device is not available it will be automatically connected as soon it becomes available.
Also see: devicestatechange
Name | Type | Description |
---|---|---|
params | object | |
params.address | string | Bluetooth address |
Name | Type | Description |
---|---|---|
result | null | Always null |
Code | Message | Description |
---|---|---|
22 | ERROR_UNKNOWN_KEY |
Unknown device |
5 | ERROR_ILLEGAL_STATE |
Device not paired |
9 | ERROR_ALREADY_CONNECTED |
Device already connected |
1 | ERROR_GENERAL |
Failed to connect the device |
27 | ERROR_REQUEST_SUBMITTED |
Device has not been connected but will be automatically connected when available |
{
"jsonrpc": "2.0",
"id": 42,
"method": "BluetoothControl.1.connect",
"params": {
"address": "81:6F:B0:91:9B:FE"
}
}
{
"jsonrpc": "2.0",
"id": 42,
"result": null
}
disconnect method
Disconnects from a connected Bluetooth device.
Device will cease to re-connect automatically.
Also see: devicestatechange
Name | Type | Description |
---|---|---|
params | object | |
params.address | string | Bluetooth address |
Name | Type | Description |
---|---|---|
result | null | Always null |
Code | Message | Description |
---|---|---|
22 | ERROR_UNKNOWN_KEY |
Unknown device |
36 | ERROR_ALREADY_RELEASED |
Device not connected |
27 | ERROR_REQUEST_SUBMITTED |
Device is currently not connected but it's autoconnection mode has been disabled |
{
"jsonrpc": "2.0",
"id": 42,
"method": "BluetoothControl.1.disconnect",
"params": {
"address": "81:6F:B0:91:9B:FE"
}
}
{
"jsonrpc": "2.0",
"id": 42,
"result": null
}
pair method
Pairs a Bluetooth device.
The client may expect PIN or passkey requests during the pairing process. The process can be cancelled any time by calling the abortpairing method
Also see: devicestatechange, pincoderequest, passkeyrequest, passkeyconfirmrequest
Name | Type | Description |
---|---|---|
params | object | |
params.address | string | Bluetooth address |
params?.timeout | integer | (optional) Maximum time allowed for the pairing process to complete (in seconds); default: 20 seconds |
Name | Type | Description |
---|---|---|
result | null | Always null |
Code | Message | Description |
---|---|---|
22 | ERROR_UNKNOWN_KEY |
Unknown device |
9 | ERROR_ALREADY_CONNECTED |
Device already paired |
1 | ERROR_GENERAL |
Failed to pair the device |
{
"jsonrpc": "2.0",
"id": 42,
"method": "BluetoothControl.1.pair",
"params": {
"address": "81:6F:B0:91:9B:FE",
"timeout": 60
}
}
{
"jsonrpc": "2.0",
"id": 42,
"result": null
}
unpair method
Unpairs a paired Bluetooth device.
Also see: devicestatechange
Name | Type | Description |
---|---|---|
params | object | |
params.address | string | Bluetooth address |
Name | Type | Description |
---|---|---|
result | null | Always null |
Code | Message | Description |
---|---|---|
22 | ERROR_UNKNOWN_KEY |
Unknown device |
36 | ERROR_ALREADY_RELEASED |
Device not paired |
{
"jsonrpc": "2.0",
"id": 42,
"method": "BluetoothControl.1.unpair",
"params": {
"address": "81:6F:B0:91:9B:FE"
}
}
{
"jsonrpc": "2.0",
"id": 42,
"result": null
}
abortpairing method
Aborts the pairing process.
Name | Type | Description |
---|---|---|
params | object | |
params.address | string | Bluetooth address |
Name | Type | Description |
---|---|---|
result | null | Always null |
Code | Message | Description |
---|---|---|
22 | ERROR_UNKNOWN_KEY |
Unknown device |
5 | ERROR_ILLEGAL_STATE |
Device not currently pairing |
{
"jsonrpc": "2.0",
"id": 42,
"method": "BluetoothControl.1.abortpairing",
"params": {
"address": "81:6F:B0:91:9B:FE"
}
}
{
"jsonrpc": "2.0",
"id": 42,
"result": null
}
pincode method
Specifies a PIN code for authentication during a legacy pairing process.
This method is to be called upon receiving a pincoderequest event during a legacy pairing process. If the specified PIN code is incorrect the pairing process will be aborted.
Also see: pincoderequest
Name | Type | Description |
---|---|---|
params | object | |
params.address | string | Bluetooth address |
params.secret | string | A PIN code string, typically consisting of (but not limited to) four decimal digits |
Name | Type | Description |
---|---|---|
result | null | Always null |
Code | Message | Description |
---|---|---|
22 | ERROR_UNKNOWN_KEY |
Unknown device |
5 | ERROR_ILLEGAL_STATE |
Device not currently pairing or PIN code has not been requested |
{
"jsonrpc": "2.0",
"id": 42,
"method": "BluetoothControl.1.pincode",
"params": {
"address": "81:6F:B0:91:9B:FE",
"secret": "0000"
}
}
{
"jsonrpc": "2.0",
"id": 42,
"result": null
}
passkey method
Specifies a passkey for authentication during a pairing process.
This method is to be called upon receiving a passkeyrequest event during a pairing process. If the specified passkey is incorrect or empty the pairing process will be aborted.
Also see: passkeyrequest
Name | Type | Description |
---|---|---|
params | object | |
params.address | string | Bluetooth address |
params.secret | integer | A six-digit decimal number passkey |
Name | Type | Description |
---|---|---|
result | null | Always null |
Code | Message | Description |
---|---|---|
22 | ERROR_UNKNOWN_KEY |
Unknown device |
5 | ERROR_ILLEGAL_STATE |
Device not currently pairing or a passkey has not been requested |
{
"jsonrpc": "2.0",
"id": 42,
"method": "BluetoothControl.1.passkey",
"params": {
"address": "81:6F:B0:91:9B:FE",
"secret": 123456
}
}
{
"jsonrpc": "2.0",
"id": 42,
"result": null
}
confirmpasskey method
Confirms a passkey for authentication during a pairing process.
This method is to be called upon receiving a passkeyconfirmationrequest event during a pairing process. If the confirmation is negative or the pairing process will be aborted.
Also see: passkeyconfirmrequest
Name | Type | Description |
---|---|---|
params | object | |
params.address | string | Bluetooth address |
params.iscorrect | boolean | Specifies if the passkey sent in passkeyconfirmrequest event is correct (true) or incorrect (false) |
Name | Type | Description |
---|---|---|
result | null | Always null |
Code | Message | Description |
---|---|---|
22 | ERROR_UNKNOWN_KEY |
Unknown device |
5 | ERROR_ILLEGAL_STATE |
Device is currently not pairing or passkey confirmation has not been requested |
{
"jsonrpc": "2.0",
"id": 42,
"method": "BluetoothControl.1.confirmpasskey",
"params": {
"address": "81:6F:B0:91:9B:FE",
"iscorrect": true
}
}
{
"jsonrpc": "2.0",
"id": 42,
"result": null
}
The following properties are provided by the BluetoothControl plugin:
BluetoothControl interface properties:
Property | Description |
---|---|
adapters RO | List of local Bluetooth adapters |
adapter RO | Local Bluetooth adapter information |
devices RO | List of known remote Bluetooth devices |
device RO | Remote Bluetooth device information |
adapters property
Provides access to the list of local Bluetooth adapters.
This property is read-only.
Name | Type | Description |
---|---|---|
(property) | array | List of local Bluetooth adapters |
(property)[#] | number | Adapter ID |
{
"jsonrpc": "2.0",
"id": 42,
"method": "BluetoothControl.1.adapters"
}
{
"jsonrpc": "2.0",
"id": 42,
"result": [
0
]
}
adapter property
Provides access to the local Bluetooth adapter information.
This property is read-only.
Name | Type | Description |
---|---|---|
(property) | object | Local Bluetooth adapter information |
(property).interface | string | Ndapter interface name |
(property).address | string | Bluetooth address |
(property).version | number | Device version |
(property)?.manufacturer | number | (optional) Device manufacturer Company Identifer |
(property)?.name | string | (optional) Device name |
(property)?.shortname | string | (optional) Device short name |
The adapter id argument shall be passed as the index to the property, e.g. BluetoothControl.1.adapter@0.
Code | Message | Description |
---|---|---|
22 | ERROR_UNKNOWN_KEY |
Unknown device |
{
"jsonrpc": "2.0",
"id": 42,
"method": "BluetoothControl.1.adapter@0"
}
{
"jsonrpc": "2.0",
"id": 42,
"result": {
"interface": "hci0",
"address": "81:6F:B0:91:9B:FE",
"version": 8,
"manufacturer": 0,
"name": "Thunder",
"shortname": "Thunder"
}
}
devices property
Provides access to the list of known remote Bluetooth devices.
This property is read-only.
Name | Type | Description |
---|---|---|
(property) | array | List of known remote Bluetooth devices |
(property)[#] | string | Bluetooth address |
{
"jsonrpc": "2.0",
"id": 42,
"method": "BluetoothControl.1.devices"
}
{
"jsonrpc": "2.0",
"id": 42,
"result": [
"81:6F:B0:91:9B:FE"
]
}
device property
Provides access to the remote Bluetooth device information.
This property is read-only.
Name | Type | Description |
---|---|---|
(property) | object | Remote Bluetooth device information |
(property).name | string | Name of the device |
(property).type | string | Bluetooth device type (must be one of the following: Classic, LowEnergy) |
(property)?.class | integer | (optional) Class of device (3 octets) |
(property).connected | boolean | Denotes if the device is currently connected to host |
(property).paired | boolean | Denotes if the device is currently paired with host |
The device address argument shall be passed as the index to the property, e.g. BluetoothControl.1.device@81:6F:B0:91:9B:FE.
Code | Message | Description |
---|---|---|
22 | ERROR_UNKNOWN_KEY |
Unknown device |
{
"jsonrpc": "2.0",
"id": 42,
"method": "BluetoothControl.1.device@81:6F:B0:91:9B:FE"
}
{
"jsonrpc": "2.0",
"id": 42,
"result": {
"name": "Acme Bluetooth Device",
"type": "LowEnergy",
"class": 2360324,
"connected": true,
"paired": true
}
}
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 BluetoothControl plugin:
BluetoothControl interface events:
Event | Description |
---|---|
scanstarted | Notifies about start scanning |
scancomplete | Notifies about scan completion |
devicestatechange | Notifies about device state change |
pincoderequest | Notifies about a PIN code request |
passkeyrequest | Notifies about a passkey request |
passkeyconfirmrequest | Notifies about a passkey confirmation request |
scanstarted event
Notifies about start scanning.
Register to this event to be notified about device scan start
This event carries no parameters.
{
"jsonrpc": "2.0",
"method": "client.events.1.scanstarted"
}
scancomplete event
Notifies about scan completion.
Register to this event to be notified about device scan completion
This event carries no parameters.
{
"jsonrpc": "2.0",
"method": "client.events.1.scancomplete"
}
devicestatechange event
Notifies about device state change.
Register to this event to be notified about device state changes
Name | Type | Description |
---|---|---|
params | object | |
params.address | string | Bluetooth address |
params.state | string | Device state (must be one of the following: Pairing, Paired, Unpaired, Connected, Disconnected) |
params?.disconnectreason | string | (optional) Disconnection reason in case of Disconnected event (must be one of the following: ConnectionTimeout, AuthenticationFailure, RemoteLowOnResources, RemotePoweredOff, TerminatedByRemote, TerminatedByHost) |
{
"jsonrpc": "2.0",
"method": "client.events.1.devicestatechange",
"params": {
"address": "81:6F:B0:91:9B:FE",
"state": "Disconnected",
"disconnectreason": "ConnectionTimeout"
}
}
pincoderequest event
Notifies about a PIN code request.
Register to this event to be notified about PIN code requests during a legacy pairing process. Upon receiving this event the client is required to respond with a pincode call in order to complete the pairing procedure. The PIN code value would typically be collected by prompting the end-user. If the client fails to respond before the pairing timeout elapses the pairing procedure will be aborted.
Note that this event will never be send for a Bluetooth LowEnergy device.
Name | Type | Description |
---|---|---|
params | object | |
params.address | string | Bluetooth address |
{
"jsonrpc": "2.0",
"method": "client.events.1.pincoderequest",
"params": {
"address": "81:6F:B0:91:9B:FE"
}
}
passkeyrequest event
Notifies about a passkey request.
Register to this event to be notified about passkey requests that may be required during a pairing process. Upon receiving this event the client is required to respond with a passkey call in order to complete the pairing procedure. The passkey value would typically be collected by prompting the end-user. If the client fails to respond before the pairing timeout elapses the pairing procedure will be aborted.
Name | Type | Description |
---|---|---|
params | object | |
params.address | string | Bluetooth address |
{
"jsonrpc": "2.0",
"method": "client.events.1.passkeyrequest",
"params": {
"address": "81:6F:B0:91:9B:FE"
}
}
passkeyconfirmrequest event
Notifies about a passkey confirmation request.
Register to this event to be notified about passkey confirmation requests that may required during a pairing process. Upon receiving this event the client is required to respond with a passkeyconfirm call in order to complete the pairing procedure. The passkey confirmation would typically be collected by prompting the end-user. If the client fails to respond before the pairing timeout elapses the pairing procedure will be aborted.
Name | Type | Description |
---|---|---|
params | object | |
params.address | string | Bluetooth address |
params.secret | integer | A six-digit decimal number passkey sent by the remote device for confirmation |
{
"jsonrpc": "2.0",
"method": "client.events.1.passkeyconfirmrequest",
"params": {
"address": "81:6F:B0:91:9B:FE",
"secret": 123456
}
}