Fix SX1280 preamble calculation bug
This commit is contained in:
parent
3f8d012457
commit
11c9522d53
10
Radio.cpp
10
Radio.cpp
@ -1819,18 +1819,20 @@ void sx128x::setPacketParams(uint32_t preamble, uint8_t headermode, uint8_t leng
|
|||||||
// because there is no access to these registers on the sx1280, we have
|
// because there is no access to these registers on the sx1280, we have
|
||||||
// to set all these parameters at once or not at all.
|
// to set all these parameters at once or not at all.
|
||||||
uint8_t buf[7];
|
uint8_t buf[7];
|
||||||
|
|
||||||
// calculate exponent and mantissa values for modem
|
// calculate exponent and mantissa values for modem
|
||||||
uint8_t e = 1;
|
uint8_t e = 1;
|
||||||
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;
|
||||||
|
Loading…
Reference in New Issue
Block a user