WISE-PaaS/2.0 Protocol

From ESS-WIKI
Jump to: navigation, search

Overview

Introduction for "EI-Agent to WISE-PaaS-2.0 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 ]    EI-Agent Protocol


Protocol

Connect

  • Description: Agent Client sends the "Connect Info" to WISE-PaaS-2.0 Server for on-line notification.
  • Type: Info
  • Direction: Agent -> Server
  • Topic: /wisepaas/device/00000001-0000-0000-0000-001077C25002/agentinfoack
  • QoS: 0
  • Retained: 0
  • Payload:
{
    "content": {
        "parentID": "00000001-0000-0000-8888-0034115521a4",
        "hostname": "ESL-Tag-5002",
        "sn": "0000001077C25002",
        "mac": "0000001077C25002",
        "version": "1.0.7.252316989",
        "type": "SenHub",
        "product": "ESL-Tag",
        "manufacture": "",
        "account": "",
        "passwd": "",
        "status": 1,
        "tag": "ESL"
    },
    "commCmd": 1,
    "agentID": "00000001-0000-0000-0000-001077C25002",
    "handlerName": "SenHub",
    "sendTS": {
        "$date": 1513232002117
    }
}

OS Info

  • Description: Agent Client sends the OS Info" to RMM Server for device OS information.
  • Type: Info
  • Direction: Agent -> Server
  • Topic: /wisepaas/RMM/00000001-0000-0000-0000-999BAB6F4000/agentactionack
  • QoS: 0
  • Retained: 0
  • Payload:
{
    "content": {
        "cagentVersion": "1.0.6.0",
        "cagentType": "IPC",
        "osVersion": "Windows Embedded Standard",
        "biosVersion": "V1.10",
        "platformName": "ARK-DS762",
        "processorName": "Intel(R) Core(TM) i7-3610QE CPU @ 2.30GHz",
        "osArch": "X64",
        "totalPhysMemKB": 1973544,
        "macs": "00:0B:AB:6F:37:52",
        "IP": "172.22.12.84"
    },
    "commCmd": 116,
    "agentID": "00000001-0000-0000-0000-999BAB6F4000",
    "handlerName": "general",
    "sendTS": {
        "$date": 1510044371812
    }
}

 

Disconnect

  • Description: Agent Client sends the "Disconnect Info" to Server for off-line notification.
  • Type: Info
  • Direction: Agent -> Server
  • Topic: /wisepaas/device/00000001-0000-0000-0000-001077C25002/agentinfoack
  • QoS: 0
  • Retained: 0
  • Payload:
{
    "content": {
        "parentID": "00000001-0000-0000-8888-0034115521a4",
        "hostname": "ESL-Tag-5002",
        "sn": "0000001077C25002",
        "mac": "0000001077C25002",
        "version": "1.0.7.252316989",
        "type": "SenHub",
        "product": "ESL-Tag",
        "manufacture": "",
        "account": "",
        "passwd": "",
        "status": 0,
        "tag": "ESL"
    },
    "commCmd": 1,
    "agentID": "00000001-0000-0000-0000-001077C25002",
    "handlerName": "SenHub",
    "sendTS": {
        "$date": 1513232002117
    }
}

Will Message

  • Description: While Client lost connection or keep-alive timeout, the will message will send to the client that subscribe the topic
  • Type: Info
  • Direction: Agent -> Broker
  • Topic: /wisepaas/device/00000001-0000-0000-0000-999BAB6F4000/willmessage
  • QoS: 0
  • Retained: 0
  • Payload:
{
    "content": {
        "parentID": "",
        "hostname": "chihyu-PC",
        "sn": "000BAB578433",
        "mac": "000BAB6F3752",
        "version": "1.0.6.0",
        "type": "IPC",
        "product": "",
        "manufacture": "",
        "account": "",
        "passwd": "",
        "status": 0,
        "tag": "RMM"
    },
    "commCmd": 1,
    "agentID": "00000001-0000-0000-0000-999BAB6F4000",
    "handlerName": "general",
    "sendTS": {
        "$date": 1510044370561
    }
}

