Senet-ized LMIC for MOTE_L152RC

Fork of lmic_MOTE_L152RC by Semtech

Files at this revision

API Documentation at this revision

Comitter:
dudmuck
Date:
Fri Jul 17 21:09:16 2015 +0000
Parent:
4:1a9a62cf220f
Child:
6:dfc048cda33f
Commit message:
add txpow_limit to limit transmit power

Changed in this revision

lmic.cpp Show annotated file Show diff for this revision Revisions of this file
lmic.h Show annotated file Show diff for this revision Revisions of this file
--- a/lmic.cpp	Tue Jul 07 18:25:05 2015 +0000
+++ b/lmic.cpp	Fri Jul 17 21:09:16 2015 +0000
@@ -728,10 +728,22 @@
 //
 
 
-static void initDefaultChannels (void) {
+static void initDefaultChannels (void)
+{
+#ifdef CHNL_HYBRID
+        LMIC.channelMap[0] = 0xFF;
+        LMIC.channelMap[1] = 0x0;
+        LMIC.channelMap[2] = 0x0;
+        LMIC.channelMap[3] = 0x0;
+        LMIC.channelMap[4] = 0x01;
+        LMIC.txpow_limit = 20;
+#else
     for( u1_t i=0; i<4; i++ )
         LMIC.channelMap[i] = 0xFFFF;
     LMIC.channelMap[4] = 0x00FF;
+    
+    LMIC.txpow_limit = 30;
+#endif
 }
 
 static u4_t convFreq (xref2u1_t ptr) {
@@ -774,10 +786,15 @@
     u1_t chnl = LMIC.txChnl;
     if( chnl < 64 ) {
         LMIC.freq = US915_125kHz_UPFBASE + chnl*US915_125kHz_UPFSTEP;
-        LMIC.txpow = 30;
+        LMIC.txpow = LMIC.txpow_limit;
         return;
     }
-    LMIC.txpow = 26;
+    
+    if (LMIC.txpow_limit >= 26)
+        LMIC.txpow = 26;
+    else
+        LMIC.txpow = LMIC.txpow_limit;
+        
     if( chnl < 64+8 ) {
         LMIC.freq = US915_500kHz_UPFBASE + (chnl-64)*US915_500kHz_UPFSTEP;
     } else {
--- a/lmic.h	Tue Jul 07 18:25:05 2015 +0000
+++ b/lmic.h	Fri Jul 17 21:09:16 2015 +0000
@@ -147,6 +147,7 @@
     u1_t        rxsyms;
     u1_t        dndr;
     s1_t        txpow;     // dBm
+    s1_t        txpow_limit;    // dBm maximum permitted
 
     osjob_t     osjob;