Communication

Communication

For the communication, we need a bus that puzzles can connect to and be removed from.
RS485 is a robust technology for this.

Protocol

There are a lot of protocols for RS485Address, strongly focused on factories. ModBUS is one of the most well-known. It is however limited to what can be communicated. We will therefor write a small protocol ourselves.
rs485 testing

The controller has to be able to:

  • address individual puzzles
  • send commands
  • send data (solutions for the puzzle)
  • receive updates on the status

This results in this protocol.

  graph LR
    A0[Address]---C0[Command]---D0[Data]---R0[Response]
s

Bits will be sent Most-Significant-Bit first (also known als Little Endian).

Address

The address is a block of 8 bits. This allows for addressing 256 individual puzzles. The following addresses have been assigned:

Address Description
0x00 Controller
0x01 Master mind
0x02 Digital safe
0x03 Simon says
…. ….
0xFF Broadcast

Command

The command is a block of 8 bits. This allows for addressing 256 individual commands. The following command are defined:

Command Data Response Description
0x00 null <ACK> Ident
0x01 null <status> Get status
0x02 null <ACK> Set active
0x03 null <ACK> Set inactive
0x10 <data> <ACK> Set solution
0xFF null <ACK> Reset

Data

The data is a blob of 32 bits, depending on the command being send.
If no data has to be send, it will be all zeros (0x00, 0x00, 0x00, 0x00).

Response

Response Response Description
0x00 <ACK> Message acknowledged, no further action
0x01 <NACK> Message received, but not acknowledged
0x02 Solved Status: puzzle solved
0x03 Not solved Status: puzzle solved

Security (spiral)

The communication will be encrypted, since people should not be able to fake signals and get to the treasure that way. AES-128 is a standard algorythm that can be implemented in a very light way on the microcontrollers. It will contain mechanisms to prevent sniffing, replay attacks and command injection.