]> git.tnoah.ca Git - lora-radio.git/commitdiff
Fix incorrect SX1280 preamble calculation
authorjacob.eva <x00010@disroot.org>
Thu, 10 Oct 2024 13:47:40 +0000 (14:47 +0100)
committerjacob.eva <x00010@disroot.org>
Thu, 10 Oct 2024 13:47:40 +0000 (14:47 +0100)
sx128x.cpp

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