rcProtocol  V.0.3.0
A protocol for diy transmitters/receivers
rcRemoteProtocol.h
Go to the documentation of this file.
1 /*
2  rcRemoteProtocol.h - Library for Remote for RCProtocol.
3  Created by Benjamin Jacobs, October 1, 2017
4 */
5 
6 #ifndef __RCREMOTEPROTOCOL_H__
7 #define __RCREMOTEPROTOCOL_H__
8 
9 #include <RF24.h>
10 
11 #include "rcSettings.h"
12 #include "rcGlobal.h"
13 
14 #ifndef __RF24_H__
15 #error "rcRemoteProtocol Requires the tmrh20 RF24 Library: https://github.com/nRF24/RF24"
16 #endif
17 
18 
19 //Userdefined Constants
20 //Global constants can be found in rcGlobal.h
21 
22 
23 //Error constants
24 //Global constants can be found in rcGlobal.h
25 
29 #define RC_ERROR_PACKET_NOT_SENT -22
30 
33 #define RC_INFO_TICK_TOO_SHORT 21
34 
35 
40 public:
50  typedef void (saveSettings)(const uint8_t* id, const uint8_t* settings);
72  typedef bool (checkIfValid)(const uint8_t* id, uint8_t* settings);
83  typedef void (getLastConnection)(uint8_t* id);
89  typedef void (setLastConnection)(const uint8_t* id);
90 
101  RemoteProtocol(RF24* tranceiver, const uint8_t remoteId[]);
102 
121 
135 
153 
159  bool isConnected();
160 
181  int8_t update(uint16_t channels[], uint8_t telemetry[] = NULL);
182 
194 
201 
202 private:
203 
204  const uint8_t* _remoteId;
205  uint8_t _deviceId[5];
206 
207  //update variables
208  bool _isConnected;
209  uint32_t _timer;
210  uint16_t _timerDelay;
211 
227  int8_t send_packet(void* data, uint8_t dataSize, void* telemetry = NULL,
228  uint8_t telemetrySize = 0);
229 
230 };
231 
232 #endif
int8_t update(uint16_t channels[], uint8_t telemetry[]=NULL)
RemoteProtocol(RF24 *tranceiver, const uint8_t remoteId[])
int8_t disconnect(setLastConnection setLastConnection)
void() getLastConnection(uint8_t *id)
void() saveSettings(const uint8_t *id, const uint8_t *settings)
void() setLastConnection(const uint8_t *id)
int8_t pair(saveSettings saveSettings)
int8_t begin(getLastConnection getLastConnection, checkIfValid checkIfValid)
bool() checkIfValid(const uint8_t *id, uint8_t *settings)
RCSettings * getSettings()
int8_t connect(checkIfValid checkIfValid, setLastConnection setLastConnection)