Skip to content

Latest commit

 

History

History
210 lines (161 loc) · 4.38 KB

pubsub.md

File metadata and controls

210 lines (161 loc) · 4.38 KB

Pubsub

N|Solid

Tài liệu mô tả format publish/subscribe cho các giao thức:

  • socket.io
  • mqtt
  • iot-core

Mọi người cần chỉnh sửa thì fork project > modify > pull request

Edit bằng vscode tabsize=2

sử dụng "Preview to the side" option
(góc trên bên phải) để preview

Tài liệu Markdown

Topic format

  • mqtt + iot-core

    ${prefix}/{object}

  • socket.io

    {object}

Topic prefix

  • iot-core

    arn:aws:iot:${AWS_REGION}:${accountArn}:topic/${provider}/${GatewayUid}

  • mqtt

    ${provider}/${GatewayUid}

  • rest

    ${host}/rest

  • socket.io

    None

payload

  • mqtt + iot-core

    JSON || Buffer

  • socket.io

    Object

  • parse
      if( data instanceof Buffer ||
          typeof data === 'string') {
        payload = JSON.parse(payload)
      }

Object: gateway event

  1. Event /devices

    • payload
    {
      "devices": [
        {"nodeId":"0x8307","deviceState":16,"deviceType":"0x0103","timeSinceLastMessage":47,"deviceEndpoint":{"eui64":"0x000B57FFFE4F4F12","endpoint":2,"clusterInfo":[{"clusterId":"0x0000","clusterType":"In"},{"clusterId":"0x0003","clusterType":"In"},{"clusterId":"0x0003","clusterType":"Out"},{"clusterId":"0x0006","clusterType":"Out"}]},"hash":"0x000B57FFFE4F4F12-2","gatewayEui":"000B57FFFE51B5A5","sleepyDevice":false,"otaUpdating":false,"otaTotalBytesSent":0,"otaUpdatePercent":0,"otaTargetImageSizeKB":0,"otaTargetFirmwareVersion":0,"supportsRelay":true,"supportedCluster":[{"clusterId":"0x0006","clusterType":"In"}]}
      ]
    }
  2. Event /heartbeat

    {
      "networkUp":true,"networkPanId":"0x43DC","radioTxPower":20,"radioChannel":14,"gatewayEui":"000B57FFFE51B5A5"
    }
  3. Event /relays

    {}
  4. Event /gatewaysettings

    {
      "ncpStackVersion":"6.5.0-188","networkUp":true,"networkPanId":"0x43DC","radioTxPower":20,"radioChannel":14
    }
  5. Event /serversettings

    {
      "ip":"10.42.0.1","otaInProgress":false,"customerTesting":false,"logStreaming":false,"cliTerminal":false,"testNumber":1
    }

Object: gateway command

  1. Device control

    • lighton/lightoff/lighttoggle

      {
        "type":"lighton", "deviceTableIndex": {}}
      }
      {
        "type":"lighton", "deviceEndpoint": {}}
      }
    • setlightlevel

      {
        "type":"setlightlevel", "deviceTableIndex": {}}
      }
      {
        "type":"setlightlevel", "deviceEndpoint": {}}
      }
    • setlightcolortemp

      {
        "type":"setlightcolortemp", "deviceTableIndex": {}}
      }
      {
        "type":"setlightcolortemp", "deviceEndpoint": {}}
      }
  2. Device add

    • permitjoinZB3OpenNetworkOnly

      {
        "type":"permitjoinZB3OpenNetworkOnly", "delayMs": "number"
      }
  3. Relay/Rule

    • addrelay/deleterelay

      {
        "type":"addrelay", "inDeviceInfo": {}, "outDeviceInfo": {}
      }
    • addcloudrule/deletecloudrule

      {
        "type":"addcloudrule", "inDeviceInfo": {}, "outDeviceInfo": {}
      }
    • clearrelays

      {
        "type":"clearrelays"
      }
    • clearcloudrules

      {
        "type":"clearcloudrules"
      }
    • servermessage: addgroup

      {
        "type":"addgroup", "group": {"devices": ["group1", "group2"]}
      }
    • servermessage: removegroup

      {
        "type":"removegroup", "groupName": "group1"
      }
  4. Gateway

    • requestgatewaystate

      {
        "type": "requestgatewaystate"
      }
    • loadgatewaylog

      {
        "type": "loadgatewaylog"
      }