IBL LoRaWAN implementation

Dependents:   Simple-LoRaWAN

Fork of LMiC by Semtech

Revision:
3:519c71d29a06
Parent:
1:d3b7bde3995c
Child:
4:85b2b647cb64
--- a/lmic.cpp	Tue Mar 31 13:36:56 2015 +0000
+++ b/lmic.cpp	Thu Nov 26 12:46:56 2015 +0000
@@ -689,7 +689,6 @@
     LMIC.txend = LMIC.bands[BAND_MILLI].avail + rndDelay(8);
 }
 
-
 static ostime_t nextJoinState (void) {
     u1_t failed = 0;
 
@@ -741,11 +740,12 @@
 
 static u4_t convFreq (xref2u1_t ptr) {
     u4_t freq = (os_rlsbf4(ptr-1) >> 8) * 100;
-    if( freq >= US915_FREQ_MIN && freq <= US915_FREQ_MAX )
+    if( freq < US915_FREQ_MIN || freq > US915_FREQ_MAX )
         freq = 0;
     return freq;
 }
 
+
 bit_t LMIC_setupChannel (u1_t chidx, u4_t freq, u2_t drmap, s1_t band) {
     if( chidx < 72 || chidx >= 72+MAX_XCHANNELS )
         return 0; // channels 0..71 are hardwired
@@ -1382,7 +1382,7 @@
         u1_t chidx=72;
 #endif
         for( ; chidx<8; chidx++, dlen+=3 )
-            LMIC_setupChannel(chidx, os_rlsbf4(&LMIC.frame[dlen-1]) >> 8, 0, -1);
+            LMIC_setupChannel(chidx, convFreq(&LMIC.frame[dlen]), 0, -1);
     }
 
     // already incremented when JOIN REQ got sent off