Publish Grove Cayenne Spider Test

Dependencies:   SX127x lorawan1v1

Fork of LoRaWAN-grove-cayenne by wayne roberts

Committer:
bootcamps
Date:
Sat Oct 20 17:30:50 2018 +0000
Revision:
12:f55c6f74cb03
Parent:
9:1a94f4a5e716
Publish Grove Cayenne Spider Tests

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Wayne Roberts 0:62e456e60083 1 /*
Wayne Roberts 0:62e456e60083 2 / _____) _ | |
Wayne Roberts 0:62e456e60083 3 ( (____ _____ ____ _| |_ _____ ____| |__
Wayne Roberts 0:62e456e60083 4 \____ \| ___ | (_ _) ___ |/ ___) _ \
Wayne Roberts 0:62e456e60083 5 _____) ) ____| | | || |_| ____( (___| | | |
Wayne Roberts 0:62e456e60083 6 (______/|_____)_|_|_| \__)_____)\____)_| |_|
Wayne Roberts 0:62e456e60083 7 (C)2015 Semtech
Wayne Roberts 0:62e456e60083 8
Wayne Roberts 0:62e456e60083 9 Description: VT100 serial display management
Wayne Roberts 0:62e456e60083 10
Wayne Roberts 0:62e456e60083 11 License: Revised BSD License, see LICENSE.TXT file include in the project
Wayne Roberts 0:62e456e60083 12
Wayne Roberts 0:62e456e60083 13 Maintainer: Miguel Luis and Gregory Cristian
Wayne Roberts 0:62e456e60083 14 */
Wayne Roberts 9:1a94f4a5e716 15 #include "lorawan_board.h"
Wayne Roberts 0:62e456e60083 16
Wayne Roberts 0:62e456e60083 17 #include "SerialDisplay.h"
Wayne Roberts 0:62e456e60083 18 #include "LoRaMacString.h"
Wayne Roberts 0:62e456e60083 19
Wayne Roberts 0:62e456e60083 20 #ifdef ENABLE_VT100
Wayne Roberts 0:62e456e60083 21 VT100 vt( USBTX, USBRX );
Wayne Roberts 0:62e456e60083 22
Wayne Roberts 0:62e456e60083 23 void SerialPrintCheckBox( bool activated, uint8_t color )
Wayne Roberts 0:62e456e60083 24 {
Wayne Roberts 0:62e456e60083 25 if( activated == true )
Wayne Roberts 0:62e456e60083 26 {
Wayne Roberts 0:62e456e60083 27 vt.SetAttribute( VT100::ATTR_OFF, color, color );
Wayne Roberts 0:62e456e60083 28 }
Wayne Roberts 0:62e456e60083 29 else
Wayne Roberts 0:62e456e60083 30 {
Wayne Roberts 0:62e456e60083 31 vt.SetAttribute( VT100::ATTR_OFF );
Wayne Roberts 0:62e456e60083 32 }
Wayne Roberts 0:62e456e60083 33 vt.printf( " " );
Wayne Roberts 0:62e456e60083 34 vt.SetAttribute( VT100::ATTR_OFF );
Wayne Roberts 0:62e456e60083 35 }
Wayne Roberts 0:62e456e60083 36
Wayne Roberts 0:62e456e60083 37 #ifdef LORAWAN_JOIN_EUI
Wayne Roberts 0:62e456e60083 38 void SerialDisplayUpdateActivationMode( bool otaa )
Wayne Roberts 0:62e456e60083 39 {
Wayne Roberts 0:62e456e60083 40 vt.SetCursorPos( 4, 17 ); // TODO
Wayne Roberts 0:62e456e60083 41 SerialPrintCheckBox( otaa, VT100::WHITE );
Wayne Roberts 0:62e456e60083 42 }
Wayne Roberts 0:62e456e60083 43
Wayne Roberts 0:62e456e60083 44 void SerialDisplayUpdateEui( uint8_t line, const uint8_t *eui )
Wayne Roberts 0:62e456e60083 45 {
Wayne Roberts 0:62e456e60083 46 vt.SetCursorPos( line, 27 );
Wayne Roberts 0:62e456e60083 47 for( uint8_t i = 0; i < 8; i++ )
Wayne Roberts 0:62e456e60083 48 {
Wayne Roberts 0:62e456e60083 49 vt.printf( "%02x ", eui[i] );
Wayne Roberts 0:62e456e60083 50 }
Wayne Roberts 0:62e456e60083 51 vt.SetCursorPos( line, 50 );
Wayne Roberts 0:62e456e60083 52 vt.printf( "]" );
Wayne Roberts 0:62e456e60083 53 }
Wayne Roberts 0:62e456e60083 54 #endif /* LORAWAN_JOIN_EUI */
Wayne Roberts 0:62e456e60083 55
Wayne Roberts 0:62e456e60083 56 void SerialDisplayUpdateKey( uint8_t line, const uint8_t *key )
Wayne Roberts 0:62e456e60083 57 {
Wayne Roberts 0:62e456e60083 58 vt.SetCursorPos( line, 29 );
Wayne Roberts 0:62e456e60083 59 for( uint8_t i = 0; i < 16; i++ )
Wayne Roberts 0:62e456e60083 60 {
Wayne Roberts 0:62e456e60083 61 vt.printf( "%02x ", key[i] );
Wayne Roberts 0:62e456e60083 62 }
Wayne Roberts 0:62e456e60083 63 vt.SetCursorPos( line, 76 );
Wayne Roberts 0:62e456e60083 64 vt.printf( "]" );
Wayne Roberts 0:62e456e60083 65 }
Wayne Roberts 0:62e456e60083 66
Wayne Roberts 0:62e456e60083 67 void SerialDisplayUpdateNwkId( uint8_t id )
Wayne Roberts 0:62e456e60083 68 {
Wayne Roberts 0:62e456e60083 69 vt.SetCursorPos( ROW_NwkId, 27 );
Wayne Roberts 0:62e456e60083 70 vt.printf( "%03d", id );
Wayne Roberts 0:62e456e60083 71 }
Wayne Roberts 0:62e456e60083 72
Wayne Roberts 0:62e456e60083 73 void SerialDisplayUpdateDevAddr( uint32_t addr )
Wayne Roberts 0:62e456e60083 74 {
Wayne Roberts 0:62e456e60083 75 vt.SetCursorPos( ROW_DevAddr, 27 );
Wayne Roberts 0:62e456e60083 76 vt.printf( "%02X %02X %02X %02X", ( addr >> 24 ) & 0xFF, ( addr >> 16 ) & 0xFF, ( addr >> 8 ) & 0xFF, addr & 0xFF );
Wayne Roberts 0:62e456e60083 77 }
Wayne Roberts 0:62e456e60083 78
Wayne Roberts 0:62e456e60083 79 void SerialDisplayUpdateFrameType( bool confirmed )
Wayne Roberts 0:62e456e60083 80 {
Wayne Roberts 0:62e456e60083 81 vt.SetCursorPos( ROW_FrameType, 17 );
Wayne Roberts 0:62e456e60083 82 SerialPrintCheckBox( confirmed, VT100::WHITE );
Wayne Roberts 0:62e456e60083 83 vt.SetCursorPos( ROW_FrameType, 32 );
Wayne Roberts 0:62e456e60083 84 SerialPrintCheckBox( !confirmed, VT100::WHITE );
Wayne Roberts 0:62e456e60083 85 }
Wayne Roberts 0:62e456e60083 86
Wayne Roberts 0:62e456e60083 87 void SerialDisplayUpdateAdr( bool adr )
Wayne Roberts 0:62e456e60083 88 {
Wayne Roberts 0:62e456e60083 89 vt.SetCursorPos( ROW_ADR, 27 );
Wayne Roberts 0:62e456e60083 90 if( adr == true )
Wayne Roberts 0:62e456e60083 91 {
Wayne Roberts 0:62e456e60083 92 vt.printf( " ON" );
Wayne Roberts 0:62e456e60083 93 }
Wayne Roberts 0:62e456e60083 94 else
Wayne Roberts 0:62e456e60083 95 {
Wayne Roberts 0:62e456e60083 96 vt.printf( "OFF" );
Wayne Roberts 0:62e456e60083 97 }
Wayne Roberts 0:62e456e60083 98 }
Wayne Roberts 0:62e456e60083 99
Wayne Roberts 0:62e456e60083 100 void SerialDisplayUpdateDutyCycle( bool dutyCycle )
Wayne Roberts 0:62e456e60083 101 {
Wayne Roberts 0:62e456e60083 102 vt.SetCursorPos( ROW_DUTY, 27 );
Wayne Roberts 0:62e456e60083 103 if( dutyCycle == true )
Wayne Roberts 0:62e456e60083 104 {
Wayne Roberts 0:62e456e60083 105 vt.printf( " ON" );
Wayne Roberts 0:62e456e60083 106 }
Wayne Roberts 0:62e456e60083 107 else
Wayne Roberts 0:62e456e60083 108 {
Wayne Roberts 0:62e456e60083 109 vt.printf( "OFF" );
Wayne Roberts 0:62e456e60083 110 }
Wayne Roberts 0:62e456e60083 111 }
Wayne Roberts 0:62e456e60083 112
Wayne Roberts 0:62e456e60083 113 void SerialDisplayUpdatePublicNetwork( bool network )
Wayne Roberts 0:62e456e60083 114 {
Wayne Roberts 0:62e456e60083 115 vt.SetCursorPos( ROW_PUBLIC, 17 );
Wayne Roberts 0:62e456e60083 116 SerialPrintCheckBox( network, VT100::WHITE );
Wayne Roberts 0:62e456e60083 117 vt.SetCursorPos( ROW_PUBLIC, 30 );
Wayne Roberts 0:62e456e60083 118 SerialPrintCheckBox( !network, VT100::WHITE );
Wayne Roberts 0:62e456e60083 119 }
Wayne Roberts 0:62e456e60083 120
Wayne Roberts 0:62e456e60083 121 #ifdef LORAWAN_JOIN_EUI
Wayne Roberts 0:62e456e60083 122 void SerialDisplayUpdateNetworkIsJoined( bool state )
Wayne Roberts 0:62e456e60083 123 {
Wayne Roberts 0:62e456e60083 124 vt.SetCursorPos( ROW_JOINED, 17 );
Wayne Roberts 0:62e456e60083 125 SerialPrintCheckBox( !state, VT100::RED );
Wayne Roberts 0:62e456e60083 126 vt.SetCursorPos( ROW_JOINED, 30 );
Wayne Roberts 0:62e456e60083 127 SerialPrintCheckBox( state, VT100::GREEN );
Wayne Roberts 0:62e456e60083 128 }
Wayne Roberts 0:62e456e60083 129 #endif /* LORAWAN_JOIN_EUI */
Wayne Roberts 0:62e456e60083 130
Wayne Roberts 0:62e456e60083 131 /*void SerialDisplayUpdateLedState( uint8_t id, uint8_t state )
Wayne Roberts 0:62e456e60083 132 {
Wayne Roberts 0:62e456e60083 133 switch( id )
Wayne Roberts 0:62e456e60083 134 {
Wayne Roberts 0:62e456e60083 135 case 1:
Wayne Roberts 0:62e456e60083 136 vt.SetCursorPos( 22, 17 );
Wayne Roberts 0:62e456e60083 137 SerialPrintCheckBox( state, VT100::RED );
Wayne Roberts 0:62e456e60083 138 break;
Wayne Roberts 0:62e456e60083 139 case 2:
Wayne Roberts 0:62e456e60083 140 vt.SetCursorPos( 22, 31 );
Wayne Roberts 0:62e456e60083 141 SerialPrintCheckBox( state, VT100::GREEN );
Wayne Roberts 0:62e456e60083 142 break;
Wayne Roberts 0:62e456e60083 143 case 3:
Wayne Roberts 0:62e456e60083 144 vt.SetCursorPos( 22, 45 );
Wayne Roberts 0:62e456e60083 145 SerialPrintCheckBox( state, VT100::BLUE );
Wayne Roberts 0:62e456e60083 146 break;
Wayne Roberts 0:62e456e60083 147 }
Wayne Roberts 0:62e456e60083 148 }*/
Wayne Roberts 0:62e456e60083 149
Wayne Roberts 0:62e456e60083 150 void SerialDisplayUpdateData( uint8_t line, const uint8_t *buffer, uint8_t size )
Wayne Roberts 0:62e456e60083 151 {
Wayne Roberts 0:62e456e60083 152 if( size != 0 )
Wayne Roberts 0:62e456e60083 153 {
Wayne Roberts 0:62e456e60083 154 vt.SetCursorPos( line, 27 );
Wayne Roberts 0:62e456e60083 155 for( uint8_t i = 0; i < size; i++ )
Wayne Roberts 0:62e456e60083 156 {
Wayne Roberts 0:62e456e60083 157 vt.printf( "%02X ", buffer[i] );
Wayne Roberts 0:62e456e60083 158 if( ( ( i + 1 ) % 16 ) == 0 )
Wayne Roberts 0:62e456e60083 159 {
Wayne Roberts 0:62e456e60083 160 line++;
Wayne Roberts 0:62e456e60083 161 vt.SetCursorPos( line, 27 );
Wayne Roberts 0:62e456e60083 162 }
Wayne Roberts 0:62e456e60083 163 }
Wayne Roberts 0:62e456e60083 164 for( uint8_t i = size; i < 64; i++ )
Wayne Roberts 0:62e456e60083 165 {
Wayne Roberts 0:62e456e60083 166 vt.printf( "__ " );
Wayne Roberts 0:62e456e60083 167 if( ( ( i + 1 ) % 16 ) == 0 )
Wayne Roberts 0:62e456e60083 168 {
Wayne Roberts 0:62e456e60083 169 line++;
Wayne Roberts 0:62e456e60083 170 vt.SetCursorPos( line, 27 );
Wayne Roberts 0:62e456e60083 171 }
Wayne Roberts 0:62e456e60083 172 }
Wayne Roberts 0:62e456e60083 173 vt.SetCursorPos( line - 1, 74 );
Wayne Roberts 0:62e456e60083 174 vt.printf( "]" );
Wayne Roberts 0:62e456e60083 175 }
Wayne Roberts 0:62e456e60083 176 else
Wayne Roberts 0:62e456e60083 177 {
Wayne Roberts 0:62e456e60083 178 vt.SetCursorPos( line, 27 );
Wayne Roberts 0:62e456e60083 179 for( uint8_t i = 0; i < 64; i++ )
Wayne Roberts 0:62e456e60083 180 {
Wayne Roberts 0:62e456e60083 181 vt.printf( "__ " );
Wayne Roberts 0:62e456e60083 182 if( ( ( i + 1 ) % 16 ) == 0 )
Wayne Roberts 0:62e456e60083 183 {
Wayne Roberts 0:62e456e60083 184 line++;
Wayne Roberts 0:62e456e60083 185 vt.SetCursorPos( line, 27 );
Wayne Roberts 0:62e456e60083 186 }
Wayne Roberts 0:62e456e60083 187 }
Wayne Roberts 0:62e456e60083 188 vt.SetCursorPos( line - 1, 74 );
Wayne Roberts 0:62e456e60083 189 vt.printf( "]" );
Wayne Roberts 0:62e456e60083 190 }
Wayne Roberts 0:62e456e60083 191 }
Wayne Roberts 0:62e456e60083 192
Wayne Roberts 0:62e456e60083 193 void SerialDisplayUpdateUplinkAcked( bool state )
Wayne Roberts 0:62e456e60083 194 {
Wayne Roberts 0:62e456e60083 195 vt.SetCursorPos( ROW_UPLINK_ACKED, 36 );
Wayne Roberts 0:62e456e60083 196 SerialPrintCheckBox( state, VT100::GREEN );
Wayne Roberts 0:62e456e60083 197 }
Wayne Roberts 0:62e456e60083 198
Wayne Roberts 0:62e456e60083 199 //void SerialDisplayUpdateUplink( bool acked, uint8_t datarate, uint32_t counter, uint8_t port, uint8_t *buffer, uint8_t bufferSize, LoRaMacEventInfoStatus_t s)
Wayne Roberts 0:62e456e60083 200 void SerialDisplayUplink(uint8_t fport, const uint8_t* buffer, uint8_t bufferSize )
Wayne Roberts 0:62e456e60083 201 {
Wayne Roberts 0:62e456e60083 202 vt.SetCursorPos( ROW_DOWNLINK_RSSI, 32 );
Wayne Roberts 0:62e456e60083 203 vt.printf( " ");
Wayne Roberts 0:62e456e60083 204 vt.SetCursorPos( ROW_DOWNLINK_SNR, 32 );
Wayne Roberts 0:62e456e60083 205 vt.printf( " ");
Wayne Roberts 0:62e456e60083 206
Wayne Roberts 0:62e456e60083 207 // Port
Wayne Roberts 0:62e456e60083 208 vt.SetCursorPos( ROW_UPLINK_PORT, 34 );
Wayne Roberts 0:62e456e60083 209 vt.printf( "%3u", fport );
Wayne Roberts 0:62e456e60083 210 // Data
Wayne Roberts 0:62e456e60083 211 SerialDisplayUpdateData( ROW_UPLINK_PAYLOAD, buffer, bufferSize );
Wayne Roberts 0:62e456e60083 212 }
Wayne Roberts 0:62e456e60083 213
Wayne Roberts 0:62e456e60083 214 void SerialDisplayMcpsConfirm( const McpsConfirm_t* mc)
Wayne Roberts 0:62e456e60083 215 {
Wayne Roberts 0:62e456e60083 216 char str[48];
Wayne Roberts 0:62e456e60083 217 static uint8_t lastStrLen = 0;
Wayne Roberts 0:62e456e60083 218 // Acked
Wayne Roberts 0:62e456e60083 219 SerialDisplayUpdateUplinkAcked(mc->AckReceived);
Wayne Roberts 0:62e456e60083 220 LoRaMacEventInfoStatus_to_string(mc->Status, str);
Wayne Roberts 0:62e456e60083 221 vt.printf("] %s", str);
Wayne Roberts 0:62e456e60083 222 for (unsigned n = 0; n < lastStrLen; n++)
Wayne Roberts 0:62e456e60083 223 vt.putc(' ' );
Wayne Roberts 0:62e456e60083 224 lastStrLen = strlen(str);
Wayne Roberts 0:62e456e60083 225 // Datarate
Wayne Roberts 0:62e456e60083 226 vt.SetCursorPos( ROW_UPLINK_DR, 33 );
Wayne Roberts 0:62e456e60083 227 vt.printf( "DR%u", mc->Datarate);
Wayne Roberts 0:62e456e60083 228 // Counter
Wayne Roberts 0:62e456e60083 229 vt.SetCursorPos( ROW_UPLINK_FCNT, 27 );
Wayne Roberts 0:62e456e60083 230 vt.printf( "%10" PRIu32, mc->UpLinkCounter);
Wayne Roberts 0:62e456e60083 231 }
Wayne Roberts 0:62e456e60083 232
Wayne Roberts 0:62e456e60083 233 void SerialDisplayMcpsIndication()
Wayne Roberts 0:62e456e60083 234 {
Wayne Roberts 0:62e456e60083 235 }
Wayne Roberts 0:62e456e60083 236
Wayne Roberts 0:62e456e60083 237 void SerialDisplayUpdateDonwlinkRxData( bool state )
Wayne Roberts 0:62e456e60083 238 {
Wayne Roberts 0:62e456e60083 239 vt.SetCursorPos( ROW_DOWNLINK_SNR, 4 );
Wayne Roberts 0:62e456e60083 240 SerialPrintCheckBox( state, VT100::GREEN );
Wayne Roberts 0:62e456e60083 241 }
Wayne Roberts 0:62e456e60083 242
Wayne Roberts 0:62e456e60083 243 void SerialDisplayMcpsIndication(const McpsIndication_t* mi)
Wayne Roberts 0:62e456e60083 244 {
Wayne Roberts 0:62e456e60083 245 int8_t Snr;
Wayne Roberts 0:62e456e60083 246
Wayne Roberts 0:62e456e60083 247 vt.SetCursorPos( ROW_DOWNLINK_RSSI, 32 );
Wayne Roberts 0:62e456e60083 248 vt.printf( "%5d", mi->Rssi );
Wayne Roberts 0:62e456e60083 249
Wayne Roberts 0:62e456e60083 250 if (mi->Snr & 0x80) { // The SNR sign bit is 1
Wayne Roberts 0:62e456e60083 251 // Invert and divide by 4
Wayne Roberts 0:62e456e60083 252 Snr = ( ( ~mi->Snr + 1 ) & 0xFF ) >> 2;
Wayne Roberts 0:62e456e60083 253 Snr = -Snr;
Wayne Roberts 0:62e456e60083 254 } else {
Wayne Roberts 0:62e456e60083 255 // Divide by 4
Wayne Roberts 0:62e456e60083 256 Snr = ( mi->Snr & 0xFF ) >> 2;
Wayne Roberts 0:62e456e60083 257 }
Wayne Roberts 0:62e456e60083 258 vt.SetCursorPos( ROW_DOWNLINK_SNR, 32 );
Wayne Roberts 0:62e456e60083 259 vt.printf( "%5d", Snr );
Wayne Roberts 0:62e456e60083 260
Wayne Roberts 0:62e456e60083 261 vt.SetCursorPos( ROW_DOWNLINK_FCNT, 27 );
Wayne Roberts 0:62e456e60083 262 vt.printf( "%10" PRIu32, mi->receivedFCntDown);
Wayne Roberts 0:62e456e60083 263
Wayne Roberts 0:62e456e60083 264 SerialDisplayUpdateDonwlinkRxData(mi->RxData);
Wayne Roberts 0:62e456e60083 265 vt.SetCursorPos( ROW_DOWNLINK_FPORT, 34 );
Wayne Roberts 0:62e456e60083 266 if (mi->RxData) {
Wayne Roberts 0:62e456e60083 267 vt.printf( "%3u", mi->Port);
Wayne Roberts 0:62e456e60083 268 SerialDisplayUpdateData( ROW_DOWNLINK_PAYLOAD, mi->Buffer, mi->BufferSize );
Wayne Roberts 0:62e456e60083 269 } else {
Wayne Roberts 0:62e456e60083 270 vt.printf(" ");
Wayne Roberts 0:62e456e60083 271 SerialDisplayUpdateData( ROW_DOWNLINK_PAYLOAD, NULL, 0 );
Wayne Roberts 0:62e456e60083 272 }
Wayne Roberts 0:62e456e60083 273 /*if (mcpsIndication->RxData) {
Wayne Roberts 0:62e456e60083 274 LoRaMacDownlinkStatus.Port = mcpsIndication->Port;
Wayne Roberts 0:62e456e60083 275 LoRaMacDownlinkStatus.Buffer = mcpsIndication->Buffer;
Wayne Roberts 0:62e456e60083 276 LoRaMacDownlinkStatus.BufferSize = mcpsIndication->BufferSize;
Wayne Roberts 0:62e456e60083 277 } else
Wayne Roberts 0:62e456e60083 278 LoRaMacDownlinkStatus.Buffer = NULL;*/
Wayne Roberts 0:62e456e60083 279 }
Wayne Roberts 0:62e456e60083 280
Wayne Roberts 0:62e456e60083 281 #if 0
Wayne Roberts 0:62e456e60083 282 void SerialDisplayUpdateDownlink( int16_t rssi, int8_t snr, uint32_t counter, uint8_t port, uint8_t *buffer, uint8_t bufferSize )
Wayne Roberts 0:62e456e60083 283 {
Wayne Roberts 0:62e456e60083 284 // Rx data
Wayne Roberts 0:62e456e60083 285 SerialDisplayUpdateDonwlinkRxData( buffer != NULL );
Wayne Roberts 0:62e456e60083 286 // RSSI
Wayne Roberts 0:62e456e60083 287 vt.SetCursorPos( ROW_DOWNLINK_RSSI, 32 );
Wayne Roberts 0:62e456e60083 288 vt.printf( "%5d", rssi );
Wayne Roberts 0:62e456e60083 289 // SNR
Wayne Roberts 0:62e456e60083 290 vt.SetCursorPos( ROW_DOWNLINK_SNR, 32 );
Wayne Roberts 0:62e456e60083 291 vt.printf( "%5d", snr );
Wayne Roberts 0:62e456e60083 292 // Counter
Wayne Roberts 0:62e456e60083 293 vt.SetCursorPos( ROW_DOWNLINK_FCNT, 27 );
Wayne Roberts 0:62e456e60083 294 vt.printf( "%10" PRIu32, counter );
Wayne Roberts 0:62e456e60083 295 if( buffer != NULL )
Wayne Roberts 0:62e456e60083 296 {
Wayne Roberts 0:62e456e60083 297 // Port
Wayne Roberts 0:62e456e60083 298 vt.SetCursorPos( ROW_DOWNLINK_FPORT, 34 );
Wayne Roberts 0:62e456e60083 299 vt.printf( "%3u", port );
Wayne Roberts 0:62e456e60083 300 // Data
Wayne Roberts 0:62e456e60083 301 SerialDisplayUpdateData( ROW_DOWNLINK_PAYLOAD, buffer, bufferSize );
Wayne Roberts 0:62e456e60083 302 }
Wayne Roberts 0:62e456e60083 303 else
Wayne Roberts 0:62e456e60083 304 {
Wayne Roberts 0:62e456e60083 305 // Port
Wayne Roberts 0:62e456e60083 306 vt.SetCursorPos( ROW_DOWNLINK_FPORT, 34 );
Wayne Roberts 0:62e456e60083 307 vt.printf( " " );
Wayne Roberts 0:62e456e60083 308 // Data
Wayne Roberts 0:62e456e60083 309 SerialDisplayUpdateData( ROW_DOWNLINK_PAYLOAD, NULL, 0 );
Wayne Roberts 0:62e456e60083 310 }
Wayne Roberts 0:62e456e60083 311 }
Wayne Roberts 0:62e456e60083 312 #endif /* if 0 */
Wayne Roberts 0:62e456e60083 313
Wayne Roberts 0:62e456e60083 314 void SerialDisplayDrawFirstLine( void )
Wayne Roberts 0:62e456e60083 315 {
Wayne Roberts 0:62e456e60083 316 vt.PutBoxDrawingChar( 'l' );
Wayne Roberts 0:62e456e60083 317 for( int8_t i = 0; i <= 77; i++ )
Wayne Roberts 0:62e456e60083 318 {
Wayne Roberts 0:62e456e60083 319 vt.PutBoxDrawingChar( 'q' );
Wayne Roberts 0:62e456e60083 320 }
Wayne Roberts 0:62e456e60083 321 vt.PutBoxDrawingChar( 'k' );
Wayne Roberts 0:62e456e60083 322 vt.printf( "\r\n" );
Wayne Roberts 0:62e456e60083 323 }
Wayne Roberts 0:62e456e60083 324
Wayne Roberts 0:62e456e60083 325 void SerialDisplayDrawTitle( const char* title )
Wayne Roberts 0:62e456e60083 326 {
Wayne Roberts 0:62e456e60083 327 vt.PutBoxDrawingChar( 'x' );
Wayne Roberts 0:62e456e60083 328 vt.printf( "%s", title );
Wayne Roberts 0:62e456e60083 329 vt.PutBoxDrawingChar( 'x' );
Wayne Roberts 0:62e456e60083 330 vt.printf( "\r\n" );
Wayne Roberts 0:62e456e60083 331 }
Wayne Roberts 0:62e456e60083 332 void SerialDisplayDrawTopSeparator( void )
Wayne Roberts 0:62e456e60083 333 {
Wayne Roberts 0:62e456e60083 334 vt.PutBoxDrawingChar( 't' );
Wayne Roberts 0:62e456e60083 335 for( int8_t i = 0; i <= 11; i++ )
Wayne Roberts 0:62e456e60083 336 {
Wayne Roberts 0:62e456e60083 337 vt.PutBoxDrawingChar( 'q' );
Wayne Roberts 0:62e456e60083 338 }
Wayne Roberts 0:62e456e60083 339 vt.PutBoxDrawingChar( 'w' );
Wayne Roberts 0:62e456e60083 340 for( int8_t i = 0; i <= 64; i++ )
Wayne Roberts 0:62e456e60083 341 {
Wayne Roberts 0:62e456e60083 342 vt.PutBoxDrawingChar( 'q' );
Wayne Roberts 0:62e456e60083 343 }
Wayne Roberts 0:62e456e60083 344 vt.PutBoxDrawingChar( 'u' );
Wayne Roberts 0:62e456e60083 345 vt.printf( "\r\n" );
Wayne Roberts 0:62e456e60083 346 }
Wayne Roberts 0:62e456e60083 347
Wayne Roberts 0:62e456e60083 348 void SerialDisplayDrawColSeparator( void )
Wayne Roberts 0:62e456e60083 349 {
Wayne Roberts 0:62e456e60083 350 vt.PutBoxDrawingChar( 'x' );
Wayne Roberts 0:62e456e60083 351 for( int8_t i = 0; i <= 11; i++ )
Wayne Roberts 0:62e456e60083 352 {
Wayne Roberts 0:62e456e60083 353 vt.PutBoxDrawingChar( ' ' );
Wayne Roberts 0:62e456e60083 354 }
Wayne Roberts 0:62e456e60083 355 vt.PutBoxDrawingChar( 't' );
Wayne Roberts 0:62e456e60083 356 for( int8_t i = 0; i <= 64; i++ )
Wayne Roberts 0:62e456e60083 357 {
Wayne Roberts 0:62e456e60083 358 vt.PutBoxDrawingChar( 'q' );
Wayne Roberts 0:62e456e60083 359 }
Wayne Roberts 0:62e456e60083 360 vt.PutBoxDrawingChar( 'u' );
Wayne Roberts 0:62e456e60083 361 vt.printf( "\r\n" );
Wayne Roberts 0:62e456e60083 362 }
Wayne Roberts 0:62e456e60083 363
Wayne Roberts 0:62e456e60083 364 void SerialDisplayDrawSeparator( void )
Wayne Roberts 0:62e456e60083 365 {
Wayne Roberts 0:62e456e60083 366 vt.PutBoxDrawingChar( 't' );
Wayne Roberts 0:62e456e60083 367 for( int8_t i = 0; i <= 11; i++ )
Wayne Roberts 0:62e456e60083 368 {
Wayne Roberts 0:62e456e60083 369 vt.PutBoxDrawingChar( 'q' );
Wayne Roberts 0:62e456e60083 370 }
Wayne Roberts 0:62e456e60083 371 vt.PutBoxDrawingChar( 'n' );
Wayne Roberts 0:62e456e60083 372 for( int8_t i = 0; i <= 64; i++ )
Wayne Roberts 0:62e456e60083 373 {
Wayne Roberts 0:62e456e60083 374 vt.PutBoxDrawingChar( 'q' );
Wayne Roberts 0:62e456e60083 375 }
Wayne Roberts 0:62e456e60083 376 vt.PutBoxDrawingChar( 'u' );
Wayne Roberts 0:62e456e60083 377 vt.printf( "\r\n" );
Wayne Roberts 0:62e456e60083 378 }
Wayne Roberts 0:62e456e60083 379
Wayne Roberts 0:62e456e60083 380 void SerialDisplayDrawLine( const char* firstCol, const char* secondCol )
Wayne Roberts 0:62e456e60083 381 {
Wayne Roberts 0:62e456e60083 382 vt.PutBoxDrawingChar( 'x' );
Wayne Roberts 0:62e456e60083 383 vt.printf( "%s", firstCol );
Wayne Roberts 0:62e456e60083 384 vt.PutBoxDrawingChar( 'x' );
Wayne Roberts 0:62e456e60083 385 vt.printf( "%s", secondCol );
Wayne Roberts 0:62e456e60083 386 vt.PutBoxDrawingChar( 'x' );
Wayne Roberts 0:62e456e60083 387 vt.printf( "\r\n" );
Wayne Roberts 0:62e456e60083 388 }
Wayne Roberts 0:62e456e60083 389
Wayne Roberts 0:62e456e60083 390 void SerialDisplayDrawBottomLine( void )
Wayne Roberts 0:62e456e60083 391 {
Wayne Roberts 0:62e456e60083 392 vt.PutBoxDrawingChar( 'm' );
Wayne Roberts 0:62e456e60083 393 for( int8_t i = 0; i <= 11; i++ )
Wayne Roberts 0:62e456e60083 394 {
Wayne Roberts 0:62e456e60083 395 vt.PutBoxDrawingChar( 'q' );
Wayne Roberts 0:62e456e60083 396 }
Wayne Roberts 0:62e456e60083 397 vt.PutBoxDrawingChar( 'v' );
Wayne Roberts 0:62e456e60083 398 for( int8_t i = 0; i <= 64; i++ )
Wayne Roberts 0:62e456e60083 399 {
Wayne Roberts 0:62e456e60083 400 vt.PutBoxDrawingChar( 'q' );
Wayne Roberts 0:62e456e60083 401 }
Wayne Roberts 0:62e456e60083 402 vt.PutBoxDrawingChar( 'j' );
Wayne Roberts 0:62e456e60083 403 vt.printf( "\r\n" );
Wayne Roberts 0:62e456e60083 404 }
Wayne Roberts 0:62e456e60083 405
Wayne Roberts 0:62e456e60083 406 void SerialDisplayInit( void )
Wayne Roberts 0:62e456e60083 407 {
Wayne Roberts 0:62e456e60083 408 vt.ClearScreen( 2 );
Wayne Roberts 0:62e456e60083 409 vt.SetCursorMode( false );
Wayne Roberts 0:62e456e60083 410 vt.SetCursorPos( 0, 0 );
Wayne Roberts 0:62e456e60083 411
Wayne Roberts 0:62e456e60083 412 // "+-----------------------------------------------------------------------------+" );
Wayne Roberts 0:62e456e60083 413 SerialDisplayDrawFirstLine( );
Wayne Roberts 0:62e456e60083 414 // "¦ LoRaWAN Demonstration Application ¦" );
Wayne Roberts 0:62e456e60083 415 SerialDisplayDrawTitle( " LoRaWAN Demonstration Application " );
Wayne Roberts 0:62e456e60083 416 // "+------------+----------------------------------------------------------------¦" );
Wayne Roberts 0:62e456e60083 417 SerialDisplayDrawTopSeparator( );
Wayne Roberts 0:62e456e60083 418 #ifdef LORAWAN_JOIN_EUI
Wayne Roberts 0:62e456e60083 419 // "¦ Activation ¦ [ ]Over The Air ¦" );
Wayne Roberts 0:62e456e60083 420 SerialDisplayDrawLine( " Activation ", " [ ]Over The Air " );
Wayne Roberts 0:62e456e60083 421 // "¦ ¦ DevEui [__ __ __ __ __ __ __ __] ¦" );
Wayne Roberts 0:62e456e60083 422 SerialDisplayDrawLine( " ", " DevEui [__ __ __ __ __ __ __ __] " );
Wayne Roberts 0:62e456e60083 423 // "¦ ¦ JoinEui [__ __ __ __ __ __ __ __] ¦" );
Wayne Roberts 0:62e456e60083 424 SerialDisplayDrawLine( " ", " JoinEui [__ __ __ __ __ __ __ __] " );
Wayne Roberts 0:62e456e60083 425 // "¦ ¦ NwkKey [__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __] ¦" );
Wayne Roberts 0:62e456e60083 426 SerialDisplayDrawLine( " ", " NwkKey [__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __] " );
Wayne Roberts 0:62e456e60083 427 #ifdef OPTNEG
Wayne Roberts 0:62e456e60083 428 SerialDisplayDrawLine( " ", " AppKey [__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __] " );
Wayne Roberts 0:62e456e60083 429 #endif
Wayne Roberts 0:62e456e60083 430 // "¦ +----------------------------------------------------------------¦" );
Wayne Roberts 0:62e456e60083 431 SerialDisplayDrawColSeparator( );
Wayne Roberts 0:62e456e60083 432 #endif /* LORAWAN_JOIN_EUI */
Wayne Roberts 0:62e456e60083 433 // "¦ ¦ [x]Personalisation ¦" );
Wayne Roberts 0:62e456e60083 434 SerialDisplayDrawLine( " ", " [ ]Personalisation " );
Wayne Roberts 0:62e456e60083 435 // "¦ ¦ NwkId [___] ¦" );
Wayne Roberts 0:62e456e60083 436 SerialDisplayDrawLine( " ", " NwkId [___] " );
Wayne Roberts 0:62e456e60083 437 // "¦ ¦ DevAddr [__ __ __ __] ¦" );
Wayne Roberts 0:62e456e60083 438 SerialDisplayDrawLine( " ", " DevAddr [__ __ __ __] " );
Wayne Roberts 0:62e456e60083 439 #ifdef OPTNEG
Wayne Roberts 0:62e456e60083 440 SerialDisplayDrawLine( " ", " FNwkSIntKey [__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __] ");
Wayne Roberts 0:62e456e60083 441 SerialDisplayDrawLine( " ", " SNwkSIntKey [__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __] ");
Wayne Roberts 0:62e456e60083 442 SerialDisplayDrawLine( " ", " NwkSEncKey [__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __] ");
Wayne Roberts 0:62e456e60083 443 #else
Wayne Roberts 0:62e456e60083 444 // "¦ ¦ NwkSKey [__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __] ¦" );
Wayne Roberts 0:62e456e60083 445 SerialDisplayDrawLine( " ", " NwkSKey [__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __] ");
Wayne Roberts 0:62e456e60083 446 #endif
Wayne Roberts 0:62e456e60083 447 // "¦ ¦ AppSKey [__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __] ¦" );
Wayne Roberts 0:62e456e60083 448 SerialDisplayDrawLine( " ", " AppSKey [__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __] ");
Wayne Roberts 0:62e456e60083 449 // "+------------+----------------------------------------------------------------¦" );
Wayne Roberts 0:62e456e60083 450 SerialDisplayDrawSeparator( );
Wayne Roberts 0:62e456e60083 451 // "¦ MAC params ¦ [ ]Confirmed / [ ]Unconfirmed ¦" );
Wayne Roberts 0:62e456e60083 452 SerialDisplayDrawLine( " MAC params ", " [ ]Confirmed / [ ]Unconfirmed " );
Wayne Roberts 0:62e456e60083 453 // "¦ ¦ ADR [ ] ¦" );
Wayne Roberts 0:62e456e60083 454 SerialDisplayDrawLine( " ", " ADR [ ] " );
Wayne Roberts 0:62e456e60083 455 // "¦ ¦ Duty cycle[ ] ¦" );
Wayne Roberts 0:62e456e60083 456 SerialDisplayDrawLine( " ", " Duty cycle[ ] " );
Wayne Roberts 0:62e456e60083 457 // "+------------+----------------------------------------------------------------¦" );
Wayne Roberts 0:62e456e60083 458 SerialDisplayDrawSeparator( );
Wayne Roberts 0:62e456e60083 459 // "¦ Network ¦ [ ]Public / [ ]Private ¦" );
Wayne Roberts 0:62e456e60083 460 SerialDisplayDrawLine( " Network ", " [ ]Public / [ ]Private " );
Wayne Roberts 0:62e456e60083 461 #ifdef LORAWAN_JOIN_EUI
Wayne Roberts 0:62e456e60083 462 // "¦ ¦ [ ]Joining / [ ]Joined ¦" );
Wayne Roberts 0:62e456e60083 463 SerialDisplayDrawLine( " ", " [ ]Joining / [ ]Joined " );
Wayne Roberts 0:62e456e60083 464 #endif /* LORAWAN_JOIN_EUI */
Wayne Roberts 0:62e456e60083 465 // "+------------+----------------------------------------------------------------¦" );
Wayne Roberts 0:62e456e60083 466 SerialDisplayDrawSeparator( );
Wayne Roberts 0:62e456e60083 467 // "¦ Uplink ¦ Acked [ ] ¦" );
Wayne Roberts 0:62e456e60083 468 SerialDisplayDrawLine( " Uplink ", " Acked [ ] " );
Wayne Roberts 0:62e456e60083 469 // "¦ ¦ Datarate [ ] ¦" );
Wayne Roberts 0:62e456e60083 470 SerialDisplayDrawLine( " ", " Datarate [ ] " );
Wayne Roberts 0:62e456e60083 471 // "¦ ¦ Counter [ ] ¦" );
Wayne Roberts 0:62e456e60083 472 SerialDisplayDrawLine( " ", " Counter [ ] " );
Wayne Roberts 0:62e456e60083 473 // "¦ ¦ Port [ ] ¦" );
Wayne Roberts 0:62e456e60083 474 SerialDisplayDrawLine( " ", " Port [ ] " );
Wayne Roberts 0:62e456e60083 475 // "¦ ¦ Data [__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ ¦" );
Wayne Roberts 0:62e456e60083 476 SerialDisplayDrawLine( " ", " Data [__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ " );
Wayne Roberts 0:62e456e60083 477 // "¦ ¦ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ ¦" );
Wayne Roberts 0:62e456e60083 478 SerialDisplayDrawLine( " ", " __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ " );
Wayne Roberts 0:62e456e60083 479 // "¦ ¦ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ ¦" );
Wayne Roberts 0:62e456e60083 480 SerialDisplayDrawLine( " ", " __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ " );
Wayne Roberts 0:62e456e60083 481 // "¦ ¦ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ ¦" );
Wayne Roberts 0:62e456e60083 482 SerialDisplayDrawLine( " ", " __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ " );
Wayne Roberts 0:62e456e60083 483 // "+------------+----------------------------------------------------------------¦" );
Wayne Roberts 0:62e456e60083 484 SerialDisplayDrawSeparator( );
Wayne Roberts 0:62e456e60083 485 // "¦ Downlink ¦ RSSI [ ] dBm ¦" );
Wayne Roberts 0:62e456e60083 486 SerialDisplayDrawLine( " Downlink ", " RSSI [ ] dBm " );
Wayne Roberts 0:62e456e60083 487 // "¦ [ ]Data ¦ SNR [ ] dB ¦" );
Wayne Roberts 0:62e456e60083 488 SerialDisplayDrawLine( " [ ]Data ", " SNR [ ] dB " );
Wayne Roberts 0:62e456e60083 489 // "¦ ¦ Counter [ ] ¦" );
Wayne Roberts 0:62e456e60083 490 // "¦ ¦ Counter [ ] ¦" );
Wayne Roberts 0:62e456e60083 491 SerialDisplayDrawLine( " ", " Counter [ ] " );
Wayne Roberts 0:62e456e60083 492 // "¦ ¦ Port [ ] ¦" );
Wayne Roberts 0:62e456e60083 493 SerialDisplayDrawLine( " ", " Port [ ] " );
Wayne Roberts 0:62e456e60083 494 // "¦ ¦ Data [__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ ¦" );
Wayne Roberts 0:62e456e60083 495 SerialDisplayDrawLine( " ", " Data [__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ " );
Wayne Roberts 0:62e456e60083 496 // "¦ ¦ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ ¦" );
Wayne Roberts 0:62e456e60083 497 SerialDisplayDrawLine( " ", " __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ " );
Wayne Roberts 0:62e456e60083 498 // "¦ ¦ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ ¦" );
Wayne Roberts 0:62e456e60083 499 SerialDisplayDrawLine( " ", " __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ " );
Wayne Roberts 0:62e456e60083 500 // "¦ ¦ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ ¦" );
Wayne Roberts 0:62e456e60083 501 SerialDisplayDrawLine( " ", " __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ " );
Wayne Roberts 0:62e456e60083 502 // "+------------+----------------------------------------------------------------+" );
Wayne Roberts 0:62e456e60083 503 SerialDisplayDrawBottomLine( );
Wayne Roberts 0:62e456e60083 504 vt.printf( "To refresh screen please hit 'r' key.\r\n" );
Wayne Roberts 0:62e456e60083 505 }
Wayne Roberts 0:62e456e60083 506
Wayne Roberts 0:62e456e60083 507 bool SerialDisplayReadable( void )
Wayne Roberts 0:62e456e60083 508 {
Wayne Roberts 0:62e456e60083 509 return vt.Readable( );
Wayne Roberts 0:62e456e60083 510 }
Wayne Roberts 0:62e456e60083 511
Wayne Roberts 0:62e456e60083 512 uint8_t SerialDisplayGetChar( void )
Wayne Roberts 0:62e456e60083 513 {
Wayne Roberts 0:62e456e60083 514 return vt.GetChar( );
Wayne Roberts 0:62e456e60083 515 }
Wayne Roberts 0:62e456e60083 516
Wayne Roberts 0:62e456e60083 517 #endif /* ENABLE_VT100 */
Wayne Roberts 0:62e456e60083 518