36 lines
706 B
C++
36 lines
706 B
C++
#include "QDPASR.h"
|
|
|
|
|
|
void QDPASR::begin(Stream& stream){
|
|
_serial = &stream;
|
|
}
|
|
|
|
void QDPASR::ReceiveData(){
|
|
if (_serial->available() > 0) {
|
|
ReceiveByte = _serial->read();
|
|
if (ReceiveByte == ',') {
|
|
ReceiveString = _serial->readStringUntil('.');
|
|
if(ReceiveString.length()>=14)
|
|
ReceiveString = ReceiveString.substring(0,14);
|
|
// Serial.println(ReceiveString);
|
|
}
|
|
}
|
|
}
|
|
|
|
void QDPASR::SendData(String Data){
|
|
_serial->write(',');
|
|
_serial->print(Data);
|
|
_serial->write('.');
|
|
}
|
|
|
|
bool QDPASR::CompareData(String Data){
|
|
if(Data.length()>=14)
|
|
Data = Data.substring(0,14);
|
|
if( ReceiveString == Data){
|
|
ReceiveString = "";
|
|
return true;
|
|
}
|
|
else{
|
|
return false;
|
|
}
|
|
} |