Configurable CRC

This commit is contained in:
Sassa NF
2025-01-16 19:19:29 +00:00
parent 32ae20632a
commit 48c5f8d1ce
5 changed files with 74 additions and 8 deletions
+13 -1
View File
@@ -188,6 +188,11 @@ int16_t RadioComms::send(Message &m)
size_t p = MAX_MSG;
uint8_t *msg = NULL;
if (loraCfg.crc)
{
p -= 2;
}
if (m.type == SCAN_RESULT)
{
msg = _serialize_scan_result(m, p, msg_buf);
@@ -207,6 +212,13 @@ int16_t RadioComms::send(Message &m)
return RADIOLIB_ERR_INVALID_FUNCTION;
}
if (loraCfg.crc)
{
uint16_t c = loraCfg.crc_seed ^ 0xffff;
c = crc16(loraCfg.crc_poly, c, p, msg);
_write(msg, MAX_MSG, p, (uint8_t *)&c, 2);
}
int16_t status = radio.transmit(msg, p);
if (msg != msg_buf)
@@ -385,7 +397,7 @@ Message *RadioComms::receive(uint16_t timeout_ms)
radio.clearDio1Action();
packetRssi = radio.getRSSI(true);
Serial.println("LORA_RSSI: " + String(packetRssi));
// Serial.println("LORA_RSSI:" + String(packetRssi));
size_t len = radio.getPacketLength(true);
uint8_t *packet = msg;