介绍

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

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

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

注册信息

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

支持模型

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

支持的操作系统和架构

操作系统架构
linuxamd64
linuxarm
linuxarm64

使用方式

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

权限

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

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

BLE 示例

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

  1. apiVersion: edge.cattle.io/v1alpha1
  2. kind: DeviceLink
  3. metadata:
  4. name: xiaomi-temp-rs2201
  5. spec:
  6. adaptor:
  7. node: edge-worker
  8. name: adaptors.edge.cattle.io/ble
  9. model:
  10. apiVersion: "devices.edge.cattle.io/v1alpha1"
  11. kind: "BluetoothDevice"
  12. template:
  13. metadata:
  14. labels:
  15. device: xiaomi-temp-rs2201
  16. spec:
  17. parameters:
  18. syncInterval: 15s
  19. timeout: 30s
  20. protocol:
  21. endpoint: "MJ_HT_V1"
  22. properties:
  23. - name: data
  24. description: XiaoMi temp sensor with temperature and humidity data
  25. accessMode: NotifyOnly
  26. visitor:
  27. characteristicUUID: 226c000064764566756266734470666d
  28. - name: humidity
  29. description: Humidity in percent
  30. accessMode: ReadOnly
  31. visitor:
  32. characteristicUUID: f000aa0304514000b000000000000000
  33. dataConverter:
  34. startIndex: 1
  35. endIndex: 0
  36. shiftRight: 2
  37. orderOfOperations:
  38. # Options are Add/Subtract/Multiply/Divide
  39. - type: Multiply
  40. value: "0.03125"
  41. - name: power-enabled
  42. description: Turn the device power on or off
  43. accessMode: ReadWrite
  44. visitor:
  45. characteristicUUID: f000aa0104514000b000000000000001
  46. # Sets the defaultValue by chosen one of option in the dataWrite
  47. defaultValue: OFF
  48. dataWrite:
  49. ON: [1]
  50. OFF: [0]
  51. dataConverter:
  52. startIndex: 1
  53. endIndex: 0
  54. shiftRight: 3
  55. orderOfOperations:
  56. - type: Multiply
  57. 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