Hello,
I have this piece of wiring code that reads a data stream from lora wireless network and passes it through USB Interface:
void onLoRaReceive(int packetSize) {
if (packetSize == 0) {
indicateError();
return; // if there's no packet, return
}
byte[packetSize] buffer=[];
while (LoRa.available()) {
site_t recievedData=LoRa.readBytes(buffer,packetSize);
Serial.write(buffer,recievedData);
}
}
void indicateError(){
digitalWrite(ERROR_LED_INDICATOR,HIGH);
sleep(1000);
digitalWrite(ERROR_LED_INDICATOR,LOW);
}
My question is on how to indicate the end of the stream/packet to the usb interface? My idea is to use either EOF or '\0' character but I fear is that some LoRa Packet may have Rogue EOF or '\0' characters that may indicate prematurely the End of the serial stream.
I have also seen the arduino uno - How to indicate an End of a stream on USB - Arduino Stack Exchange without any answer.