Actility / Mbed 2 deprecated LoRaWAN_actility

Dependencies:   LoRaMacLib SX1276Lib mbed Chainable_RGB_LED DigitDisplay

Fork of LoRaWAN by LoRa All

Revision:
16:590e0f613893
Parent:
15:c8c3a96b7247
Child:
17:660ab11cd0ad
--- a/main.cpp	Wed Nov 25 16:24:17 2015 +0000
+++ b/main.cpp	Wed Nov 25 17:36:02 2015 +0000
@@ -37,15 +37,16 @@
 /*!
  * Device address
  */
-static uint32_t DevAddr = 0x00000000;                               /// <<< Change here
+static uint32_t DevAddr = 0x40001091;                               /// <<< Change here
 
 /*!
  * AES encryption/decryption cipher network session key
  */
 static uint8_t NwkSKey[] = 
 { 
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,                 /// <<< Change here
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+//    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,                 /// <<< Change here
+//    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+    0x8c, 0x8f, 0x26, 0x76, 0x4c, 0x45, 0x7c, 0xd5, 0xf8, 0x7c, 0xd3, 0x6d, 0xc6, 0x83, 0x57, 0x0b
 };
 
 /*!
@@ -53,8 +54,9 @@
  */
 static uint8_t AppSKey[] = 
 { 
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,                 /// <<< Change here
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+//    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,                 /// <<< Change here
+//    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+    0x8c, 0x8f, 0x26, 0x76, 0x4c, 0x45, 0x7c, 0xd5, 0xf8, 0x7c, 0xd3, 0x6d, 0xc6, 0x83, 0x57, 0x0b
 };
 
 
@@ -115,10 +117,13 @@
 Ticker Led2Timer;
 Ticker BuzTimer;
 
-#define NUM_LED 3
 
+InterruptIn userButton(USER_BUTTON);      // User button on NUCLEO board
+//DigitalOut TxLed(LED1);               // not used, do not use LED1 with the Semtech SX1276MB1xAS board
+//DigitalOut RxLed(A2);                 // not used
 
 AnalogIn LightSens( A1 ); 
+#define NUM_LED 3
 ChainableLED color_led(D6, D7, NUM_LED);
 DigitDisplay display(D8, D9);
 DigitalOut buzzer(A2);
@@ -181,6 +186,8 @@
 {
     uint8_t sendFrameStatus = 0;
 
+//    TxLed = 1;
+    
     sendFrameStatus = LoRaMacSendFrame( AppPort, AppData, AppDataSize );
  //   sendFrameStatus = LoRaMacSendConfirmedFrame( AppPort, AppData, AppDataSize, 8 );
     switch( sendFrameStatus )
@@ -221,6 +228,10 @@
  */
 static void OnMacEvent( LoRaMacEventFlags_t *flags, LoRaMacEventInfo_t *info )
 {
+//    TxLed = 0;  
+//  RxLed = 1;
+    
+    debug( "[OnMacEvent]\n\r");
     if( flags->Bits.JoinAccept == 1 )
     {
 #if( OVER_THE_AIR_ACTIVATION != 0 )
@@ -242,6 +253,7 @@
     }
 
     // Schedule a new transmission
+//  RxLed = 0;
     TxDone = true;
 }
 
@@ -256,6 +268,9 @@
     bool trySendingFrameAgain = false;
     float tempLightValue = 0;   
     
+//    TxLed = 0;
+//    RxLed = 0;
+    
     LightMode = 0;      // 0: manual,   1: automatic
     buzzer = 0;         // 0: OFF,      1: ON
 
@@ -305,7 +320,7 @@
                 TxNextPacket = false;
                 
                 sendFrameStatus = LoRaMacJoinReq( DevEui, AppEui, AppKey );
-                debug("Req Sent\n\r");
+                debug("[OTAA] JoinReq Sent\n\r");
                 switch( sendFrameStatus )
                 {
                 case 1: // BUSY
@@ -330,7 +345,7 @@
             
             TxDone = false;
             
-            debug( "TxDone \n\n\r" );
+            debug( "[Tx] done\n\r");
             // Schedule next packet transmission
             TxDutyCycleTime = APP_TX_DUTYCYCLE + randr( -APP_TX_DUTYCYCLE_RND, APP_TX_DUTYCYCLE_RND );
             TxNextPacketTimer.attach_us( &OnTxNextPacketTimerEvent, TxDutyCycleTime );