简体   繁体   English

我无法通过 Orion 将 Southbound 命令正确读取到 MQTT 设备

[英]I cannot properly read Southbound commands through Orion to MQTT devices

I am trying to send commands in the Southbound direction following this flow:我正在尝试按照以下流程向南行方向发送命令:

在此处输入图像描述

The commands supported by the devices are provisioned as follows:设备支持的命令规定如下:

    "services": [
        {
            "apikey": "5jggokgpepnvsb2uv4s40d59ov",
            "cbroker":     "'"http://orion:$ORION_PORT"'",
            "entity_type": "Agv",
            "transport": "MQTT",
            "resource": "",
            "commands": [
                {
                    "object_id": "AGV_Alarm",
                    "name": "AGV_Alarm",
                    "type": "command",
                    "value": {
                        "data": "metadata_for_AGV_Alarm"
                    }
                },
                {
                    "object_id": "AGV_Event",
                    "name": "AGV_Event",
                    "type": "command",
                    "value": {
                        "data": "metadata_for_AGV_Event"
                    }
                }
            ],

The request to send the command in the Southbound direction is made through the Orion Context Broker:向南方向发送命令的请求是通过 Orion Context Broker 发出的:

curl -iX PATCH \
  'http://orion:1026/v2/entities/urn:ngsi-ld:Agv:001/attrs' \
  -H 'Content-Type: application/json' \
  -H 'fiware-service: openiot' \
  -H 'fiware-servicepath: /' \
  -d '{
  "AGV_Event": {
      "type" : "command",
      "value": "152"
  }
}'

To simulate actuators the following tool is used which is listening for commands via MQTT:为了模拟执行器,使用了以下工具,它通过 MQTT 侦听命令:

docker run -it --rm --name mqtt-subscriber --network fiware_default efrecon/mqtt-client sub -h mosquitto -t "/5jggokgpepnvsb2uv4s40d59ov/agv001/cmd"

I can receive only a part of the payload of the command:我只能收到命令的一部分有效负载:

ubuntu@ip-172-31-85-246:~/FiwareDockerDevMode$ docker run -it --rm --name mqtt-subscriber --network fiware_default efrecon/mqtt-client sub -h mosquitto -t "/5jggokgpepnvsb2uv4s40d59ov/agv001/cmd"
{"AGV_Event":""}
{"AGV_Event":""}
{"AGV_Event":""}

In the temporary MongoDB, the command status appears as PENDING在临时MongoDB中,命令状态显示为PENDING

AGV_Event_status: {
            type: 'commandStatus',
            creDate: 1669583822.6813245,
            modDate: 1669584130.4993052,
            value: 'PENDING',
            mdNames: [
                'TimeInstant'
            ],
            md: {
                TimeInstant: {
                    type: 'DateTime',
                    value: 1669584130.495
                }
            }
        },
        AGV_Event_info: {
            type: 'commandResult',
            creDate: 1669583822.6813245,
            modDate: 1669583822.6813245,
            value: ' ',
            mdNames: []
        },

Update更新

If, on the other hand, I send the command according to the structure it has in MongoDB:另一方面,如果我根据 MongoDB 中的结构发送命令:

curl -iX PATCH \
  'http://orion:1026/v2/entities/urn:ngsi-ld:Agv:001/attrs' \
  -H 'Content-Type: application/json' \
  -H 'fiware-service: openiot' \
  -H 'fiware-servicepath: /' \
  -d '{
    "AGV_Event_info": {
    "type": "commandResult",
    "value": "200"
    },
   "AGV_Event_status": {
    "type": "commandStatus",
    "value": "OK"
   }
  }'

Now, nothing is received in the actuator simulator:现在,执行器模拟器没有收到任何信息:

ubuntu@ip-172-31-85-246:~/FiwareDockerDevMode$ docker run -it --rm --name mqtt-subscriber --network fiware_default efrecon/mqtt-client sub -h mosquitto -t "/5jggokgpepnvsb2uv4s40d59ov/agv001/cmd"

However, the temporary MongoDB is updated properly:但是,临时 MongoDB 已正确更新:

        AGV_Event_status: {
            type: 'commandStatus',
            creDate: 1669731581.9883916,
            modDate: 1669733857.6557434,
            value: 'OK',
            mdNames: []
        },
        AGV_Event_info: {
            type: 'commandResult',
            creDate: 1669731581.9883916,
            modDate: 1669733857.6557305,
            value: '200',
            mdNames: []
        },

The official documentation of the IoTAgent-JSON suggests that when commands are sent in the Southbound direction the actuator will send a response, which would make sense considering that my actuators are dummies. IoTAgent-JSON的官方文档表明,当向南方向发送命令时,执行器将发送响应,考虑到我的执行器是假人,这是有道理的。

Any suggestions on how to receive all the information sent through the Orion Context Broker?关于如何接收通过 Orion Context Broker 发送的所有信息的任何建议?

It looks like the command is incorrectly provisioned.看起来命令配置不正确。 For testing, try something like name only:对于测试,请尝试仅使用name之类的东西:

"commands": [
        { "name": "ring", "type": "command" }
],

For each command rather than adding object_id or value .对于每个命令而不是添加object_idvalue

object_id is only required if there is a different naming convention between the Context Broker data model and the MQTT topic.只有在 Context Broker 数据 model 和 MQTT 主题之间存在不同的命名约定时,才需要object_id

The PATCH for XXX_status and XXX_info is not relevant here. XXX_statusXXX_info的 PATCH 与此处无关。 This request is made by the.这个请求是由。 IoT Agent itself once it receives an cmdExe topic from MQTT. IoT 代理本身一旦从 MQTT 接收到cmdExe主题。 Since the MQTT transport is asynchronous, the status will remain at PENDING unless the device (or a dummy topic on MQTT) has explicitly returned a status update.由于 MQTT 传输是异步的,除非设备(或 MQTT 上的虚拟主题)明确返回状态更新,否则状态将保持在PENDING

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM