The goal was to design a lightweight communication protocol so that the server can receive data from the microcontrollers (and their associated sensors). The protocol should handle test cases such as dummy data (for testing purposes) and checking if the server is ready.
WOMSCP works on top of TCP. Since the communication prioritizes data integrity over data transmission rates TCP was chosen over UDP.
Each sensor will have a unique ID (1 byte) within the domain of a microcontroller. All the microcontrollers will each have a global ID of 2 bytes. That way the receiver can tell which sensor the data is coming from. A single byte is reserved for the type of the sensor.
A WOMSCPv1 request data packet will be 10 bytes long.
- 1 byte for versioning (since v1, we leave this as v=0x01)
- 2 bytes for microcontrollerID (mID)
- 1 byte for sensor ID (sID)
- 1 byte for sensor type (t)
- 4 bytes for sensor data
- 1 byte for flags (f), for more details see Minutiae
- SRVR_RDY = 1
- DUMMY = 1 >> 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| v | mID |sID| t | data | f |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1 2 1 1 4 1
Sensor with sID=0x05 on microcontroller mID=0x000d sends data=123=0x0000007b. The sensor has type t=0x03. The request is a normal request, so no flags are set.
The WOMSCPv1 request data packet will look like this: 0x 01 000d 05 03 0000007b 00
- Maximum concurrent microcontrollers = 2^16
- Maximum sensors per microcontroller = 2^8 - 1 (see Minutiae)
- Maximum sensor types supported = 2^8
- Maximum value that data can be = 2^32
- Maximum flags supported = 4
- SRVR_RDY flag signals a special kind of request, asking if server is ready to handle requests
- DUMMY flag signals that the data is for debugging purposes only
A WOMSCPv1 response data packet will be 2 bytes long.
- 1 byte for versioning (since v1, we leave this as v=0x01)
- 1 byte for response (r), for more details see Minutiae
- SRVR_OK = 0
- SRVR_NOT_RDY = 1
- SRVR_VERSION = 2
- SRVR_UNREC = 3
- SRVR_TCP = 4
- SRVR_DB_ERR = 5
+-+-+-+-+
| v | r |
+-+-+-+-+
1 1
Consider the response to the request from the previous example to be positive/
The WOMSCPv1 response data packet will look like this: 0x 01 01
Maximum responses supported = 2^8
- SRVR_OK signals that the server finished processing the request successfully
- SRVR_NOT_RDY signals that the server is not ready to handle incoming requests
- SRVR_VERSION signals that there is a version mismatch between the server’s and microcontroller’s implementation of the WOMSCP
- SRVR_UNREC signals that the identification of the microcontroller and/or sensor does not match the entry in the server’s database
- SRVR_TCP signals a problem with the TCP connection
- SERVER_DB signals that there was an error writing the data to the database
cargo build --release
cargo test
The unit tests can be found in src/tests.rs
.