Merge pull request #88 from jacobeva/preamble-fix

Fix incorrect SX1280 preamble calculation
This commit is contained in:
markqvist 2024-10-10 18:00:11 +02:00 committed by GitHub
commit 1bd7de8f97
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -328,12 +328,15 @@ void sx128x::setPacketParams(uint32_t preamble, uint8_t headermode, uint8_t leng
uint8_t m = 1; uint8_t m = 1;
uint32_t preamblelen; uint32_t preamblelen;
for (e <= 15; e++;) { while (e <= 15) {
for (m <= 15; m++;) { while (m <= 15) {
preamblelen = m * (uint32_t(1) << e); preamblelen = m * (pow(2,e));
if (preamblelen >= preamble) break; if (preamblelen >= preamble) break;
m++;
} }
if (preamblelen >= preamble) break; if (preamblelen >= preamble) break;
m = 0;
e++;
} }
buf[0] = (e << 4) | m; buf[0] = (e << 4) | m;