Serial port driven Elmo based on TxRxTemplate. Serial port communication has been expanded and configuration mode has been added.

Dependencies:   SX1272lib-PABOOST-HW-Modification mbed

Fork of LoRaWAN_ELMO_TxRx_Template by Espotel

Revision:
10:ceaf618066ca
Parent:
7:3d16d6fe3b12
--- a/RadioHandler.cpp	Mon Oct 10 09:53:50 2016 +0000
+++ b/RadioHandler.cpp	Mon Oct 10 12:00:53 2016 +0000
@@ -8,6 +8,7 @@
 Description: LoRaMac classA device implementation
 License: Revised BSD License, see LICENSE.TXT file include in the project
 Maintainer: Miguel Luis and Gregory Cristian
+Latest modifier: Teemu Koskinen
 */
 
 /*! \file classA/LoRaMote/main.c */
@@ -23,6 +24,19 @@
 #include "RadioHandler.h"
 #include <stdlib.h>
 
+/* -- Latest updates -- */
+//Version 1.0b
+/* RadioHandler contains new funtions */
+//void RadioSetup( void );
+//void SetRadioValues(void);
+//void SetDevEui(void);
+//void SetAppEui(void);
+//void SetAppKey(void);
+/* Some of these functions should not be here cause they are not about radio handling. Refactoring is recommended if this branch is continued */
+
+
+
+
 
 DigitalOut Led2(LED2);
 
@@ -105,6 +119,7 @@
 //static uint8_t AppEui[] = LORAWAN_APPLICATION_EUI;
 //static uint8_t AppKey[] = LORAWAN_APPLICATION_KEY;
 
+//Setting the default values
 uint8_t DevEui[8] = LORAWAN_DEVICE_EUI;
 uint8_t AppEui[8] = LORAWAN_APPLICATION_EUI;
 uint8_t AppKey[16] = LORAWAN_APPLICATION_KEY;
@@ -815,6 +830,7 @@
     Serial port(SERIAL_TX, SERIAL_RX);
     port.baud(9600);
     
+    /* Read answer to entering the configuration mode */
     while( 1 )
     {
         if (port.readable()) 
@@ -829,6 +845,7 @@
                 port.printf("%d\r\n",strncmp( answer, answer_yes, 3));
                 if (strncmp( answer, answer_yes, 3) == 0 )
                 {
+                 /* Setting the new values function*/
                  SetRadioValues();            
                 }
                 memset(answer,' ', sizeof(answer));
@@ -845,6 +862,7 @@
   
 }
 
+/* Function for setting new values */
 void SetRadioValues(void)
 {
     Serial port(SERIAL_TX, SERIAL_RX);
@@ -854,6 +872,7 @@
     uint16_t index = 0;
     printf("\r\nWelcome configuration. Please enter your selection:\r\n\t1: SetDevEui\r\n\t2: SetAppEui\r\n\t3: SetAppKey\r\n");
     
+    /* Read answer which item is goin to be updated */
     while( 1 )
     {
         if (port.readable()) 
@@ -868,6 +887,7 @@
                 port.printf("%d\r\n",strncmp( answer, answer_yes, 3));
                 if (strncmp( answer, answer_yes, 1) == 0 )
                 {
+                    /* Setting new DevEui */
                     SetDevEui();           
                 }
                 strcpy(answer_yes,"2\n");
@@ -875,6 +895,7 @@
                 port.printf("%d\r\n",strncmp( answer, answer_yes, 3));
                 if (strncmp( answer, answer_yes, 1) == 0 )
                 {
+                    /* Setting new AppEui */
                     SetAppEui();           
                 }
                 strcpy(answer_yes,"3\n");
@@ -882,6 +903,7 @@
                 port.printf("%d\r\n",strncmp( answer, answer_yes, 3));
                 if (strncmp( answer, answer_yes, 1) == 0 )
                 {
+                    /* Setting new AppKey */
                     SetAppKey();           
                 }        
                 memset(answer,' ', sizeof(answer));
@@ -896,11 +918,13 @@
         }
     }
     port.printf("Returning to setup\r\n");
+    /* Init Radio with new values */
     RadioInit();
+    /* Print current values, configure more or exit menu */ 
     RadioSetup();
 }
 
-/* Set new RadioHandler values */
+/* Set new DevEui values one by one */
 void SetDevEui(void)
 {
     char answer[100];
@@ -943,6 +967,7 @@
     }   
 }
 
+/* Set new AppEui values one by one */
 void SetAppEui(void)
 {
     char answer[100];
@@ -986,6 +1011,7 @@
       
 }
 
+/* Set new AppKey values one by one */
 void SetAppKey(void)
 {
     char answer[100];
@@ -1028,5 +1054,3 @@
       
 }
 
-
-