mQ Branch for NA mote testing

Dependencies:   LoRaWAN-lib SX1272Lib-mQ lib_gps lib_mma8451q lib_mpl3115a2 mbed

Fork of LoRaWAN-NAMote72-Application-Demo by Semtech

Revision:
18:18408c3c2d0c
Parent:
0:69f2e28d12c1
diff -r f00701a2e2da -r 18408c3c2d0c app/SerialDisplay.cpp
--- a/app/SerialDisplay.cpp	Sun Apr 16 23:12:47 2017 +0000
+++ b/app/SerialDisplay.cpp	Mon Apr 24 13:47:27 2017 +0000
@@ -12,26 +12,62 @@
 
 Maintainer: Miguel Luis and Gregory Cristian
 */
-
 #include "SerialDisplay.h"
 
 VT100 vt( USBTX, USBRX );
 
 void SerialDisplayJoinUpdate( void )
 {
+    MibRequestConfirm_t mibGet;
+
     printf( "###### ===== JOINING ==== ######\r\n" );
-    
     DisplayNetworkParam( );
-
+    if( LoRaMacJoinStatus.Status == LORAMAC_STATUS_OK )
+    {
+        mibGet.Type = MIB_CHANNELS_DATARATE;
+        LoRaMacMibGetRequestConfirm( &mibGet );
+        printf( "DATA RATE: DR%d\r\n", mibGet.Param.ChannelsDatarate );
+    }
+    else
+    {
+        printf( "JOIN TRANSMIT ERROR: %d\r\n", LoRaMacJoinStatus.Status );
+    }
     printf( "\r\n" );
 }
 
-void SerialDisplayTxUpdate(void)
+void SerialDisplayJoinDataRateUpdate( uint8_t Datarate )
+{
+#if defined( USE_BAND_915 ) || defined( USE_BAND_915_HYBRID )
+    // Debug to check for reported issue where join datarate does not
+    // alternate after compliance mode exit on command 6
+    if( Datarate == LoRaMacJoinStatus.LastDatarate )
+    {
+        printf( "###### ===== JOIN WARNING ==== ######\r\n" );
+        printf( "DATA RATE IS NOT ALTERNATING: CURRENT=DR%d, LAST=DR%d\r\n",
+                LoRaMacJoinStatus.LastDatarate, Datarate);
+
+        MibRequestConfirm_t mibGet;
+        mibGet.Type = MIB_CHANNELS_MASK;
+        if( LoRaMacMibGetRequestConfirm( &mibGet ) == LORAMAC_STATUS_OK)
+        {
+            printf("CHANNEL MASK: ");
+            for( uint8_t i = 0; i < 5; i++ )
+            {
+                printf("%04x ", mibGet.Param.ChannelsMask[i] );
+            }
+            printf("\r\n");
+        }
+        printf("\r\n");
+    }
+#endif
+}
+
+void SerialDisplayTxUpdate( void )
 {
     printf( "###### ===== UPLINK FRAME %d ==== ######\r\n", LoRaMacUplinkStatus.UplinkCounter );
 
     DisplayNetworkParam( );
-    
+
     printf( "TX PORT: %d\r\n", LoRaMacUplinkStatus.Port );
 
     if( LoRaMacUplinkStatus.BufferSize != 0 )
@@ -50,11 +86,26 @@
 
     printf( "DATA RATE: DR%d\r\n", LoRaMacUplinkStatus.Datarate );
 
+    printf( "U/L FREQ: %d\r\n", LoRaMacUplinkStatus.UpLinkFrequency );
+
     printf( "TX POWER: %d dBm\r\n", 30 - ( LoRaMacUplinkStatus.TxPower << 1 ) );
 
-    printf( "BATTERY: %2.2fV\r\n", BoardGetBatteryVoltage( ) );
+#if defined( USE_BAND_915 ) || defined( USE_BAND_915_HYBRID )
+    MibRequestConfirm_t mibGet;
+    mibGet.Type  = MIB_CHANNELS_MASK;
+    if( LoRaMacMibGetRequestConfirm( &mibGet ) == LORAMAC_STATUS_OK)
+    {
+        printf("CHANNEL MASK: ");
+        for( uint8_t i = 0; i < 5; i++)
+        {
+            printf("%04x ", mibGet.Param.ChannelsMask[i] );
+        }
+        printf("\r\n");
+    }
+#endif
 
-    printf( "\r\n");
+    printf( "BATTERY: %2.2fV\r\n", BoardGetBatteryVoltage( ) / 1000.0 );
+    printf( "\r\n" );
 }
 
 void SerialDisplayRxUpdate( void )
@@ -125,33 +176,40 @@
 
 void DisplayNetworkParam( void )
 {
-#if( OVER_THE_AIR_ACTIVATION != 0 )
+    if( Otaa == true )
+    {
+        printf( "DEVEUI: " );
+        SerialDisplayHex( DevEui, 8 );
 
-    printf( "DEVEUI: " );
-    SerialDisplayHex( DevEui, 8 );
+        printf( "APPEUI: " );
+        SerialDisplayHex( AppEui, 8 );
 
-    printf( "APPEUI: " );
-    SerialDisplayHex( AppEui, 8 );
-
-    printf( "APPKEY: " );
-    SerialDisplayHex( AppKey, 16 );
-
-#else
+        printf( "APPKEY: " );
+        SerialDisplayHex( AppKey, 16 );
+    }
+#if ( OVER_THE_AIR_ACTIVATION == 0 )
+    else
+    {
+        printf( "DEVADDR: " );
 
-    printf( "DEVADDR: " );
-    
-    uint8_t *pData = ( uint8_t* )&DevAddr;
-    for( int32_t i = 3; i >= 0; i-- )
-    {
-        printf( "%02X ", pData[i] );
-    }
-    printf( "\r\n" );
+        uint8_t *pData = ( uint8_t* )&DevAddr;
+        for( int32_t i = 3; i >= 0; i-- )
+        {
+            printf( "%02X ", pData[i] );
+        }
+        printf( "\r\n" );
+
+        printf( "NWKSKEY: " );
+        SerialDisplayHex( NwkSKey, 16 );
 
-    printf( "NWKSKEY: " );
-    SerialDisplayHex( NwkSKey, 16 );
+        printf( "APPSKEY: " );
+        SerialDisplayHex( AppSKey, 16 );
+    }
+#endif
+}
 
-    printf( "APPSKEY: " );
-    SerialDisplayHex( AppSKey, 16 );
-
-#endif
-}
\ No newline at end of file
+void DisplaySwVersion( void )
+{
+    printf( "###### ===== NAMote-72 Application Demo v1.0.0 ==== ######\r\n" );
+    printf( "###### ===== Based on GitHub master branch commit e506c24 ==== ######\r\n\r\n" );
+}