The following page is based on requested CSE switch modifications to provide remote command-and-control. The key idea is that there are two levels to how things get connected:
Connectivity-wise, this looks like the following:
From the switch's perspective, the agent is required to connect to the MQTT broker and subscribe to an MQTT topic based on the MAC address of the switch in the form of mac/command. As the agent receives commands, it processes them and them publishes its response on a topic of the form mac/response. 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:
00:de:ad:be:ef:01/command,00:de:ad:be:ef:01/response.As an architecture stack, this looks like the following:
Ultimately the switch will need to have the following configuration options available to be set to connect to this system:
Note that all IPs *may* be either IPv4 *or* IPv6.
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.