Info or Update Device's Capability

  • Description: Agent will send it's capability to Server for description all resource.
  • Type: Auto update
  • Direction: Agent-> Server
  • Topic: /wisepaas/RMM/00000001-0000-0000-0000-999BAB6F4000/agentactionack
  • QoS: 0
  • Retained: 0
  • Payload: 

Example: HDD PMQ Capability

{
    "content": {
        "HDD_PMQ": {
            "info": {
                "bn": "info",
                "e": [{"n": "type","sv": "PMQ","asm": "r"},{"n": "name","sv": "HDD_PMQ","asm": "r"},{"n": "description","sv": "This service is HDD PMQ Service","asm": "r"},
                      {"n": "version","sv": "1.0.2","asm": "r"},{"n": "confidence level","v": 83.12,"asm": "r","u": "%"},{"n": "update","sv": null,"asm": "rw"},
                      {"n": "eventNotify","bv": true,"asm": "r"}]
            },
            "action": {
                "bn": "action",
                "e": [{"n": "a1","bv": false,"asm": "r","msg": "Lower system temperature ( < 40 Celsius )."},{"n": "a2","bv": false,"asm": "r","msg": "Backup data to new disk."},
                      {"n": "a3","bv": false,"asm": "r","msg": "Check power source."},{"n": "ActionLog","sv": null,"asm": "r"}]
            },
            "param": {
                "bn": "param",
                "e": [{"n": "report interval","v": 60,"max": 3600,"min": 10,"asm": "rw","u": "sec"},{"n": "enable report","bv": true,"asm": "rw"}]
            },
            "opTS": {
                "$date": 1510044371815
            }
        }
    },
    "commCmd": 2052,
    "agentID": "00000001-0000-0000-0000-999BAB6F4000",
    "handlerName": "general",
    "sendTS": {
        "$date": 1510044371815
    }
}

Auto Update Data Value

  • Description: Agent will update latest value to server.
  • Type: Auto update
  • Direction: Agent-> Server
  • Topic: /wisepaas/device/00000001-0000-0000-0000-999BAB6F4000/devinfoack
  • QoS: 0
  • Retained: 0
  • Payload:
{
    "content": {
        "HDD_PMQ": {
            "info": {
                "bn": "info",
                "e": [{"n": "version","sv": "1.0.2"},{"n": "confidence level","v": 89.6,"asm": "r","u": "%"}]
            },
            "param": {
                "bn": "param",
                "e": [{"n": "report interval","v": 30},{"n": "enable report","bv": true}]
            },
            "opTS": {
                "$date": 1510044371815
            }
        }
    },
    "commCmd": 2055,
    "agentID": "00000001-0000-0000-0000-999BAB6F4000",
    "handlerName": "general",
    "sendTS": {
        "$date": 1510044371815
    }
}

Get Sensor Data

  • Description: Server can send mqtt message to get sensor data value.
  • Type: Request
  • Direction: Server -> Agent
  • Topic: /wisepaas/RMM/00000001-0000-0000-0000-000babbb7ef3/agentactionreq
  • QoS: 0
  • Retained: 0
  • Payload:
{
    "agentId": "00000001-0000-0000-0000-000babbb7ef3",
    "handlerName": "custom",
    "commCmd": 523,
    "content": {
        "sessionID": "2A1FBCA22A64C2E27341DB5FA7E83FBF",
        "sensorIDList": {
            "e": [{"n": "custom/custom_data2"}]
        }
    }
}
  • Description: Agent will reply its data value.
  • Type: Reply
  • Direction: Agent -> Server
  • Topic: /wisepaas/RMM/00000001-0000-0000-0000-000babbb7ef3/agentactionack
  • QoS: 0
  • Retained: 0
  • Payload:
{
    "agentID": "00000001-0000-0000-0000-000babbb7ef3",
    "commCmd": 524,
    "handlerName": "custom",
    "content": {
        "sessionID": "2A1FBCA22A64C2E27341DB5FA7E83FBF",
        "sensorInfoList": {
            "e": [{"n": "custom/custom_data2","v": 123,"StatusCode": 200}]
        }
    },
    "sendTS": {"$date": 1499328934471}
}


