to be used with the DSPLoRa module (minor changes wrt transmit power)

Dependents:   DSP_LoRaWAN

Fork of LoRaWAN-lib by S P

Files at this revision

API Documentation at this revision

Comitter:
spcores
Date:
Fri Apr 01 05:09:17 2016 +0000
Parent:
4:06708c793508
Child:
6:090cec5a0d5f
Commit message:
Updated 1.Apr.16

Changed in this revision

LoRaMac-board.h Show annotated file Show diff for this revision Revisions of this file
LoRaMac.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/LoRaMac-board.h	Thu Mar 31 16:05:20 2016 +0000
+++ b/LoRaMac-board.h	Fri Apr 01 05:09:17 2016 +0000
@@ -214,7 +214,7 @@
 /*!
  * LoRaMac maximum number of channels
  */
-#define LORA_MAX_NB_CHANNELS                        8   //SP: original 16
+#define LORA_MAX_NB_CHANNELS                        8   //SP: For 868 band it is 16
 
 /*!
  * Minimal datarate that can be used by the node
@@ -244,15 +244,13 @@
 /*!
  * LoRaMac TxPower definition
  */
-
-#define TC_POWER_27_DBM                             0   //SP:Added support for 27dBM channel(Power = 500mW)
-#define TX_POWER_20_DBM                             1
-#define TX_POWER_14_DBM                             2
-#define TX_POWER_11_DBM                             3
-#define TX_POWER_08_DBM                             4
-#define TX_POWER_05_DBM                             5
-#define TX_POWER_02_DBM                             6
-
+//#define TC_POWER_27_DBM                             0   //SP:Added support for 27dBM channel(Power = 500mW)
+#define TX_POWER_20_DBM                             0
+#define TX_POWER_14_DBM                             1
+#define TX_POWER_11_DBM                             2
+#define TX_POWER_08_DBM                             3
+#define TX_POWER_05_DBM                             4
+#define TX_POWER_02_DBM                             5
 
 /*!
  * Minimal Tx output power that can be used by the node
@@ -293,28 +291,8 @@
  */
 #define LORA_MAX_NB_BANDS                           1   //5
 
-/*!
- * LoRaMac EU865 default bands
- */
-typedef enum
-{
-    BAND_G1_0,
-/*
-    BAND_G1_1,
-    BAND_G1_2,
-    BAND_G1_3,
-    BAND_G1_4,
-*/
-}BandId_t;
-
 // Band = { DutyCycle, TxMaxPower, LastTxDoneTime, TimeOff }
-#define BAND0              { 100 , TX_POWER_14_DBM, 0,  0 } //  1.0 %
-/*
-#define BAND1              { 100 , TX_POWER_14_DBM, 0,  0 } //  1.0 %
-#define BAND2              { 1000, TX_POWER_14_DBM, 0,  0 } //  0.1 %
-#define BAND3              { 10  , TX_POWER_14_DBM, 0,  0 } // 10.0 %
-#define BAND4              { 100 , TX_POWER_14_DBM, 0,  0 } //  1.0 %
-*/
+#define BAND0              { 100 , TX_POWER_20_DBM, 0,  0 } //  1.0 %
 
 /*!
  * LoRaMac default channels
--- a/LoRaMac.cpp	Thu Mar 31 16:05:20 2016 +0000
+++ b/LoRaMac.cpp	Fri Apr 01 05:09:17 2016 +0000
@@ -282,7 +282,7 @@
 /*!
  * Tx output powers table definition
  */
