获取模版
请在examples/mqttDeviceShifu查看模板文件。
批改配置
在examples/mqttDeviceShifu/mqtt_deploy/mqtt_edgedevice.yaml
中:
...spec: sku: "testMQTT" # 批改此值 connection: Ethernet address: 192.168.62.231:1883 # 批改此值 protocol: MQTT protocolSettings: MQTTSetting:
在examples/mqttDeviceShifu/mqtt_deploy/mqtt_deviceshifu_configmap.yaml
中:
...data: driverProperties: | driverSku: testMQTT driverImage: instructions: | instructions: # 一条命令能够订阅一个topic,如需订阅多个topic,减少命令即可 get_topicmsg1: # 批改此值 protocolPropertyList: MQTTTopic: "/test/test1" # 批改此值 get_topicmsg2: protocolPropertyList: MQTTTopic: "/test/test2" ... # 依据本人的须要可持续配置命令及对应的Topic,只需依照此格局持续增加即可
部署deviceShifu
运行上面的命令:
kubectl apply -f examples/mqttDeviceShifu/mqtt_deploy
获取设施最新的MQTT音讯
在您的集群中运行上面的命令:
curl deviceshifu-mqtt/get_topicmsg1
这里get_topicmsg1
是须要查问的字段。
MQTTdeviceShifu返回的内容如下:
{"mqtt_message":"test2333","mqtt_receive_timestamp":"2022-04-29 08:57:49.9492744 +0000 UTC m=+75.407609501"}
其中mqtt_message
是设施承受到的最新字符串。mqtt_receive_timestamp
是接管到该音讯的工夫戳。
通过deviceShifu公布MQTT音讯
在您的集群中运行上面的命令:
curl -X POST -d 'test_publish' deviceshifu-mqtt/get_topicmsg1
这里get_topicmsg1
是须要查问或公布的字段。
公布之后,再次查问MQTTdeviceShifu返回的内容如下:
{"mqtt_message":"test_publish","mqtt_receive_timestamp":"2022-04-29 08:57:59.7397692 +0000 UTC m=+75.407609501"}
本文由边无际受权公布