Hello..
I'm using a Lora node to node communication and everything works. Now i have added a code in receiver to send acknowledgement to sender.
In return the transmitter sends it a transmission delay value. And at that point i want the communication to stop.
For this i want to check the LoRa packet if it starts with "Time:....."
But it gives error: LoRaData was not declared in this scope..
#include <SPI.h>
#include <LoRa.h>
#define ss 10
#define rst 9
#define dio0 2
void setup() {
Serial.begin(9600);
while (!Serial);
Serial.println("LoRa Receiver");
LoRa.setPins(ss, rst, dio0);
while (!LoRa.begin(866E6)){
Serial.println(".");
delay(500);
}
Serial.println("tocheck");
//
// if (!LoRa.begin(866E6)) {
// Serial.println("Starting LoRa failed!");
// while (1);
// }
}
void loop() {
int packetSize = LoRa.parsePacket();
if (packetSize){
Serial.println("Received packet ");
while (LoRa.available()){
String LoRaData = LoRa.readString();
Serial.println(LoRaData);
}
if (LoRaData.startsWith("Time")){
Serial.println("Finished");
}
else {
Serial.println("' with RSSI ");
Serial.println(LoRa.packetRssi());
LoRa.beginPacket();
LoRa.print("received");
Serial.println("sent acknowledgement");
LoRa.endPacket();
}
}
}
Any ideas how to fix it?