2017-12-21 14 views
1

Auf meinem Server habe ich Orion-Kontext-Broker und einen IoT-Agenten, der in Docker-Containern arbeitet. Ich kann meine Entität registrieren und aktualisieren mit MQTT-Protokoll kein Problem. Aber ich möchte in der Lage sein, Befehl an mein Gerät mit dem Befehlssystem im IoT-Agent zu senden. In der Documentation heißt es, dass wenn ein Befehl registriert ist, der IoT-Agent etwas in/apiKey/EntityID/cmd veröffentlicht. Aber wenn ich das tue, habe ich nichts veröffentlicht. Die Entität wird ordnungsgemäß aktualisiert (ich kann den Status des Befehls zu PENDING sehen, und positives LOG sagt mir, dass alles in Ordnung ist. Aber nichts ist in meinem MQTT-Thema veröffentlicht.iotagent-json, das MQTT verwendet, das nichts veröffentlicht, wenn Befehl gesendet wird

Hier ist meine docker-compose.yml-Datei :

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 

ich meine Einheit wie folgt zu erstellen:

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" } ] } 
     ] 
    }' 

ich meine Einheit mit dem folgenden Befehl aktualisieren:

mosquitto_pub -h 127.23.64.163 -t /1234/iotsensor10/attrs -m '{"title": "mqtttitle", "percentage": "31.5"}' 

und einen Befehl wie diesen erstellen:

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" } 
    ] 
    } 
]}' 

und ich subscribe mit:

mosquitto_sub -h 127.23.64.163 -t /# -v 

Aber ich sehe nichts kommt, wenn ich einen Befehl erstellen.

Allerdings, wenn ich laufe:

mosquitto_pub -h 127.23.64.163 -t /1234/iotsensor10/cmdexe -m '{"ping": "kebab"}' 

kann ich den Befehl bestätigen und das Ergebnis auf meiner Einheit sehen. Das einzige Problem, das ich habe, ist, dass nichts veröffentlicht wird, wenn der Befehl erstellt wird, wenn ich erwarte, dass etwas auf/apikey/sensor10/cmd veröffentlicht wird. Irgendeine Idee warum und wie man es repariert?

Update 1

Ich habe versucht, die gleichen Manipulationen mit dem Bild fiware/iotagent-ul aber ich habe genau das gleiche Ergebnis zu tun. Nichts ist veröffentlicht.

Antwort

1

Das Problem kommt davon, wie ich mein Gerät auf meinem IoT Agent erstelle. Ich muss das Transportfeld angeben, das MQTT ist. So, damit es funktioniert, ich habe ein Gerät wie diese erstellen:

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' 

und jetzt, wenn ich meinen Befehl zu erstellen, habe ich den erstellten Eintrag in dem Thema/1234/iotsensor6/cmd

Verwandte Themen