Skip to content
This repository has been archived by the owner on Sep 19, 2024. It is now read-only.

Commit

Permalink
refactor: adjust mqtt util
Browse files Browse the repository at this point in the history
- adjust the mqtt configuration

BREAKING CHANGE:
- change static/dynamic topic to template topic, which has five template
  key: `:namespace`, `:name`, `:uid`, `:path` and `:operator`.
- move will message configuration item to `message` field, and then
  don't need to set `qos` and `retained` in will message.
  • Loading branch information
Frank Mai authored and guangbochen committed Jul 11, 2020
1 parent 4bfb6e1 commit bb92675
Show file tree
Hide file tree
Showing 57 changed files with 2,474 additions and 4,220 deletions.
4 changes: 0 additions & 4 deletions adaptors/ble/api/v1alpha1/bluetoothdevice_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,6 @@ const (

// BluetoothDeviceStatus defines the observed state of BluetoothDevice
type BluetoothDeviceStatus struct {
// Reports the extension of device.
// +optional
Extension *DeviceExtensionStatus `json:"extension,omitempty"`

// Reports the status of the BLE device.
// +optional
Properties []StatusProperties `json:"properties,omitempty"`
Expand Down
11 changes: 2 additions & 9 deletions adaptors/ble/api/v1alpha1/extension_type.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
package v1alpha1

import "github.com/rancher/octopus/pkg/mqtt/api/v1alpha1"
import mqttapi "github.com/rancher/octopus/pkg/mqtt/api"

// DeviceExtensionSpec defines the desired state of device extension.
type DeviceExtensionSpec struct {
// Specifies the MQTT settings.
// +optional
MQTT *v1alpha1.MQTTOptionsSpec `json:"mqtt,omitempty"`
}

// DeviceExtensionStatus defines the observed state of device extension.
type DeviceExtensionStatus struct {
// Reports the MQTT settings.
// +optional
MQTT *v1alpha1.MQTTOptionsStatus `json:"mqtt,omitempty"`
MQTT *mqttapi.MQTTOptions `json:"mqtt,omitempty"`
}
29 changes: 2 additions & 27 deletions adaptors/ble/api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

294 changes: 67 additions & 227 deletions adaptors/ble/deploy/e2e/all_in_one.yaml

Large diffs are not rendered by default.

58 changes: 0 additions & 58 deletions adaptors/ble/deploy/e2e/dl-all.yaml

This file was deleted.

28 changes: 0 additions & 28 deletions adaptors/ble/deploy/e2e/dl.yaml

This file was deleted.

59 changes: 59 additions & 0 deletions adaptors/ble/deploy/e2e/dl_ble.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
apiVersion: edge.cattle.io/v1alpha1
kind: DeviceLink
metadata:
name: xiaomi-temp-rs2200
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-rs2200
spec:
parameters:
syncInterval: 15s
timeout: 10s
protocol:
name: "MJ_HT_V1"
macAddress: ""
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 is optional
dataConverter:
startIndex: 1
endIndex: 0
shiftRight: 2
orderOfOperations:
- operationType: Multiply # options are Add/Subtract/Multiply/Divide
operationValue: "0.03125"
- name: power-enabled
description: turn the device power on or off
accessMode: ReadWrite
visitor:
# characteristicUUID, dataWrite and defaultValue is required when accessMode is ReadWrite
characteristicUUID: f000aa0104514000b000000000000001
defaultValue: OFF # set the defaultValue by chosen one of option in the dataWrite
dataWrite:
ON: [1]
OFF: [0]
# dataConverter is optional
dataConverter:
startIndex: 1
endIndex: 0
shiftRight: 3
orderOfOperations:
- operationType: Multiply
operationValue: "0.03125"
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ spec:
client:
server: tcp://test.mosquitto.org:1883
message:
topic:
prefix: cattle.io/octopus
with: nn # namespace/name
# uses dynamic topic with namespaced name
topic: "cattle.io/octopus/:namespace/:name"
protocol:
name: "MJ_HT_V1"
macAddress: ""
Expand Down
Loading

0 comments on commit bb92675

Please sign in to comment.