arduino-LoRa
arduino-LoRa copied to clipboard
Is there a way tu purpesfully ignore packets?
Hi, is there a way to ignore packets comming in that isn't intended for the receiving device? To pick a example:
void onReceive(int packetSize) {
if (packetSize == 0) return; // if there's no packet, return
// read packet header bytes:
int recipient = LoRa.read(); // recipient address
byte sender = LoRa.read(); // sender address
byte incomingMsgId = LoRa.read(); // incoming msg ID
byte incomingLength = LoRa.read(); // incoming msg length
String incoming = "";
while (LoRa.available()) {
incoming += (char)LoRa.read();
}
if (incomingLength != incoming.length()) { // check length for error
Serial.println("error: message length does not match length");
return; // skip rest of function
}
// if the recipient isn't this device or broadcast,
if (recipient != localAddress && recipient != 0xFF) {
Serial.println("This message is not for me.");
return; // skip rest of function
}
Is there a way to skip the
while (LoRa.available()) {
incoming += (char)LoRa.read();
}
and not waste the computational time if the recipient isn't the receiving device (recipient != local address)?
To put a byte in front of the message to store node id. Only process if the id is matched.