NOTE: This document supercedes the original spec, which has been archived here.
The following page is based on requested CSE switch modifications to provide remote command-and-control. The key idea is that Azure IoT Hub (direct command/response via Eventhub). This means:
From the switch's perspective, the agent is required to connect to the MQTT broker and subscribe to an MQTT topic with a given SSL client certificate. As the agent receives commands, it processes them and them publishes its response on a topic. The payload is in JSON format based on the command parameters.
For example, on the switch with MAC 00:de:ad:be:ef:01, the switch should:
iot-poc)iot-poc.azure-devices.net/dmp-oodeadbeef01/?api-version=2021-04-12 and the provided SSL client certificate$iothub/methods/POST/#,123), and$iothub/methods/res/200/?$rid=123.Ultimately the switch will need to have the following configuration options available to be set to connect to this system:
Commands will vary in their specific options, but generally they will be in JSON format and look something like this:
{
"cmd": "poe_enable_set",
"port": 1,
"enabled": 0
}
NOTE: This is just an example, the source code for the client will be the ultimate guide.
The response will be either a simple acknowledgement in JSON or an info dump, as in a call to sys_info_get:
{
"cmd": "sys_info_get",
"system_name": "8P-MA-POE-V2",
"mac_address": "38:73:EA:AA:87:4E",
"firmware_version": "2.03.xx",
"uptime": 12345
}
NOTE: Again, this is a general example and not normative.
To help jumpstart development, a number of resources are available to speed both implementation and testing:
mac/command, parse incoming JSON commands, and dispatch to functions based on the cmd item. It's README.md documents in markdown the various commands it supports and their parameters, acting as API documentation.