Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: LoRaWAN-lib SX1272Lib lib_gps lib_mma8451q lib_mpl3115a2 mbed
Fork of LoRaWAN-NAMote72-Application-Demo_Multitech by
SerialDisplay.cpp
00001 /* 00002 / _____) _ | | 00003 ( (____ _____ ____ _| |_ _____ ____| |__ 00004 \____ \| ___ | (_ _) ___ |/ ___) _ \ 00005 _____) ) ____| | | || |_| ____( (___| | | | 00006 (______/|_____)_|_|_| \__)_____)\____)_| |_| 00007 (C)2015 Semtech 00008 00009 Description: VT100 serial display management 00010 00011 License: Revised BSD License, see LICENSE.TXT file include in the project 00012 00013 Maintainer: Miguel Luis and Gregory Cristian 00014 */ 00015 00016 #include "SerialDisplay.h" 00017 00018 VT100 vt( USBTX, USBRX ); 00019 00020 void SerialDisplayJoinUpdate( void ) 00021 { 00022 printf( "###### ===== JOINING ==== ######\r\n" ); 00023 00024 DisplayNetworkParam( ); 00025 00026 printf( "\r\n" ); 00027 } 00028 00029 void SerialDisplayTxUpdate(void) 00030 { 00031 printf( "###### ===== UPLINK FRAME %d ==== ######\r\n", LoRaMacUplinkStatus.UplinkCounter ); 00032 00033 DisplayNetworkParam( ); 00034 00035 printf( "TX PORT: %d\r\n", LoRaMacUplinkStatus.Port ); 00036 00037 if( LoRaMacUplinkStatus.BufferSize != 0 ) 00038 { 00039 printf( "TX DATA: " ); 00040 if( LoRaMacUplinkStatus.Type == MCPS_CONFIRMED ) 00041 { 00042 printf( "CONFIRMED\r\n" ); 00043 } 00044 else 00045 { 00046 printf( "UNCONFIRMED\r\n" ); 00047 } 00048 SerialDisplayHex( LoRaMacUplinkStatus.Buffer, LoRaMacUplinkStatus.BufferSize ); 00049 } 00050 00051 printf( "DATA RATE: DR%d\r\n", LoRaMacUplinkStatus.Datarate ); 00052 00053 printf( "TX POWER: %d dBm\r\n", 30 - ( LoRaMacUplinkStatus.TxPower << 1 ) ); 00054 00055 printf( "BATTERY: %2.2fV\r\n", BoardGetBatteryVoltage( ) ); 00056 00057 printf( "\r\n"); 00058 } 00059 00060 void SerialDisplayRxUpdate( void ) 00061 { 00062 printf( "###### ===== DOWNLINK FRAME %d ==== ######\r\n", LoRaMacDownlinkStatus.DownlinkCounter ); 00063 00064 printf( "RX WINDOW: %d\r\n", LoRaMacDownlinkStatus.RxSlot + 1 ); 00065 00066 printf( "RX PORT: %d\r\n", LoRaMacDownlinkStatus.Port ); 00067 00068 if( LoRaMacDownlinkStatus.BufferSize != 0 ) 00069 { 00070 printf( "RX DATA: \r\n" ); 00071 SerialDisplayHex( LoRaMacDownlinkStatus.Buffer, LoRaMacDownlinkStatus.BufferSize ); 00072 } 00073 00074 printf( "RX RSSI: %d\r\n", LoRaMacDownlinkStatus.Rssi ); 00075 00076 printf( "RX SNR: %d\r\n", LoRaMacDownlinkStatus.Snr ); 00077 00078 printf( "\r\n" ); 00079 } 00080 00081 void SerialDisplayHex( uint8_t *pData, uint8_t len ) 00082 { 00083 int i; 00084 bool newline = 0; 00085 00086 for( i = 0; i < len; i++ ) 00087 { 00088 if( newline != 0 ) 00089 { 00090 printf( "\r\n" ); 00091 newline = 0; 00092 } 00093 00094 printf( "%02X ", pData[i] ); 00095 00096 if( ( ( i + 1 ) % 16 ) == 0 ) 00097 { 00098 newline = 1; 00099 } 00100 } 00101 printf( "\r\n" ); 00102 } 00103 00104 void SerialAcclMetrDisplay( uint8_t statusReg ) 00105 { 00106 printf( "===== DEVICE ORIENTATION ====\r\n" ); 00107 if( ( statusReg & 0x40 ) != 0 ) 00108 { 00109 printf( "HORIZONTAL + " ); 00110 if( ( statusReg & 0x01 ) != 0 ) 00111 { 00112 printf( "FACE DOWN" ); 00113 } 00114 else 00115 { 00116 printf( "FACE UP" ); 00117 } 00118 } 00119 else 00120 { 00121 printf( "VERTICAL" ); 00122 } 00123 printf( "\r\n\r\n" ); 00124 } 00125 00126 void DisplayNetworkParam( void ) 00127 { 00128 #if( OVER_THE_AIR_ACTIVATION != 0 ) 00129 00130 printf( "DEVEUI: " ); 00131 SerialDisplayHex( DevEui, 8 ); 00132 00133 printf( "APPEUI: " ); 00134 SerialDisplayHex( AppEui, 8 ); 00135 00136 printf( "APPKEY: " ); 00137 SerialDisplayHex( AppKey, 16 ); 00138 00139 #else 00140 00141 printf( "DEVADDR: " ); 00142 00143 uint8_t *pData = ( uint8_t* )&DevAddr; 00144 for( int32_t i = 3; i >= 0; i-- ) 00145 { 00146 printf( "%02X ", pData[i] ); 00147 } 00148 printf( "\r\n" ); 00149 00150 printf( "NWKSKEY: " ); 00151 SerialDisplayHex( NwkSKey, 16 ); 00152 00153 printf( "APPSKEY: " ); 00154 SerialDisplayHex( AppSKey, 16 ); 00155 00156 #endif 00157 }
Generated on Thu Jul 28 2022 06:45:12 by
 1.7.2
 1.7.2 
    