eBoard ①⑧⑨
Written for SIA 2017/2018
eagle_Bluetooth.h
Go to the documentation of this file.
1 #ifndef EAGLE_EBOARD_HELPLIB_BLUETOOTH
2  #define EAGLE_EBOARD_HELPLIB_BLUETOOTH
3 
12 //=====================================================================================================================================================
13 // bluetooth
14 //=====================================================================================================================================================
15 
16  //-------------------------------------------------------------------------------------------------------------------------------------------------
17  // read1
18  //-------------------------------------------------------------------------------------------------------------------------------------------------
19 
27  inline char readVal(char oF = '.');
28 
29  //-------------------------------------------------------------------------------------------------------------------------------------------------
30  // overflow
31  //-------------------------------------------------------------------------------------------------------------------------------------------------
32 
40  inline bool checkOverflow(void);
41 
42  //-------------------------------------------------------------------------------------------------------------------------------------------------
43  // send1
44  //-------------------------------------------------------------------------------------------------------------------------------------------------
45 
50  template <typename T>
51  inline void writeVal(const T& val);
52 
53  //-------------------------------------------------------------------------------------------------------------------------------------------------
54  // connected
55  //-------------------------------------------------------------------------------------------------------------------------------------------------
56 
68  inline bool isConnected(void);
69 
71  inline bool checkOverflow(void) {
72  #if (EBOARD_BLUETOOTH > 0x0) && (((PIN_BLUETOOTH_RX==0x13) && (PIN_BLUETOOTH_TX==0x12)) && defined(__AVR_ATmega2560__))
73  return false; //there is no hardware provided control for hardwareserial overflow
74  #else
75  return (_serial.overflow());
76  #endif
77  }
78  inline char readVal(char oF) {
79  #if (EBOARD_BLUETOOTH > 0x0) && (((PIN_BLUETOOTH_RX==0x13) && (PIN_BLUETOOTH_TX==0x12)) && defined(__AVR_ATmega2560__))
80  return ((Serial1.available())?(Serial1.read()):(oF));
81  #else
82  return ((_serial.available())?(_serial.read()):(oF));
83  #endif
84  }
85  template<typename T>
86  inline void writeVal(const T& val){
87  #if (EBOARD_BLUETOOTH > 0x0) && (((PIN_BLUETOOTH_RX==0x13) && (PIN_BLUETOOTH_TX==0x12)) && defined(__AVR_ATmega2560__))
88  Serial1.write(val);
89  #else
90  _serial.write(val);
91  #endif
92  }
93  inline bool isConnected(void) {
94  #if PIN_BLUETOOTH_RX != PIN_BLUETOOTH_STATE
95  return digitalRead(PIN_BLUETOOTH_STATE);
96  #else
97  return true;
98  #endif
99  }
101 #endif
char readVal(char oF='.')
[BLUETOOTH] reads a single value from bluetooth if available!
SoftwareSerial _serial
this is the recomenned-to-use _serial object for bluetooth communcation :D
Definition: eBoard.h:625
bool isConnected(void)
[BLUETOOTH] this will check if the HC-05 is paired
bool checkOverflow(void)
[BLUETOOTH] checks if theres a lack of Data!
void writeVal(const T &val)
[BLUETOOTH] writes Data to bluetooth
#define PIN_BLUETOOTH_STATE
Definition: eBoard.h:533