9 for(uint8_t i = 0; i < 5; i++) {
33 _radio->openWritingPipe(
id);
34 _radio->openReadingPipe(1, _deviceId);
45 for(uint8_t i = 0; i < 5; i++) {
68 _radio->setPALevel(RF24_PA_LOW);
94 _radio->openWritingPipe(radioId);
100 sent =
_radio->write(const_cast<uint8_t*>(_deviceId), 5);
122 uint8_t connectSuccess = 0;
130 _isConnected =
false;
132 _radio->setPALevel(RF24_PA_LOW);
136 _radio->openWritingPipe(remoteId);
137 _radio->openReadingPipe(1, _deviceId);
156 _radio->read(&connectSuccess, 1);
161 if(connectSuccess ==
_NACK) {
163 }
else if(connectSuccess !=
_ACK) {
169 _radio->setPALevel(RF24_PA_HIGH);
230 for(uint8_t i = 0; i < 5; i++) {
231 _remoteId[i] = remoteId[i];
241 int8_t DeviceProtocol::check_packet(
void* returnData, uint8_t dataSize,
242 void* telemetry, uint8_t telemetrySize) {
249 if(
_radio->available(&pipe)) {
250 _radio->read(returnData, dataSize);
254 _radio->writeAckPayload(pipe, telemetry, telemetrySize);
263 int8_t DeviceProtocol::check_packet(
void* returnData, uint8_t dataSize) {
264 return check_packet(returnData, dataSize, NULL, 0);
275 int8_t packetStatus = 0;
279 packetStatus = check_packet(packet,
285 while(packetStatus == 1) {
295 channels[i] = ((packet[i * 2 + 1] << 8)) | (packet[i * 2 + 2]);
303 _radio->write(const_cast<uint8_t*>(&
_ACK), 1);
307 _isConnected =
false;
315 _radio->write(const_cast<uint8_t*>(&
_ACK), 1);
321 packetStatus = check_packet(packet,
325 if(packetStatus < 0) {
326 status = packetStatus;
DeviceProtocol(RF24 *tranceiver, const uint8_t deviceId[])
#define RC_CONNECT_TIMEOUT
int8_t connect(loadRemoteID loadRemoteID, setConnected setConnected)
#define RC_ERROR_BAD_DATA
const uint8_t _PAIR_ADDRESS[5]
const uint8_t _PACKET_CHANNELS
void apply_settings(RCSettings *settings)
void setSettings(const uint8_t *settings)
int8_t pair(saveRemoteID saveRemoteID)
void() setConnected(bool connected)
const uint8_t _PACKET_DISCONNECT
int8_t wait_till_available(unsigned long timeout)
void() loadRemoteID(uint8_t *id)
#define RC_ERROR_LOST_CONNECTION
RCSettings * getSettings()
int8_t update(uint16_t channels[], uint8_t telemetry[], setConnected setConnected)
uint8_t getCommsFrequency()
void() saveRemoteID(const uint8_t *id)
int8_t force_send(void *buf, uint8_t size, unsigned long timeout)
#define RC_ERROR_ALREADY_CONNECTED
#define RC_ERROR_NOT_CONNECTED
int8_t begin(RCSettings *settings, checkConnected checkConnected, loadRemoteID loadRemoteID)
bool getEnableAckPayload()
#define RC_ERROR_CONNECTION_REFUSED
const uint8_t _PACKET_RECONNECT