timmbogner / Farm-Data-Relay-System

A system that uses ESP-NOW, LoRa, and other protocols to transport sensor data in remote areas without relying on WiFi.
MIT License
485 stars 108 forks source link

#54 Packet Confirmation - LoRa ACK and CRC #76

Closed aviateur17 closed 1 year ago

aviateur17 commented 1 year ago

Code submission per discussion #54

timmbogner commented 1 year ago

I think I resolved the conflicts correctly. That's probably my mistake for merging another PR a bit ago.

aviateur17 commented 1 year ago

Better than me. I'm just getting the hang of all this git stuff. Should have another improvement on CRC soon.

aviateur17 commented 1 year ago

Just added commit to enhance LoRa packet validation. Instead of sending fixed CRC when sensor does not want an ACK the sensor will add a known byte to the CRC calculation in the case that it does not want the ACK and therefore including the CRC with the data. The gateway will check the CRC without that known byte and if there is mismatch then add that known byte to the CRC calculation and if that matches will assume that the sensor does not want an ACK. If that still does not match then the packet is not valid and will be discarded by the gateway. That way the CRC is still calculated for packets where the sensor does not want a return ACK reply.

timmbogner commented 1 year ago

Just added commit to enhance LoRa packet validation. Instead of sending fixed CRC when sensor does not want an ACK the sensor will add a known byte to the CRC calculation in the case that it does not want the ACK and therefore including the CRC with the data. The gateway will check the CRC without that known byte and if there is mismatch then add that known byte to the CRC calculation and if that matches will assume that the sensor does not want an ACK. If that still does not match then the packet is not valid and will be discarded by the gateway. That way the CRC is still calculated for packets where the sensor does not want a return ACK reply.

I see the conundrum here and that's a clever way to fix it.

aviateur17 commented 1 year ago

There might be a code issue with #endif between the two fdrs_functions.h files, one in the root and one in the FDRS_Gateway folder. I'm gonna fix that today if there is an issue.