【发布时间】:2017-12-21 16:20:41
【问题描述】:
在我的服务器上,我有 Orion 上下文代理和一个在 docker 容器中工作的 IoT 代理。我可以使用 MQTT 协议注册和更新我的实体没有问题。但我希望能够使用 IoT 代理中的命令系统向我的设备发送命令。在Documentation 中,它表示当注册命令时,IoT 代理会在 /apiKey/EntityID/cmd 中发布一些内容。但是,当我这样做时,我没有发布任何内容。实体已正确更新(我可以看到命令的状态变为 PENDING,并且正面 LOG 告诉我一切正常。但我的 MQTT 主题上没有发布任何内容。
这是我的 docker-compose.yml 文件:
version: '3.3'
services:
iot-mongo:
image: mongo:3.2
ports:
- "27017:27017"
volumes:
- ./data/mongo:/data/db
iot-agent:
image: fiware/iotagent-json
ports:
- "4041:4041"
links:
- iot-mongo
- orion
- mosquitto
volumes:
- ./config.js:/opt/iotajson/config.js
mosquitto:
image: toke/mosquitto
ports:
- "1883:1883"
- "9001:9001"
orion:
image: fiware/orion:1.9.0
links:
- iot-mongo
ports:
- "1026:1026"
command: -dbhost iot-mongo
我这样创建我的实体:
curl -X POST http://127.23.64.163:4041/iot/devices \
-i \
-H "Content-Type: application/json" \
-H "Fiware-Service: proj" \
-H "Fiware-ServicePath: /proj" \
-d ' { "devices": [
{ "device_id": "iotsensor10", "entity_name": "iotsensor10", "entity_type": "sensorping", "timezone": "America/Santiago",
"commands": [
{ "name": "ping", "type": "command", "value": ""}
],
"attributes": [
{ "object_id": "title", "name": "title", "type": "Text" },
{ "object_id": "percentage", "name": "percentage", "type": "Text" }
],
"static_attributes": [ { "name": "att_name", "type": "string", "value": "value" } ] }
]
}'
我可以使用以下命令更新我的实体:
mosquitto_pub -h 127.23.64.163 -t /1234/iotsensor10/attrs -m '{"title": "mqtttitle", "percentage": "31.5"}'
并创建一个这样的命令:
curl --request POST http://127.23.64.163:1026/v1/updateContext \
-i \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Fiware-Service: proj" \
-H "Fiware-ServicePath: /proj" \
-d ' {"updateAction": "UPDATE", "contextElements": [
{"id": "iotsensor10", "type": "sensorping", "isPattern": "false",
"attributes": [
{"name": "ping", "type": "command", "value": "ALIVE" }
]
}
]}'
我订阅了:
mosquitto_sub -h 127.23.64.163 -t /# -v
但是当我创建一个命令时,我什么也没看到。
但是,如果我运行:
mosquitto_pub -h 127.23.64.163 -t /1234/iotsensor10/cmdexe -m '{"ping": "kebab"}'
我可以验证命令并在我的实体上观察结果。我唯一的问题是,当我希望在 /apikey/sensor10/cmd 上发布某些内容时,创建命令时没有发布任何内容。知道为什么以及如何解决它吗?
更新 1
我尝试对图像 fiware/iotagent-ul 进行相同的操作,但结果完全相同。没有发布任何内容。
【问题讨论】:
标签: mqtt iot fiware mosquitto fiware-orion