this is avaiable project

Dependents:   LoRaWAN_MBED

Fork of LoRaMacLib by LoRa All

Revision:
9:b3ddbad8c5e3
Parent:
8:19a3b4a82c69
Child:
11:29686c1ac910
diff -r 19a3b4a82c69 -r b3ddbad8c5e3 mac/LoRaMac.cpp
--- a/mac/LoRaMac.cpp	Fri Nov 06 17:38:56 2015 +0000
+++ b/mac/LoRaMac.cpp	Mon Nov 30 10:00:41 2015 +0000
@@ -123,6 +123,12 @@
 static bool IsUpLinkCounterFixed = false;
 
 /*!
+ * Used for replying the uplink
+ * Added by pzheng 20151111
+ */
+static bool UpLinkTestOn = false;
+
+/*!
  * Used for test purposes. Disables the opening of the reception windows.
  */
 static bool IsRxWindowsEnabled = true;
@@ -224,6 +230,12 @@
     LC1,
     LC2,
     LC3,
+    LC4,
+    LC5,
+    LC6,
+    LC7,
+    LC8,
+//    LC9,
 };
 #endif
 
@@ -591,6 +603,8 @@
  */
 static uint8_t AddMacCommand( uint8_t cmd, uint8_t p1, uint8_t p2 )
 {
+    //Added by pzheng 20151112
+    debug( "_LoRaMacMoteCmd = 0x%x\n\r", cmd );
     MacCommandsBuffer[MacCommandsBufferIndex++] = cmd;
     switch( cmd )
     {
@@ -672,11 +686,11 @@
     IsLoRaMacNetworkJoined = false;
     LoRaMacState = MAC_IDLE;
 
-#if defined( USE_BAND_868 )
+//#if defined( USE_BAND_868 )
     ChannelsMask = LC( 1 ) + LC( 2 ) + LC( 3 ) + LC( 4 ) + LC( 5 ) + LC( 6 ) + LC( 7 ) + LC( 8 ) + LC( 9 );
-#else
-    ChannelsMask = LC( 1 ) + LC( 2 ) + LC( 3 );
-#endif
+//#else
+//    ChannelsMask = LC( 1 ) + LC( 2 ) + LC( 3 );
+//#endif
     ChannelsTxPower = LORAMAC_DEFAULT_TX_POWER;
     ChannelsDefaultDatarate = ChannelsDatarate = LORAMAC_DEFAULT_DATARATE;
     ChannelsNbRep = 1;
@@ -688,6 +702,7 @@
     AggregatedTimeOff = 0;
 
     DutyCycleOn = true;
+    UpLinkTestOn = false;
 
     MaxRxWindow = MAX_RX_WINDOW;
     ReceiveDelay1 = RECEIVE_DELAY1;
@@ -698,7 +713,7 @@
 //    MacStateCheckTimer.attach_us( &OnMacStateCheckTimerEvent, MAC_STATE_CHECK_TIMEOUT );
     
     // Random seed initialization
-    srand( RAND_SEED );
+    srand1( RAND_SEED );
 
     // Initialize channel index.
     Channel = LORA_MAX_NB_CHANNELS;
@@ -713,6 +728,18 @@
     AdrCtrlOn = enable;
 }
 
+//Added by pzheng 20151111
+void LoRaMacSetUpLinkTestOn( bool enable )
+{
+    UpLinkTestOn = enable;
+}
+
+//Added by pzheng 20151111
+bool LoRaMacGetUpLinkTestOn( )
+{
+    return(bool)UpLinkTestOn;
+}
+
 void LoRaMacInitNwkIds( uint32_t netID, uint32_t devAddr, uint8_t *nwkSKey, uint8_t *appSKey )
 {
     LoRaMacNetID = netID;
@@ -832,6 +859,7 @@
     LoRaMacHeader_t macHdr;
 
     macHdr.Value = 0;
+    
     macHdr.Bits.MType = FRAME_TYPE_DATA_UNCONFIRMED_UP;
     return LoRaMacSend( &macHdr, NULL, fPort, fBuffer, fBufferSize );
 }
@@ -1127,6 +1155,9 @@
 {
     while( macIndex < commandsSize )
     {
+        //Added by pzheng 20151112
+        debug( "_LoRaMacProcessMacCommands = 0x%x\n\r", payload[macIndex]);
+        
         // Decode Frame MAC commands
         switch( payload[macIndex++] )
         {