A communication protocol for RemoteControllers. This enables cross-platform applications using RemoteController libraries for different programming languages.
Every RemoteController implementation should follow an api simliar to the following:
There should be a RemoteController class (or similar). This class should setup and hold everything that the RC needs. Additionally, it should hold an Instance of the Abstract-Type Connection. The abstract Connection class (or similar) provides a unified interface to receive and transmit binary payloads. The RemoteController only uses this abstract connection to receive and transmit its payloads. This allows for a large variety of different connection possibilites with the same RemoteController class and api
Example Connection Implementations:
- SPIConnection (A wired connection interface)
- RF24Connection (A radio connection using the cheap NRF24L01 modules)
- BluetoothConnection
- ...
Every RemoteController implemenation has to implement the following two data types and encode them as specified.
Commands should be the primary data type used in RemoteControllers. A command consists of (1) an enum-like instruction and (2) a throttle float (32-bit) value to go along with that instruction. E.g.: GoForward and 200.1, this would signal the other RemoteController to perform the GoForward action with a throttle of 200.1.
| Type | Structure | Recommended Type Representation | Required Encoded Type | Required Encoded Size |
|---|---|---|---|---|
| Command | Instruction | Enum | unsigned 8-bit integer | 8 bit (0-255) |
| Throttle | Float | 32-bit float | 32 bit |
As this table already suggests how exactly a Command is represented in a RemoteController implementation is not specified, it should be the most conveninet and practical representation that the programming language allows.
It is, however, crucial that the command before being transmitted is encoded in the follwing format:
When transmitting commands the first 16 bits (2 bytes) have to be the following Command Identifier bits:
0xEEAF
This makes the receiver know that the payload after these 16 identifier bits, is of Command Type. The payload following the Command Identifier consists of a binary array of 40-bit (5-byte) Commands.
A Command is encoded as follows: The first 8 bits represent the Instruction (thus 256 different instructions are possible), the following 32 bits represent a throttle value of type float, in total a command is of 40 bit or 5 byte size.
| Instruction | Throttle |
|---|---|
| 8 bits | 32 bits |
| unsigned int (0-255) | float |
Binary payloads allow the user to send and receive whatever they want, at the cost of having to deal with the binary payloads themselves. Every RemoteController implementation has to include an api to send and receive pure binary payloads.