rcProtocol  V.0.3.0
A protocol for diy transmitters/receivers
rcGlobal.h
Go to the documentation of this file.
1 #ifndef __RCGLOBAL_H__
2 #define __RCGLOBAL_H__
3 
4 #include <RF24.h>
5 
6 #include "rcSettings.h"
7 
8 //Global User defined constants
9 
10 #ifndef RC_TIMEOUT
11 #define RC_TIMEOUT 15000
12 #endif
13 
14 #ifndef RC_CONNECT_TIMEOUT
15 #define RC_CONNECT_TIMEOUT 2500
16 #endif
17 
18 //Global Error Constants
19 
23 #define RC_ERROR_LOST_CONNECTION -11
24 
27 #define RC_ERROR_TIMEOUT -12
28 
31 #define RC_ERROR_BAD_DATA -13
32 
35 #define RC_ERROR_CONNECTION_REFUSED -14
36 
39 #define RC_ERROR_NOT_CONNECTED -21
40 
43 #define RC_ERROR_ALREADY_CONNECTED -22
44 
54 class RCGlobal {
55 protected:
56 
57  RCGlobal();
58 
59  const uint8_t _PAIR_ADDRESS[5] = {'P', 'a', 'i', 'r', '0'};//Pair0: 0x50 61 69 72 30
60  const uint8_t _DISCONNECT[5] = {255, 255, 255, 255, 255};
61  const uint8_t _ACK = 0x06;
62  const uint8_t _NACK = 0x15;
63  const uint8_t _TEST = 0x02;
64 
65  const uint8_t _PACKET_CHANNELS = 0xA0;
66  const uint8_t _PACKET_UPDATE_TRANS_SETTINGS = 0xB1;//TODO: Implement
67  const uint8_t _PACKET_UPDATE_RECVR_SETTINGS = 0xB2;//TODO: Implement
68  const uint8_t _PACKET_DISCONNECT = 0xC0;
69  const uint8_t _PACKET_RECONNECT = 0xCA;
70 
73 
74  RF24* _radio;
75 
86  int8_t force_send(void* buf, uint8_t size, unsigned long timeout);
92  int8_t wait_till_available(unsigned long timeout);
93 
99  void apply_settings(RCSettings* settings);
100 
104  void flush_buffer();
105 };
106 
107 #endif
const uint8_t _PACKET_UPDATE_TRANS_SETTINGS
Definition: rcGlobal.h:66
const uint8_t _PAIR_ADDRESS[5]
Definition: rcGlobal.h:59
const uint8_t _PACKET_CHANNELS
Definition: rcGlobal.h:65
const uint8_t _TEST
Definition: rcGlobal.h:63
RF24 * _radio
Definition: rcGlobal.h:74
void apply_settings(RCSettings *settings)
Definition: rcGlobal.cpp:40
const uint8_t _ACK
Definition: rcGlobal.h:61
RCGlobal()
Definition: rcGlobal.cpp:3
void flush_buffer()
Definition: rcGlobal.cpp:65
const uint8_t _PACKET_DISCONNECT
Definition: rcGlobal.h:68
int8_t wait_till_available(unsigned long timeout)
Definition: rcGlobal.cpp:28
RCSettings _pairSettings
Definition: rcGlobal.h:72
int8_t force_send(void *buf, uint8_t size, unsigned long timeout)
Definition: rcGlobal.cpp:15
RCSettings _settings
Definition: rcGlobal.h:71
const uint8_t _DISCONNECT[5]
Definition: rcGlobal.h:60
const uint8_t _PACKET_UPDATE_RECVR_SETTINGS
Definition: rcGlobal.h:67
const uint8_t _NACK
Definition: rcGlobal.h:62
const uint8_t _PACKET_RECONNECT
Definition: rcGlobal.h:69