Update comments and debugs

This commit is contained in:
Jeff Lehman 2024-06-16 22:39:12 -05:00
parent 1e64654eeb
commit 71a5d67e2d
2 changed files with 14 additions and 9 deletions

View File

@ -245,7 +245,7 @@ void transmitLoRa(uint16_t *destMac, DataReading *packet, uint8_t len)
transmitFlag = true;
if (state != RADIOLIB_ERR_NONE)
{
DBG("Xmit failed, code " + String(state));
DBG("Xmit failed, code " + String(state) + " program halted.");
while (true)
;
}
@ -293,7 +293,7 @@ void transmitLoRa(uint16_t *destMac, SystemPacket *packet, uint8_t len)
transmitFlag = true;
if (state != RADIOLIB_ERR_NONE)
{
DBG("Xmit failed, code " + String(state));
DBG("Xmit failed, code " + String(state) + " program halted.");
while (true)
;
}
@ -373,7 +373,7 @@ void begin_lora()
}
else
{
DBG("RadioLib initialization failed, code " + String(state));
DBG("RadioLib initialization failed, code " + String(state) + " program halted.");
while (true)
;
}
@ -392,7 +392,7 @@ void begin_lora()
state = radio.startReceive(); // start listening for LoRa packets
if (state != RADIOLIB_ERR_NONE)
{
DBG(" failed, code " + String(state));
DBG(" failed, code " + String(state) + " program halted.");
while (true)
;
}
@ -552,7 +552,7 @@ crcResult receiveLoRa()
// for Node - need to listen to broadcast
if (destMAC == (selfAddress[4] << 8 | selfAddress[5]) || (destMAC == 0xFFFF))
#endif
{ // Check if addressed to this device or broadcast
{
// printLoraPacket(packet,sizeof(packet));
DBG1("Incoming LoRa. Size: " + String(packetSize) + " Bytes, RSSI: " + String(radio.getRSSI()) + "dBm, SNR: " + String(radio.getSNR()) + "dB, PacketCRC: 0x" + String(packetCRC, HEX));
// Evaluate CRC
@ -567,12 +567,12 @@ crcResult receiveLoRa()
if (calcCRC == packetCRC)
{ // We've received a DR and sending an ACK
SystemPacket ACK = {.cmd = cmd_ack, .param = CRC_OK};
DBG1("CRC Match, sending ACK packet to node 0x" + String(sourceMAC, HEX) + "(hex)");
DBG1("CRC Match, sending ACK packet to node 0x" + String(sourceMAC, HEX));
transmitLoRaAsync(&sourceMAC, &ACK, 1); // Send ACK back to source
}
else if (packetCRC == crc16_update(calcCRC, 0xA1))
{ // Sender does not want ACK and CRC is valid
DBG1("Node address 0x" + String(sourceMAC, 16) + " does not want ACK");
DBG1("CRC Match, node address 0x" + String(sourceMAC, 16) + " does not want ACK");
}
else
{ // We've received a DR and CRC is bad
@ -654,7 +654,7 @@ crcResult receiveLoRa()
else
{ // data we have received is not yet programmed. How we handle is future enhancement.
DBG2("Received some LoRa SystemPacket data that is not yet handled. To be handled in future enhancement.");
DBG2("ln: " + String(ln) + "data type: " + String(receiveData[0].cmd));
DBG2("ln: " + String(ln) + " data type: " + String(receiveData[0].cmd + " param: " + String(receiveData[0].param)));
}
rxCountCrcOk++;
return CRC_OK;

View File

@ -189,11 +189,13 @@ bool sendFDRS()
if (esp_now_ack_flag == CRC_OK)
{
data_count = 0;
DBG1("FDRS Packet sent successfully!");
return true;
}
else
{
data_count = 0;
DBG1("FDRS Packet send failed!");
return false;
}
#endif // USE_ESPNOW
@ -204,17 +206,20 @@ bool sendFDRS()
#ifdef LORA_ACK
if(crcReturned == CRC_OK) {
data_count = 0;
DBG1("FDRS Packet sent successfully!");
return true;
}
#endif // LORA_ACK
#ifndef LORA_ACK
if(crcReturned == CRC_OK || crcReturned == CRC_NULL) {
data_count = 0;
return true;
DBG1("FDRS Packet sent successfully!");
return true;
}
#endif // !LORA_ACK
else {
data_count = 0;
DBG1("FDRS Packet send failed!");
return false;
}
#endif // USE_LORA