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 
10  inline char readVal(char oF = '.');
18  inline bool checkOverflow(void);
23  template <typename T>
24  inline void writeVal(const T& val);
25 
37  inline bool isConnected(void);
39  inline bool checkOverflow(void) {
40  #if (EBOARD_BLUETOOTH > 0x0) && (((PIN_BLUETOOTH_RX==0x13) && (PIN_BLUETOOTH_TX==0x12)) && defined(__AVR_ATmega2560__))
41  return false; //there is no hardware provided control for hardwareserial overflow
42  #else
43  return (_serial.overflow());
44  #endif
45  }
46  inline char readVal(char oF) {
47  #if (EBOARD_BLUETOOTH > 0x0) && (((PIN_BLUETOOTH_RX==0x13) && (PIN_BLUETOOTH_TX==0x12)) && defined(__AVR_ATmega2560__))
48  return ((Serial1.available())?(Serial1.read()):(oF));
49  #else
50  return ((_serial.available())?(_serial.read()):(oF));
51  #endif
52  }
53  template<typename T>
54  inline void writeVal(const T& val){
55  #if (EBOARD_BLUETOOTH > 0x0) && (((PIN_BLUETOOTH_RX==0x13) && (PIN_BLUETOOTH_TX==0x12)) && defined(__AVR_ATmega2560__))
56  Serial1.write(val);
57  #else
58  _serial.write(val);
59  #endif
60  }
61  inline bool isConnected(void) {
62  #if PIN_BLUETOOTH_RX != PIN_BLUETOOTH_STATE
63  return digitalRead(PIN_BLUETOOTH_STATE);
64  #else
65  return true;
66  #endif
67  }
69 #endif
SoftwareSerial _serial(0x13, 0x12)
this is the recomenned-to-use _serial object for bluetooth communcation :D
char readVal(char oF='.')
[BLUETOOTH] reads a single value from bluetooth if available!
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:388