2017-12-21 26 views
1

제 서버에는 오리온 컨텍스트 브로커와 도킹 컨테이너에서 작업하는 IoT 에이전트가 있습니다. MQTT 프로토콜을 사용하여 엔티티를 등록하고 업데이트 할 수 있습니다. 하지만 IoT Agent에서 명령 시스템을 사용하여 장치에 명령을 보내고 싶습니다. Documentation에서 명령이 등록되면 IoT 에이전트는/apiKey/EntityID/cmd에 내용을 게시합니다. 그러나 그렇게 할 때 게시 된 내용이 없습니다. 엔티티가 올바르게 업데이트되었습니다. (명령의 상태가 PENDING으로 표시되고, 긍정적 인 LOG로 모든 것이 OK임을 알 수 있습니다.) MQTT 주제에 게시 된 내용이 없습니다.MQTT를 사용하는 iotagent-json은 명령을 보낼 때 아무 것도 게시하지 않습니다.

여기에 내 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"}' 
,691 363,210

이 같은 명령을 생성합니다

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과 같은 조작을 수행하려고하지만 동일한 결과가 있습니다. 아무것도 게시되지 않습니다.

답변

1

문제는 IoT Agent에서 장치를 만드는 방법에서 비롯됩니다. MQTT 인 전송 필드를 지정해야합니다. 그래서 나는이 같은 장치를 만들 필요가, 그것이 작동되도록하기 :

curl -X POST -H "Fiware-Service: MyService" -H "Fiware-ServicePath: /MyService" -H "Content-Type: application/json" -d '{ 
"devices": [ 
    { 
     "device_id": "iotsensor6", 
     "entity_name": "iotsensor6", 
     "entity_type": "sensorping", 
     "transport": "MQTT", 

"commands": [ { "name": "ping", "type": "command", "value": ""} ], 
     "attributes": [ 
       { "object_id": "title", "name": "title", "type": "text" }, 
       { "object_id": "percentage", "name": "percentage", "type": "text" }     
     ] 
    } 
] 
}' 'http://127.23.64.163:4041/iot/devices' 

와 내 명령을 만들 때 지금은 주제/1234/iotsensor6/cmd를

에서 만든 항목이