BLE Adaptor

Introduction

BLE stands for Bluetooth Low Energy (marketed as Bluetooth Smart). BLE is a form of wireless communication designed for short-range communications.

BLE adaptor implements on bettercap/gatt and helps to communicate with BLE supported equipment or define the attributes of the connected device.

Noted: The host that deploys BLE adaptor needs to turn on the Bluetooth module.

Registration Information

VersionsRegister NameEndpoint SocketAvailable
v1alpha1adaptors.edge.cattle.io/bleble.sock*

Support Model

KindGroupVersionAvailable
BluetoothDevicedevices.edge.cattle.iov1alpha1*

Support Platform

OSArch
linuxamd64
linuxarm
linuxarm64

Usage

kubectl apply -f https://raw.githubusercontent.com/cnrancher/octopus/master/adaptors/ble/deploy/e2e/all_in_one.yaml

Authority

Grant permissions to Octopus as below:

Resources Non-Resource URLs Resource Names Verbs
--------- ----------------- -------------- -----
bluetoothdevices.devices.edge.cattle.io [] [] [create delete get list patch update watch]
bluetoothdevices.devices.edge.cattle.io/status [] [] [get patch update]

Example

apiVersion: edge.cattle.io/v1alpha1
kind: DeviceLink
metadata:
name: xiaomi-temp-rs2201
spec:
adaptor:
node: edge-worker
name: adaptors.edge.cattle.io/ble
model:
apiVersion: "devices.edge.cattle.io/v1alpha1"
kind: "BluetoothDevice"
template:
metadata:
labels:
device: xiaomi-temp-rs2201
spec:
parameters:
syncInterval: 15s
timeout: 30s
protocol:
endpoint: "MJ_HT_V1"
properties:
- name: data
description: XiaoMi temp sensor with temperature and humidity data
accessMode: NotifyOnly
visitor:
characteristicUUID: 226c000064764566756266734470666d
- name: humidity
description: Humidity in percent
accessMode: ReadOnly
visitor:
characteristicUUID: f000aa0304514000b000000000000000
dataConverter:
startIndex: 1
endIndex: 0
shiftRight: 2
orderOfOperations:
# Options are Add/Subtract/Multiply/Divide
- type: Multiply
value: "0.03125"
- name: power-enabled
description: Turn the device power on or off
accessMode: ReadWrite
visitor:
characteristicUUID: f000aa0104514000b000000000000001
# Sets the defaultValue by chosen one of option in the dataWrite
defaultValue: OFF
dataWrite:
ON: [1]
OFF: [0]
dataConverter:
startIndex: 1
endIndex: 0
shiftRight: 3
orderOfOperations:
- type: Multiply
value: "0.03125"

For more BluetoothDevice device link examples, please refer to the deploy/e2e directory.

BluetoothDevice

ParameterDescriptionSchemaRequired
metadatametav1.ObjectMetafalse
specDefines the desired state of BluetoothDevice.BluetoothDeviceSpectrue
statusDefines the observed state of BluetoothDevice.BluetoothDeviceStatusfalse

BluetoothDeviceSpec

ParameterDescriptionSchemaRequired
extensionSpecifies the extension of device.*BluetoothDeviceExtensionfalse
parametersSpecifies the parameters of device.*BluetoothDeviceParametersfalse
protocolSpecifies the protocol for accessing. the deviceBluetoothDeviceProtocoltrue
propertiesSpecifies the properties of device.[]BluetoothDevicePropertyfalse

BluetoothDeviceStatus

ParameterDescriptionSchemaRequired
propertiesReports the properties of device.[]BluetoothDeviceStatusPropertyfalse

BluetoothDeviceParameters

ParameterDescriptionSchemaRequired
syncIntervalSpecifies default device sync interval, default to 15s.stringfalse
timeoutSpecifies default device connection timeout, default to 30s.stringfalse

BluetoothDeviceProtocol

ParameterDescriptionSchemaRequired
endpointSpecifies the endpoint of device, it can be the name or MAC address of device.stringtrue

BluetoothDeviceProperty

ParameterDescriptionSchemaRequired
nameSpecifies the name of property.stringtrue
descriptionSpecifies the description of property.stringfalse
accessModeSpecifies the access mode of property, default to NotifyOnly.BluetoothDevicePropertyAccessModetrue
visitorSpecifies the visitor of property.*BluetoothDevicePropertyVisitortrue

BluetoothDeviceStatusProperty

ParameterDescriptionSchemaRequired
nameReports the name of property.stringfalse
valueReports the value of property.stringfalse
accessModeReports the access mode of property.BluetoothDevicePropertyAccessModefalse
updatedAtReports the updated timestamp of property.*metav1.Timefalse

BluetoothDevicePropertyAccessMode

ParameterDescriptionSchema
ReadOnlyProperty access mode is read only.string
ReadWriteProperty access mode is read and write.string
NotifyOnlyProperty access mode is notify only.string

BluetoothDevicePropertyVisitor

ParameterDescriptionSchemaRequired
characteristicUUIDSpecifies the characteristic UUID of property.stringtrue
defaultValueSpecifies the default value of property, when access mode is ReadWrite.stringfalse
dataWriteSpecifies the data to write to device.stringfalse
dataConverterSpecifies the converter to convert data read from device to a string.BluetoothDataConverterfalse

BluetoothDataConverter

ParameterDescriptionSchemaRequired
startIndexSpecifies the start index of the incoming byte stream to be converted.inttrue
endIndexSpecifies the end index of incoming byte stream to be converted.inttrue
shiftLeftSpecifies the number of bits to shift left.intfalse
shiftRightSpecifies the number of bits to shift right.intfalse
orderOfOperationsSpecifies in what order the operations.[]BluetoothDeviceArithmeticOperationfalse

BluetoothDeviceArithmeticOperation

ParameterDescriptionSchemaRequired
typeSpecifies the type of arithmetic operation.BluetoothDeviceArithmeticOperationTypetrue
valueSpecifies the value for arithmetic operation, which is in form of float string.stringtrue

BluetoothDeviceArithmeticOperationType

ParameterDescriptionSchema
AddArithmetic operation of add.string
SubtractArithmetic operation of subtract.string
MultiplyArithmetic operation of multiply.string
DivideArithmetic operation of divide.string

BluetoothDeviceExtension

ParameterDescriptionSchemaRequired
mqttSpecifies the MQTT settings.*v1alpha1.MQTTOptionsSpecfalse