rcProtocol
V.0.3.0
A protocol for diy transmitters/receivers
|
#include <rcDeviceProtocol.h>
Public Types | |
typedef void() | saveRemoteID(const uint8_t *id) |
typedef void() | loadRemoteID(uint8_t *id) |
typedef bool() | checkConnected() |
typedef void() | setConnected(bool connected) |
Public Member Functions | |
DeviceProtocol (RF24 *tranceiver, const uint8_t deviceId[]) | |
int8_t | begin (RCSettings *settings, checkConnected checkConnected, loadRemoteID loadRemoteID) |
int8_t | pair (saveRemoteID saveRemoteID) |
bool | isConnected () |
int8_t | connect (loadRemoteID loadRemoteID, setConnected setConnected) |
int8_t | update (uint16_t channels[], uint8_t telemetry[], setConnected setConnected) |
RCSettings * | getSettings () |
Communication Protocol for receivers
Definition at line 27 of file rcDeviceProtocol.h.
typedef void() DeviceProtocol::saveRemoteID(const uint8_t *id) |
Save the transmitter id to non-volitile memory.
Very simple, all that needs to be done, is to save the Id to memory, so that when the receiver tries to connect, it will know which id to request to connect with.
id | 5 byte char array |
Definition at line 38 of file rcDeviceProtocol.h.
typedef void() DeviceProtocol::loadRemoteID(uint8_t *id) |
Load the transmitter id from non-volitile memory.
Load the transmitter id set from saveRemoteID() into id
id | 5 byte array to put remote id in. |
Definition at line 46 of file rcDeviceProtocol.h.
typedef bool() DeviceProtocol::checkConnected() |
Check if the device was previously connected to the remote.
This checks the data set from setConnected(), and should be non-volitile
Definition at line 54 of file rcDeviceProtocol.h.
typedef void() DeviceProtocol::setConnected(bool connected) |
Set whether the device is connected to the remote.
connected | true if connected, false if not. |
Definition at line 63 of file rcDeviceProtocol.h.
DeviceProtocol::DeviceProtocol | ( | RF24 * | tranceiver, |
const uint8_t | deviceId[] | ||
) |
Constructor
Creates a new instance of the protocol. You create an instance and send a reference to the RF24 driver as well as the id of the remote
tranceiver | A reference to the RF24 chip, this allows you to create your own instance, allowing multi-platform support |
deviceId | The 5 byte char array of the receiver's ID: ex "MyRcr" |
Definition at line 6 of file rcDeviceProtocol.cpp.
int8_t DeviceProtocol::begin | ( | RCSettings * | settings, |
DeviceProtocol::checkConnected | checkConnected, | ||
DeviceProtocol::loadRemoteID | loadRemoteID | ||
) |
Begin the Protocol
If the system power cycled or reset while in use, it will try to reconnect immidiately.
settings | RCSettings |
checkConnected | checkConnected() |
loadRemoteID | loadRemoteID() |
Definition at line 18 of file rcDeviceProtocol.cpp.
int8_t DeviceProtocol::pair | ( | DeviceProtocol::saveRemoteID | saveRemoteID | ) |
Attempt to pair with a transmitter
saveRemoteID | A function pointer to save the id of the transmitter. |
Definition at line 58 of file rcDeviceProtocol.cpp.
bool DeviceProtocol::isConnected | ( | ) |
Check if the receiver is connected with a transmitter.
Definition at line 237 of file rcDeviceProtocol.cpp.
int8_t DeviceProtocol::connect | ( | DeviceProtocol::loadRemoteID | loadRemoteID, |
DeviceProtocol::setConnected | setConnected | ||
) |
Attempt to pair with a transmitter
loadRemoteID | loadRemoteID() |
setConnected | setConnected() |
Definition at line 116 of file rcDeviceProtocol.cpp.
int8_t DeviceProtocol::update | ( | uint16_t | channels[], |
uint8_t | telemetry[], | ||
DeviceProtocol::setConnected | setConnected | ||
) |
Update the communications with the currently connected device
If there was a packet sent, it will process it.
channels | RCSettings.setNumChannels() size array that is set when a standard packet is received. |
telemetry | RCSettings.setPayloadSize() size array of telemetry data to send to the transmitter |
setConnected | setConnected() |
Definition at line 267 of file rcDeviceProtocol.cpp.
RCSettings * DeviceProtocol::getSettings | ( | ) |
Get pointer for the current settings
Definition at line 332 of file rcDeviceProtocol.cpp.