test TDOA

Dependencies:   mbed LoRaWAN-lib SX1272Lib

Fork of LoRaWAN-demo-72 by Semtech

Files at this revision

API Documentation at this revision

Comitter:
nicocarv
Date:
Wed May 17 13:08:22 2017 +0000
Parent:
7:5077515c163b
Child:
9:30bc2a5fd8dc
Commit message:
canales 9 y 10 out. asi adr off pero usa los canales de bouygues

Changed in this revision

app/Commissioning.h Show annotated file Show diff for this revision Revisions of this file
app/main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/app/Commissioning.h	Mon Apr 24 13:29:34 2017 +0000
+++ b/app/Commissioning.h	Wed May 17 13:08:22 2017 +0000
@@ -30,22 +30,22 @@
  * IEEE Organizationally Unique Identifier ( OUI ) (big endian)
  * \remark This is unique to a company or organization
  */
-#define IEEE_OUI                                    0x11, 0x22, 0x33
+#define IEEE_OUI                                    0x7C ,0xA9 ,0x7D
 
 /*!
  * Mote device IEEE EUI (big endian)
  */
-#define LORAWAN_DEVICE_EUI                          { IEEE_OUI, 0x44, 0x55, 0x66, 0x77, 0x88 }
+#define LORAWAN_DEVICE_EUI                          { IEEE_OUI, 0x00 ,0x00 ,0x00 ,0x11 ,0x16 }
 
 /*!
  * Application IEEE EUI (big endian)
  */
-#define LORAWAN_APPLICATION_EUI                     { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
+#define LORAWAN_APPLICATION_EUI                     { 0x7C ,0xA9 ,0x7D ,0xF0 ,0x00 ,0x00 ,0x11 ,0x10 }
 
 /*!
  * AES encryption/decryption cipher application key
  */
-#define LORAWAN_APPLICATION_KEY                     { 0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6, 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C }
+#define LORAWAN_APPLICATION_KEY                     { 0xA9 ,0xC1 ,0xC8 ,0x91 ,0x6F ,0x0D ,0xE4 ,0xA1 ,0x33 ,0x2C ,0x2D ,0x71 ,0xB1 ,0xA0 ,0xF5 ,0x3B }
 
 /*!
  * Current network ID
--- a/app/main.cpp	Mon Apr 24 13:29:34 2017 +0000
+++ b/app/main.cpp	Wed May 17 13:08:22 2017 +0000
@@ -21,15 +21,33 @@
 #include "SerialDisplay.h"
 
 /*!
- * Defines the application data transmission duty cycle. 5s, value in [ms].
+ *  *********************                                           *********************
+ *  * N unconfirmed TXs * - - time between periods of transmit - -  * N unconfirmed TXs * 
+ *  *********************                                           *********************
+ *    APP_N_PERIOD_TX            PERIOD_TX_DUTYCYCLE                    APP_N_PERIOD_TX 
+ *
+ *
+ * Defines the application data transmission duty cycle inside a period of transmission. 
+ * value in [ms].
  */
 #define APP_TX_DUTYCYCLE                            5000
 
 /*!
- * Defines a random delay for application data transmission duty cycle. 1s,
+ * Defines a random delay for application data transmission duty cycle.
  * value in [ms].
  */
-#define APP_TX_DUTYCYCLE_RND                        1000
+#define APP_TX_DUTYCYCLE_RND                        10
+
+/*!
+ * Defines the Number of Unconfirmed Uplinks to send in each period of transmission
+ */
+#define APP_N_PERIOD_TX                        10
+
+/*!
+ * Defines the delay between periods of transmissions
+ * value in [ms].
+ */
+#define PERIOD_TX_DUTYCYCLE                        60000
 
 /*!
  * Default datarate
@@ -39,7 +57,7 @@
 /*!
  * LoRaWAN confirmed messages
  */
-#define LORAWAN_CONFIRMED_MSG_ON                    true
+#define LORAWAN_CONFIRMED_MSG_ON                    false
 
 /*!
  * LoRaWAN Adaptive Data Rate
@@ -107,6 +125,13 @@
 
 #endif
 
+
+/*!
+ * Count the number of TX in a TX period slot
+ */
+int PERIODS_COUNT = 0;
+
+
 /*!
  * Application port
  */
@@ -761,6 +786,7 @@
  */
 int main( void )
 {
+    
     LoRaMacPrimitives_t LoRaMacPrimitives;
     LoRaMacCallback_t LoRaMacCallbacks;
     MibRequestConfirm_t mibReq;
@@ -854,8 +880,8 @@
                 LoRaMacChannelAdd( 5, ( ChannelParams_t )LC6 );
                 LoRaMacChannelAdd( 6, ( ChannelParams_t )LC7 );
                 LoRaMacChannelAdd( 7, ( ChannelParams_t )LC8 );
-                LoRaMacChannelAdd( 8, ( ChannelParams_t )LC9 );
-                LoRaMacChannelAdd( 9, ( ChannelParams_t )LC10 );
+                //LoRaMacChannelAdd( 8, ( ChannelParams_t )LC9 );
+                //LoRaMacChannelAdd( 9, ( ChannelParams_t )LC10 );
 
                 mibReq.Type = MIB_RX2_DEFAULT_CHANNEL;
                 mibReq.Param.Rx2DefaultChannel = ( Rx2ChannelParams_t ){ 869525000, DR_3 };
@@ -925,7 +951,8 @@
                     SerialDisplayUpdateUplinkAcked( false );
                     SerialDisplayUpdateDonwlinkRxData( false );
                     PrepareTxFrame( AppPort );
-
+                    PERIODS_COUNT = PERIODS_COUNT + 1;
+                    
                     NextTx = SendFrame( );
                 }
                 if( ComplianceTest.Running == true )
@@ -935,8 +962,17 @@
                 }
                 else
                 {
-                    // Schedule next packet transmission
-                    TxDutyCycleTime = APP_TX_DUTYCYCLE + randr( -APP_TX_DUTYCYCLE_RND, APP_TX_DUTYCYCLE_RND );
+                    if ( PERIODS_COUNT > APP_N_PERIOD_TX - 1)
+                    {
+                        // Last Tx sent so period of tx finisehd. We wait time between perdiods
+                        PERIODS_COUNT = 0;
+                        TxDutyCycleTime = PERIOD_TX_DUTYCYCLE;
+                    }
+                    else
+                    {
+                        // Schedule next packet transmission
+                        TxDutyCycleTime = APP_TX_DUTYCYCLE + randr( -APP_TX_DUTYCYCLE_RND, APP_TX_DUTYCYCLE_RND );
+                    }
                 }
                 DeviceState = DEVICE_STATE_CYCLE;
                 break;