7. PlainTalk Protocol

7.1. Command format

Nodes talk to each other and to the gateway using PlainTalk, a custom protocol designed to be human readable. You can interact with NodeWire by connecting a zigbee module to a computer and then using a terminal software to send commands and receive responses. You can also directly connect a node’s serial i/o to your computer’s usb port through a uart-usb cable. Each command is sent as a separate line in the following format:

NODE Command parameters sender

where NODE is the name of the node the command is meant for and sender is the sender of the command or the node that should receive the response.

For example,

node02 set 4 1 remote

Sends the value ‘1’ to port 4 of node02.

7.2. How autodiscovery and autolayout works

When a node is first switched on, it announces its presence by repeatedly sending a command to the gateway to identify itself. The nodename for the gateway is cp.

cp ThisIs node02

The gateway responses by sending,

node02 ack cp

This switches the NODE into normal mode and stops the annunciation.

You can test your setup by connecting to the cloud-based command processor (cp) over telnet as follows:

$ telnet 10001

once you have established a connection to the cp, you can directly type PlainTalk commands and receive responses interactively. To determine to nodes that are currently registered by the gateway you can send:

cp getnodes 7wttxiyzahvf:remote

Note that when connecting over telnet, the first time we send a command, we have to use the full address format, i.e. instance:nodename. Feel free to use any other sender name other than ‘remote’. Just be consistent if you want to be able to receive all responses that are meant for you.

Nodes are characterized by the number and nature of ports they are equipped with. NodeWire supports auto-configuration and nodes must be able to provide details about their ports when queried. In order to determine the available ports on a node we send:

node02 get ports remote

This will return a list of port names depending on the nature of the node. To determine the nature of any particular port we send:

node02 get properties 2 remote

where ‘2’ is the port name

We can set the value of a port by sending

node02 set 2 0 remote

this sets the value of port ‘2’ of node02 to 0. We can determine the value of a port by,

node02 get 2 remote

this queries the value of port ‘2’