7
Advanced Operation:
All messages are encapsulated in standard XML format. As per XML standard, It
is required that the XML version declaration be included at the start of each mes-
sage. Messages that do not conform to the standard will be ignored. In addition
to the XML version declaration, every message must also specify the type of de-
vice (model) and its unique MAC ID (mac) in its root element using the <device>
tag. For M4000-PRO, device class is “m4000” and the MAC is expressed with no
formatting. An example message would thus look like:
<?xml version=”1.0” ?><device class=”m4000” id=”1065a3030000”>…</
device>
This would be considered the “envelope” for all messages, where the “…” is to
be considered the “contents” of the message.
Example Event Message
Event message for outlet bank 3 switched ON
<?xml version=”1.0” ?>
<device class=”m4000” id=”1065a30000”>
<event time=”1403729752”>
<settings time=”1403729752”>
<outlet id=”3”>1</outlet>
</settings>
</event>
</device>
There are three types of messages: event messages, information messages and
command messages.
Event messages are sent in response to a change of device status or settings. It
should be noted that events are not sent in reply to a query.
Command messages are set to the M4000-PRO to query information, change
settings or initiate an action.
Information messages are sent from M4000-PRO in response to a query com-
mand.
Examples of the message format are provided in the table below.
Example Command Message
Command to switch outlet bank 2 OFF
<?xml version=”1.0” ?>
<device class=”m4000” id=”1065a30000”>
<command>
<outlet id=”2”>1</outlet>
</command>
</device>
Example Information Message
Snippet of the response to <sendinfo> query
<?xml version=”1.0” ?>
<device class=”m4000” id=”1065a30000”>
<info time=”1403729752”>
<sernum>12345678</sernum>
<fwver>1.0.1</fwver>
..
</info>
</device>
The following sections document the possible message content and it should be assumed that the contents are always enclosed by the “envelope” and that the “enve-
lope” text will not be repeated, unless needed for clarity.
Action and Queries
Command messages are sent to the M4000-PRO to have it perform a task. The task can be to perform a physical action such as switching an outlet bank and is referred
to as an action. When the task is to transmit data such as device status it is referred to as a query. Whether the task is an action or query, the message is classified as a
command.
General Query Element Structure
All query command messages are contained within a <command> element. The M4000-PRO responds to the query with a set of elements enclosed in the <info>,
<status> or <settings> element depending on the type of query. Every query contains a timestamp attribute “time”. The timestamp is in standard UNIX time, up to 10
decimal digit characters and represents the number of seconds that have passed since January 1st 1970 GMT.
A sample query and response:
Query
Response
<command><sendinfo/></command>
<info time=”1403729752”>
<sernum>12345678</sernum>
<fwver>1.0</fwver>
<bootcodever>1.0</bootcodever>
<ipaddr>3194548209</ipaddr>
</info>
If the command is for an action such as switching an outlet bank, the M4000-PRO will not necessarily provide a response message. If it is desired to receive an acknowl-
edgement of receiving the command, the optional “xid” attribute may be included in the <command> element. Command messages with the “xid” attribute expressed
will return an acknowledgement enclosed in an <ack> element.
For example, when the message
<?xml version=”1.0” ?><device class=”m4000” id=”1065a3030000”><command xid=”123”><outlet id=”1”>0</outlet></command></device>
Is received by the M4000-PRO, it will respond with
<?xml version=”1.0” ?><device class=”m4000” id=”1065a3030000”><ack xid=”123”></device>