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 mbed lib_mpl3115a2 lib_mma8451q lib_gps SX1272Lib
Dependents: LoRaWAN-NAMote72-BVS-confirmed-tester-0-7v1_copy
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 #include "SerialDisplay.h" 00016 00017 VT100 vt( USBTX, USBRX ); 00018 00019 void SerialDisplayJoinUpdate( void ) 00020 { 00021 MibRequestConfirm_t mibGet; 00022 00023 printf( "###### ===== JOINING ==== ######\r\n" ); 00024 DisplayNetworkParam( ); 00025 if( LoRaMacJoinStatus.Status == LORAMAC_STATUS_OK ) 00026 { 00027 mibGet.Type = MIB_CHANNELS_DATARATE; 00028 LoRaMacMibGetRequestConfirm( &mibGet ); 00029 printf( "DATA RATE: DR%d\r\n", mibGet.Param.ChannelsDatarate ); 00030 } 00031 else 00032 { 00033 printf( "JOIN TRANSMIT ERROR: %d\r\n", LoRaMacJoinStatus.Status ); 00034 } 00035 printf( "\r\n" ); 00036 } 00037 00038 void SerialDisplayJoinDataRateUpdate( uint8_t Datarate ) 00039 { 00040 #if defined( USE_BAND_915 ) || defined( USE_BAND_915_HYBRID ) 00041 // Debug to check for reported issue where join datarate does not 00042 // alternate after compliance mode exit on command 6 00043 if( Datarate == LoRaMacJoinStatus.LastDatarate ) 00044 { 00045 printf( "###### ===== JOIN WARNING ==== ######\r\n" ); 00046 printf( "DATA RATE IS NOT ALTERNATING: CURRENT=DR%d, LAST=DR%d\r\n", 00047 LoRaMacJoinStatus.LastDatarate, Datarate); 00048 00049 MibRequestConfirm_t mibGet; 00050 mibGet.Type = MIB_CHANNELS_MASK; 00051 if( LoRaMacMibGetRequestConfirm( &mibGet ) == LORAMAC_STATUS_OK) 00052 { 00053 printf("CHANNEL MASK: "); 00054 for( uint8_t i = 0; i < 5; i++ ) 00055 { 00056 printf("%04x ", mibGet.Param.ChannelsMask[i] ); 00057 } 00058 printf("\r\n"); 00059 } 00060 printf("\r\n"); 00061 } 00062 #endif 00063 } 00064 00065 void SerialDisplayTxUpdate( void ) 00066 { 00067 printf( "###### ===== UPLINK FRAME %d ==== ######\r\n", LoRaMacUplinkStatus.UplinkCounter ); 00068 00069 DisplayNetworkParam( ); 00070 00071 printf( "TX PORT: %d\r\n", LoRaMacUplinkStatus.Port ); 00072 00073 if( LoRaMacUplinkStatus.BufferSize != 0 ) 00074 { 00075 printf( "TX DATA: " ); 00076 if( LoRaMacUplinkStatus.Type == MCPS_CONFIRMED ) 00077 { 00078 printf( "CONFIRMED\r\n" ); 00079 } 00080 else 00081 { 00082 printf( "UNCONFIRMED\r\n" ); 00083 } 00084 SerialDisplayHex( LoRaMacUplinkStatus.Buffer, LoRaMacUplinkStatus.BufferSize ); 00085 } 00086 00087 printf( "DATA RATE: DR%d\r\n", LoRaMacUplinkStatus.Datarate ); 00088 00089 printf( "U/L FREQ: %d\r\n", LoRaMacUplinkStatus.UpLinkFrequency ); 00090 00091 printf( "TX POWER: %d dBm\r\n", 30 - ( LoRaMacUplinkStatus.TxPower << 1 ) ); 00092 00093 #if defined( USE_BAND_915 ) || defined( USE_BAND_915_HYBRID ) 00094 MibRequestConfirm_t mibGet; 00095 mibGet.Type = MIB_CHANNELS_MASK; 00096 if( LoRaMacMibGetRequestConfirm( &mibGet ) == LORAMAC_STATUS_OK) 00097 { 00098 printf("CHANNEL MASK: "); 00099 for( uint8_t i = 0; i < 5; i++) 00100 { 00101 printf("%04x ", mibGet.Param.ChannelsMask[i] ); 00102 } 00103 printf("\r\n"); 00104 } 00105 #endif 00106 00107 printf( "BATTERY: %2.2fV\r\n", BoardGetBatteryVoltage( ) / 1000.0 ); 00108 printf( "\r\n" ); 00109 } 00110 00111 void SerialDisplayRxUpdate( void ) 00112 { 00113 printf( "###### ===== DOWNLINK FRAME %d ==== ######\r\n", LoRaMacDownlinkStatus.DownlinkCounter ); 00114 00115 printf( "RX WINDOW: %d\r\n", LoRaMacDownlinkStatus.RxSlot + 1 ); 00116 00117 printf( "RX PORT: %d\r\n", LoRaMacDownlinkStatus.Port ); 00118 00119 if( LoRaMacDownlinkStatus.BufferSize != 0 ) 00120 { 00121 printf( "RX DATA: \r\n" ); 00122 SerialDisplayHex( LoRaMacDownlinkStatus.Buffer, LoRaMacDownlinkStatus.BufferSize ); 00123 } 00124 00125 printf( "RX RSSI: %d\r\n", LoRaMacDownlinkStatus.Rssi ); 00126 00127 printf( "RX SNR: %d\r\n", LoRaMacDownlinkStatus.Snr ); 00128 00129 printf( "\r\n" ); 00130 } 00131 00132 void SerialDisplayHex( uint8_t *pData, uint8_t len ) 00133 { 00134 int i; 00135 bool newline = 0; 00136 00137 for( i = 0; i < len; i++ ) 00138 { 00139 if( newline != 0 ) 00140 { 00141 printf( "\r\n" ); 00142 newline = 0; 00143 } 00144 00145 printf( "%02X ", pData[i] ); 00146 00147 if( ( ( i + 1 ) % 16 ) == 0 ) 00148 { 00149 newline = 1; 00150 } 00151 } 00152 printf( "\r\n" ); 00153 } 00154 00155 void SerialAcclMetrDisplay( uint8_t statusReg ) 00156 { 00157 printf( "===== DEVICE ORIENTATION ====\r\n" ); 00158 if( ( statusReg & 0x40 ) != 0 ) 00159 { 00160 printf( "HORIZONTAL + " ); 00161 if( ( statusReg & 0x01 ) != 0 ) 00162 { 00163 printf( "FACE DOWN" ); 00164 } 00165 else 00166 { 00167 printf( "FACE UP" ); 00168 } 00169 } 00170 else 00171 { 00172 printf( "VERTICAL" ); 00173 } 00174 printf( "\r\n\r\n" ); 00175 } 00176 00177 void DisplayNetworkParam( void ) 00178 { 00179 if( Otaa == true ) 00180 { 00181 printf( "DEVEUI: " ); 00182 SerialDisplayHex( DevEui, 8 ); 00183 00184 printf( "APPEUI: " ); 00185 SerialDisplayHex( AppEui, 8 ); 00186 00187 printf( "APPKEY: " ); 00188 SerialDisplayHex( AppKey, 16 ); 00189 } 00190 #if ( OVER_THE_AIR_ACTIVATION == 0 ) 00191 else 00192 { 00193 printf( "DEVADDR: " ); 00194 00195 uint8_t *pData = ( uint8_t* )&DevAddr; 00196 for( int32_t i = 3; i >= 0; i-- ) 00197 { 00198 printf( "%02X ", pData[i] ); 00199 } 00200 printf( "\r\n" ); 00201 00202 printf( "NWKSKEY: " ); 00203 SerialDisplayHex( NwkSKey, 16 ); 00204 00205 printf( "APPSKEY: " ); 00206 SerialDisplayHex( AppSKey, 16 ); 00207 } 00208 #endif 00209 } 00210 00211 void DisplaySwVersion( void ) 00212 { 00213 printf( "###### ===== NAMote-72 Application Demo v1.0.0 ==== ######\r\n" ); 00214 printf( "###### ===== Based on GitHub master branch commit e506c24 ==== ######\r\n\r\n" ); 00215 }
Generated on Fri Jul 15 2022 22:53:35 by
1.7.2