This post will describe the main functionality.
The entire library is a basic wrapper for a class. This single class has both transmitting and receiving logic inside of it through the use of different member functions.
The TX Side:
The data structure that holds all data that can be sent to the receiver is an array of 16-bit integers. This array is called "outgoingArray" and has a fixed length of 20. In order to send any of the values in this array, a few things must happen:
1.) Identify which index in the array corresponds to the value to be sent. Insert the new value into the array at that index. Repeat for all values the user desires to send in the next packet.
For instance, on my plane, I might want to constantly send 3 data values: elevator servo angle, aileron servo angle, and rudder servo angle. In order to keep track of which value corresponds to which servo angle, I make a convention. I might say elevator servo angle is always stored in outgoingArray[0], aileron servo angle is always stored in outgoingArray[1], and rudder servo angle is always stored in outgoingArray[2].
Note that "outgoingArray" is a public array and is accessed directly.
2.) Create a boolean array with 20 elements (the size of "outgoingArray" - defined by DATA_LEN). At each index, insert a "True" if you want to send the 16-bit value in the "outgoingArray" at the same index - false where the 16-bit value should not be sent.
For instance, if I only want to send the aileron servo angle for the next transition, I would make the following array:
bool outputMask[] = {False};
outputMask[2] = {True}; //aileron data is at index 2 in outgoingArray, all other indices are false and so that no other data will be sent except the aileron data
3.) Pass that array to "sendData()" and watch the desired values show up on the receiving Arduino.
The RX Side:
1.) Periodically call "getData()" to poll the serial buffer and see if data is present for parsing. If data is present, one of 5 reports will be returned, 0 if no data was present. Here is the list of error returns:
//incoming serial data/parsing errors
#define NO_DATA 0
#define SERIAL_BUFF_ERROR -1
#define END_BYTE_ERROR -2
#define CHECKSUM_ERROR -3
#define TIMEOUT_ERROR -4
#define PAYLOAD_ERROR -5
If data was successfully parsed, the function "getData()" will return a 1.
2.) If data was successfully parsed, data in "incomingArray" has been updated. It is up to the user to figure out which indices were changed. It is also up to the user to define which index corresponds to which type of data value - BUT it must remain consistent with which index corresponds to which type of data value in "outgoingArray".
For instance, if the aileron servo angle to be transmitted is always stored in outgoingArray[1], then the aileron servo angle that was received must always stored in incomingArray[1].
Note that "incomingArray" is also a public array and is accessed directly.