-const int8_t TxPowers[]    = { 27, 20, 14, 11,  8,  5,  2 };        //Added by SP 31.03.2016
+const int8_t TxPowers[]    = { /*27,*/ 20, 14, 11,  8,  5,  2 };        //Added by SP 31.03.2016
 
 /*!
  * LoRaMac bands
@@ -290,12 +290,6 @@
 static Band_t Bands[LORA_MAX_NB_BANDS] =
 {
     BAND0,
- /*
-    BAND1,
-    BAND2,
-    BAND3,
-    BAND4,
-*/
 };
 
 /*!
@@ -1417,7 +1411,7 @@
             }
             else
             {
-#if defined( USE_BAND_433 ) || defined( USE_BAND_780 ) || defined( USE_BAND_868 )
+#if defined( USE_BAND_433 ) || defined( USE_BAND_780 ) || defined( USE_BAND_868 ) || defined( USE_BAND_865 )
                 // Re-enable default channels LC1, LC2, LC3
                 ChannelsMask[0] = ChannelsMask[0] | ( LC( 1 ) + LC( 2 ) + LC( 3 ) );
 #elif defined( USE_BAND_915 )
@@ -1508,7 +1502,7 @@
         Radio.Standby( );
     }
 
-#if defined( USE_BAND_433 ) || defined( USE_BAND_780 ) || defined( USE_BAND_868 )
+#if defined( USE_BAND_433 ) || defined( USE_BAND_780 ) || defined( USE_BAND_868 ) || defined ( USE_BAND_865 )
     datarate = ChannelsDatarate - Rx1DrOffset;
     if( datarate < 0 )
     {
@@ -1554,7 +1548,7 @@
     TimerStop( &RxWindowTimer2 );
     RxSlot = 1;
 
-#if defined( USE_BAND_433 ) || defined( USE_BAND_780 ) || defined( USE_BAND_868 )
+#if defined( USE_BAND_433 ) || defined( USE_BAND_780 ) || defined( USE_BAND_868 ) || defined( USE_BAND_865 )
     // For higher datarates, we increase the number of symbols generating a Rx Timeout
     if( Rx2Channel.Datarate >= DR_3 )
     { // DR_6, DR_5, DR_4, DR_3
@@ -1756,7 +1750,7 @@
         // Store downlink datarate
         McpsIndication.RxDatarate = ( uint8_t ) datarate;
 
-#if defined( USE_BAND_433 ) || defined( USE_BAND_780 ) || defined( USE_BAND_868 )
+#if defined( USE_BAND_433 ) || defined( USE_BAND_780 ) || defined( USE_BAND_868 ) || defined( USE_BAND_865 )
         if( datarate == DR_7 )
         {
             modem = MODEM_FSK;
@@ -1909,7 +1903,7 @@
             {
                 if( ( ( AdrAckCounter - ADR_ACK_DELAY ) % ADR_ACK_LIMIT ) == 0 )
                 {
-#if defined( USE_BAND_433 ) || defined( USE_BAND_780 ) || defined( USE_BAND_868 )
+#if defined( USE_BAND_433 ) || defined( USE_BAND_780 ) || defined( USE_BAND_868 ) || defined( USE_BAND_865 )
                     if( datarate > LORAMAC_MIN_DATARATE )
                     {
                         datarate--;
@@ -2099,7 +2093,7 @@
                     {
                         nbRep = 1;
                     }
-#if defined( USE_BAND_433 ) || defined( USE_BAND_780 ) || defined( USE_BAND_868 )
+#if defined( USE_BAND_433 ) || defined( USE_BAND_780 ) || defined( USE_BAND_868 ) || defined( USE_BAND_865 )
                     if( ( chMaskCntl == 0 ) && ( chMask == 0 ) )
                     {
                         status &= 0xFE; // Channel mask KO
@@ -2416,7 +2410,7 @@
         // Set the default datarate
         ChannelsDatarate = ChannelsDefaultDatarate;
 
-#if defined( USE_BAND_433 ) || defined( USE_BAND_780 ) || defined( USE_BAND_868 )
+#if defined( USE_BAND_433 ) || defined( USE_BAND_780 ) || defined( USE_BAND_868 ) || defined( USE_BAND_865 )
         // Re-enable default channels LC1, LC2, LC3
         ChannelsMask[0] = ChannelsMask[0] | ( LC( 1 ) + LC( 2 ) + LC( 3 ) );
 #endif
@@ -2601,7 +2595,7 @@
 
     Radio.SetChannel( channel.Frequency );
 
-#if defined( USE_BAND_433 ) || defined( USE_BAND_780 ) || defined( USE_BAND_868 )
+#if defined( USE_BAND_433 ) || defined( USE_BAND_780 ) || defined( USE_BAND_868 ) || defined( USE_BAND_865 )
     if( ChannelsDatarate == DR_7 )
     { // High Speed FSK channel
         Radio.SetMaxPayloadLength( MODEM_FSK, LoRaMacBufferPktLen );
@@ -2687,6 +2681,8 @@
     ChannelsMask[0] = LC( 1 ) + LC( 2 ) + LC( 3 );
 #elif defined( USE_BAND_780 )
     ChannelsMask[0] = LC( 1 ) + LC( 2 ) + LC( 3 );
+#elif defined( USE_BAND_865 )
+    ChannelsMask[0] = LC( 1 ) + LC( 2 ) + LC( 3 );
 #elif defined( USE_BAND_868 )
     ChannelsMask[0] = LC( 1 ) + LC( 2 ) + LC( 3 );
 #elif defined( USE_BAND_915 )
@@ -2742,6 +2738,8 @@
     DutyCycleOn = false;
 #elif defined( USE_BAND_780 )
     DutyCycleOn = false;
+#elif defined( USE_BAND_865 )
+    DutyCycleOn = true;
 #elif defined( USE_BAND_868 )
     DutyCycleOn = true;
 #elif defined( USE_BAND_915 ) || defined( USE_BAND_915_HYBRID )
@@ -3208,7 +3206,7 @@
         datarateInvalid = true;
     }
 
-#if defined( USE_BAND_433 ) || defined( USE_BAND_780 ) || defined( USE_BAND_868 )
+#if defined( USE_BAND_433 ) || defined( USE_BAND_780 ) || defined( USE_BAND_868 ) || defined( USE_BAND_865 )
     if( id < 3 )
     {
         if( params.Frequency != Channels[id].Frequency )
@@ -3286,7 +3284,7 @@
 
 LoRaMacStatus_t LoRaMacChannelRemove( uint8_t id )
 {
-#if defined( USE_BAND_433 ) || defined( USE_BAND_780 ) || defined( USE_BAND_868 )
+#if defined( USE_BAND_433 ) || defined( USE_BAND_780 ) || defined( USE_BAND_868 ) || defined( USE_BAND_865 )
     if( ( LoRaMacState & MAC_TX_RUNNING ) == MAC_TX_RUNNING )
     {
         if( ( LoRaMacState & MAC_TX_CONFIG ) != MAC_TX_CONFIG )