2018-10-31 18:57:21 +00:00
|
|
|
#include <Arduino.h>
|
2018-11-06 09:43:54 +00:00
|
|
|
#include "UtilClasses.h"
|
2018-10-31 18:57:21 +00:00
|
|
|
|
|
|
|
class CProtocol;
|
|
|
|
|
|
|
|
extern void Command_Interpret(const char* pLine); // decodes received command lines, implemented in main .ino file!
|
|
|
|
|
|
|
|
|
|
|
|
class CBluetoothAbstract {
|
|
|
|
protected:
|
|
|
|
sRxLine _rxLine;
|
2018-11-06 09:43:54 +00:00
|
|
|
CContextTimeStamp _timeStamp;
|
2018-10-31 18:57:21 +00:00
|
|
|
public:
|
|
|
|
virtual void init() {};
|
2018-11-06 09:43:54 +00:00
|
|
|
virtual void setRefTime() {
|
|
|
|
_timeStamp.setRefTime();
|
|
|
|
};
|
2018-10-31 18:57:21 +00:00
|
|
|
virtual void sendFrame(const char* pHdr, const CProtocol& Frame, bool lineterm=true) {
|
2018-11-06 09:43:54 +00:00
|
|
|
_timeStamp.report(pHdr);
|
2018-10-31 18:57:21 +00:00
|
|
|
DebugReportFrame(pHdr, Frame, lineterm ? "\r\n" : " ");
|
|
|
|
};
|
|
|
|
virtual void check() {};
|
|
|
|
virtual void collectRxData(char rxVal) {
|
2018-11-06 09:43:54 +00:00
|
|
|
// provide common behviour for bytes received from a bluetooth client
|
2018-10-31 18:57:21 +00:00
|
|
|
if(isControl(rxVal)) { // "End of Line"
|
|
|
|
Command_Interpret(_rxLine.Line);
|
|
|
|
_rxLine.clear();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
_rxLine.append(rxVal); // append new char to our Rx buffer
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|