Hi friends,
I wrote codes for simple a gateway and a node. gateway send a message to node. but after 5 or 6 times send and receive, the node is hanging and not receive from gateway.
I attach the codes below:
sender:
Receiver
#include <SPI.h>
#include <LoRa.h>
String inString = “”;
String outgoing; // outgoing message
long lastSendTime = 0; // last send time
int interval = 10000; // interval between sends
void setup() {
Serial.begin(9600);
while (!Serial);
Serial.println(“LoRa node”);
if (!LoRa.begin(433E6)){
Serial.println(“Starting LoRa failed!”);
while (1);
}
// register the receive callback
LoRa.onReceive(onReceive);
// put the radio into receive mode
LoRa.receive();
}
void loop() {
onReceive(LoRa.parsePacket());
}
void onReceive(int packetSize) {
if (packetSize == 0) return; // if there’s no packet, return
String incoming = “”;
while (LoRa.available()) {
incoming += (char)LoRa.read();
}
Serial.print("Message: " + incoming);
}
result is not permanent. gateway send 4 or 5 time to node but after that node can’t receive anything.!!! I tried many changes in my code but at first lets discuss about this simple one. please help me. thanks.