Set Data

  • Description: Server can send mqtt message to set sensor data value.
  • Type: Request
  • Direction: Server -> Agent
  • Topic:/wisepaas/RMM/00000001-0000-0000-0000-000babbb7ef3/agentactionreq
  • QoS: 0
  • Retained: 0
  • Payload:
{
    "agentId": "00000001-0000-0000-0000-000babbb7ef3",
    "handlerName": "custom",
    "commCmd": 525,
    "content": {
        "sessionID": "B303E3DE2C062B8C148DAEF2D3F6C723",
        "sensorIDList": {
            "e": [{"v": 12,"n": "custom/custom_data2"}]
        }
    }
}
  • Description: Agent will reply its result. There are have two status 1. status code: 202 -> device receive this command, 2. code: 200 -> succesful to set, code: is not 200 => Fail to set
  • Type: Reply
  • Direction: Agent -> Server
  • Topic: /wisepaas/RMM/00000001-0000-0000-0000-000babbb7ef3/agentactionack
  • QoS: 0
  • Retained: 0
  • Payload:

Accept 1:

{
    "agentID": "00000001-0000-0000-0000-000babbb7ef3",
    "commCmd": 526,
    "handlerName": "custom",
    "content": {
        "sessionID": "B303E3DE2C062B8C148DAEF2D3F6C723",
        "sensorInfoList":{
            "e": [
                {
                    "n": "custom/custom_data2",
                    "sv": "Accept",
                    "StatusCode": 202
                }
            ]
        },
    },
    "sendTS": {"$date": 1499329284038}
}

Success:

{
    "agentID": "00000001-0000-0000-0000-000babbb7ef3",
    "commCmd": 526,
    "handlerName": "custom",
    "content": {
        "sessionID": "B303E3DE2C062B8C148DAEF2D3F6C723",
        "sensorInfoList":{
            "e": [
                {
                    "n": "custom/custom_data2",
                    "sv": "Success",
                    "StatusCode": 200
                }
            ]
        },
    },
    "sendTS": {"$date": 1499329284038}
}

Event Notify

Description: Agent send event notify to Server Type: Auto Report Direction: Server -> Agent Topic:/wisepaas/RMM/00000001-0000-0000-0000-000babbb7ef3/eventnotify QoS: 0 Retained: 0

{
  "commCmd":2059,
  "agentID":"00000001-0000-0000-0000-305A3A77B1DA",
  "handlerName":"general",
  "content":{
    "eventnotify":{
      "subtype":"ACTION_TRIGGER_INFO",
      "msg":"Action "00000001-0000-0000-0000-305A3A77B1DA/SUSIControl/Hardware Monitor/GPIO/DI0" triggered by 00000001-0000-0000-0000-305A3A77B1DA/HDDMonitor/hddSmartInfoList/Disk0/TotalLBAsWritten/value:1",
      "extMsg": {
        "rules":[
          {
            "n": "00000001-0000-0000-0000-305A3A77B1DA/HDDMonitor/hddSmartInfoList/Disk0/TotalLBAsWritten/value",
            "v":1,
            "action":"00000001-0000-0000-0000-305A3A77B1DA/SUSIControl/Hardware Monitor/GPIO/DI0",
            "param":true,
            "status":"trigger"
          }
        ]
      }
    },
    "opTS":{"$date":1494308768000}
  },
  "sendTS":{"$date":1522457629328}
}