BLE 适配器

介绍

BLE代表低功耗蓝牙。 BLE是一种设计用于短距离通信的无线通信形式。

BLE适配器实现了蓝牙协议的支持,并用于定义所连接的BLE设备的属性与配置。

说明: 使用BLE适配器前,请检查您的主机是否具有蓝牙传输功能。如果您的主机不支持蓝牙传输,则会导致工作负载和Pods启动失败。

注册信息

版本注册名称端点 Socket是否可用
v1alpha1adaptors.edge.cattle.io/bleble.sock*

支持模型

类型设备组版本是否可用
BluetoothDevicedevices.edge.cattle.iov1alpha1*

支持的操作系统和架构

操作系统架构
linuxamd64
linuxarm
linuxarm64

使用方式

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

国内用户,可以使用以下方法加速安装:

kubectl apply -f http://rancher-mirror.cnrancher.com/octopus/master/adaptors/ble/deploy/e2e/all_in_one.yaml

权限

对Octopus授予权限,如下所示:

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]

BLE示例

指定一个 "蓝牙设备 "设备链接来连接小米温度计

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"

有关更多BLE DeviceLink示例,请参考deploy/e2e目录。

BluetoothDevice

参数描述类型是否必填
metadata元数据metav1.ObjectMeta
spec定义 "BluetoothDevice"的预期状态BluetoothDeviceSpec
statusD定义 "BluetoothDevice"的实际状态BluetoothDeviceStatus

BluetoothDeviceSpec

参数描述类型是否必填
extension指定设备的插件*BluetoothDeviceExtension
parameters指定设备的参数*BluetoothDeviceParameters
protocol指定访问设备时使用的协议BluetoothDeviceProtocol
properties指定设备的属性[]BluetoothDeviceProperty
参数描述类型是否必填
properties上报设备的属性[]BluetoothDeviceStatusProperty

BluetoothDeviceParameters

参数描述类型是否必填
syncInterval指定默认的设备同步时间间隔,默认为15sstring
timeout指定默认的设备的连接超时时间,默认为30sstring

BluetoothDeviceProtocol

参数描述类型是否必填
endpoint指定设备的端点,可以是设备的名称或MAC地址string

BluetoothDeviceProperty

参数描述类型是否必填
name指定属性名称string
description指定属性的描述string
accessMode指定属性的访问模式,默认为 "NotifyOnly"BluetoothDevicePropertyAccessMode
visitor指定属性的visitor*BluetoothDevicePropertyVisitor

BluetoothDeviceStatusProperty

参数描述类型是否必填
name属性名称string
value属性值string
accessMode属性的权限BluetoothDevicePropertyAccessMode
updatedAt修改属性的时间戳*metav1.Time

BluetoothDevicePropertyAccessMode

ParameterDescriptionScheme
ReadOnly属性的权限是read onlystring
ReadWrite属性的权限是read and writestring
NotifyOnly属性的权限模式是notify onlystring

BluetoothDevicePropertyVisitor

参数描述类型是否必填
characteristicUUID指定属性的UUID。string
defaultValue当访问模式为 "读写 "时,指定属性的默认值string
dataWrite指定要写入设备的数据string
dataConverter指定将从设备读取的数据转换为字符串的转换器BluetoothDataConverter

BluetoothDataConverter

参数描述类型是否必填
startIndex指定要转换的输入字节流的起始索引int
endIndex指定要转换的输入字节流的结束索引int
shiftLeft指定要左移的位数int
shiftRight指定要右移的位数int
orderOfOperations指定操作的顺序[]BluetoothDeviceArithmeticOperation

BluetoothDeviceArithmeticOperation

参数描述类型是否必填
type指定算术运算的类型BluetoothDeviceArithmeticOperationType
value指定算术运算的值,其形式为浮点数字符串string

BluetoothDeviceArithmeticOperationType

参数描述类型
Add加法的算术运算。string
Subtract减法的算术运算。string
Multiply乘法的算术运算。string
Divide除法的算术运算。string

BluetoothDeviceExtension

参数描述类型是否必填
mqtt指定MQTT的设置*v1alpha1.MQTTOptionsSpec