Using Following codes for TX and RX. Communication doesn’t seem to work.
If someone can suggest troubleshooting tips or snags in the code.
LoRa Freq is adjusted accordingly for Australia.
TX:
void send_cb(void) {
// Optional: leave empty
}
void recv_cb(rui_lora_p2p_recv_t data) {
// Not used for sending
}
void setup() {
Serial.begin(115200);
delay(2000);
api.lora.nwm.set(); // Set to P2P mode
api.lora.pfreq.set(921000000); // Match receiver frequency
api.lora.psf.set(12); // Spreading Factor
api.lora.pbw.set(125); // Bandwidth
api.lora.pcr.set(0); // Coding Rate
api.lora.ppl.set(8); // Preamble Length
api.lora.ptp.set(22); // TX Power (max)
api.lora.registerPSendCallback(send_cb);
api.lora.registerPRecvCallback(recv_cb); // Optional
delay(1000); // Small delay before first transmission
}
void loop() {
uint8_t payload[] = "Hello";
api.lora.psend(sizeof(payload), payload);
delay(3000); // Send every 5 seconds (adjust as needed)
}
RX:
void recv_cb(rui_lora_p2p_recv_t data) {
Serial.println("Data received");
}
void setup() {
Serial.begin(115200);
delay(2000);
api.lora.nwm.set(); // P2P mode
api.lora.pfreq.set(921000000); // Australia frequency
api.lora.psf.set(12); // Spreading Factor
api.lora.pbw.set(125); // Bandwidth
api.lora.pcr.set(0); // Coding Rate
api.lora.ppl.set(8); // Preamble Length
api.lora.ptp.set(22); // TX power (not used)
api.lora.registerPRecvCallback(recv_cb);
api.lora.precv(65533); // Permanent RX with TX allowed
}
void loop() {
// RX is handled by callback
}
Appreciate the help.