-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathReceive.ino
More file actions
47 lines (43 loc) · 1.68 KB
/
Copy pathReceive.ino
File metadata and controls
47 lines (43 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//============================================================================
// Process a received LoRa packet.
// This function will run if a packet has been received
// You should create your own actions here.
// Be sure to check if a correct packet was received!
//============================================================================
void ProcessRXPacket() {
// Buffer to hold the received data from the radio
byte buf[PACKETLEN];
int16_t state;
// EXAMPLE OF RX ACTION
toSerialConsole("============================================\n");
toSerialConsole("PACKET RECEIVED!\n");
toSerialConsole("============================================\n");
// Grab the data from the radio module
switch (LORA_MODE) {
case 1: // Implicit header, so tell the radio how many bytes to read
state = radio.readData(buf, LoRaSettings.implicitHeader);
break;
default:
state = radio.readData(buf, 0);
break;
}
// Packet was successfully received
if (state == RADIOLIB_ERR_NONE) {
toSerialConsole("Packet length: ");
toSerialConsole(radio.getPacketLength());toSerialConsole("\n");
toSerialConsole(" RSSI: ");
toSerialConsole(radio.getRSSI());toSerialConsole("\n");
toSerialConsole(" SNR: ");
toSerialConsole(radio.getSNR());toSerialConsole("\n");
toSerialConsole("First 10 chars: ");
// Print the first 10 hex chars of the packet
toSerialConsole("[RADIO] first 10 hex chars:\t");
for (int i = 0; i < 10; i++) {
toSerialConsole(buf[i], HEX);
toSerialConsole(" ");
}
toSerialConsole("\n============================================\n");
}
// Reset the received flag
receivedFlag = false;
}