BayEOS-Arduino  1.8.0_0.0.4
BayXBee.h
1 
10 #ifndef BayXBee_h
11 #define BayXBee_h
12 
13 #define ENABLE_RX 1
14 
15 #define XBeeError_Timeout 0x2
16 #define XBeeError_NoSuccess 0x1
17 
18 #ifndef BayEOS_MAX_PAYLOAD
19 #define BayEOS_MAX_PAYLOAD 100
20 #endif
21 
22 #ifndef BAYXBEE_GATEWAY
23 #define BAYXBEE_GATEWAY 0x1
24 #endif
25 
26 #include "XBee.h"
27 #include "../BayEOS/BayEOS.h"
28 #include <inttypes.h>
29 #include <WString.h>
30 
31 
32 class BayXBeeInterface : public XBeeInterface, public BayEOS{
33 public:
43  BayXBeeInterface(uint8_t sleep_pin=0, uint8_t wakeup_time=15, int wait_time_for_response=5000,uint16_t dest=BAYXBEE_GATEWAY);
44 
48  uint8_t sendPayload(void);
49 
50  int available(void){
51  return 0; //Note this is a dummy to make BayXBee to compile!
52  }
53 
54 
55 
56 #if ENABLE_RX
57  uint8_t readIntoPayload(int timeout=5000);
58 #endif
59 
63  void begin(long baud);
64 
65  virtual void i_begin(long baud) = 0;
66 
67 
68 private:
69  Tx16Request _tx;
70  TxStatusResponse _txStatus;
71  uint8_t _sleepPin;
72  uint8_t _wakeupTime;
73  int _waitTimeForResponse;
74  uint16_t _destination;
75 #if ENABLE_RX
76  Rx16Response _rx;
77 #endif
78 };
79 
80 class BayXBee: public BayXBeeInterface {
81 private:
82  HardwareSerial* _serial;
83 
84 public:
85  BayXBee(HardwareSerial& serial, uint8_t sleep_pin=0, uint8_t wakeup_time=15, int wait_time_for_response=5000,uint16_t dest=BAYXBEE_GATEWAY):
86  BayXBeeInterface(sleep_pin,wakeup_time,wait_time_for_response,dest)
87  {
88  _serial = &serial;
89  }
90 
91  void setSerial(HardwareSerial &serial){
92  _serial = &serial;
93  }
94 
95  int i_available(void){
96  return _serial->available();
97  }
98  void i_begin(long baud){
99  _serial->begin(baud);
100  }
101  void flush(void){
102  _serial->flush();
103  }
104  int read(void){
105  return _serial->read();
106  }
107  size_t write(uint8_t c){
108  return _serial->write(c);
109  }
110 
111 
112 
113 };
114 
115 /*
116  * Get PANID of XBee
117  */
118 /*uint16_t getPANID(XBee &xbee);
119 uint8_t parseRX16(BayEOS &client, XBee &xbee,int rx_panid);
120 */
121 #endif
122 
123 
int available(void)
Definition: BayXBee.h:50
uint8_t sendPayload(void)
Definition: BayXBee.cpp:28
BayXBeeInterface(uint8_t sleep_pin=0, uint8_t wakeup_time=15, int wait_time_for_response=5000, uint16_t dest=BAYXBEE_GATEWAY)
Definition: BayXBee.cpp:3
void begin(long baud)
Definition: BayXBee.cpp:13
uint8_t readIntoPayload(int timeout=5000)
Definition: BayXBee.cpp:56
Definition: BayEOS.h:160