WiSense gateway interface message format

In this post, I am going to explain the format of messages sent/received to/from WiSense coordinator/gateway nodes. Each instance of a WiSense network has exactly one coordinator/gateway node which is responsible for bringing up and maintaining the sensor network. It also acts as the gateway between the sensor nodes and the external world. In the simplest case, a WiSense network consists of one coordinator/gateway node connected to a PC through a USB/serial bridge and just one sensor node. Let us assume that the app layer on the sensor node samples one or more on-board sensors every 10 seconds and sends the sensor data in a message to the coordinator. The coordinator simply forwards all received application layer messages over the serial connection to the PC. The coordinator does not interpret application layer messages received from any node in the network.

The serial port configuration is 9600 bps / 8-n-1 (8 bits, no parity bit, 1 stop bit).

For each application layer message received from a WiSense sensor node, the coordinator prefixes a header whose format is given below –

  • Byte Offset       Length            Description
  • ——————————————————————————————————————————-
  • 0                               2                     Message Type (16 bit value in network byte order)
  • 1                                1                     Flags
  • 2                               1                      Message sequence number (Monotonically increasing 8 bit value)
  • 4                               2                     Message payload length field
  • 6                               2                     Header CRC (covers the previous 6 bytes)
  • 8                               2                     Payload CRC (covers the complete payload)

When the message type is  0x0006 (LPWMN_GW_MSG_TYPE_RELAY_FROM_NODE), the format of the payload is given below –

  • Byte Offset       Length          Description
  • ——————————————————————————————————————————-
  • 0                                2                   16 bit short address of the sensor node which has sent this app layer message
  • 2                                1                   RSSI (received signal strength) of the message as reported by the PHY layer on the coordinator
  • 3                                1                   Correlation factor of the message as reported by the PHY layer on the coordinator
  • 4                               N                  N byte app layer message received from sensor node.

Allowed message types are defined within the WiSense application layer. You can look up the file “gw/inc/gw.h”.

An application running on the PC can also send messages to any sensor node via the coordinator.  Such messages are sent using the message type 0x0005 (LPWMN_GW_MSG_TYPE_RELAY_TO_NODE).

Messages sent over the serial link to the coordinator/gateway node are sent in two phases. In the first phase, only the header portion (10 bytes) is sent. When the coordinator/gateway receives this header, it will use the payload length field in the header to allocate a buffer for the payload portion. If this buffer is allocated successfully, the coordinator/gateway will send an acknowledgement  to the PC. The ack message only has the header (no payload). The message type in the header will be 0x0 (UART_MSG_TYPE_ACK) and the flags field will be set to 0x81  indicating that the sender can now send the payload portion.

Note that messages sent by the coordinator/gateway to the PC are sent in one shot.

The coordinator uses the message type 0x00b0 (LPWMN_GW_MSG_TYPE_EVENT) to send network events to the application running on the PC. For example, the coordinator sends event with id 0x1 (LPWMN_GW_EVT_TYPE_NODE_REG) whenever a sensor node joins the WiSense sensor network managed by this coordinator. The event message contains the 64 bit extended address of the node (which has just joined) and the 16 bit short address allocated to this node.

You can get more info on the different message types from the WiSense gateway message specification.

Posted on February 17, 2014, in Uncategorized. Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: