Difference between revisions of "Connectivity/Agent Communication Protocol in MQTT"

From ESS-WIKI
Jump to: navigation, search
(Auto Update Sensor Data Value)
(Get Sensor Data)
Line 142: Line 142:
  
 
==Get Sensor Data==
 
==Get Sensor Data==
Description: Server can send mqtt message to get sensor data value.
+
*Description: Server can send mqtt message to get sensor data value.
Type: Request
+
*Type: Request
Direction: Server -> Agent
+
*Direction: Server -> Agent
Topic: /cagent/admin/<devID>/agentcallbackreq
+
*Topic: /cagent/admin/<devID>/agentcallbackreq
QoS: 0
+
*QoS: 0
Retained: 0
+
*Retained: 0
Payload:
+
*Payload:
 
  {   
 
  {   
 
   "susiCommData":{   
 
   "susiCommData":{   
Line 190: Line 190:
 
   }
 
   }
 
  }
 
  }
 +
 
==Set Sensor Data==
 
==Set Sensor Data==

Revision as of 05:13, 18 August 2016

Overview

Introduction for "WISEAgent communication protocol". WISEAgent communication protocol is base on standard MQTT protocol. We also define Advantech IoT Topic and message in JSON format. Follow standard to design our [Sensor Format in JSON ]

Protocol

Connect

  • Description: Agent Client sends the "Connect Info" to Server for on-line notification.
  • Type: Info
  • Direction: Agent -> Server
  • Topic: /cagent/admin/<devID>/agentinfoack
  • QoS: 2
  • Retained: 0
  • Payload:
{
  "susiCommData": {
    	"devID":"0017000E40000001",
    	"hostname":"AAA",
    	"sn":"0017000E40000001",
    	"mac":"0017000E40000001",
    	"version":"3.1.23",
    	"type":"SenHub",
    	"product":"WISE-1020",
    	"manufacture":"",
    	"status":"1",
    	"commCmd":1,
    	"requestID":30002,
    	"agentID":"0017000E40000001",
    	"handlerName":"general",
    	"sendTS":160081026
   }
}

Disconnect

  • Description: Agent Client sends the "Disconnect Info" to Server for off-line notification.
  • Type: Info
  • Direction: Agent -> Server
  • Topic: /cagent/admin/<devID>/agentinfoack
  • QoS: 2
  • Retained: 0
  • Payload:
{
  "susiCommData": {
    	"devID":"0017000E40000001",
    	"hostname":"AAA",
    	"sn":"0017000E40000001",
    	"mac":"0017000E40000001",
    	"version":"3.1.23",
    	"type":"SenHub",
    	"product":"WISE-1020",
    	"manufacture":"",
    	"status":"0",
    	"commCmd":1,
    	"requestID":30002,
    	"agentID":"0017000E40000001",
    	"handlerName":"general",
    	"sendTS":160081026
   }
}

Send or Auto Update Device's Capability

  • Description: Agent will send it's capability to Server for description all resource.
  • Type: Auto update
  • Direction: Agent-> Server
  • Topic: /cagent/admin/<devID>/agentactionreq
  • QoS: 0
  • Retained: 0
  • Payload:
{
  "susiCommData":{
    "infoSpec": {
        "SenHub": {
            "SenData": {"e":[ {"n":"Temperature","u":"Cel","v":0.000000,"min":-100.000000,"max":200.000000,"asm":"r","type":"d","rt":"ucum.Cel","st":"ipso","exten":""},
                              {"n":"Humidity","u":"%","v":0.000000,"min":0.000000,"max":100.000000,"asm":"r","type":"d","rt":"ucum.%","st":"ipso","exten":""},
                              {"n":"GPIO1","u":"","bv":0,"min":0.000000,"max":1.000000,"asm":"r","type":"b","rt":"","st":"ipso","exten":""},
                              {"n":"GPIO2","u":"","bv":0,"min":0.000000,"max":1.000000,"asm":"r","type":"b","rt":"","st":"ipso","exten":""}
                            ],
            "bn":"SenData"
            },
            "Info": {"e":[{"n":"Name","sv":"SenHub1","asm":"rw"},
                          {"n":"sw","sv":"1.0.00","asm":"r"}
                         ],
            "bn":"Info"
           },
           "Net": {"e":[{"n":"sw","sv":"1.0.00","asm":"r"},
                        {"n":"Neighbor","sv":"","asm":"r"},
                        {"n":"Health","v":"100.000000","asm":"r"}
                       ],
            "bn":"Net"
           }
       }
   },
   "commCmd":2052,
   "requestID":2001,
   "agentID":"0017000E40000001",
   "handlerName":"general",
   "sendTS":160081024
  }
}

Auto Update Sensor Data Value

  • Description: Agent will update latest value to server.
  • Type: Auto update
  • Direction: Agent-> Server
  • Topic: /cagent/admin/<devID>/deviceinfo
  • QoS: 0
  • Retained: 0
  • Payload:
{  
  "susiCommData":{  
     "data":{  
        "SenHub":{  
           "SenData":{  
              "e":[  
                 {  
                    "n":"Temperature",
                    "v":1
                 },
                 {  
                    "n":"Humidity",
                    "v":57
                 },
                 {  
                    "n":"GPIO1",
                    "bv":0
                 },
                 {  
                    "n":"GPIO2",
                    "bv":0
                 }
              ],
              "bn":"SenData"
           },
           "ver":1
        }
     },
     "commCmd":2055,
     "requestID":2001,
     "agentID":"0017000E40000001",
     "handlerName":"general",
     "sendTS":160081031
  }
}

Get Sensor Data

  • Description: Server can send mqtt message to get sensor data value.
  • Type: Request
  • Direction: Server -> Agent
  • Topic: /cagent/admin/<devID>/agentcallbackreq
  • QoS: 0
  • Retained: 0
  • Payload:
{  
  "susiCommData":{  
     "sessionID":"2746E3B65BAB115338B9668CDC5C35C4",
     "sensorIDList":{  
        "e":[  
           {  
              "n":"SenHub/Info/sw"
           }
        ]
     },
     "commCmd":523,
     "requestID":0,
     "agentID":"",
     "handlerName":"SenHub",
     "sendTS":1466057267
  }
}
Description: Agent will reply its data value.
Type: Reply
Direction: Agent -> Server
Topic: /cagent/admin/<devID>/agentactionreq
QoS: 0
Retained: 0
Payload:
{  
  "susiCommData":{  
     "commCmd":524,
     "handlerName":"SenHub",
     "sessionID":"2746E3B65BAB115338B9668CDC5C35C4",
     "sensorInfoList":{  
        "e":[  
           {  
              "n":"/Info/sw",
              "sv":"1.0.00",
              "StatusCode":200
           }
        ]
     }
  }
}

Set Sensor Data