Difference between revisions of "Serial Sensor Protocol"
(New page: '''Serial Sensor Protocol''' is a protocol for serial communications between sensors and base stations on a meshed sensor network. '''THIS IS A DRAFT''' == Terminology == * CAN and MAY b...) |
(→Command codes) |
||
Line 55: | Line 55: | ||
|- | |- | ||
| 0x20 || Get sensor status || @sensorstruct || | | 0x20 || Get sensor status || @sensorstruct || | ||
+ | |- | ||
+ | | 0xE0 || Get network neighbors || @netnodes || | ||
+ | |- | ||
+ | | 0xE1 || Get MAC address || 8 byte MAC address || | ||
+ | |- | ||
+ | | 0xE2 || Get packets sent || 4 bytes, bytes sent || | ||
+ | |- | ||
+ | | 0xE3 || Get packets received || 4 bytes, bytes recvd || | ||
|- | |- | ||
| 0xF0 || Get battery status || @status, float || | | 0xF0 || Get battery status || @status, float || | ||
|} | |} | ||
+ | |||
+ | === Command responses === | ||
+ | A command response SHOULD address the sender of the comamnd and MUST contain the same command code as was originally posted. | ||
+ | |||
+ | For example: | ||
+ | |||
+ | * Master sends: <pre>01:FF:04:00</pre> | ||
+ | ** Meaning: Request to Host 0x01 from Master, Get Logger Time Zero, no payload | ||
+ | * Host 0x01 replies: <pre>FF:01:04:04:4A:4B:58:6F | ||
+ | ** Meaning: Reply to Master from Host 0x01, Get Logger Time Zero, response: 0x4a4b586f, which in decimal is 1246451823, which is the Unix Time Stamp for Wed, 01 Jul 2009 12:37:03 GMT | ||
== Data structures == | == Data structures == |
Revision as of 12:42, 1 July 2009
Serial Sensor Protocol is a protocol for serial communications between sensors and base stations on a meshed sensor network.
THIS IS A DRAFT
Contents
Terminology
- CAN and MAY both mean that it is allowed but not required.
- SHOULD means that it generally should be a certain way but legitimate exceptions may arise; in this case care must be taken not to break compatibility with other aspects of the protocol.
- MUST means that there are no acceptable exceptions to this rule.
Negations both in the form of CAN NOT and CAN'T should be understood canonically.
Transaction block
The basic unit of communications is a transaction block, which consists of:
- Recipient ID (1 byte)
- Sender ID (1 byte)
- Command code (1 byte)
- Payload length in bytes (1 byte)
- (optional) Payload (maximum 255 bytes)
Identification codes
Each sensor MUST have an ID code. These ID codes SHOULD be unique, as ID collisions will render two sensors indistinguishable, but of course there MAY arise situations where this is beneficial; to all other extents there should be no ill effects of collisions.
ID codes 0x00 and 0xFF are reserved.
- 0x00 is a multicast address, which ALL sensors MUST respond to.
- 0xFF is the master address, which is not considered a sensor.
Sensors SHOULD in general address messages to the master unless they have specific reason not to. Sensors SHOULD never use multicast addressing.
Command codes
Code | Function | Returns | Params |
---|---|---|---|
0x00 | No operation | 0x00 | |
0x01 | Read logger memory | @memstruct | |
0x02 | Get logger memory checksum | 2 byte checksum | |
0x03 | Get logger memory entry count | 2 byte entry count | |
0x04 | Get logger time zero | @UTS | |
0x05 | Get logger current time | @UTS | |
0x10 | Clear logger memory | @status | |
0x11 | Set logger time zero | @status | @UTS |
0x12 | Set logger time offset | @status | 2 byte offset |
0x13 | Clear logger time offset | @status | |
0x20 | Get sensor status | @sensorstruct | |
0xE0 | Get network neighbors | @netnodes | |
0xE1 | Get MAC address | 8 byte MAC address | |
0xE2 | Get packets sent | 4 bytes, bytes sent | |
0xE3 | Get packets received | 4 bytes, bytes recvd | |
0xF0 | Get battery status | @status, float |
Command responses
A command response SHOULD address the sender of the comamnd and MUST contain the same command code as was originally posted.
For example:
- Master sends:
01:FF:04:00
- Meaning: Request to Host 0x01 from Master, Get Logger Time Zero, no payload
- Host 0x01 replies:
FF:01:04:04:4A:4B:58:6F