Modularizando o src

Dependencies:   EALib EthernetInterface_vz mbed-rtos mbed

Fork of header_main_colinas_V0-20-09-14 by VZTECH

Committer:
klauss
Date:
Fri Mar 13 19:40:56 2015 +0000
Revision:
106:a34fcf9f0e02
Parent:
105:a930035b6556
Child:
107:cf1e43414adb
bugfix do refresh/wake_all_up; agora o unico parametro passado ? o vetor de CBx, os dois buffers s?o locais

Who changed what in which revision?

UserRevisionLine numberNew contents of line
klauss 44:cc4996469404 1 #include "prompt.h"
klauss 45:c80574f24dc3 2
klauss 60:b4ec6beb3be3 3 bool flood_silence = false;
klauss 65:0b653cfe95db 4 bool delayed_flood = false;
klauss 63:0d95da692bb4 5
klauss 78:1353744f01e1 6 Timer tcp_timer;
klauss 105:a930035b6556 7
klauss 78:1353744f01e1 8 bool tcp_alive = false;
klauss 105:a930035b6556 9 bool serial_pc_pending = false;
klauss 19:ab2088e0dec6 10
klauss 58:af7e8788f106 11 char __debug_buf__[ DEBUGBUFSIZE ];
klauss 35:96885a7931f0 12 char * debug_buf = __debug_buf__;
klauss 58:af7e8788f106 13 char last_cmd[ DEBUGBUFSIZE ];
klauss 58:af7e8788f106 14 char tmp_cmd[ DEBUGBUFSIZE ] = "help";
klauss 30:8dfb6d8de53d 15 char last_debug_buf[ DEBUGBUFSIZE ] = "help";
klauss 105:a930035b6556 16 char eth_buffer[ __PROMPT_ETH_BUFFER_SIZE__ ];
klauss 105:a930035b6556 17 char gp_buff[ DEBUGBUFSIZE ];
klauss 60:b4ec6beb3be3 18
klauss 106:a34fcf9f0e02 19 FILE *fip, *fmask, *fgate, *fport, *fsip, *fsport, *fext, *fserext, *fudpport, *ftcpport, *ffwip, *ffwport, *fmax, *fmin, *fshift_port;
klauss 81:3656f00ab3db 20
klauss 19:ab2088e0dec6 21 uint8_t bufptr = 0;
klauss 35:96885a7931f0 22 uint8_t last_bufptr = 0;
klauss 19:ab2088e0dec6 23
klauss 105:a930035b6556 24 void init_prompt_eth()
klauss 105:a930035b6556 25 {
klauss 105:a930035b6556 26 int udp_bind = udp_client.bind( UDP_PORT_LISTENER );
klauss 105:a930035b6556 27 udp_client.set_blocking( false, 0 );
klauss 106:a34fcf9f0e02 28 if( debug_uart3 && !( from_eth ) ) pc.printf("\r\n******* Prompt eth UDP Ready [ %d ] *******\r\n", udp_bind );
klauss 19:ab2088e0dec6 29
klauss 105:a930035b6556 30 int tcp_bind = tcp_server.bind( TCP_PORT_LISTENER );
klauss 89:0fe315117b00 31 tcp_server.set_blocking( false, 0 );
klauss 105:a930035b6556 32 int tcp_listen = tcp_server.listen();
klauss 106:a34fcf9f0e02 33 if( debug_uart3 && !( from_eth ) ) pc.printf("\r\n******* Prompt eth TCP Ready [ %d, %d ] *******\r\n", tcp_bind, tcp_listen );
klauss 19:ab2088e0dec6 34 }
klauss 19:ab2088e0dec6 35
klauss 28:94aec56c6329 36 // main prompt process
klauss 105:a930035b6556 37 char * prompt_process( char * msg_from_cb, int length )
klauss 103:e3cabfc2f533 38 {
klauss 28:94aec56c6329 39 //FIXME dar flush na serial
klauss 19:ab2088e0dec6 40 volatile char b = 0;
klauss 19:ab2088e0dec6 41 static uint8_t bufret = 0;
klauss 30:8dfb6d8de53d 42 static Timer flood_timeout;
klauss 60:b4ec6beb3be3 43 static Timer flood_silence_timer;
klauss 60:b4ec6beb3be3 44 static uint8_t id_msg = 0x10;
klauss 60:b4ec6beb3be3 45 static int start_ext, end_ext, ext_count;
klauss 36:728498a78e1e 46 bool miss_match = true;
klauss 105:a930035b6556 47 uint8_t write_buffer[ CB_BUFFER_SIZE ];
klauss 103:e3cabfc2f533 48
klauss 103:e3cabfc2f533 49 if( flood_timeout.read() > 60 ) {
klauss 45:c80574f24dc3 50 pflood = 0;
klauss 45:c80574f24dc3 51 flood_timeout.stop();
klauss 45:c80574f24dc3 52 flood_timeout.reset();
klauss 45:c80574f24dc3 53 }
klauss 103:e3cabfc2f533 54
klauss 103:e3cabfc2f533 55 if( tcp_timer.read() >= TCP_IDLE_MAX_TIME ) {
klauss 103:e3cabfc2f533 56 tcp_alive = false;
klauss 103:e3cabfc2f533 57 tcp_timer.stop();
klauss 103:e3cabfc2f533 58 tcp_timer.reset();
klauss 103:e3cabfc2f533 59 tcp_session = false;
klauss 103:e3cabfc2f533 60 debug_buf = __debug_buf__;
klauss 103:e3cabfc2f533 61 bufptr = last_bufptr;
klauss 103:e3cabfc2f533 62 bufret = 0;
klauss 103:e3cabfc2f533 63 from_eth = false;
klauss 103:e3cabfc2f533 64 tcp_client.close();
klauss 103:e3cabfc2f533 65 return( NULL );
klauss 105:a930035b6556 66 }
klauss 105:a930035b6556 67
klauss 105:a930035b6556 68 if( udp_query )
klauss 105:a930035b6556 69 {
klauss 105:a930035b6556 70 if( msg_from_cb != NULL )
klauss 105:a930035b6556 71 {
klauss 105:a930035b6556 72 last_bufptr = bufptr;
klauss 105:a930035b6556 73 if( ( length > 2 ) && ( msg_from_cb[ length - 2 ] == '\r' ) ) msg_from_cb[ length - 2 ] = 0;
klauss 105:a930035b6556 74
klauss 105:a930035b6556 75 if( ( length > 1 ) && ( msg_from_cb[ length - 1 ] == '\n' ) ) msg_from_cb[ length - 1 ] = 0;
klauss 103:e3cabfc2f533 76
klauss 105:a930035b6556 77 if( ( length == 1 ) && msg_from_cb[ 0 ] == 0x0A ) strcpy( msg_from_cb, "\r" );
klauss 105:a930035b6556 78
klauss 105:a930035b6556 79 bufptr = strlen( msg_from_cb );
klauss 105:a930035b6556 80 debug_buf = msg_from_cb;
klauss 103:e3cabfc2f533 81 from_eth = true;
klauss 103:e3cabfc2f533 82 bufret = 1;
klauss 105:a930035b6556 83 }
klauss 105:a930035b6556 84 }
klauss 105:a930035b6556 85 else
klauss 105:a930035b6556 86 {
klauss 105:a930035b6556 87 if( !tcp_server.accept( tcp_client ) )
klauss 105:a930035b6556 88 {
klauss 105:a930035b6556 89 tcp_session = true;
klauss 105:a930035b6556 90 tcp_timer.start();
klauss 105:a930035b6556 91 last_bufptr = bufptr;
klauss 105:a930035b6556 92 for( register int i = 0; i < __PROMPT_ETH_BUFFER_SIZE__; i++ ) eth_buffer[ i ] = 0;
klauss 105:a930035b6556 93 }
klauss 105:a930035b6556 94 if( tcp_session && !udp_query )
klauss 105:a930035b6556 95 {
klauss 105:a930035b6556 96 tcp_client.set_blocking( false, 0 );
klauss 105:a930035b6556 97 //for( register int i = 0; i < __PROMPT_ETH_BUFFER_SIZE__; i++ ) eth_buffer[ i ] = 0;
klauss 105:a930035b6556 98 int n = tcp_client.receive( eth_buffer, sizeof( eth_buffer ) - 1 );
klauss 105:a930035b6556 99 if( n > 0 ) {
klauss 103:e3cabfc2f533 100 tcp_timer.reset();
klauss 105:a930035b6556 101
klauss 105:a930035b6556 102 if( ( n > 2 ) && ( eth_buffer[ n - 2 ] == '\r' ) ) eth_buffer[ n - 2 ] = 0;
klauss 105:a930035b6556 103
klauss 105:a930035b6556 104 if( ( n > 1 ) && ( eth_buffer[ n - 1 ] == '\n' ) ) eth_buffer[ n - 1 ] = 0;
klauss 105:a930035b6556 105
klauss 105:a930035b6556 106 if( ( n == 1 ) && eth_buffer[ 0 ] == 0x0A ) strcpy( eth_buffer, "\r" );
klauss 105:a930035b6556 107
klauss 105:a930035b6556 108 bufptr = strlen( eth_buffer );
klauss 105:a930035b6556 109 debug_buf = eth_buffer;
klauss 105:a930035b6556 110 from_eth = true;
klauss 105:a930035b6556 111 bufret = 1;
klauss 105:a930035b6556 112
klauss 105:a930035b6556 113 if( !( strcmp( eth_buffer, "quit" ) ) ) {
klauss 105:a930035b6556 114 tcp_timer.reset();
klauss 105:a930035b6556 115 debug_buf = __debug_buf__;
klauss 105:a930035b6556 116 bufptr = last_bufptr;
klauss 105:a930035b6556 117 from_eth = false;
klauss 105:a930035b6556 118 tcp_session = false;
klauss 105:a930035b6556 119 tcp_client.close();
klauss 105:a930035b6556 120 bufret = 0;
klauss 105:a930035b6556 121 return( NULL );
klauss 105:a930035b6556 122 }
klauss 105:a930035b6556 123 } else {
klauss 48:195c97f12e8e 124 debug_buf = __debug_buf__;
klauss 48:195c97f12e8e 125 bufptr = last_bufptr;
klauss 57:78f7191a8b69 126 from_eth = false;
klauss 45:c80574f24dc3 127 }
klauss 103:e3cabfc2f533 128 }
klauss 53:bb492a8f115a 129 }
klauss 105:a930035b6556 130
klauss 105:a930035b6556 131 if( ( !from_eth ) && ( !udp_query ) )
klauss 105:a930035b6556 132 {
klauss 105:a930035b6556 133 if( pc.readable() ) {
klauss 53:bb492a8f115a 134 b = pc.getc();
klauss 105:a930035b6556 135 if( b == 0x0D ) {
klauss 105:a930035b6556 136 // enter
klauss 53:bb492a8f115a 137 bufret = 1;
klauss 105:a930035b6556 138 if( from_eth ) serial_pc_pending = true;
klauss 105:a930035b6556 139 } else {
klauss 53:bb492a8f115a 140 pc.putc( b );
klauss 105:a930035b6556 141 if( b == 0x08 || b == 0x7F ) {
klauss 105:a930035b6556 142 // BS | DEL
klauss 105:a930035b6556 143 if( bufptr > 0 ) {
klauss 105:a930035b6556 144 __debug_buf__[ --bufptr ] = 0;
klauss 105:a930035b6556 145 }
klauss 105:a930035b6556 146 } else if( b == 0x09 ) {
klauss 53:bb492a8f115a 147 // ignore tab
klauss 105:a930035b6556 148 } else {
klauss 105:a930035b6556 149 //debug_msg("--%c,%d--%d--", b, bufptr, last_bufptr );
klauss 105:a930035b6556 150 __debug_buf__[ bufptr ] = b;
klauss 53:bb492a8f115a 151 bufptr++;
klauss 42:480335bdde12 152 }
klauss 104:62646ef786a3 153 last_bufptr = bufptr;
klauss 31:bb5fb28a77df 154 }
klauss 53:bb492a8f115a 155 }
klauss 48:195c97f12e8e 156 }
klauss 105:a930035b6556 157
klauss 105:a930035b6556 158 if( flood_silence ) {
klauss 105:a930035b6556 159 if( flood_silence_timer.read_ms() > 250 ) {
klauss 60:b4ec6beb3be3 160 char cmd[ 16 ] = "flood off";
klauss 60:b4ec6beb3be3 161 int str_end = strlen( cmd );
klauss 60:b4ec6beb3be3 162 cmd[ str_end ] = 0x0D;
klauss 60:b4ec6beb3be3 163 cmd[ str_end + 1 ] = 0x00;
klauss 105:a930035b6556 164
klauss 60:b4ec6beb3be3 165 int port = convert_ext_to_port( ext_count );
klauss 105:a930035b6556 166 send2callboxes( build_cb_package( ext_count, port, __PROMPT__, cmd, id_msg++, CB_BUFFER_SIZE - __VZ_HEADER_OFFSET__, write_buffer ) );
klauss 104:62646ef786a3 167 if( debug_uart3 && !( from_eth ) ) pc.printf("\r\nSilence sent to ext=%d port=%d", ext_count, port );
klauss 105:a930035b6556 168
klauss 105:a930035b6556 169 if( tcp_session && !udp_query ) {
klauss 60:b4ec6beb3be3 170 snprintf( eth_buffer, __PROMPT_ETH_BUFFER_SIZE__, "\r\nSilence sent to ext=%d port=%d", ext_count, port );
klauss 60:b4ec6beb3be3 171 tcp_client.send_all( eth_buffer, strlen( eth_buffer ) );
klauss 105:a930035b6556 172 } else if( udp_query ) {
klauss 60:b4ec6beb3be3 173 snprintf( eth_buffer, __PROMPT_ETH_BUFFER_SIZE__, "\r\nSilence sent to ext=%d port=%d", ext_count, port );
klauss 105:a930035b6556 174 udp_query_send_msg( eth_buffer );
klauss 60:b4ec6beb3be3 175 }
klauss 60:b4ec6beb3be3 176 flood_silence_timer.reset();
klauss 105:a930035b6556 177
klauss 103:e3cabfc2f533 178 // importante para o uso da funçao silence
klauss 105:a930035b6556 179 if( ++ext_count > end_ext ) {
klauss 60:b4ec6beb3be3 180 flood_silence = false;
klauss 60:b4ec6beb3be3 181 flood_silence_timer.stop();
klauss 60:b4ec6beb3be3 182 flood_silence_timer.reset();
klauss 105:a930035b6556 183
klauss 104:62646ef786a3 184 if( debug_uart3 && !( from_eth ) ) pc.printf("\r\n> " );
klauss 105:a930035b6556 185 if( tcp_session && !udp_query ) {
klauss 60:b4ec6beb3be3 186 snprintf( eth_buffer, __PROMPT_ETH_BUFFER_SIZE__, "\r\n> " );
klauss 60:b4ec6beb3be3 187 tcp_client.send_all( eth_buffer, strlen( eth_buffer ) );
klauss 105:a930035b6556 188 } else if( udp_query ) {
klauss 60:b4ec6beb3be3 189 snprintf( eth_buffer, __PROMPT_ETH_BUFFER_SIZE__, "\r\n> " );
klauss 105:a930035b6556 190 udp_query_send_msg( eth_buffer );
klauss 60:b4ec6beb3be3 191 }
klauss 60:b4ec6beb3be3 192 }
klauss 60:b4ec6beb3be3 193 }
klauss 60:b4ec6beb3be3 194 }
klauss 105:a930035b6556 195
klauss 105:a930035b6556 196 if( delayed_flood ) {
klauss 65:0b653cfe95db 197 tflood.start();
klauss 65:0b653cfe95db 198 tflood.reset();
klauss 65:0b653cfe95db 199 floodcount =0;
klauss 65:0b653cfe95db 200 pflood = 1;
klauss 65:0b653cfe95db 201 flood_timeout.start();
klauss 65:0b653cfe95db 202 delayed_flood = false;
klauss 104:62646ef786a3 203 if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rFlood ON\n\r");
klauss 105:a930035b6556 204 //FIXME avaliar melhor essa expressao
klauss 105:a930035b6556 205 if( from_eth ) {
klauss 65:0b653cfe95db 206 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Flood On\n\r" );
klauss 65:0b653cfe95db 207 }
klauss 65:0b653cfe95db 208 }
klauss 105:a930035b6556 209
klauss 105:a930035b6556 210 if( serial_pc_pending && !from_eth ) {
klauss 105:a930035b6556 211 bufret = 1;
klauss 105:a930035b6556 212 }
klauss 45:c80574f24dc3 213 // Prompt commands here
klauss 58:af7e8788f106 214 if ( bufret == 1 ) {
klauss 105:a930035b6556 215 static unsigned int promptcb_last_ext = 0;
klauss 105:a930035b6556 216 static unsigned int promptcb_last_port = 0;
klauss 55:2f5e7374af9d 217 static char promptcb_last_cmd[ 300 ];
klauss 60:b4ec6beb3be3 218
klauss 58:af7e8788f106 219 strcpy( tmp_cmd, debug_buf );
klauss 105:a930035b6556 220 if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "." ) ) {
klauss 45:c80574f24dc3 221 miss_match = false;
klauss 58:af7e8788f106 222 strcpy( debug_buf, last_cmd );
klauss 58:af7e8788f106 223 strcpy( tmp_cmd, debug_buf );
klauss 105:a930035b6556 224 } else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "+" ) ) {
klauss 59:e1e300880d2d 225 miss_match = false;
klauss 59:e1e300880d2d 226 strcpy( debug_buf, "flood on" );
klauss 59:e1e300880d2d 227 strcpy( tmp_cmd, debug_buf );
klauss 105:a930035b6556 228 } else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "-" ) ) {
klauss 59:e1e300880d2d 229 miss_match = false;
klauss 59:e1e300880d2d 230 strcpy( debug_buf, "flood off" );
klauss 59:e1e300880d2d 231 strcpy( tmp_cmd, debug_buf );
klauss 105:a930035b6556 232 } else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "++ ", 3 ) ) {
klauss 59:e1e300880d2d 233 miss_match = false;
klauss 65:0b653cfe95db 234 delayed_flood = true;
klauss 59:e1e300880d2d 235 int ext = atoi( debug_buf + 3 );
klauss 59:e1e300880d2d 236 sprintf( debug_buf, "pcb %i flood on", ext );
klauss 105:a930035b6556 237 } else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "-- ", 3 ) ) {
klauss 59:e1e300880d2d 238 miss_match = false;
klauss 59:e1e300880d2d 239 int ext = atoi( debug_buf + 3 );
klauss 104:62646ef786a3 240 if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rFlood OFF\n\r");
klauss 105:a930035b6556 241 if( from_eth ) {
klauss 59:e1e300880d2d 242 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Flood OFF\n\r" );
klauss 59:e1e300880d2d 243 }
klauss 59:e1e300880d2d 244 pflood = 0;
klauss 59:e1e300880d2d 245 tflood.stop();
klauss 59:e1e300880d2d 246 flood_timeout.reset();
klauss 105:a930035b6556 247 sprintf( debug_buf, "pcb %i flood off", ext );
klauss 45:c80574f24dc3 248 }
klauss 105:a930035b6556 249
klauss 48:195c97f12e8e 250 //tratamento dos enters
klauss 105:a930035b6556 251 if( !bufptr ) {
klauss 45:c80574f24dc3 252 miss_match = false;
klauss 105:a930035b6556 253 } else if( bufptr == 1 ) {
klauss 48:195c97f12e8e 254 if( debug_buf[ 0 ] == 0x0D || debug_buf[ 0 ] == 0x0D ) miss_match = false;
klauss 48:195c97f12e8e 255 }
klauss 105:a930035b6556 256
klauss 105:a930035b6556 257 if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "ifconfig" ) ) {
klauss 45:c80574f24dc3 258 miss_match = false;
klauss 104:62646ef786a3 259 if( debug_uart3 && !( from_eth ) ) pc.printf("\n\r");
klauss 45:c80574f24dc3 260 files('s');
klauss 106:a34fcf9f0e02 261 for( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0;
klauss 106:a34fcf9f0e02 262 bufptr = 0;
klauss 45:c80574f24dc3 263 }
klauss 105:a930035b6556 264
klauss 105:a930035b6556 265 else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "rx" ) ) {
klauss 62:07e5bdc9f8f7 266 miss_match = false;
klauss 62:07e5bdc9f8f7 267 rx = true;
klauss 62:07e5bdc9f8f7 268 }
klauss 105:a930035b6556 269
klauss 105:a930035b6556 270 else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "tx" ) ) {
klauss 63:0d95da692bb4 271 miss_match = false;
klauss 63:0d95da692bb4 272 tx = true;
klauss 63:0d95da692bb4 273 }
klauss 105:a930035b6556 274
klauss 105:a930035b6556 275 else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "stats" ) ) {
klauss 63:0d95da692bb4 276 miss_match = false;
klauss 63:0d95da692bb4 277 stats = true;
klauss 105:a930035b6556 278 } else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "reset_stats" ) ) {
klauss 63:0d95da692bb4 279 miss_match = false;
klauss 63:0d95da692bb4 280 r_stats = true;
klauss 63:0d95da692bb4 281 }
klauss 105:a930035b6556 282
klauss 105:a930035b6556 283 else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "format" ) ) {
klauss 45:c80574f24dc3 284 miss_match = false;
klauss 104:62646ef786a3 285 if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rFormatando o sistema de arquivos... espere o sistema reiniciar\n\r");
klauss 105:a930035b6556 286
klauss 105:a930035b6556 287 if( from_eth )
klauss 105:a930035b6556 288 {
klauss 105:a930035b6556 289 char msg[ 32 ];
klauss 105:a930035b6556 290 snprintf( msg, 32, "Not Allowed\n\r");
klauss 105:a930035b6556 291
klauss 105:a930035b6556 292 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 293 tcp_client.send_all( msg, strlen( msg ) );
klauss 105:a930035b6556 294 } else if( udp_query ) {
klauss 105:a930035b6556 295 udp_query_send_msg( msg );
klauss 105:a930035b6556 296 }
klauss 105:a930035b6556 297 } else {
klauss 62:07e5bdc9f8f7 298 files('e');
klauss 62:07e5bdc9f8f7 299 files('w');
klauss 62:07e5bdc9f8f7 300 __disable_irq();
klauss 62:07e5bdc9f8f7 301 NVIC_SystemReset();
klauss 42:480335bdde12 302 }
klauss 45:c80574f24dc3 303 }
klauss 45:c80574f24dc3 304
klauss 59:e1e300880d2d 305 else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "ipset ", 6 )) {
klauss 45:c80574f24dc3 306 miss_match = false;
klauss 54:448d57291be6 307 set_ip( debug_buf + 6 );
klauss 45:c80574f24dc3 308 files('s');
klauss 45:c80574f24dc3 309 }
klauss 105:a930035b6556 310
klauss 105:a930035b6556 311 else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "extset ", 7 ) ) {
klauss 45:c80574f24dc3 312 miss_match = false;
klauss 55:2f5e7374af9d 313 set_header_ext( atoi( debug_buf + 7 ) );
klauss 45:c80574f24dc3 314 files('s');
klauss 45:c80574f24dc3 315 }
klauss 105:a930035b6556 316
klauss 105:a930035b6556 317 else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "serextset ", 10 ) ) {
klauss 45:c80574f24dc3 318 miss_match = false;
klauss 55:2f5e7374af9d 319 set_server_ext( atoi( debug_buf + 10 ) );
klauss 45:c80574f24dc3 320 files('s');
klauss 45:c80574f24dc3 321 }
klauss 45:c80574f24dc3 322
klauss 105:a930035b6556 323 else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "maskset ",8 ) ) {
klauss 45:c80574f24dc3 324 miss_match = false;
klauss 55:2f5e7374af9d 325 set_mask( debug_buf + 8 );
klauss 45:c80574f24dc3 326 files('s');
klauss 45:c80574f24dc3 327 }
klauss 45:c80574f24dc3 328
klauss 105:a930035b6556 329 else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "gatewayset ",11 ) ) {
klauss 45:c80574f24dc3 330 miss_match = false;
klauss 55:2f5e7374af9d 331 set_gateway( debug_buf + 11 );
klauss 45:c80574f24dc3 332 files('s');
klauss 45:c80574f24dc3 333 }
klauss 45:c80574f24dc3 334
klauss 105:a930035b6556 335 else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "msipport ",9 ) ) {
klauss 45:c80574f24dc3 336 miss_match = false;
klauss 55:2f5e7374af9d 337 set_header_sip_port( atoi( debug_buf + 9 ) );
klauss 45:c80574f24dc3 338 files('s');
klauss 45:c80574f24dc3 339 }
klauss 45:c80574f24dc3 340
klauss 105:a930035b6556 341 else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "serverip ",9 ) ) {
klauss 45:c80574f24dc3 342 miss_match = false;
klauss 55:2f5e7374af9d 343 set_server_ip( debug_buf + 9 );
klauss 45:c80574f24dc3 344 files('s');
klauss 45:c80574f24dc3 345 }
klauss 105:a930035b6556 346
klauss 105:a930035b6556 347 else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "maxext ", 7 ) ) {
klauss 81:3656f00ab3db 348 miss_match = false;
klauss 81:3656f00ab3db 349 set_max_ext( atoi( debug_buf + 7 ) );
klauss 81:3656f00ab3db 350 files('s');
klauss 81:3656f00ab3db 351 }
klauss 105:a930035b6556 352
klauss 105:a930035b6556 353 else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "minext ", 7 ) ) {
klauss 81:3656f00ab3db 354 miss_match = false;
klauss 81:3656f00ab3db 355 set_min_ext( atoi( debug_buf + 7 ) );
klauss 81:3656f00ab3db 356 files('s');
klauss 81:3656f00ab3db 357 }
klauss 45:c80574f24dc3 358
klauss 105:a930035b6556 359 else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "ssport ", 7 ) ) {
klauss 45:c80574f24dc3 360 miss_match = false;
klauss 55:2f5e7374af9d 361 set_server_port( atoi( debug_buf + 7 ) );
klauss 45:c80574f24dc3 362 files('s');
klauss 45:c80574f24dc3 363 }
klauss 105:a930035b6556 364
klauss 105:a930035b6556 365 else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "fw_ip ", 6 ) ) {
klauss 99:e80850c51106 366 miss_match = false;
klauss 99:e80850c51106 367 set_fw_ip( debug_buf + 6 );
klauss 99:e80850c51106 368 files('s');
klauss 99:e80850c51106 369 }
klauss 105:a930035b6556 370
klauss 105:a930035b6556 371 else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "fw_port ", 8 ) ) {
klauss 99:e80850c51106 372 miss_match = false;
klauss 99:e80850c51106 373 set_fw_port( atoi( debug_buf + 8 ) );
klauss 99:e80850c51106 374 files('s');
klauss 99:e80850c51106 375 }
klauss 106:a34fcf9f0e02 376
klauss 106:a34fcf9f0e02 377 else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "shift_port ", 11 ) ) {
klauss 106:a34fcf9f0e02 378 miss_match = false;
klauss 106:a34fcf9f0e02 379 set_shift_port( atoi( debug_buf + 11 ) );
klauss 106:a34fcf9f0e02 380 files('s');
klauss 106:a34fcf9f0e02 381 }
klauss 45:c80574f24dc3 382
klauss 105:a930035b6556 383 else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "dconfig" ) ) {
klauss 45:c80574f24dc3 384 miss_match = false;
klauss 50:d9b6577a70f5 385 files('e');
klauss 45:c80574f24dc3 386 files('w');
klauss 45:c80574f24dc3 387 files('s');
klauss 45:c80574f24dc3 388 }
klauss 45:c80574f24dc3 389
klauss 105:a930035b6556 390 else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "reset" ) ) {
klauss 45:c80574f24dc3 391 miss_match = false;
klauss 104:62646ef786a3 392 if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rJob is done\n\r");
klauss 105:a930035b6556 393 if( from_eth ) {
klauss 45:c80574f24dc3 394 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Job is done\n\r");
klauss 45:c80574f24dc3 395 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 396 if( tcp_session && !udp_query ) {
klauss 45:c80574f24dc3 397 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 45:c80574f24dc3 398 tcp_client.close();
klauss 105:a930035b6556 399 } else if( udp_query ) {
klauss 105:a930035b6556 400 udp_query_send_msg( debug_buf );
klauss 42:480335bdde12 401 }
klauss 45:c80574f24dc3 402 }
klauss 48:195c97f12e8e 403 __disable_irq();
klauss 45:c80574f24dc3 404 NVIC_SystemReset();
klauss 45:c80574f24dc3 405 }
klauss 45:c80574f24dc3 406
klauss 105:a930035b6556 407 else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "dog" ) ) {
klauss 45:c80574f24dc3 408 miss_match = false;
klauss 104:62646ef786a3 409 if( debug_uart3 && !( from_eth ) ) pc.printf("\n\r MUUUUUUUuuuuUUUUUU - I'm not a dog!!!! \n\r");
klauss 105:a930035b6556 410 if( from_eth ) {
klauss 45:c80574f24dc3 411 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "MUUUUUUUuuuuUUUUUU - I'm not a dog!!!!\n\r");
klauss 105:a930035b6556 412 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 413 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 414 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 415 } else if( udp_query ) {
klauss 105:a930035b6556 416 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 417 }
klauss 45:c80574f24dc3 418 }
klauss 45:c80574f24dc3 419 }
klauss 105:a930035b6556 420
klauss 105:a930035b6556 421 else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "test" ) ) {
klauss 105:a930035b6556 422 miss_match = false;
klauss 105:a930035b6556 423 debug_msg("Test something");
klauss 105:a930035b6556 424 }
klauss 48:195c97f12e8e 425
klauss 106:a34fcf9f0e02 426 else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "deleted" ) ) {
klauss 106:a34fcf9f0e02 427 miss_match = false;
klauss 106:a34fcf9f0e02 428 send_msg("::%d::", deleted_sip );
klauss 106:a34fcf9f0e02 429 }
klauss 106:a34fcf9f0e02 430
klauss 105:a930035b6556 431 else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "missed" ) ) {
klauss 105:a930035b6556 432 miss_match = false;
klauss 105:a930035b6556 433 missed_send_udp_pkg = true;
klauss 105:a930035b6556 434 }
klauss 105:a930035b6556 435
klauss 105:a930035b6556 436 else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "reset_missed" ) ) {
klauss 105:a930035b6556 437 miss_match = false;
klauss 105:a930035b6556 438 reset_missed_send_udp_pkg = true;
klauss 105:a930035b6556 439 }
klauss 105:a930035b6556 440
klauss 105:a930035b6556 441 else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "ftq" ) ) {
klauss 100:09a23fcd3bdf 442 miss_match = false;
klauss 104:62646ef786a3 443 if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rFTQ ON\n\r" );
klauss 105:a930035b6556 444 send_msg("FTQ On");
klauss 105:a930035b6556 445 /*
klauss 105:a930035b6556 446 if( from_eth ) {
klauss 105:a930035b6556 447 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "FTQ On\n\r" );
klauss 105:a930035b6556 448 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 449 }
klauss 105:a930035b6556 450 */
klauss 105:a930035b6556 451 big_bug_pkg = true;
klauss 100:09a23fcd3bdf 452 }
klauss 105:a930035b6556 453
klauss 105:a930035b6556 454 else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "ktq" ) ) {
klauss 100:09a23fcd3bdf 455 miss_match = false;
klauss 104:62646ef786a3 456 if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rFTQ!!!\n\r" );
klauss 105:a930035b6556 457 send_msg("FTQ");
klauss 105:a930035b6556 458 /*
klauss 105:a930035b6556 459 if( from_eth ) {
klauss 105:a930035b6556 460 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "FTQ!!!\n\r" );
klauss 105:a930035b6556 461 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 462 }
klauss 105:a930035b6556 463 */
klauss 105:a930035b6556 464 flood_bug_pkg = !flood_bug_pkg;
klauss 100:09a23fcd3bdf 465 }
klauss 105:a930035b6556 466
klauss 105:a930035b6556 467 else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "ls" ) ) {
klauss 62:07e5bdc9f8f7 468 miss_match = false;
klauss 62:07e5bdc9f8f7 469 list = true;
klauss 62:07e5bdc9f8f7 470 }
klauss 105:a930035b6556 471
klauss 105:a930035b6556 472 else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "ls -l" ) ) {
klauss 81:3656f00ab3db 473 miss_match = false;
klauss 81:3656f00ab3db 474 long_list = true;
klauss 81:3656f00ab3db 475 }
klauss 105:a930035b6556 476
klauss 105:a930035b6556 477 else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "tt" ) ) {
klauss 53:bb492a8f115a 478 miss_match = false;
klauss 62:07e5bdc9f8f7 479 main_test = !main_test;
klauss 53:bb492a8f115a 480 }
klauss 105:a930035b6556 481
klauss 105:a930035b6556 482 else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "size" ) ) {
klauss 104:62646ef786a3 483 miss_match = false;
klauss 104:62646ef786a3 484 sizes = !sizes;
klauss 104:62646ef786a3 485 }
klauss 105:a930035b6556 486
klauss 105:a930035b6556 487 else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "show_sip" ) ) {
klauss 97:8985817e8847 488 miss_match = false;
klauss 97:8985817e8847 489 show_sip = true;
klauss 97:8985817e8847 490 }
klauss 105:a930035b6556 491
klauss 105:a930035b6556 492 else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "reset_cks" ) ) {
klauss 52:12930cef17c4 493 miss_match = false;
klauss 52:12930cef17c4 494 reset_cks = true;
klauss 52:12930cef17c4 495 }
klauss 105:a930035b6556 496
klauss 64:5b011d5707d2 497 //replaced by ls
klauss 105:a930035b6556 498 else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "status" ) ) {
klauss 48:195c97f12e8e 499 miss_match = false;
klauss 64:5b011d5707d2 500 list = true;
klauss 64:5b011d5707d2 501 }
klauss 105:a930035b6556 502
klauss 105:a930035b6556 503 else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "wdt" ) ) {
klauss 81:3656f00ab3db 504 miss_match = false;
klauss 81:3656f00ab3db 505 debug_wdt = true;
klauss 81:3656f00ab3db 506 }
klauss 105:a930035b6556 507
klauss 105:a930035b6556 508 else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "eth" ) ) {
klauss 81:3656f00ab3db 509 miss_match = false;
klauss 81:3656f00ab3db 510 debug_eth = true;
klauss 81:3656f00ab3db 511 }
klauss 105:a930035b6556 512
klauss 105:a930035b6556 513 else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "types" ) ) {
klauss 104:62646ef786a3 514 miss_match = false;
klauss 105:a930035b6556 515
klauss 105:a930035b6556 516 //send_msg("hex :: dec :: Type \n\r0x00 :: 0 :: boot \n\r0x02 :: 2 :: registry \n\r0x04 :: 4 :: invite \n\r0x08 :: 8 :: audio \n\r0x10 :: 16 :: telemetry \n\r0x20 :: 32 :: cb_bye \n\r0x01 :: 1 :: prompt \n\r0x40 :: 64 :: flood" );
klauss 105:a930035b6556 517
klauss 104:62646ef786a3 518 if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rhex :: dec :: Type \n\r0x00 :: 0 :: boot \n\r0x02 :: 2 :: registry \n\r0x04 :: 4 :: invite \n\r0x08 :: 8 :: audio \n\r0x10 :: 16 :: telemetry \n\r0x20 :: 32 :: cb_bye \n\r0x01 :: 1 :: prompt \n\r0x40 :: 64 :: flood \n\r" );
klauss 105:a930035b6556 519
klauss 105:a930035b6556 520 if( from_eth ) {
klauss 105:a930035b6556 521 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "hex :: dec :: Type \n\r0x00 :: 0 :: boot \n\r0x02 :: 2 :: registry \n\r0x04 :: 4 :: invite \n\r0x08 :: 8 :: audio \n\r0x10 :: 16 :: telemetry \n\r0x20 :: 32 :: cb_bye \n\r0x01 :: 1 :: prompt \n\r0x40 :: 64 :: flood\n\r");
klauss 105:a930035b6556 522 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 523 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 524 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 525 } else if( udp_query ) {
klauss 105:a930035b6556 526 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 527 }
klauss 64:5b011d5707d2 528 }
klauss 48:195c97f12e8e 529 }
klauss 105:a930035b6556 530
klauss 105:a930035b6556 531 else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "protocol" ) ) {
klauss 64:5b011d5707d2 532 miss_match = false;
klauss 105:a930035b6556 533
klauss 105:a930035b6556 534 if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\r| E | E | P | P | C | C | T | [ Seq_num | Audio ] | 14[ Clock | Audio ] | [ TS | Audio ] | ... |\n\r \n\rE = Ext = Ramal\n\r \n\rP = Port = Porta\n\r \n\rC = Checksum\n\r \n\rT = Type = Tipo\n\r \n\rSeq_num = Sequence Number = Numero de sequencia\n\r \n\rClock = 14 bytes to sync\n\r \n\r... = demais CB_BUFFER_SIZE - __VZ_HEADER_OFFSET__ bytes\n\r" );
klauss 105:a930035b6556 535
klauss 105:a930035b6556 536 if( from_eth ) {
klauss 105:a930035b6556 537 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "| E | E | P | P | C | C | T | [ Seq_num | Audio ] | 14[ Clock | Audio ] | [ TS | Audio ] | ... |\n\r \n\rE = Ext = Ramal\n\r \n\rP = Port = Porta\n\r \n\rC = Checksum\n\r \n\rT = Type = Tipo\n\r \n\rSeq_num = Sequence Number = Numero de sequencia\n\r \n\rClock = 14 bytes to sync\n\r \n\r... = demais CB_BUFFER_SIZE - __VZ_HEADER_OFFSET__ bytes\n\r");
klauss 105:a930035b6556 538 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 539 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 540 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 541 } else if( udp_query ) {
klauss 105:a930035b6556 542 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 543 }
klauss 64:5b011d5707d2 544 }
klauss 64:5b011d5707d2 545 }
klauss 105:a930035b6556 546
klauss 105:a930035b6556 547 else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "flood ", 6 ) ) {
klauss 105:a930035b6556 548 if (xmemmatch( (uint8_t*)(debug_buf+6), (uint8_t*) "on", 2 ) ) {
klauss 45:c80574f24dc3 549 miss_match = false;
klauss 104:62646ef786a3 550 if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rFlood ON\n\r");
klauss 105:a930035b6556 551
klauss 105:a930035b6556 552 if( from_eth ) {
klauss 105:a930035b6556 553 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Flood On\n\r");
klauss 45:c80574f24dc3 554 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 555 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 556 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 557 } else if( udp_query ) {
klauss 105:a930035b6556 558 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 559 }
klauss 105:a930035b6556 560 }
klauss 45:c80574f24dc3 561 tflood.start();
klauss 45:c80574f24dc3 562 tflood.reset();
klauss 45:c80574f24dc3 563 floodcount =0;
klauss 45:c80574f24dc3 564 pflood = 1;
klauss 45:c80574f24dc3 565 flood_timeout.start();
klauss 45:c80574f24dc3 566 }
klauss 105:a930035b6556 567
klauss 105:a930035b6556 568 if (xmemmatch( (uint8_t*)(debug_buf+6), (uint8_t*) "more", 4 ) ) {
klauss 61:06e77dff6f00 569 miss_match = false;
klauss 104:62646ef786a3 570 if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rFlood ON\n\r");
klauss 105:a930035b6556 571 if( from_eth ) {
klauss 105:a930035b6556 572 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Flood On\n\r");
klauss 105:a930035b6556 573 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 574 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 575 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 576 } else if( udp_query ) {
klauss 105:a930035b6556 577 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 578 }
klauss 61:06e77dff6f00 579 }
klauss 105:a930035b6556 580
klauss 61:06e77dff6f00 581 tflood.start();
klauss 61:06e77dff6f00 582 tflood.reset();
klauss 61:06e77dff6f00 583 floodcount = 0;
klauss 61:06e77dff6f00 584 pflood = 1;
klauss 61:06e77dff6f00 585 }
klauss 105:a930035b6556 586
klauss 60:b4ec6beb3be3 587 if (xmemmatch( (uint8_t*)(debug_buf+6), (uint8_t*) "off", 3 )) {
klauss 45:c80574f24dc3 588 miss_match = false;
klauss 104:62646ef786a3 589 if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rFlood OFF\n\r");
klauss 105:a930035b6556 590
klauss 105:a930035b6556 591 if( from_eth ) {
klauss 105:a930035b6556 592 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Flood Off\n\r");
klauss 45:c80574f24dc3 593 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 594 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 595 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 596 } else if( udp_query ) {
klauss 105:a930035b6556 597 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 598 }
klauss 42:480335bdde12 599 }
klauss 45:c80574f24dc3 600 pflood = 0;
klauss 45:c80574f24dc3 601 tflood.stop();
klauss 45:c80574f24dc3 602 flood_timeout.reset();
klauss 31:bb5fb28a77df 603 }
klauss 105:a930035b6556 604 } else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "silence ", 8 ) ) {
klauss 60:b4ec6beb3be3 605 miss_match = false;
klauss 60:b4ec6beb3be3 606 char *ref, *split;
klauss 105:a930035b6556 607
klauss 60:b4ec6beb3be3 608 strcpy( promptcb_last_cmd, debug_buf );
klauss 105:a930035b6556 609
klauss 105:a930035b6556 610 if( !( strcmp( debug_buf + 8, "-h" ) && strcmp( debug_buf + 8, "--help" ) ) ) {
klauss 104:62646ef786a3 611 if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rUsage :: silence start_ext end_ext | start_ext must be greater than end_ext\n\rObs : ( end_ext - start_ext ) < 50 ");
klauss 105:a930035b6556 612
klauss 105:a930035b6556 613 if( from_eth ) {
klauss 105:a930035b6556 614 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Usage :: silence start_ext end_ext | start_ext must be greater than end_ext\n\rObs : ( end_ext - start_ext ) < 50 ");
klauss 105:a930035b6556 615 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 616 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 617 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 618 } else if( udp_query ) {
klauss 105:a930035b6556 619 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 620 }
klauss 65:0b653cfe95db 621 }
klauss 105:a930035b6556 622 } else {
klauss 65:0b653cfe95db 623 ref = debug_buf;
klauss 105:a930035b6556 624
klauss 65:0b653cfe95db 625 split = strtok( debug_buf + 8, " " );
klauss 105:a930035b6556 626
klauss 65:0b653cfe95db 627 start_ext = atoi( split );
klauss 105:a930035b6556 628
klauss 65:0b653cfe95db 629 split += strlen( split ) + 1;
klauss 105:a930035b6556 630
klauss 65:0b653cfe95db 631 end_ext = atoi( split );
klauss 105:a930035b6556 632
klauss 65:0b653cfe95db 633 debug_buf = ref;
klauss 105:a930035b6556 634
klauss 105:a930035b6556 635 if( start_ext < end_ext && ( end_ext - start_ext ) < 50 ) {
klauss 65:0b653cfe95db 636 if( start_ext % 2 ) start_ext--;
klauss 65:0b653cfe95db 637 if( !( end_ext % 2 ) ) end_ext++;
klauss 105:a930035b6556 638
klauss 65:0b653cfe95db 639 ext_count = start_ext;
klauss 65:0b653cfe95db 640 flood_silence_timer.start();
klauss 105:a930035b6556 641 } else {
klauss 104:62646ef786a3 642 if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rUsage Error :: silence start_ext end_ext | start_ext must be greater than end_ext\n\rObs : ( end_ext - start_ext ) < 50 ");
klauss 105:a930035b6556 643
klauss 105:a930035b6556 644 if( from_eth ) {
klauss 105:a930035b6556 645 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Usage Error :: silence start_ext end_ext | start_ext must be greater than end_ext\n\rObs : ( end_ext - start_ext ) < 50 ");
klauss 105:a930035b6556 646 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 647 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 648 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 649 } else if( udp_query ) {
klauss 105:a930035b6556 650 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 651 }
klauss 65:0b653cfe95db 652 }
klauss 48:195c97f12e8e 653 }
klauss 65:0b653cfe95db 654 flood_silence = true;
klauss 48:195c97f12e8e 655 }
klauss 45:c80574f24dc3 656 }
klauss 105:a930035b6556 657
klauss 105:a930035b6556 658 else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "debug ",6 ) ) {
klauss 45:c80574f24dc3 659 if( xmemmatch( (uint8_t*)(debug_buf+6), (uint8_t*) "on",2 )) {
klauss 45:c80574f24dc3 660 miss_match = false;
klauss 104:62646ef786a3 661 if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rDebug ON\n\r");
klauss 105:a930035b6556 662 if( from_eth ) {
klauss 105:a930035b6556 663 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Debug On\n\r");
klauss 45:c80574f24dc3 664 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 665 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 666 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 667 } else if( udp_query ) {
klauss 105:a930035b6556 668 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 669 }
klauss 45:c80574f24dc3 670 }
klauss 78:1353744f01e1 671 debug_alive = true;
klauss 45:c80574f24dc3 672 }
klauss 45:c80574f24dc3 673 if( xmemmatch( (uint8_t*)(debug_buf+6), (uint8_t*) "off",3 )) {
klauss 45:c80574f24dc3 674 miss_match = false;
klauss 104:62646ef786a3 675 if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rDebug OFF\n\r");
klauss 105:a930035b6556 676 if( from_eth ) {
klauss 105:a930035b6556 677 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Debug Off\n\r");
klauss 45:c80574f24dc3 678 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 679 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 680 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 681 } else if( udp_query ) {
klauss 105:a930035b6556 682 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 683 }
klauss 42:480335bdde12 684 }
klauss 78:1353744f01e1 685 debug_alive = false;
klauss 31:bb5fb28a77df 686 }
klauss 105:a930035b6556 687 if( xmemmatch( (uint8_t*)(debug_buf+6), (uint8_t*) "show",4 ) ) {
klauss 45:c80574f24dc3 688 miss_match = false;
klauss 104:62646ef786a3 689 if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rdsip");
klauss 104:62646ef786a3 690 if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rdebug_alive");
klauss 104:62646ef786a3 691 if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rdebug_prompt");
klauss 104:62646ef786a3 692 if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rdebug_vector");
klauss 104:62646ef786a3 693 if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rdebug_cb");
klauss 104:62646ef786a3 694 if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rdebug_main");
klauss 104:62646ef786a3 695 if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rdcks");
klauss 104:62646ef786a3 696 if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rdebug_cb_rx");
klauss 104:62646ef786a3 697 if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rdebug_cb_tx*");
klauss 104:62646ef786a3 698 if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rdebug_eth_rx*");
klauss 104:62646ef786a3 699 if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rdebug_eth_tx*");
klauss 104:62646ef786a3 700 if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rdebug_file");
klauss 45:c80574f24dc3 701
klauss 105:a930035b6556 702 if( from_eth ) {
klauss 105:a930035b6556 703 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "\n\rdsip \n\rdebug_alive \n\rdebug_prompt \n\rdebug_vector \n\rdebug_cb \n\rdebug_main \n\rdcks \n\rdebug_cb_rx \n\rdebug_cb_tx* \n\rdebug_eth_rx* \n\rdebug_eth_tx* \n\rdebug_file\n\r");
klauss 42:480335bdde12 704 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 705 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 706 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 707 } else if( udp_query ) {
klauss 105:a930035b6556 708 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 709 }
klauss 42:480335bdde12 710 }
klauss 42:480335bdde12 711 }
klauss 45:c80574f24dc3 712 }
klauss 105:a930035b6556 713
klauss 105:a930035b6556 714 else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dsip ", 5 ) ) {
klauss 105:a930035b6556 715 if (xmemmatch( (uint8_t*)(debug_buf + 5 ), (uint8_t*) "on", 2 ) ) {
klauss 45:c80574f24dc3 716 miss_match = false;
klauss 104:62646ef786a3 717 if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rSip Debug ON\n\r" );
klauss 105:a930035b6556 718 if( from_eth ) {
klauss 105:a930035b6556 719 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Sip Debug On\n\r");
klauss 45:c80574f24dc3 720 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 721 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 722 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 723 } else if( udp_query ) {
klauss 105:a930035b6556 724 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 725 }
klauss 45:c80574f24dc3 726 }
klauss 78:1353744f01e1 727 debug_sip = true;
klauss 45:c80574f24dc3 728 }
klauss 50:d9b6577a70f5 729 if (xmemmatch( (uint8_t*)(debug_buf + 5 ), (uint8_t*) "off",3 )) {
klauss 45:c80574f24dc3 730 miss_match = false;
klauss 104:62646ef786a3 731 if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rSip Debug OFF\n\r" );
klauss 105:a930035b6556 732 if( from_eth ) {
klauss 105:a930035b6556 733 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Sip Debug Off\n\r");
klauss 45:c80574f24dc3 734 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 735 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 736 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 737 } else if( udp_query ) {
klauss 105:a930035b6556 738 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 739 }
klauss 45:c80574f24dc3 740 }
klauss 78:1353744f01e1 741 debug_sip = false;
klauss 78:1353744f01e1 742 }
klauss 78:1353744f01e1 743 }
klauss 78:1353744f01e1 744
klauss 105:a930035b6556 745 else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dmissed ", 8 ) ) {
klauss 105:a930035b6556 746 if (xmemmatch( (uint8_t*)(debug_buf + 8 ), (uint8_t*) "on", 2 ) ) {
klauss 105:a930035b6556 747 miss_match = false;
klauss 105:a930035b6556 748 if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rDebug Missed ON\n\r" );
klauss 105:a930035b6556 749 if( from_eth ) {
klauss 105:a930035b6556 750 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Debug Missed ON\n\r");
klauss 105:a930035b6556 751 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 752 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 753 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 754 } else if( udp_query ) {
klauss 105:a930035b6556 755 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 756 }
klauss 105:a930035b6556 757 }
klauss 105:a930035b6556 758 debug_missed = true;
klauss 105:a930035b6556 759 }
klauss 105:a930035b6556 760 if (xmemmatch( (uint8_t*)(debug_buf + 8 ), (uint8_t*) "off", 3 )) {
klauss 105:a930035b6556 761 miss_match = false;
klauss 105:a930035b6556 762 if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rDebug Missed Off\n\r" );
klauss 105:a930035b6556 763 if( from_eth ) {
klauss 105:a930035b6556 764 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Debug Missed Off\n\r");
klauss 105:a930035b6556 765 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 766 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 767 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 768 } else if( udp_query ) {
klauss 105:a930035b6556 769 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 770 }
klauss 105:a930035b6556 771 }
klauss 105:a930035b6556 772 debug_missed = false;
klauss 105:a930035b6556 773 }
klauss 105:a930035b6556 774 }
klauss 105:a930035b6556 775
klauss 105:a930035b6556 776 else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dreconnect ", 11 ) ) {
klauss 105:a930035b6556 777 if (xmemmatch( (uint8_t*)(debug_buf + 11 ), (uint8_t*) "on", 2 ) ) {
klauss 104:62646ef786a3 778 miss_match = false;
klauss 104:62646ef786a3 779 if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rReconnecet Debug ON\n\r" );
klauss 105:a930035b6556 780 if( from_eth ) {
klauss 105:a930035b6556 781 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Reconnecet Debug On\n\r");
klauss 104:62646ef786a3 782 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 783 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 784 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 785 } else if( udp_query ) {
klauss 105:a930035b6556 786 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 787 }
klauss 104:62646ef786a3 788 }
klauss 104:62646ef786a3 789 debug_reconnect = true;
klauss 104:62646ef786a3 790 }
klauss 104:62646ef786a3 791 if (xmemmatch( (uint8_t*)(debug_buf + 11 ), (uint8_t*) "off", 3 )) {
klauss 104:62646ef786a3 792 miss_match = false;
klauss 104:62646ef786a3 793 if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rReconnecet Debug OFF\n\r" );
klauss 105:a930035b6556 794 if( from_eth ) {
klauss 105:a930035b6556 795 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Reconnecet Debug Off\n\r");
klauss 104:62646ef786a3 796 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 797 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 798 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 799 } else if( udp_query ) {
klauss 105:a930035b6556 800 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 801 }
klauss 104:62646ef786a3 802 }
klauss 104:62646ef786a3 803 debug_reconnect = false;
klauss 104:62646ef786a3 804 }
klauss 104:62646ef786a3 805 }
klauss 105:a930035b6556 806
klauss 105:a930035b6556 807 else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "duart ", 6 ) ) {
klauss 105:a930035b6556 808 if (xmemmatch( (uint8_t*)(debug_buf + 6 ), (uint8_t*) "on", 2 ) ) {
klauss 100:09a23fcd3bdf 809 miss_match = false;
klauss 104:62646ef786a3 810 if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rEnable UART3 usage\n\r" );
klauss 105:a930035b6556 811 if( from_eth ) {
klauss 105:a930035b6556 812 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Enable UART3 usage\n\r");
klauss 100:09a23fcd3bdf 813 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 814 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 815 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 816 } else if( udp_query ) {
klauss 105:a930035b6556 817 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 818 }
klauss 100:09a23fcd3bdf 819 }
klauss 100:09a23fcd3bdf 820 debug_uart3 = true;
klauss 100:09a23fcd3bdf 821 }
klauss 100:09a23fcd3bdf 822 if (xmemmatch( (uint8_t*)(debug_buf + 6 ), (uint8_t*) "off",3 )) {
klauss 100:09a23fcd3bdf 823 miss_match = false;
klauss 104:62646ef786a3 824 if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rDisable UART3 usage\n\r" );
klauss 105:a930035b6556 825 if( from_eth ) {
klauss 105:a930035b6556 826 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Disable UART3 usage\n\r");
klauss 100:09a23fcd3bdf 827 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 828 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 829 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 830 } else if( udp_query ) {
klauss 105:a930035b6556 831 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 832 }
klauss 100:09a23fcd3bdf 833 }
klauss 100:09a23fcd3bdf 834 debug_uart3 = false;
klauss 100:09a23fcd3bdf 835 }
klauss 100:09a23fcd3bdf 836 }
klauss 105:a930035b6556 837
klauss 105:a930035b6556 838 else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dmatch ", 7 ) ) {
klauss 105:a930035b6556 839 if (xmemmatch( (uint8_t*)(debug_buf + 7 ), (uint8_t*) "on", 2 ) ) {
klauss 98:43b45f26b430 840 miss_match = false;
klauss 104:62646ef786a3 841 if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rPort Match Debug ON\n\r" );
klauss 105:a930035b6556 842 if( from_eth ) {
klauss 105:a930035b6556 843 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Port Match Debug On\n\r");
klauss 98:43b45f26b430 844 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 845 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 846 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 847 } else if( udp_query ) {
klauss 105:a930035b6556 848 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 849 }
klauss 98:43b45f26b430 850 }
klauss 98:43b45f26b430 851 debug_port_match = true;
klauss 98:43b45f26b430 852 }
klauss 98:43b45f26b430 853 if (xmemmatch( (uint8_t*)(debug_buf + 7 ), (uint8_t*) "off",3 )) {
klauss 98:43b45f26b430 854 miss_match = false;
klauss 104:62646ef786a3 855 if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rPort Match Debug OFF\n\r" );
klauss 105:a930035b6556 856 if( from_eth ) {
klauss 105:a930035b6556 857 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Port Match Debug Off\n\r");
klauss 98:43b45f26b430 858 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 859 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 860 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 861 } else if( udp_query ) {
klauss 105:a930035b6556 862 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 863 }
klauss 98:43b45f26b430 864 }
klauss 98:43b45f26b430 865 debug_port_match = false;
klauss 98:43b45f26b430 866 }
klauss 98:43b45f26b430 867 }
klauss 105:a930035b6556 868
klauss 105:a930035b6556 869 else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dmuted ", 7 ) ) {
klauss 105:a930035b6556 870 if (xmemmatch( (uint8_t*)(debug_buf + 7 ), (uint8_t*) "on", 2 ) ) {
klauss 81:3656f00ab3db 871 miss_match = false;
klauss 104:62646ef786a3 872 if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rMuted Debug ON\n\r" );
klauss 105:a930035b6556 873 if( from_eth ) {
klauss 105:a930035b6556 874 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Muted Debug On\n\r");
klauss 81:3656f00ab3db 875 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 876 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 877 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 878 } else if( udp_query ) {
klauss 105:a930035b6556 879 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 880 }
klauss 81:3656f00ab3db 881 }
klauss 81:3656f00ab3db 882 debug_muted = true;
klauss 81:3656f00ab3db 883 }
klauss 81:3656f00ab3db 884 if (xmemmatch( (uint8_t*)(debug_buf + 7 ), (uint8_t*) "off",3 )) {
klauss 81:3656f00ab3db 885 miss_match = false;
klauss 104:62646ef786a3 886 if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rMuted Debug OFF\n\r" );
klauss 105:a930035b6556 887 if( from_eth ) {
klauss 105:a930035b6556 888 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Muted Debug Off\n\r");
klauss 81:3656f00ab3db 889 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 890 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 891 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 892 } else if( udp_query ) {
klauss 105:a930035b6556 893 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 894 }
klauss 81:3656f00ab3db 895 }
klauss 81:3656f00ab3db 896 debug_muted = false;
klauss 81:3656f00ab3db 897 }
klauss 81:3656f00ab3db 898 }
klauss 105:a930035b6556 899
klauss 105:a930035b6556 900 else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dwdt ", 5 ) ) {
klauss 105:a930035b6556 901 if (xmemmatch( (uint8_t*)(debug_buf + 5 ), (uint8_t*) "on", 2 ) ) {
klauss 81:3656f00ab3db 902 miss_match = false;
klauss 104:62646ef786a3 903 if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rWdt Debug ON\n\r" );
klauss 105:a930035b6556 904 if( from_eth ) {
klauss 105:a930035b6556 905 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Wdt Debug On\n\r");
klauss 81:3656f00ab3db 906 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 907 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 908 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 909 } else if( udp_query ) {
klauss 105:a930035b6556 910 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 911 }
klauss 81:3656f00ab3db 912 }
klauss 81:3656f00ab3db 913 wdt_show = true;
klauss 81:3656f00ab3db 914 }
klauss 81:3656f00ab3db 915 if (xmemmatch( (uint8_t*)(debug_buf + 5 ), (uint8_t*) "off",3 )) {
klauss 81:3656f00ab3db 916 miss_match = false;
klauss 104:62646ef786a3 917 if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rWdt Debug OFF\n\r" );
klauss 105:a930035b6556 918 if( from_eth ) {
klauss 105:a930035b6556 919 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Wdt Debug Off\n\r");
klauss 81:3656f00ab3db 920 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 921 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 922 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 923 } else if( udp_query ) {
klauss 105:a930035b6556 924 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 925 }
klauss 81:3656f00ab3db 926 }
klauss 81:3656f00ab3db 927 wdt_show = false;
klauss 81:3656f00ab3db 928 }
klauss 81:3656f00ab3db 929 }
klauss 105:a930035b6556 930
klauss 105:a930035b6556 931 else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "drefresh ", 9 ) ) {
klauss 105:a930035b6556 932 if (xmemmatch( (uint8_t*)(debug_buf + 9 ), (uint8_t*) "on", 2 ) ) {
klauss 81:3656f00ab3db 933 miss_match = false;
klauss 104:62646ef786a3 934 if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rRefresh Debug ON\n\r" );
klauss 105:a930035b6556 935 if( from_eth ) {
klauss 105:a930035b6556 936 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Refresh Debug On\n\r");
klauss 81:3656f00ab3db 937 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 938 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 939 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 940 } else if( udp_query ) {
klauss 105:a930035b6556 941 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 942 }
klauss 81:3656f00ab3db 943 }
klauss 81:3656f00ab3db 944 debug_refresh= true;
klauss 81:3656f00ab3db 945 }
klauss 81:3656f00ab3db 946 if (xmemmatch( (uint8_t*)(debug_buf + 9 ), (uint8_t*) "off",3 )) {
klauss 81:3656f00ab3db 947 miss_match = false;
klauss 104:62646ef786a3 948 if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rRefresh Debug OFF\n\r" );
klauss 105:a930035b6556 949 if( from_eth ) {
klauss 105:a930035b6556 950 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Refresh Debug Off\n\r");
klauss 81:3656f00ab3db 951 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 952 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 953 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 954 } else if( udp_query ) {
klauss 105:a930035b6556 955 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 956 }
klauss 81:3656f00ab3db 957 }
klauss 81:3656f00ab3db 958 debug_refresh = false;
klauss 81:3656f00ab3db 959 }
klauss 81:3656f00ab3db 960 }
klauss 105:a930035b6556 961
klauss 105:a930035b6556 962 else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dping ", 6 ) ) {
klauss 105:a930035b6556 963 if (xmemmatch( (uint8_t*)(debug_buf + 6 ), (uint8_t*) "on", 2 ) ) {
klauss 78:1353744f01e1 964 miss_match = false;
klauss 104:62646ef786a3 965 if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rPing Debug ON\n\r" );
klauss 105:a930035b6556 966 if( from_eth ) {
klauss 105:a930035b6556 967 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Ping Debug On\n\r");
klauss 78:1353744f01e1 968 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 969 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 970 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 971 } else if( udp_query ) {
klauss 105:a930035b6556 972 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 973 }
klauss 78:1353744f01e1 974 }
klauss 78:1353744f01e1 975 debug_ping = true;
klauss 78:1353744f01e1 976 }
klauss 78:1353744f01e1 977 if (xmemmatch( (uint8_t*)(debug_buf + 6 ), (uint8_t*) "off",3 )) {
klauss 78:1353744f01e1 978 miss_match = false;
klauss 104:62646ef786a3 979 if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rPing Debug OFF\n\r" );
klauss 105:a930035b6556 980 if( from_eth ) {
klauss 105:a930035b6556 981 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Ping Debug Off\n\r");
klauss 78:1353744f01e1 982 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 983 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 984 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 985 } else if( udp_query ) {
klauss 105:a930035b6556 986 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 987 }
klauss 78:1353744f01e1 988 }
klauss 78:1353744f01e1 989 debug_ping= false;
klauss 78:1353744f01e1 990 }
klauss 78:1353744f01e1 991 }
klauss 105:a930035b6556 992
klauss 105:a930035b6556 993 else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dwu ", 4 ) ) {
klauss 105:a930035b6556 994 if (xmemmatch( (uint8_t*)(debug_buf + 4 ), (uint8_t*) "on", 2 ) ) {
klauss 78:1353744f01e1 995 miss_match = false;
klauss 104:62646ef786a3 996 if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rWake Up Debug ON\n\r" );
klauss 105:a930035b6556 997 if( from_eth ) {
klauss 105:a930035b6556 998 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Wake Up Debug On\n\r");
klauss 78:1353744f01e1 999 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 1000 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 1001 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 1002 } else if( udp_query ) {
klauss 105:a930035b6556 1003 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 1004 }
klauss 78:1353744f01e1 1005 }
klauss 78:1353744f01e1 1006 debug_wake = true;
klauss 78:1353744f01e1 1007 }
klauss 78:1353744f01e1 1008 if (xmemmatch( (uint8_t*)(debug_buf + 4 ), (uint8_t*) "off",3 )) {
klauss 78:1353744f01e1 1009 miss_match = false;
klauss 104:62646ef786a3 1010 if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rWake Up Debug OFF\n\r" );
klauss 105:a930035b6556 1011 if( from_eth ) {
klauss 105:a930035b6556 1012 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Wake Up Debug Off\n\r");
klauss 78:1353744f01e1 1013 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 1014 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 1015 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 1016 } else if( udp_query ) {
klauss 105:a930035b6556 1017 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 1018 }
klauss 78:1353744f01e1 1019 }
klauss 78:1353744f01e1 1020 debug_wake = false;
klauss 78:1353744f01e1 1021 }
klauss 78:1353744f01e1 1022 }
klauss 105:a930035b6556 1023
klauss 105:a930035b6556 1024 else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "tcp_alive ", 10 ) ) {
klauss 105:a930035b6556 1025 if (xmemmatch( (uint8_t*)(debug_buf + 10 ), (uint8_t*) "on", 2 ) ) {
klauss 78:1353744f01e1 1026 miss_match = false;
klauss 104:62646ef786a3 1027 if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rTCP don't drop mode on\n\r" );
klauss 105:a930035b6556 1028 if( from_eth ) {
klauss 105:a930035b6556 1029 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "TCP don't drop mode on\n\r");
klauss 78:1353744f01e1 1030 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 1031 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 1032 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 1033 } else if( udp_query ) {
klauss 105:a930035b6556 1034 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 1035 }
klauss 78:1353744f01e1 1036 }
klauss 78:1353744f01e1 1037 tcp_alive = true;
klauss 78:1353744f01e1 1038 }
klauss 78:1353744f01e1 1039 if (xmemmatch( (uint8_t*)(debug_buf + 10 ), (uint8_t*) "off",3 )) {
klauss 78:1353744f01e1 1040 miss_match = false;
klauss 104:62646ef786a3 1041 if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rTCP don't drop mode off\n\r" );
klauss 105:a930035b6556 1042 if( from_eth ) {
klauss 105:a930035b6556 1043 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "TCP don't drop mode off\n\r");
klauss 78:1353744f01e1 1044 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 1045 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 1046 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 1047 } else if( udp_query ) {
klauss 105:a930035b6556 1048 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 1049 }
klauss 78:1353744f01e1 1050 }
klauss 78:1353744f01e1 1051 tcp_alive = false;
klauss 78:1353744f01e1 1052 }
klauss 78:1353744f01e1 1053 }
klauss 105:a930035b6556 1054
klauss 105:a930035b6556 1055 else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "daging ",7 ) ) {
klauss 105:a930035b6556 1056 if (xmemmatch( (uint8_t*)(debug_buf + 7 ), (uint8_t*) "on", 2 ) ) {
klauss 78:1353744f01e1 1057 miss_match = false;
klauss 104:62646ef786a3 1058 if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rAging Debug ON\n\r" );
klauss 105:a930035b6556 1059 if( from_eth ) {
klauss 105:a930035b6556 1060 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Aging Debug On\n\r");
klauss 78:1353744f01e1 1061 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 1062 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 1063 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 1064 } else if( udp_query ) {
klauss 105:a930035b6556 1065 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 1066 }
klauss 78:1353744f01e1 1067 }
klauss 78:1353744f01e1 1068 debug_aging = true;
klauss 78:1353744f01e1 1069 }
klauss 78:1353744f01e1 1070 if (xmemmatch( (uint8_t*)(debug_buf + 7 ), (uint8_t*) "off",3 )) {
klauss 78:1353744f01e1 1071 miss_match = false;
klauss 104:62646ef786a3 1072 if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rAging Debug OFF\n\r" );
klauss 105:a930035b6556 1073 if( from_eth ) {
klauss 105:a930035b6556 1074 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Aging Debug Off\n\r");
klauss 78:1353744f01e1 1075 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 1076 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 1077 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 1078 } else if( udp_query ) {
klauss 105:a930035b6556 1079 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 1080 }
klauss 78:1353744f01e1 1081 }
klauss 78:1353744f01e1 1082 debug_aging = false;
klauss 78:1353744f01e1 1083 }
klauss 78:1353744f01e1 1084 }
klauss 105:a930035b6556 1085
klauss 105:a930035b6556 1086 else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dcpld ", 6 ) ) {
klauss 105:a930035b6556 1087 if (xmemmatch( (uint8_t*)(debug_buf + 6 ), (uint8_t*) "on", 2 ) ) {
klauss 78:1353744f01e1 1088 miss_match = false;
klauss 104:62646ef786a3 1089 if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rDCPLD Debug ON\n\r" );
klauss 105:a930035b6556 1090 if( from_eth ) {
klauss 105:a930035b6556 1091 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "DCPLD Debug On\n\r");
klauss 78:1353744f01e1 1092 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 1093 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 1094 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 1095 } else if( udp_query ) {
klauss 105:a930035b6556 1096 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 1097 }
klauss 78:1353744f01e1 1098 }
klauss 78:1353744f01e1 1099 debug_cpld = true;
klauss 105:a930035b6556 1100 debug_cb_rx = true;
klauss 105:a930035b6556 1101 debug_cb_tx = true;
klauss 78:1353744f01e1 1102 }
klauss 105:a930035b6556 1103 if (xmemmatch( (uint8_t*)(debug_buf + 6 ), (uint8_t*) "off",3 ) ) {
klauss 78:1353744f01e1 1104 miss_match = false;
klauss 104:62646ef786a3 1105 if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rDCPLD Debug OFF\n\r" );
klauss 105:a930035b6556 1106 if( from_eth ) {
klauss 105:a930035b6556 1107 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "DCPLD Debug Off\n\r");
klauss 78:1353744f01e1 1108 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 1109 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 1110 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 1111 } else if( udp_query ) {
klauss 105:a930035b6556 1112 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 1113 }
klauss 78:1353744f01e1 1114 }
klauss 78:1353744f01e1 1115 debug_cpld = false;
klauss 105:a930035b6556 1116 debug_cb_rx = false;
klauss 105:a930035b6556 1117 debug_cb_tx = false;
klauss 78:1353744f01e1 1118 }
klauss 78:1353744f01e1 1119 }
klauss 78:1353744f01e1 1120
klauss 105:a930035b6556 1121 else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dshowcpld ", 10 ) ) {
klauss 105:a930035b6556 1122 if (xmemmatch( (uint8_t*)(debug_buf + 10 ), (uint8_t*) "on", 2 ) ) {
klauss 105:a930035b6556 1123 miss_match = false;
klauss 105:a930035b6556 1124 if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rDCPLD Show Debug ON\n\r" );
klauss 105:a930035b6556 1125 if( from_eth ) {
klauss 105:a930035b6556 1126 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "DCPLD Show Debug On\n\r");
klauss 105:a930035b6556 1127 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 1128 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 1129 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 1130 } else if( udp_query ) {
klauss 105:a930035b6556 1131 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 1132 }
klauss 105:a930035b6556 1133 }
klauss 105:a930035b6556 1134 debug_show_cpld = true;
klauss 105:a930035b6556 1135 }
klauss 105:a930035b6556 1136 if (xmemmatch( (uint8_t*)(debug_buf + 10 ), (uint8_t*) "off",3 ) ) {
klauss 105:a930035b6556 1137 miss_match = false;
klauss 105:a930035b6556 1138 if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rDCPLD Show Debug OFF\n\r" );
klauss 105:a930035b6556 1139 if( from_eth ) {
klauss 105:a930035b6556 1140 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "DCPLD Show Debug Off\n\r");
klauss 105:a930035b6556 1141 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 1142 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 1143 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 1144 } else if( udp_query ) {
klauss 105:a930035b6556 1145 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 1146 }
klauss 105:a930035b6556 1147 }
klauss 105:a930035b6556 1148 debug_show_cpld = false;
klauss 105:a930035b6556 1149 }
klauss 105:a930035b6556 1150 }
klauss 105:a930035b6556 1151
klauss 105:a930035b6556 1152 else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dcks_err ", 9 ) ) {
klauss 105:a930035b6556 1153 if (xmemmatch( (uint8_t*)(debug_buf + 9 ), (uint8_t*) "on", 2 ) ) {
klauss 78:1353744f01e1 1154 miss_match = false;
klauss 104:62646ef786a3 1155 if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rCKS_ERR Debug ON\n\r" );
klauss 105:a930035b6556 1156 if( from_eth ) {
klauss 105:a930035b6556 1157 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "CKS_ERR Debug On\n\r");
klauss 78:1353744f01e1 1158 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 1159 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 1160 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 1161 } else if( udp_query ) {
klauss 105:a930035b6556 1162 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 1163 }
klauss 78:1353744f01e1 1164 }
klauss 78:1353744f01e1 1165 debug_cks_err = true;
klauss 78:1353744f01e1 1166 }
klauss 105:a930035b6556 1167 if (xmemmatch( (uint8_t*)(debug_buf + 9 ), (uint8_t*) "off", 3 ) ) {
klauss 78:1353744f01e1 1168 miss_match = false;
klauss 104:62646ef786a3 1169 if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rCKS_ERR Debug OFF\n\r" );
klauss 105:a930035b6556 1170 if( from_eth ) {
klauss 105:a930035b6556 1171 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "CKS_ERR Debug off\n\r");
klauss 78:1353744f01e1 1172 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 1173 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 1174 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 1175 } else if( udp_query ) {
klauss 105:a930035b6556 1176 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 1177 }
klauss 78:1353744f01e1 1178 }
klauss 78:1353744f01e1 1179 debug_cks_err = false;
klauss 78:1353744f01e1 1180 }
klauss 78:1353744f01e1 1181 }
klauss 105:a930035b6556 1182
klauss 105:a930035b6556 1183 else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dinvite ", 8 ) ) {
klauss 105:a930035b6556 1184 if( xmemmatch( (uint8_t*)(debug_buf + 8 ), (uint8_t*) "on", 2 ) ) {
klauss 78:1353744f01e1 1185 miss_match = false;
klauss 104:62646ef786a3 1186 if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rInvite Debug ON\n\r" );
klauss 105:a930035b6556 1187 if( from_eth ) {
klauss 105:a930035b6556 1188 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Invite Debug On\n\r");
klauss 78:1353744f01e1 1189 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 1190 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 1191 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 1192 } else if( udp_query ) {
klauss 105:a930035b6556 1193 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 1194 }
klauss 78:1353744f01e1 1195 }
klauss 81:3656f00ab3db 1196 debug_invite = true;
klauss 78:1353744f01e1 1197 }
klauss 78:1353744f01e1 1198 if( xmemmatch( (uint8_t*)(debug_buf + 8 ), (uint8_t*) "off",3 )) {
klauss 78:1353744f01e1 1199 miss_match = false;
klauss 104:62646ef786a3 1200 if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rInvite Debug OFF\n\r" );
klauss 105:a930035b6556 1201 if( from_eth ) {
klauss 105:a930035b6556 1202 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Invite Debug Off\n\r");
klauss 78:1353744f01e1 1203 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 1204 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 1205 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 1206 } else if( udp_query ) {
klauss 105:a930035b6556 1207 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 1208 }
klauss 78:1353744f01e1 1209 }
klauss 78:1353744f01e1 1210 debug_invite = 0;
klauss 45:c80574f24dc3 1211 }
klauss 45:c80574f24dc3 1212 }
klauss 105:a930035b6556 1213
klauss 105:a930035b6556 1214 else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dparallel ", 10 ) ) {
klauss 105:a930035b6556 1215 if( xmemmatch( ( uint8_t * )( debug_buf + 10 ), ( uint8_t * )"on", 2 ) ) {
klauss 72:895ca792c647 1216 miss_match = false;
klauss 104:62646ef786a3 1217 if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rParallel Write Debug ON\n\r" );
klauss 105:a930035b6556 1218 if( from_eth ) {
klauss 105:a930035b6556 1219 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "\n\rParallel Write Debug ON\n\r");
klauss 72:895ca792c647 1220 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 1221 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 1222 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 1223 } else if( udp_query ) {
klauss 105:a930035b6556 1224 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 1225 }
klauss 72:895ca792c647 1226 }
klauss 72:895ca792c647 1227 dparallel = true;
klauss 72:895ca792c647 1228 }
klauss 72:895ca792c647 1229 if( xmemmatch( ( uint8_t * )( debug_buf + 10 ), ( uint8_t *)"off", 3 )) {
klauss 72:895ca792c647 1230 miss_match = false;
klauss 104:62646ef786a3 1231 if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rParallel Write Debug OFF\n\r" );
klauss 105:a930035b6556 1232 if( from_eth ) {
klauss 105:a930035b6556 1233 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "\n\rParallel Write Debug Off\n\r");
klauss 72:895ca792c647 1234 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 1235 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 1236 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 1237 } else if( udp_query ) {
klauss 105:a930035b6556 1238 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 1239 }
klauss 72:895ca792c647 1240 }
klauss 72:895ca792c647 1241 dparallel = false;
klauss 72:895ca792c647 1242 }
klauss 72:895ca792c647 1243 }
klauss 105:a930035b6556 1244
klauss 105:a930035b6556 1245 else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dtelos ", 7 ) ) {
klauss 105:a930035b6556 1246 if (xmemmatch( (uint8_t*)( debug_buf + 7 ), (uint8_t*) "on", 2 ) ) {
klauss 53:bb492a8f115a 1247 miss_match = false;
klauss 104:62646ef786a3 1248 if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rTelemetry Debug ON\n\r" );
klauss 105:a930035b6556 1249 if( from_eth ) {
klauss 105:a930035b6556 1250 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "\n\rTelemetry Debug On\n\r");
klauss 53:bb492a8f115a 1251 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 1252 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 1253 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 1254 } else if( udp_query ) {
klauss 105:a930035b6556 1255 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 1256 }
klauss 53:bb492a8f115a 1257 }
klauss 53:bb492a8f115a 1258 debug_telemetry = true;
klauss 53:bb492a8f115a 1259 }
klauss 78:1353744f01e1 1260 if (xmemmatch( (uint8_t*)(debug_buf + 7 ), (uint8_t*) "off", 3 )) {
klauss 53:bb492a8f115a 1261 miss_match = false;
klauss 104:62646ef786a3 1262 if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rTelemetry Debug OFF\n\r" );
klauss 105:a930035b6556 1263 if( from_eth ) {
klauss 105:a930035b6556 1264 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "\n\rTelemetry Debug Off\n\r");
klauss 53:bb492a8f115a 1265 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 1266 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 1267 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 1268 } else if( udp_query ) {
klauss 105:a930035b6556 1269 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 1270 }
klauss 53:bb492a8f115a 1271 }
klauss 53:bb492a8f115a 1272 debug_telemetry = false;
klauss 53:bb492a8f115a 1273 }
klauss 53:bb492a8f115a 1274 }
klauss 105:a930035b6556 1275
klauss 105:a930035b6556 1276 else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dcks ", 5 ) ) {
klauss 105:a930035b6556 1277 if (xmemmatch( (uint8_t*)(debug_buf + 5 ), (uint8_t*) "on",2 ) ) {
klauss 45:c80574f24dc3 1278 miss_match = false;
klauss 104:62646ef786a3 1279 if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rCKS Debug ON\n\r" );
klauss 105:a930035b6556 1280 if( from_eth ) {
klauss 105:a930035b6556 1281 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "CKS Debug On\n\r");
klauss 45:c80574f24dc3 1282 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 1283 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 1284 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 1285 } else if( udp_query ) {
klauss 105:a930035b6556 1286 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 1287 }
klauss 45:c80574f24dc3 1288 }
klauss 78:1353744f01e1 1289 debug_cks = true;
klauss 45:c80574f24dc3 1290 }
klauss 50:d9b6577a70f5 1291 if (xmemmatch( (uint8_t*)(debug_buf + 5 ), (uint8_t*) "off",3 )) {
klauss 45:c80574f24dc3 1292 miss_match = false;
klauss 104:62646ef786a3 1293 if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rCKS Debug OFF\n\r" );
klauss 105:a930035b6556 1294 if( from_eth ) {
klauss 105:a930035b6556 1295 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "CKS Debug Off\n\r");
klauss 45:c80574f24dc3 1296 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 1297 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 1298 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 1299 } else if( udp_query ) {
klauss 105:a930035b6556 1300 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 1301 }
klauss 45:c80574f24dc3 1302 }
klauss 78:1353744f01e1 1303 debug_cks = false;
klauss 45:c80574f24dc3 1304 }
klauss 45:c80574f24dc3 1305 }
klauss 105:a930035b6556 1306
klauss 105:a930035b6556 1307 else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "promptcb ", 9 ) ) {
klauss 78:1353744f01e1 1308 miss_match = false;
klauss 105:a930035b6556 1309 uint8_t write_buffer[ CB_BUFFER_SIZE ];
klauss 78:1353744f01e1 1310 int ext,port;
klauss 78:1353744f01e1 1311 char *split, *ref, *cmd;
klauss 105:a930035b6556 1312
klauss 78:1353744f01e1 1313 ref = debug_buf;
klauss 105:a930035b6556 1314
klauss 78:1353744f01e1 1315 strcat( debug_buf, "\r" );
klauss 105:a930035b6556 1316
klauss 78:1353744f01e1 1317 split = strtok( debug_buf + 9, " " );
klauss 78:1353744f01e1 1318 ext = atoi( split );
klauss 78:1353744f01e1 1319 split = strtok( NULL, " " );
klauss 78:1353744f01e1 1320 port = atoi( split );
klauss 78:1353744f01e1 1321 split += strlen( split ) + 1;
klauss 78:1353744f01e1 1322 cmd = split;
klauss 105:a930035b6556 1323
klauss 78:1353744f01e1 1324 promptcb_last_ext = ext;
klauss 78:1353744f01e1 1325 promptcb_last_port = port;
klauss 105:a930035b6556 1326
klauss 78:1353744f01e1 1327 strcpy( promptcb_last_cmd, cmd );
klauss 78:1353744f01e1 1328 strcat( cmd, "\r\r\r\n" );
klauss 105:a930035b6556 1329
klauss 104:62646ef786a3 1330 if( debug_uart3 && !( from_eth ) ) pc.printf("\r\next=%d port=%d cmd=%s", ext, port, cmd );
klauss 105:a930035b6556 1331 send2callboxes( build_cb_package( ext, port, __PROMPT__, cmd, id_msg++, CB_BUFFER_SIZE - __VZ_HEADER_OFFSET__, write_buffer ) );
klauss 104:62646ef786a3 1332 if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rComando enviado");
klauss 105:a930035b6556 1333
klauss 105:a930035b6556 1334 if( from_eth ) {
klauss 78:1353744f01e1 1335 char eth_msg[ 512 ];
klauss 78:1353744f01e1 1336 snprintf( eth_msg, 512 - 1, "\r\next=%d port=%d cmd=%s\r\nComando enviado\n\r", ext, port, cmd );
klauss 105:a930035b6556 1337 if( tcp_session && !udp_query ) {
klauss 78:1353744f01e1 1338 tcp_client.send_all( eth_msg, strlen( eth_msg ) );
klauss 105:a930035b6556 1339 } else if( udp_query ) {
klauss 105:a930035b6556 1340 udp_query_send_msg( eth_msg );
klauss 78:1353744f01e1 1341 }
klauss 78:1353744f01e1 1342 }
klauss 105:a930035b6556 1343
klauss 78:1353744f01e1 1344 debug_buf = ref;
klauss 78:1353744f01e1 1345 bufptr = 0;
klauss 104:62646ef786a3 1346 for( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0;
klauss 78:1353744f01e1 1347 }
klauss 105:a930035b6556 1348
klauss 105:a930035b6556 1349 else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "bye ", 4 ) ) {
klauss 92:92df17f538a8 1350 miss_match = false;
klauss 92:92df17f538a8 1351 int ext,port;
klauss 92:92df17f538a8 1352 char *split, *ref;
klauss 105:a930035b6556 1353 uint8_t write_buffer[ CB_BUFFER_SIZE ], data[ CB_BUFFER_SIZE ];
klauss 105:a930035b6556 1354
klauss 92:92df17f538a8 1355 ref = debug_buf;
klauss 105:a930035b6556 1356
klauss 92:92df17f538a8 1357 strcat( debug_buf, "\r\r\r\n" );
klauss 105:a930035b6556 1358
klauss 92:92df17f538a8 1359 split = strtok( debug_buf + 4, " " );
klauss 92:92df17f538a8 1360 ext = atoi( split );
klauss 92:92df17f538a8 1361 port = convert_ext_to_port( ext );
klauss 105:a930035b6556 1362
klauss 104:62646ef786a3 1363 if( debug_uart3 && !( from_eth ) ) pc.printf("\r\next=%d port=%d request bye", ext, port );
klauss 105:a930035b6556 1364 send2callboxes( build_cb_package( ext, port, __CB_BYE__, (char * )data, 0x20, CB_BUFFER_SIZE - __VZ_HEADER_OFFSET__, write_buffer ) );
klauss 104:62646ef786a3 1365 if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rBye enviado");
klauss 105:a930035b6556 1366
klauss 105:a930035b6556 1367 if( from_eth ) {
klauss 92:92df17f538a8 1368 char eth_msg[ 512 ];
klauss 92:92df17f538a8 1369 snprintf( eth_msg, 512 - 1, "\r\next=%d port=%d request bye\n\r", ext, port );
klauss 105:a930035b6556 1370 if( tcp_session && !udp_query ) {
klauss 92:92df17f538a8 1371 tcp_client.send_all( eth_msg, strlen( eth_msg ) );
klauss 105:a930035b6556 1372 } else if( udp_query ) {
klauss 105:a930035b6556 1373 udp_query_send_msg( eth_msg );
klauss 92:92df17f538a8 1374 }
klauss 92:92df17f538a8 1375 }
klauss 105:a930035b6556 1376
klauss 92:92df17f538a8 1377 debug_buf = ref;
klauss 92:92df17f538a8 1378 bufptr = 0;
klauss 104:62646ef786a3 1379 for( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0;
klauss 92:92df17f538a8 1380 }
klauss 105:a930035b6556 1381
klauss 45:c80574f24dc3 1382 //promptcb ramal porta comando
klauss 50:d9b6577a70f5 1383 //FIXME colocar a parte eth de novo
klauss 59:e1e300880d2d 1384 else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "pcb ", 4 )) {
klauss 45:c80574f24dc3 1385 miss_match = false;
klauss 48:195c97f12e8e 1386 int ext,port;
klauss 54:448d57291be6 1387 char *split, *ref, *cmd;
klauss 105:a930035b6556 1388
klauss 62:07e5bdc9f8f7 1389 ref = debug_buf;
klauss 105:a930035b6556 1390
klauss 74:81c47fff88a5 1391 strcat( debug_buf, "\r" );
klauss 105:a930035b6556 1392
klauss 48:195c97f12e8e 1393 split = strtok( debug_buf + 4, " " );
klauss 48:195c97f12e8e 1394 ext = atoi( split );
klauss 105:a930035b6556 1395
klauss 50:d9b6577a70f5 1396 port = convert_ext_to_port( ext );
klauss 48:195c97f12e8e 1397 split += strlen( split ) + 1;
klauss 54:448d57291be6 1398 cmd = split;
klauss 105:a930035b6556 1399
klauss 48:195c97f12e8e 1400 promptcb_last_ext = ext;
klauss 48:195c97f12e8e 1401 promptcb_last_port = port;
klauss 105:a930035b6556 1402
klauss 55:2f5e7374af9d 1403 strcpy( promptcb_last_cmd, cmd );
klauss 105:a930035b6556 1404
klauss 104:62646ef786a3 1405 for( register int i = strlen( cmd ); i < DEBUGBUFSIZE; i++ ) cmd[ i ] = 0;
klauss 105:a930035b6556 1406
klauss 104:62646ef786a3 1407 if( debug_uart3 && !( from_eth ) ) pc.printf("\r\next=%d port=%d cmd=%s", ext, port, cmd );
klauss 105:a930035b6556 1408 send2callboxes( build_cb_package( ext, port, __PROMPT__, cmd, id_msg++, CB_BUFFER_SIZE - __VZ_HEADER_OFFSET__, write_buffer ) );
klauss 104:62646ef786a3 1409 if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rComando enviado");
klauss 105:a930035b6556 1410
klauss 105:a930035b6556 1411 if( from_eth ) {
klauss 62:07e5bdc9f8f7 1412 char eth_msg[ 512 ];
klauss 78:1353744f01e1 1413 snprintf( eth_msg, 512 - 1, "\r\next=%d port=%d cmd=%s\r\nComando enviado\n\r", ext, port, cmd );
klauss 105:a930035b6556 1414 if( tcp_session && !udp_query ) {
klauss 62:07e5bdc9f8f7 1415 tcp_client.send_all( eth_msg, strlen( eth_msg ) );
klauss 105:a930035b6556 1416 } else if( udp_query ) {
klauss 105:a930035b6556 1417 udp_query_send_msg( eth_msg );
klauss 62:07e5bdc9f8f7 1418 }
klauss 54:448d57291be6 1419 }
klauss 105:a930035b6556 1420
klauss 48:195c97f12e8e 1421 debug_buf = ref;
klauss 62:07e5bdc9f8f7 1422 bufptr = 0;
klauss 104:62646ef786a3 1423 for( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0;
klauss 45:c80574f24dc3 1424 }
klauss 105:a930035b6556 1425
klauss 98:43b45f26b430 1426 else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "pcc ", 4 )) {
klauss 98:43b45f26b430 1427 miss_match = false;
klauss 98:43b45f26b430 1428 int ext,port;
klauss 98:43b45f26b430 1429 char *split, *ref, *cmd;
klauss 105:a930035b6556 1430
klauss 98:43b45f26b430 1431 ref = debug_buf;
klauss 105:a930035b6556 1432
klauss 98:43b45f26b430 1433 strcat( debug_buf, "\r" );
klauss 105:a930035b6556 1434
klauss 98:43b45f26b430 1435 split = strtok( debug_buf + 4, " " );
klauss 98:43b45f26b430 1436 ext = atoi( split );
klauss 105:a930035b6556 1437
klauss 98:43b45f26b430 1438 split += strlen( split ) + 1;
klauss 98:43b45f26b430 1439 split = strtok( NULL, " " );
klauss 98:43b45f26b430 1440 port = atoi( split );
klauss 105:a930035b6556 1441
klauss 98:43b45f26b430 1442 split += strlen( split ) + 1;
klauss 98:43b45f26b430 1443 cmd = split;
klauss 105:a930035b6556 1444
klauss 98:43b45f26b430 1445 promptcb_last_ext = ext;
klauss 98:43b45f26b430 1446 promptcb_last_port = port;
klauss 105:a930035b6556 1447
klauss 98:43b45f26b430 1448 strcpy( promptcb_last_cmd, cmd );
klauss 105:a930035b6556 1449
klauss 104:62646ef786a3 1450 for( register int i = strlen( cmd ); i < DEBUGBUFSIZE; i++ ) cmd[ i ] = 0;
klauss 105:a930035b6556 1451
klauss 104:62646ef786a3 1452 if( debug_uart3 && !( from_eth ) ) pc.printf("\r\next=%d port=%d cmd=%s", ext, port, cmd );
klauss 105:a930035b6556 1453 send2callboxes( build_cb_package( ext, port, __PROMPT__, cmd, id_msg++, CB_BUFFER_SIZE - __VZ_HEADER_OFFSET__, write_buffer ) );
klauss 104:62646ef786a3 1454 if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rComando enviado");
klauss 105:a930035b6556 1455
klauss 105:a930035b6556 1456 if( from_eth ) {
klauss 98:43b45f26b430 1457 char eth_msg[ 512 ];
klauss 98:43b45f26b430 1458 snprintf( eth_msg, 512 - 1, "\r\next=%d port=%d cmd=%s\r\nComando enviado\n\r", ext, port, cmd );
klauss 105:a930035b6556 1459 if( tcp_session && !udp_query ) {
klauss 98:43b45f26b430 1460 tcp_client.send_all( eth_msg, strlen( eth_msg ) );
klauss 105:a930035b6556 1461 } else if( udp_query ) {
klauss 105:a930035b6556 1462 udp_query_send_msg( eth_msg );
klauss 98:43b45f26b430 1463 }
klauss 98:43b45f26b430 1464 }
klauss 105:a930035b6556 1465
klauss 98:43b45f26b430 1466 debug_buf = ref;
klauss 98:43b45f26b430 1467 bufptr = 0;
klauss 104:62646ef786a3 1468 for( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0;
klauss 98:43b45f26b430 1469 }
klauss 105:a930035b6556 1470
klauss 99:e80850c51106 1471 else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "rush ", 5 )) {
klauss 99:e80850c51106 1472 miss_match = false;
klauss 99:e80850c51106 1473 int ext,port;
klauss 99:e80850c51106 1474 char *split, *ref, cmd[ 32 ];
klauss 105:a930035b6556 1475
klauss 99:e80850c51106 1476 ref = debug_buf;
klauss 105:a930035b6556 1477
klauss 99:e80850c51106 1478 strcat( debug_buf, "\r" );
klauss 105:a930035b6556 1479
klauss 99:e80850c51106 1480 split = strtok( debug_buf + 5, " " );
klauss 99:e80850c51106 1481 ext = atoi( split );
klauss 105:a930035b6556 1482
klauss 99:e80850c51106 1483 split += strlen( split ) + 1;
klauss 99:e80850c51106 1484 split = strtok( NULL, " " );
klauss 99:e80850c51106 1485 port = atoi( split );
klauss 105:a930035b6556 1486
klauss 99:e80850c51106 1487 strcpy( cmd, "ping\r\n" );
klauss 105:a930035b6556 1488
klauss 99:e80850c51106 1489 promptcb_last_ext = ext;
klauss 99:e80850c51106 1490 promptcb_last_port = port;
klauss 105:a930035b6556 1491
klauss 99:e80850c51106 1492 strcpy( promptcb_last_cmd, cmd );
klauss 99:e80850c51106 1493 strcat( cmd, "\r\r\r\n" );
klauss 105:a930035b6556 1494
klauss 105:a930035b6556 1495 for( register uint8_t i = 0; i < 3; i++ ) {
klauss 104:62646ef786a3 1496 if( debug_uart3 && !( from_eth ) ) pc.printf("\r\next=%d port=%d cmd=%s", ext, port, cmd );
klauss 105:a930035b6556 1497 send2callboxes( build_cb_package( ext, port, __PROMPT__, cmd, id_msg++, CB_BUFFER_SIZE - __VZ_HEADER_OFFSET__, write_buffer ) );
klauss 104:62646ef786a3 1498 if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rComando enviado");
klauss 105:a930035b6556 1499
klauss 105:a930035b6556 1500 if( from_eth ) {
klauss 99:e80850c51106 1501 char eth_msg[ 512 ];
klauss 99:e80850c51106 1502 snprintf( eth_msg, 512 - 1, "\r\next=%d port=%d cmd=%s\r\nComando enviado\n\r", ext, port, cmd );
klauss 105:a930035b6556 1503 if( tcp_session && !udp_query ) {
klauss 99:e80850c51106 1504 tcp_client.send_all( eth_msg, strlen( eth_msg ) );
klauss 105:a930035b6556 1505 } else if( udp_query ) {
klauss 105:a930035b6556 1506 udp_query_send_msg( eth_msg );
klauss 99:e80850c51106 1507 }
klauss 99:e80850c51106 1508 }
klauss 99:e80850c51106 1509 }
klauss 105:a930035b6556 1510
klauss 99:e80850c51106 1511 debug_buf = ref;
klauss 99:e80850c51106 1512 bufptr = 0;
klauss 104:62646ef786a3 1513 for( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0;
klauss 99:e80850c51106 1514 }
klauss 105:a930035b6556 1515
klauss 105:a930035b6556 1516
klauss 105:a930035b6556 1517
klauss 59:e1e300880d2d 1518 else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "_pcb",4 )) {
klauss 45:c80574f24dc3 1519 miss_match = false;
klauss 48:195c97f12e8e 1520 debug_buf[ bufptr++ ] = 0x0D;
klauss 48:195c97f12e8e 1521 debug_buf[ bufptr++ ] = 0x00;
klauss 45:c80574f24dc3 1522
klauss 104:62646ef786a3 1523 if( debug_uart3 && !( from_eth ) ) pc.printf("\r\next=%d port=%d\r\ncmd=%s\r\n",promptcb_last_ext, promptcb_last_port, debug_buf + 4 );
klauss 105:a930035b6556 1524 send2callboxes( build_cb_package( promptcb_last_ext, promptcb_last_port, __PROMPT__, debug_buf + 4, id_msg++, CB_BUFFER_SIZE - __VZ_HEADER_OFFSET__, write_buffer ) );
klauss 104:62646ef786a3 1525 if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rComando enviado\n\r");
klauss 45:c80574f24dc3 1526 }
klauss 62:07e5bdc9f8f7 1527
klauss 58:af7e8788f106 1528 else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "cks",3 )) {
klauss 45:c80574f24dc3 1529 miss_match = false;
klauss 81:3656f00ab3db 1530 pcks_s = true;
klauss 45:c80574f24dc3 1531 }
klauss 45:c80574f24dc3 1532
klauss 58:af7e8788f106 1533 else if (xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "showcb",6 )) {
klauss 45:c80574f24dc3 1534 miss_match = false;
klauss 81:3656f00ab3db 1535 pshowcb = true;
klauss 45:c80574f24dc3 1536 }
klauss 105:a930035b6556 1537
klauss 58:af7e8788f106 1538 else if (xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "debug_main ", 11 )) {
klauss 81:3656f00ab3db 1539 if (xmemmatch( (uint8_t*)( debug_buf + 11 ), (uint8_t*) "on", 2 )) {
klauss 45:c80574f24dc3 1540 miss_match = false;
klauss 104:62646ef786a3 1541 if( debug_uart3 && !( from_eth ) ) pc.printf("\r\nDebug Main ON");
klauss 105:a930035b6556 1542 if( from_eth ) {
klauss 105:a930035b6556 1543 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Debug Main On\n\r");
klauss 45:c80574f24dc3 1544 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 1545 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 1546 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 1547 } else if( udp_query ) {
klauss 105:a930035b6556 1548 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 1549 }
klauss 45:c80574f24dc3 1550 }
klauss 81:3656f00ab3db 1551 debug_main = true;
klauss 45:c80574f24dc3 1552 }
klauss 81:3656f00ab3db 1553 if (xmemmatch( (uint8_t*)( debug_buf + 11 ), (uint8_t*) "off", 3 )) {
klauss 45:c80574f24dc3 1554 miss_match = false;
klauss 104:62646ef786a3 1555 if( debug_uart3 && !( from_eth ) ) pc.printf("\r\nDebug Main OFF");
klauss 105:a930035b6556 1556 if( from_eth ) {
klauss 105:a930035b6556 1557 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Debug Main Off\n\r");
klauss 45:c80574f24dc3 1558 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 1559 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 1560 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 1561 } else if( udp_query ) {
klauss 105:a930035b6556 1562 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 1563 }
klauss 45:c80574f24dc3 1564 }
klauss 45:c80574f24dc3 1565 debug_main = 0;
klauss 45:c80574f24dc3 1566 }
klauss 45:c80574f24dc3 1567 }
klauss 105:a930035b6556 1568
klauss 105:a930035b6556 1569 else if (xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dout ", 5 ) ) {
klauss 105:a930035b6556 1570 if (xmemmatch( (uint8_t*)( debug_buf + 5 ), (uint8_t*) "on", 2 ) ) {
klauss 81:3656f00ab3db 1571 miss_match = false;
klauss 104:62646ef786a3 1572 if( debug_uart3 && !( from_eth ) ) pc.printf("\r\nOut Debug ON");
klauss 105:a930035b6556 1573 if( from_eth ) {
klauss 105:a930035b6556 1574 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Out Debug On\n\r");
klauss 81:3656f00ab3db 1575 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 1576 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 1577 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 1578 } else if( udp_query ) {
klauss 105:a930035b6556 1579 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 1580 }
klauss 81:3656f00ab3db 1581 }
klauss 81:3656f00ab3db 1582 debug_out_of_range = true;
klauss 81:3656f00ab3db 1583 }
klauss 105:a930035b6556 1584 if (xmemmatch( (uint8_t*)( debug_buf + 5 ), (uint8_t*) "off", 3 ) ) {
klauss 81:3656f00ab3db 1585 miss_match = false;
klauss 104:62646ef786a3 1586 if( debug_uart3 && !( from_eth ) ) pc.printf("\r\nOut Debug OFF");
klauss 105:a930035b6556 1587 if( from_eth ) {
klauss 105:a930035b6556 1588 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Out Debug Off\n\r");
klauss 81:3656f00ab3db 1589 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 1590 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 1591 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 1592 } else if( udp_query ) {
klauss 105:a930035b6556 1593 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 1594 }
klauss 81:3656f00ab3db 1595 }
klauss 81:3656f00ab3db 1596 debug_out_of_range = false;
klauss 81:3656f00ab3db 1597 }
klauss 81:3656f00ab3db 1598 }
klauss 105:a930035b6556 1599
klauss 105:a930035b6556 1600 else if (xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dboot ", 6 ) ) {
klauss 105:a930035b6556 1601 if (xmemmatch( (uint8_t*)( debug_buf + 6 ), (uint8_t*) "on", 2 ) ) {
klauss 99:e80850c51106 1602 miss_match = false;
klauss 104:62646ef786a3 1603 if( debug_uart3 && !( from_eth ) ) pc.printf("\r\nBoot Debug ON");
klauss 105:a930035b6556 1604 if( from_eth ) {
klauss 105:a930035b6556 1605 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Boot Debug On\n\r");
klauss 99:e80850c51106 1606 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 1607 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 1608 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 1609 } else if( udp_query ) {
klauss 105:a930035b6556 1610 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 1611 }
klauss 99:e80850c51106 1612 }
klauss 99:e80850c51106 1613 debug_boot = true;
klauss 99:e80850c51106 1614 }
klauss 105:a930035b6556 1615 if (xmemmatch( (uint8_t*)( debug_buf + 6 ), (uint8_t*) "off", 3 ) ) {
klauss 99:e80850c51106 1616 miss_match = false;
klauss 104:62646ef786a3 1617 if( debug_uart3 && !( from_eth ) ) pc.printf("\r\nBoot Debug OFF");
klauss 105:a930035b6556 1618 if( from_eth ) {
klauss 105:a930035b6556 1619 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Boot Debug Off\n\r");
klauss 99:e80850c51106 1620 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 1621 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 1622 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 1623 } else if( udp_query ) {
klauss 105:a930035b6556 1624 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 1625 }
klauss 99:e80850c51106 1626 }
klauss 99:e80850c51106 1627 debug_boot = false;
klauss 99:e80850c51106 1628 }
klauss 99:e80850c51106 1629 }
klauss 105:a930035b6556 1630
klauss 105:a930035b6556 1631 else if (xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dfw ", 4 ) ) {
klauss 105:a930035b6556 1632 if (xmemmatch( (uint8_t*)( debug_buf + 4 ), (uint8_t*) "on", 2 ) ) {
klauss 99:e80850c51106 1633 miss_match = false;
klauss 104:62646ef786a3 1634 if( debug_uart3 && !( from_eth ) ) pc.printf("\r\nFW Debug ON");
klauss 105:a930035b6556 1635 if( from_eth ) {
klauss 105:a930035b6556 1636 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "FW Debug On\n\r");
klauss 99:e80850c51106 1637 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 1638 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 1639 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 1640 } else if( udp_query ) {
klauss 105:a930035b6556 1641 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 1642 }
klauss 99:e80850c51106 1643 }
klauss 99:e80850c51106 1644 debug_fw = true;
klauss 99:e80850c51106 1645 }
klauss 105:a930035b6556 1646 if (xmemmatch( (uint8_t*)( debug_buf + 4 ), (uint8_t*) "off", 3 ) ) {
klauss 99:e80850c51106 1647 miss_match = false;
klauss 104:62646ef786a3 1648 if( debug_uart3 && !( from_eth ) ) pc.printf("\r\nFW Debug OFF");
klauss 105:a930035b6556 1649 if( from_eth ) {
klauss 105:a930035b6556 1650 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "FW Debug Off\n\r");
klauss 99:e80850c51106 1651 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 1652 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 1653 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 1654 } else if( udp_query ) {
klauss 105:a930035b6556 1655 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 1656 }
klauss 99:e80850c51106 1657 }
klauss 99:e80850c51106 1658 debug_fw = false;
klauss 99:e80850c51106 1659 }
klauss 99:e80850c51106 1660 }
klauss 105:a930035b6556 1661
klauss 105:a930035b6556 1662 else if (xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dfwp ", 5 ) ) {
klauss 105:a930035b6556 1663 if (xmemmatch( (uint8_t*)( debug_buf + 5 ), (uint8_t*) "on", 2 ) ) {
klauss 99:e80850c51106 1664 miss_match = false;
klauss 104:62646ef786a3 1665 if( debug_uart3 && !( from_eth ) ) pc.printf("\r\nFWPrint Debug ON");
klauss 105:a930035b6556 1666 if( from_eth ) {
klauss 105:a930035b6556 1667 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "FWPrint Debug On\n\r");
klauss 99:e80850c51106 1668 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 1669 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 1670 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 1671 } else if( udp_query ) {
klauss 105:a930035b6556 1672 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 1673 }
klauss 99:e80850c51106 1674 }
klauss 99:e80850c51106 1675 debug_fw_print = true;
klauss 99:e80850c51106 1676 }
klauss 105:a930035b6556 1677 if (xmemmatch( (uint8_t*)( debug_buf + 5 ), (uint8_t*) "off", 3 ) ) {
klauss 99:e80850c51106 1678 miss_match = false;
klauss 104:62646ef786a3 1679 if( debug_uart3 && !( from_eth ) ) pc.printf("\r\nFWPrint Debug OFF");
klauss 105:a930035b6556 1680 if( from_eth ) {
klauss 105:a930035b6556 1681 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "FWPrint Debug Off\n\r");
klauss 99:e80850c51106 1682 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 1683 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 1684 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 1685 } else if( udp_query ) {
klauss 105:a930035b6556 1686 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 1687 }
klauss 99:e80850c51106 1688 }
klauss 99:e80850c51106 1689 debug_fw_print = false;
klauss 99:e80850c51106 1690 }
klauss 99:e80850c51106 1691 }
klauss 105:a930035b6556 1692
klauss 99:e80850c51106 1693 else if (xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "drx ", 4 )) {
klauss 99:e80850c51106 1694 if (xmemmatch( (uint8_t*)( debug_buf + 4 ), (uint8_t*) "on",2 )) {
klauss 45:c80574f24dc3 1695 miss_match = false;
klauss 104:62646ef786a3 1696 if( debug_uart3 && !( from_eth ) ) pc.printf("\tDebug Cbx Rx ON");
klauss 105:a930035b6556 1697 if( from_eth ) {
klauss 105:a930035b6556 1698 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "\tDebug Cbx On Rx on\n\r");
klauss 45:c80574f24dc3 1699 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 1700 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 1701 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 1702 } else if( udp_query ) {
klauss 105:a930035b6556 1703 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 1704 }
klauss 45:c80574f24dc3 1705 }
klauss 81:3656f00ab3db 1706 debug_cb_rx = true;
klauss 45:c80574f24dc3 1707 }
klauss 99:e80850c51106 1708 if (xmemmatch( (uint8_t*)( debug_buf + 4 ), (uint8_t*) "off",3 )) {
klauss 45:c80574f24dc3 1709 miss_match = false;
klauss 104:62646ef786a3 1710 if( debug_uart3 && !( from_eth ) ) pc.printf("\tDebug Cbx Rx OFF");
klauss 105:a930035b6556 1711 if( from_eth ) {
klauss 105:a930035b6556 1712 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "\tDebug Cbx On Rx off\n\r");
klauss 45:c80574f24dc3 1713 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 1714 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 1715 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 1716 } else if( udp_query ) {
klauss 105:a930035b6556 1717 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 1718 }
klauss 45:c80574f24dc3 1719 }
klauss 99:e80850c51106 1720 debug_cb_rx = false;
klauss 99:e80850c51106 1721 }
klauss 99:e80850c51106 1722 }
klauss 105:a930035b6556 1723
klauss 99:e80850c51106 1724 else if (xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dtx ", 4 )) {
klauss 99:e80850c51106 1725 if (xmemmatch( (uint8_t*)( debug_buf + 4 ), (uint8_t*) "on",2 )) {
klauss 99:e80850c51106 1726 miss_match = false;
klauss 104:62646ef786a3 1727 if( debug_uart3 && !( from_eth ) ) pc.printf("\tDebug Cbx Tx ON");
klauss 105:a930035b6556 1728 if( from_eth ) {
klauss 105:a930035b6556 1729 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "\tDebug Cbx Tx on\n\r");
klauss 99:e80850c51106 1730 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 1731 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 1732 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 1733 } else if( udp_query ) {
klauss 105:a930035b6556 1734 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 1735 }
klauss 99:e80850c51106 1736 }
klauss 99:e80850c51106 1737 debug_cb_tx = true;
klauss 99:e80850c51106 1738 }
klauss 99:e80850c51106 1739 if (xmemmatch( (uint8_t*)( debug_buf + 4 ), (uint8_t*) "off",3 )) {
klauss 99:e80850c51106 1740 miss_match = false;
klauss 104:62646ef786a3 1741 if( debug_uart3 && !( from_eth ) ) pc.printf("\tDebug Cbx Tx OFF");
klauss 105:a930035b6556 1742 if( from_eth ) {
klauss 105:a930035b6556 1743 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "\tDebug Cbx Tx off\n\r");
klauss 99:e80850c51106 1744 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 1745 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 1746 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 1747 } else if( udp_query ) {
klauss 105:a930035b6556 1748 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 1749 }
klauss 99:e80850c51106 1750 }
klauss 99:e80850c51106 1751 debug_cb_tx = false;
klauss 45:c80574f24dc3 1752 }
klauss 45:c80574f24dc3 1753 }
klauss 105:a930035b6556 1754
klauss 58:af7e8788f106 1755 else if (xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "debug_file ", 11 )) {
klauss 45:c80574f24dc3 1756 if (xmemmatch( (uint8_t*)( debug_buf + 11 ), (uint8_t*) "on",2 )) {
klauss 45:c80574f24dc3 1757 miss_match = false;
klauss 104:62646ef786a3 1758 if( debug_uart3 && !( from_eth ) ) pc.printf("\tDebug File ON");
klauss 105:a930035b6556 1759 if( from_eth ) {
klauss 105:a930035b6556 1760 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "\tDebug File On\n\r");
klauss 45:c80574f24dc3 1761 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 1762 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 1763 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 1764 } else if( udp_query ) {
klauss 105:a930035b6556 1765 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 1766 }
klauss 45:c80574f24dc3 1767 }
klauss 105:a930035b6556 1768 debug_file = true;
klauss 45:c80574f24dc3 1769 }
klauss 45:c80574f24dc3 1770 if (xmemmatch( (uint8_t*)( debug_buf + 11 ), (uint8_t*) "off",3 )) {
klauss 45:c80574f24dc3 1771 miss_match = false;
klauss 104:62646ef786a3 1772 if( debug_uart3 && !( from_eth ) ) pc.printf("Debug File OFF");
klauss 105:a930035b6556 1773 if( from_eth ) {
klauss 105:a930035b6556 1774 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Debug File Off\n\r");
klauss 45:c80574f24dc3 1775 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 1776 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 1777 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 1778 } else if( udp_query ) {
klauss 105:a930035b6556 1779 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 1780 }
klauss 45:c80574f24dc3 1781 }
klauss 105:a930035b6556 1782 debug_file = false;
klauss 45:c80574f24dc3 1783 }
klauss 45:c80574f24dc3 1784 }
klauss 45:c80574f24dc3 1785
klauss 105:a930035b6556 1786 else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "uptime" ) )
klauss 105:a930035b6556 1787 {
klauss 105:a930035b6556 1788 miss_match = false;
klauss 105:a930035b6556 1789 show_uptime = true;
klauss 105:a930035b6556 1790 }
klauss 105:a930035b6556 1791
klauss 58:af7e8788f106 1792 else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "help" )) {
klauss 45:c80574f24dc3 1793 miss_match = false;
klauss 104:62646ef786a3 1794 if( debug_uart3 && !( from_eth ) ) pc.printf("\n\r****************************PROMPT HELP******************\n\r");
klauss 105:a930035b6556 1795 if( from_eth ) {
klauss 45:c80574f24dc3 1796 snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "\n\r****************************PROMPT HELP******************\n\r" );
klauss 105:a930035b6556 1797 if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) );
klauss 105:a930035b6556 1798
klauss 105:a930035b6556 1799 else if( udp_query ) {
klauss 105:a930035b6556 1800 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 1801 /*
klauss 105:a930035b6556 1802 int send = udp_client.sendTo( udp_server, debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 1803
klauss 105:a930035b6556 1804 if( send != strlen( debug_buf ) ) {
klauss 105:a930035b6556 1805 if( debug_reconnect ) send_msg("Reconnect udp_query client");
klauss 104:62646ef786a3 1806 reconnect_prompt_udp_socket();
klauss 104:62646ef786a3 1807 miss_prompt_udp_send_pkg++;
klauss 104:62646ef786a3 1808 }
klauss 105:a930035b6556 1809 */
klauss 45:c80574f24dc3 1810 }
klauss 44:cc4996469404 1811 }
klauss 105:a930035b6556 1812
klauss 104:62646ef786a3 1813 if( debug_uart3 && !( from_eth ) ) pc.printf("ifconfig - mostra o arquivo de configuracao do sistema\n\r");
klauss 105:a930035b6556 1814 if( from_eth ) {
klauss 45:c80574f24dc3 1815 snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "ifconfig - mostra o arquivo de configuracao do sistema\n\r" );
klauss 105:a930035b6556 1816 if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) );
klauss 105:a930035b6556 1817
klauss 105:a930035b6556 1818 else if( udp_query ) {
klauss 105:a930035b6556 1819 udp_query_send_msg( debug_buf );
klauss 45:c80574f24dc3 1820 }
klauss 45:c80574f24dc3 1821 }
klauss 104:62646ef786a3 1822 if( debug_uart3 && !( from_eth ) ) pc.printf("dconfig - volta as configuracoes do sistema para o padrao de fabrica\n\r");
klauss 105:a930035b6556 1823 if( from_eth ) {
klauss 45:c80574f24dc3 1824 snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "dconfig - volta as configuracoes do sistema para o padrao de fabrica\n\r" );
klauss 105:a930035b6556 1825 if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) );
klauss 105:a930035b6556 1826
klauss 105:a930035b6556 1827 else if( udp_query ) {
klauss 105:a930035b6556 1828 udp_query_send_msg( debug_buf );
klauss 45:c80574f24dc3 1829 }
klauss 45:c80574f24dc3 1830 }
klauss 104:62646ef786a3 1831 if( debug_uart3 && !( from_eth ) ) pc.printf("callme [ramal porta] - envia o pedido de ligacao para o callbox com o ramal e porta indicada\n\r");
klauss 105:a930035b6556 1832 if( from_eth ) {
klauss 45:c80574f24dc3 1833 snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "callme [ramal porta] - envia o pedido de ligacao para o callbox com o ramal e porta indicada\n\r" );
klauss 105:a930035b6556 1834 if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) );
klauss 105:a930035b6556 1835
klauss 105:a930035b6556 1836 else if( udp_query ) {
klauss 105:a930035b6556 1837 udp_query_send_msg( debug_buf );
klauss 45:c80574f24dc3 1838 }
klauss 45:c80574f24dc3 1839 }
klauss 104:62646ef786a3 1840 if( debug_uart3 && !( from_eth ) ) pc.printf("pcb porta comando - envia o <comando> para o cbx <ramal> e <porta> executar\n\r");
klauss 105:a930035b6556 1841 if( from_eth ) {
klauss 45:c80574f24dc3 1842 snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "promptcb ramal porta comando - envia o <comando> para o cbx <ramal> e <porta> executar\n\r" );
klauss 105:a930035b6556 1843 if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) );
klauss 105:a930035b6556 1844
klauss 105:a930035b6556 1845 else if( udp_query ) {
klauss 105:a930035b6556 1846 udp_query_send_msg( debug_buf );
klauss 45:c80574f24dc3 1847 }
klauss 45:c80574f24dc3 1848 }
klauss 104:62646ef786a3 1849 if( debug_uart3 && !( from_eth ) ) pc.printf("format - formata o sistema de arquivos\n\r");
klauss 104:62646ef786a3 1850 if( debug_uart3 && !( from_eth ) ) pc.printf("reset - resta o sistema\n\r");
klauss 105:a930035b6556 1851 if( from_eth ) {
klauss 45:c80574f24dc3 1852 snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "reset - resta o sistema\n\r" );
klauss 105:a930035b6556 1853 if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) );
klauss 105:a930035b6556 1854
klauss 105:a930035b6556 1855 else if( udp_query ) {
klauss 105:a930035b6556 1856 udp_query_send_msg( debug_buf );
klauss 45:c80574f24dc3 1857 }
klauss 45:c80574f24dc3 1858 }
klauss 104:62646ef786a3 1859 if( debug_uart3 && !( from_eth ) ) pc.printf("ipset [ip] - Configura o IP da cabeceira\n\r");
klauss 105:a930035b6556 1860 if( from_eth ) {
klauss 45:c80574f24dc3 1861 snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "ipset [ip] - Configura o IP da cabeceira\n\r" );
klauss 105:a930035b6556 1862 if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) );
klauss 105:a930035b6556 1863
klauss 105:a930035b6556 1864 else if( udp_query ) {
klauss 105:a930035b6556 1865 udp_query_send_msg( debug_buf );
klauss 45:c80574f24dc3 1866 }
klauss 45:c80574f24dc3 1867 }
klauss 104:62646ef786a3 1868 if( debug_uart3 && !( from_eth ) ) pc.printf("extset [ext] - Configura a ext da cabeceira\n\r");
klauss 105:a930035b6556 1869 if( from_eth ) {
klauss 45:c80574f24dc3 1870 snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "extset [ext] - Configura a ext da cabeceira\n\r" );
klauss 105:a930035b6556 1871 if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) );
klauss 105:a930035b6556 1872
klauss 105:a930035b6556 1873 else if( udp_query ) {
klauss 105:a930035b6556 1874 udp_query_send_msg( debug_buf );
klauss 45:c80574f24dc3 1875 }
klauss 45:c80574f24dc3 1876 }
klauss 104:62646ef786a3 1877 if( debug_uart3 && !( from_eth ) ) pc.printf("msipport [port] - Configura a porta SIP da cabeceira\n\r");
klauss 105:a930035b6556 1878 if( from_eth ) {
klauss 45:c80574f24dc3 1879 snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "msipport [port] - Configura a porta SIP da cabeceira\n\r" );
klauss 105:a930035b6556 1880 if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) );
klauss 105:a930035b6556 1881
klauss 105:a930035b6556 1882 else if( udp_query ) {
klauss 105:a930035b6556 1883 udp_query_send_msg( debug_buf );
klauss 45:c80574f24dc3 1884 }
klauss 45:c80574f24dc3 1885 }
klauss 104:62646ef786a3 1886 if( debug_uart3 && !( from_eth ) ) pc.printf("serverip [ip] - Configura o ip do servidor asterisk\n\r");
klauss 105:a930035b6556 1887 if( from_eth ) {
klauss 45:c80574f24dc3 1888 snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "serverip [ip] - Configura o ip do servidor asterisk\n\r" );
klauss 105:a930035b6556 1889 if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) );
klauss 105:a930035b6556 1890
klauss 105:a930035b6556 1891 else if( udp_query ) {
klauss 105:a930035b6556 1892 udp_query_send_msg( debug_buf );
klauss 45:c80574f24dc3 1893 }
klauss 45:c80574f24dc3 1894 }
klauss 104:62646ef786a3 1895 if( debug_uart3 && !( from_eth ) ) pc.printf("serextset [ext] - Configura a server ext da cabeceira\n\r");
klauss 105:a930035b6556 1896 if( from_eth ) {
klauss 45:c80574f24dc3 1897 snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "serextset [ext] - Configura a server ext da cabeceira\n\r" );
klauss 105:a930035b6556 1898 if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) );
klauss 105:a930035b6556 1899
klauss 105:a930035b6556 1900 else if( udp_query ) {
klauss 105:a930035b6556 1901 udp_query_send_msg( debug_buf );
klauss 45:c80574f24dc3 1902 }
klauss 45:c80574f24dc3 1903 }
klauss 104:62646ef786a3 1904 if( debug_uart3 && !( from_eth ) ) pc.printf("ssport [port] - Configura a porta SIP do servidor asterisk\n\r");
klauss 105:a930035b6556 1905 if( from_eth ) {
klauss 45:c80574f24dc3 1906 snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "ssport [port] - Configura a porta SIP do servidor asterisk\n\r" );
klauss 105:a930035b6556 1907 if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) );
klauss 105:a930035b6556 1908
klauss 105:a930035b6556 1909 else if( udp_query ) {
klauss 105:a930035b6556 1910 udp_query_send_msg( debug_buf );
klauss 45:c80574f24dc3 1911 }
klauss 45:c80574f24dc3 1912 }
klauss 104:62646ef786a3 1913 if( debug_uart3 && !( from_eth ) ) pc.printf("maskset [mask] - Configura a mascara da cabeceira\n\r");
klauss 105:a930035b6556 1914 if( from_eth ) {
klauss 45:c80574f24dc3 1915 snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "maskset [mask] - Configura a mascara da cabeceira\n\r" );
klauss 105:a930035b6556 1916 if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) );
klauss 105:a930035b6556 1917
klauss 105:a930035b6556 1918 else if( udp_query ) {
klauss 105:a930035b6556 1919 udp_query_send_msg( debug_buf );
klauss 45:c80574f24dc3 1920 }
klauss 45:c80574f24dc3 1921 }
klauss 104:62646ef786a3 1922 if( debug_uart3 && !( from_eth ) ) pc.printf("gatewayset [gateway] - Configura o gateway da cabeceira\n\r");
klauss 105:a930035b6556 1923 if( from_eth ) {
klauss 45:c80574f24dc3 1924 snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "gatewayset [gateway] - Configura o gateway da cabeceira\n\r" );
klauss 105:a930035b6556 1925 if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) );
klauss 105:a930035b6556 1926
klauss 105:a930035b6556 1927 else if( udp_query ) {
klauss 105:a930035b6556 1928 udp_query_send_msg( debug_buf );
klauss 56:c64bcbaa621a 1929 }
klauss 56:c64bcbaa621a 1930 }
klauss 105:a930035b6556 1931
klauss 104:62646ef786a3 1932 if( debug_uart3 && !( from_eth ) ) pc.printf("fw_ip - Configura o IP do servidor de fw\n\r");
klauss 105:a930035b6556 1933 if( from_eth ) {
klauss 99:e80850c51106 1934 snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "fw_ip - Configura o IP do servidor de fw\n\r" );
klauss 105:a930035b6556 1935 if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) );
klauss 105:a930035b6556 1936
klauss 105:a930035b6556 1937 else if( udp_query ) {
klauss 105:a930035b6556 1938 udp_query_send_msg( debug_buf );
klauss 99:e80850c51106 1939 }
klauss 99:e80850c51106 1940 }
klauss 104:62646ef786a3 1941 if( debug_uart3 && !( from_eth ) ) pc.printf("fw_port - Configura a porta do servidor de fw\n\r");
klauss 105:a930035b6556 1942 if( from_eth ) {
klauss 99:e80850c51106 1943 snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "fw_port - Configura a porta do servidor de fw\n\r" );
klauss 105:a930035b6556 1944 if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) );
klauss 105:a930035b6556 1945
klauss 105:a930035b6556 1946 else if( udp_query ) {
klauss 105:a930035b6556 1947 udp_query_send_msg( debug_buf );
klauss 99:e80850c51106 1948 }
klauss 99:e80850c51106 1949 }
klauss 105:a930035b6556 1950
klauss 104:62646ef786a3 1951 if( debug_uart3 && !( from_eth ) ) pc.printf("maxext - Configura o maior ramal possivel de ser registrado nesse ramo\n\r");
klauss 105:a930035b6556 1952 if( from_eth ) {
klauss 81:3656f00ab3db 1953 snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "maxext - Configura o maior ramal possivel de ser registrado nesse ramo\n\r" );
klauss 105:a930035b6556 1954 if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) );
klauss 105:a930035b6556 1955
klauss 105:a930035b6556 1956 else if( udp_query ) {
klauss 105:a930035b6556 1957 udp_query_send_msg( debug_buf );
klauss 81:3656f00ab3db 1958 }
klauss 81:3656f00ab3db 1959 }
klauss 105:a930035b6556 1960
klauss 104:62646ef786a3 1961 if( debug_uart3 && !( from_eth ) ) pc.printf("minext - Configura o menor ramal possivel de ser registrado nesse ramo\n\r");
klauss 105:a930035b6556 1962 if( from_eth ) {
klauss 81:3656f00ab3db 1963 snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "minext - Configura o menor ramal possivel de ser registrado nesse ramo\n\r" );
klauss 105:a930035b6556 1964 if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) );
klauss 105:a930035b6556 1965
klauss 105:a930035b6556 1966 else if( udp_query ) {
klauss 105:a930035b6556 1967 udp_query_send_msg( debug_buf );
klauss 81:3656f00ab3db 1968 }
klauss 81:3656f00ab3db 1969 }
klauss 105:a930035b6556 1970
klauss 104:62646ef786a3 1971 if( debug_uart3 && !( from_eth ) ) pc.printf("showcb - lista os Cbx registrados na header\n\r");
klauss 105:a930035b6556 1972 if( from_eth ) {
klauss 45:c80574f24dc3 1973 snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "showcb - lista os Cbx registrados na header\n\r" );
klauss 105:a930035b6556 1974 if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) );
klauss 105:a930035b6556 1975
klauss 105:a930035b6556 1976 else if( udp_query ) {
klauss 105:a930035b6556 1977 udp_query_send_msg( debug_buf );
klauss 45:c80574f24dc3 1978 }
klauss 45:c80574f24dc3 1979 }
klauss 104:62646ef786a3 1980 if( debug_uart3 && !( from_eth ) ) pc.printf("cks - exibe estatisticas de check sum\n\r");
klauss 105:a930035b6556 1981 if( from_eth ) {
klauss 45:c80574f24dc3 1982 snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "cks - exibe estatisticas de check sum\n\r" );
klauss 105:a930035b6556 1983 if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) );
klauss 105:a930035b6556 1984
klauss 105:a930035b6556 1985 else if( udp_query ) {
klauss 105:a930035b6556 1986 udp_query_send_msg( debug_buf );
klauss 45:c80574f24dc3 1987 }
klauss 45:c80574f24dc3 1988 }
klauss 104:62646ef786a3 1989 if( debug_uart3 && !( from_eth ) ) pc.printf("reset_cks - reseta estatisticas de check sum\n\r");
klauss 105:a930035b6556 1990 if( from_eth ) {
klauss 52:12930cef17c4 1991 snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "reset_cks - reseta estatisticas de check sum\n\r" );
klauss 105:a930035b6556 1992 if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) );
klauss 105:a930035b6556 1993
klauss 105:a930035b6556 1994 else if( udp_query ) {
klauss 105:a930035b6556 1995 udp_query_send_msg( debug_buf );
klauss 52:12930cef17c4 1996 }
klauss 52:12930cef17c4 1997 }
klauss 105:a930035b6556 1998
klauss 104:62646ef786a3 1999 if( debug_uart3 && !( from_eth ) ) pc.printf(". - executa o comando anterior novamente\n\r");
klauss 105:a930035b6556 2000 if( from_eth ) {
klauss 45:c80574f24dc3 2001 snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, ". - executa o comando anterior novamente\n\r" );
klauss 105:a930035b6556 2002 if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) );
klauss 105:a930035b6556 2003
klauss 105:a930035b6556 2004 else if( udp_query ) {
klauss 105:a930035b6556 2005 udp_query_send_msg( debug_buf );
klauss 45:c80574f24dc3 2006 }
klauss 45:c80574f24dc3 2007 }
klauss 104:62646ef786a3 2008 if( debug_uart3 && !( from_eth ) ) pc.printf("debug [on|off|show] - seleciona debugs gerais | lista de debugs \n\r");
klauss 105:a930035b6556 2009 if( from_eth ) {
klauss 45:c80574f24dc3 2010 snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "debug [on|off|show] - seleciona debugs gerais | lista de debugs \n\r" );
klauss 105:a930035b6556 2011 if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) );
klauss 105:a930035b6556 2012
klauss 105:a930035b6556 2013 else if( udp_query ) {
klauss 105:a930035b6556 2014 udp_query_send_msg( debug_buf );
klauss 45:c80574f24dc3 2015 }
klauss 45:c80574f24dc3 2016 }
klauss 104:62646ef786a3 2017 if( debug_uart3 && !( from_eth ) ) pc.printf("{ flood [ on | off ] | [+|-] } - simula envio de pacotes de audio\n\r");
klauss 105:a930035b6556 2018 if( from_eth ) {
klauss 62:07e5bdc9f8f7 2019 snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "{ flood [ on | off ] | [+|-] } - simula envio de pacotes de audio\n\r");
klauss 105:a930035b6556 2020 if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) );
klauss 105:a930035b6556 2021
klauss 105:a930035b6556 2022 else if( udp_query ) {
klauss 105:a930035b6556 2023 udp_query_send_msg( debug_buf );
klauss 62:07e5bdc9f8f7 2024 }
klauss 62:07e5bdc9f8f7 2025 }
klauss 105:a930035b6556 2026
klauss 104:62646ef786a3 2027 if( debug_uart3 && !( from_eth ) ) pc.printf("silence <start_ext end_ext> - envia comando de flood off para os ramais no intervalo end_ext - start_ext\n\r");
klauss 105:a930035b6556 2028 if( from_eth ) {
klauss 65:0b653cfe95db 2029 snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "silence <start_ext end_ext> - envia comando de flood off para os ramais no intervalo end_ext - start_ext\n\r");
klauss 105:a930035b6556 2030 if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) );
klauss 105:a930035b6556 2031
klauss 105:a930035b6556 2032 else if( udp_query ) {
klauss 105:a930035b6556 2033 udp_query_send_msg( debug_buf );
klauss 65:0b653cfe95db 2034 }
klauss 65:0b653cfe95db 2035 }
klauss 105:a930035b6556 2036
klauss 104:62646ef786a3 2037 if( debug_uart3 && !( from_eth ) ) pc.printf("++ ext - Header flood on, ext flood on\n\r");
klauss 105:a930035b6556 2038 if( from_eth ) {
klauss 62:07e5bdc9f8f7 2039 snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "++ ext - Header flood on, ext flood on\n\r");
klauss 105:a930035b6556 2040 if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) );
klauss 105:a930035b6556 2041
klauss 105:a930035b6556 2042 else if( udp_query ) {
klauss 105:a930035b6556 2043 udp_query_send_msg( debug_buf );
klauss 45:c80574f24dc3 2044 }
klauss 45:c80574f24dc3 2045 }
klauss 105:a930035b6556 2046
klauss 104:62646ef786a3 2047 if( debug_uart3 && !( from_eth ) ) pc.printf("-- ext - Header flood off, ext flood off\n\r");
klauss 105:a930035b6556 2048 if( from_eth ) {
klauss 66:3f1d22e69e7b 2049 snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "++ ext - Header flood on, ext flood on\n\r");
klauss 105:a930035b6556 2050 if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) );
klauss 105:a930035b6556 2051
klauss 105:a930035b6556 2052 else if( udp_query ) {
klauss 105:a930035b6556 2053 udp_query_send_msg( debug_buf );
klauss 66:3f1d22e69e7b 2054 }
klauss 66:3f1d22e69e7b 2055 }
klauss 105:a930035b6556 2056
klauss 104:62646ef786a3 2057 if( debug_uart3 && !( from_eth ) ) pc.printf("rx - Exibe ultimo pacote recebido dos CBx\n\r");
klauss 105:a930035b6556 2058 if( from_eth ) {
klauss 64:5b011d5707d2 2059 snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "rx - Exibe ultimo pacote recebido dos CBx\n\r");
klauss 105:a930035b6556 2060 if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) );
klauss 105:a930035b6556 2061
klauss 105:a930035b6556 2062 else if( udp_query ) {
klauss 105:a930035b6556 2063 udp_query_send_msg( debug_buf );
klauss 64:5b011d5707d2 2064 }
klauss 64:5b011d5707d2 2065 }
klauss 104:62646ef786a3 2066 if( debug_uart3 && !( from_eth ) ) pc.printf("tx - Exibe ultimo pacote enviado para os CBx\n\r");
klauss 105:a930035b6556 2067 if( from_eth ) {
klauss 64:5b011d5707d2 2068 snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "tx - Exibe ultimo pacote enviado para os CBx\n\r");
klauss 105:a930035b6556 2069 if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) );
klauss 105:a930035b6556 2070
klauss 105:a930035b6556 2071 else if( udp_query ) {
klauss 105:a930035b6556 2072 udp_query_send_msg( debug_buf );
klauss 64:5b011d5707d2 2073 }
klauss 64:5b011d5707d2 2074 }
klauss 104:62646ef786a3 2075 if( debug_uart3 && !( from_eth ) ) pc.printf("ls | status - Exibe uma lista ordenada por ext do CBx registrados na Header\n\r");
klauss 105:a930035b6556 2076 if( from_eth ) {
klauss 64:5b011d5707d2 2077 snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "ls | status - Exibe uma lista ordenada por ext do CBx registrados na Header\n\r");
klauss 105:a930035b6556 2078 if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) );
klauss 105:a930035b6556 2079
klauss 105:a930035b6556 2080 else if( udp_query ) {
klauss 105:a930035b6556 2081 udp_query_send_msg( debug_buf );
klauss 64:5b011d5707d2 2082 }
klauss 64:5b011d5707d2 2083 }
klauss 104:62646ef786a3 2084 if( debug_uart3 && !( from_eth ) ) pc.printf("types - Lista os types usados no protocolo de comunicacao Header -- CBx\n\r");
klauss 105:a930035b6556 2085 if( from_eth ) {
klauss 64:5b011d5707d2 2086 snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "types - Lista os types usados no protocolo de comunicacao Header -- CBx\n\r");
klauss 105:a930035b6556 2087 if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) );
klauss 105:a930035b6556 2088
klauss 105:a930035b6556 2089 else if( udp_query ) {
klauss 105:a930035b6556 2090 udp_query_send_msg( debug_buf );
klauss 64:5b011d5707d2 2091 }
klauss 64:5b011d5707d2 2092 }
klauss 104:62646ef786a3 2093 if( debug_uart3 && !( from_eth ) ) pc.printf("protocol - Exibe formato do pacote seguindo o protocolo de comunicacao Header -- CBx\n\r");
klauss 105:a930035b6556 2094 if( from_eth ) {
klauss 64:5b011d5707d2 2095 snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "protocol - Exibe formato do pacote seguindo o protocolo de comunicacao Header -- CBx\n\r");
klauss 105:a930035b6556 2096 if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) );
klauss 105:a930035b6556 2097
klauss 105:a930035b6556 2098 else if( udp_query ) {
klauss 105:a930035b6556 2099 udp_query_send_msg( debug_buf );
klauss 64:5b011d5707d2 2100 }
klauss 64:5b011d5707d2 2101 }
klauss 105:a930035b6556 2102
klauss 104:62646ef786a3 2103 if( debug_uart3 && !( from_eth ) ) pc.printf("PROMPT VERSION: V%d\n\r", PVERSION);
klauss 105:a930035b6556 2104 if( from_eth ) {
klauss 104:62646ef786a3 2105 snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "PROMPT VERSION: V%d\n\r", PVERSION);
klauss 105:a930035b6556 2106 if( tcp_session && !udp_query ) {
klauss 104:62646ef786a3 2107 while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) );
klauss 105:a930035b6556 2108 } else if( udp_query ) {
klauss 105:a930035b6556 2109 udp_query_send_msg( debug_buf );
klauss 104:62646ef786a3 2110 }
klauss 104:62646ef786a3 2111 }
klauss 104:62646ef786a3 2112 //*------------ formatando a saida ----------------*//
klauss 105:a930035b6556 2113 strcpy( last_cmd, tmp_cmd );
klauss 105:a930035b6556 2114 bufptr = 0;
klauss 105:a930035b6556 2115 for( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0;
klauss 105:a930035b6556 2116
klauss 105:a930035b6556 2117 if( from_eth ) {
klauss 105:a930035b6556 2118 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 2119 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "> " );
klauss 105:a930035b6556 2120 if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) );
klauss 105:a930035b6556 2121 } else if( udp_query ) {
klauss 105:a930035b6556 2122 udp_query_send_msg( "> " );
klauss 104:62646ef786a3 2123 }
klauss 104:62646ef786a3 2124 }
klauss 105:a930035b6556 2125 }
klauss 105:a930035b6556 2126
klauss 105:a930035b6556 2127 else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "callme ", 7 )) {
klauss 105:a930035b6556 2128 miss_match = false;
klauss 105:a930035b6556 2129 int ext,port;
klauss 105:a930035b6556 2130 char cmd[ 16 ];
klauss 105:a930035b6556 2131
klauss 105:a930035b6556 2132 ext = atoi( debug_buf + 7 );
klauss 105:a930035b6556 2133 port = convert_ext_to_port( ext );
klauss 105:a930035b6556 2134
klauss 105:a930035b6556 2135 strcpy( cmd, ( ext % 2 ) ? "call init B" : "call init A" );
klauss 105:a930035b6556 2136
klauss 105:a930035b6556 2137 if( ext % 2 ) ext--;
klauss 105:a930035b6556 2138
klauss 105:a930035b6556 2139 promptcb_last_ext = ext;
klauss 105:a930035b6556 2140 promptcb_last_port = port;
klauss 105:a930035b6556 2141
klauss 105:a930035b6556 2142 int tmp = strlen( cmd );
klauss 105:a930035b6556 2143 cmd[ tmp ] = 0x0D;
klauss 105:a930035b6556 2144 cmd[ tmp + 1 ] = 0x00;
klauss 105:a930035b6556 2145 strcpy( promptcb_last_cmd, cmd );
klauss 105:a930035b6556 2146
klauss 105:a930035b6556 2147 if( debug_uart3 && !( from_eth ) ) pc.printf("\r\next=%d port=%d\r\ncmd=%s\r\n", ext, port, cmd );
klauss 105:a930035b6556 2148
klauss 105:a930035b6556 2149 if( debug_uart3 && !( from_eth ) ) pc.printf("\n\r--------------------------------------------------------\n\r");
klauss 105:a930035b6556 2150 for( uint16_t i = 0; i < strlen( cmd ) ; i++ ) if( debug_uart3 && !( from_eth ) ) pc.printf( "%02x ", cmd[ i ] );
klauss 105:a930035b6556 2151
klauss 105:a930035b6556 2152 send2callboxes( build_cb_package( ext, port, __PROMPT__, cmd, id_msg++, CB_BUFFER_SIZE - __VZ_HEADER_OFFSET__, write_buffer ) );
klauss 105:a930035b6556 2153 if( debug_uart3 && !( from_eth ) ) pc.printf("\n\r--------------------------------------------------------\n\r");
klauss 105:a930035b6556 2154 for( uint16_t i = 0; i < 300 ; i++ ) {
klauss 105:a930035b6556 2155 if( debug_uart3 && !( from_eth ) ) pc.printf( "%02x ", write_buffer[ i ] );
klauss 105:a930035b6556 2156 if( i != 0 && !( ( i + 1 ) % 30 ) ) if( debug_uart3 && !( from_eth ) ) pc.printf("\n\r");
klauss 105:a930035b6556 2157 }
klauss 105:a930035b6556 2158
klauss 105:a930035b6556 2159
klauss 105:a930035b6556 2160 if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rComando enviado\n\r");
klauss 105:a930035b6556 2161
klauss 105:a930035b6556 2162 if( from_eth ) {
klauss 105:a930035b6556 2163 char eth_msg[ 512 ];
klauss 105:a930035b6556 2164 snprintf( eth_msg, 512 - 1, "\r\next=%d port=%d\r\ncmd=%s\r\n\n\rComando enviado\n\r", ext, port, cmd );
klauss 105:a930035b6556 2165 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 2166 tcp_client.send_all( eth_msg, strlen( eth_msg ) );
klauss 105:a930035b6556 2167 } else if( udp_query ) {
klauss 105:a930035b6556 2168 udp_query_send_msg( eth_msg );
klauss 105:a930035b6556 2169 }
klauss 105:a930035b6556 2170 }
klauss 105:a930035b6556 2171
klauss 105:a930035b6556 2172 bufptr = 0;
klauss 105:a930035b6556 2173 for( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0;
klauss 105:a930035b6556 2174 }
klauss 105:a930035b6556 2175
klauss 105:a930035b6556 2176 if( miss_match ) {
klauss 105:a930035b6556 2177 if( debug_uart3 && !( from_eth ) ) pc.printf("\n\r> %s: command not found\n\r", debug_buf );
klauss 105:a930035b6556 2178 if( from_eth ) {
klauss 105:a930035b6556 2179 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "> %s: command not found\n ", debug_buf );
klauss 105:a930035b6556 2180 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 2181 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 2182 } else if( udp_query ) {
klauss 105:a930035b6556 2183 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 2184 }
klauss 105:a930035b6556 2185 }
klauss 105:a930035b6556 2186 } else {
klauss 105:a930035b6556 2187 if( from_eth && strlen( debug_buf ) > 2 ) strcpy( last_cmd, tmp_cmd );
klauss 105:a930035b6556 2188
klauss 105:a930035b6556 2189 else if( strlen( debug_buf ) > 2 ) strcpy( last_cmd, tmp_cmd );
klauss 105:a930035b6556 2190 }
klauss 105:a930035b6556 2191 }
klauss 105:a930035b6556 2192 if( b == 0x0D || bufret == 1 || bufptr > DEBUGBUFSIZE ) {
klauss 105:a930035b6556 2193 bufret = 0;
klauss 105:a930035b6556 2194
klauss 105:a930035b6556 2195 if( debug_uart3 && !( from_eth ) ) pc.putc(0x0A);
klauss 105:a930035b6556 2196 if( debug_uart3 && !( from_eth ) ) pc.putc(0x0D);
klauss 105:a930035b6556 2197 if( debug_uart3 && !( from_eth ) ) pc.printf("> ");
klauss 105:a930035b6556 2198
klauss 105:a930035b6556 2199 if( from_eth )
klauss 105:a930035b6556 2200 {
klauss 106:a34fcf9f0e02 2201 if( strlen( debug_buf ) > 0 )
klauss 105:a930035b6556 2202 {
klauss 106:a34fcf9f0e02 2203
klauss 106:a34fcf9f0e02 2204 if( debug_buf[ strlen( debug_buf ) - 1 ] == '\r' || debug_buf[ strlen( debug_buf ) - 1 ] == '\n' )
klauss 106:a34fcf9f0e02 2205 {
klauss 106:a34fcf9f0e02 2206 //strcat( debug_buf, "> " );
klauss 106:a34fcf9f0e02 2207 strcpy( debug_buf, "> " );
klauss 106:a34fcf9f0e02 2208 } else {
klauss 106:a34fcf9f0e02 2209 //strcat( debug_buf, "\n\r> " );
klauss 106:a34fcf9f0e02 2210 strcpy( debug_buf, "\n\r> " );
klauss 106:a34fcf9f0e02 2211 }
klauss 106:a34fcf9f0e02 2212 }else{
klauss 106:a34fcf9f0e02 2213
klauss 105:a930035b6556 2214 }
klauss 104:62646ef786a3 2215
klauss 105:a930035b6556 2216 if( tcp_session && !udp_query )
klauss 105:a930035b6556 2217 {
klauss 105:a930035b6556 2218 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 2219 } else if( udp_query ) {
klauss 106:a34fcf9f0e02 2220
klauss 106:a34fcf9f0e02 2221 udp_query_send_msg( debug_buf );
klauss 106:a34fcf9f0e02 2222
klauss 105:a930035b6556 2223 }
klauss 105:a930035b6556 2224 for( register uint16_t i = 0; i < __PROMPT_ETH_BUFFER_SIZE__; i++ ) eth_buffer[ i ] = 0;
klauss 106:a34fcf9f0e02 2225
klauss 105:a930035b6556 2226 debug_buf = __debug_buf__;
klauss 106:a34fcf9f0e02 2227
klauss 105:a930035b6556 2228 bufptr = last_bufptr;
klauss 106:a34fcf9f0e02 2229
klauss 105:a930035b6556 2230 }
klauss 105:a930035b6556 2231 else
klauss 105:a930035b6556 2232 {
klauss 104:62646ef786a3 2233 bufptr = 0;
klauss 104:62646ef786a3 2234 last_bufptr = 0;
klauss 104:62646ef786a3 2235 for( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0;
klauss 27:98f824719d1c 2236 }
klauss 105:a930035b6556 2237 }
klauss 105:a930035b6556 2238 return( NULL );
klauss 105:a930035b6556 2239 }//fim prompt_process
klauss 105:a930035b6556 2240
klauss 105:a930035b6556 2241
klauss 105:a930035b6556 2242 // operantion with the system config files
klauss 105:a930035b6556 2243 void files( const char type )
klauss 105:a930035b6556 2244 {
klauss 105:a930035b6556 2245 // show files
klauss 105:a930035b6556 2246 if (type == 's' ) {
klauss 106:a34fcf9f0e02 2247
klauss 105:a930035b6556 2248 if( debug_uart3 && !( from_eth ) ) pc.printf("Header IP " );
klauss 105:a930035b6556 2249 if( from_eth ) {
klauss 105:a930035b6556 2250 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Header IP " );
klauss 105:a930035b6556 2251 if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) );
klauss 105:a930035b6556 2252
klauss 105:a930035b6556 2253 else if( udp_query ) {
klauss 105:a930035b6556 2254 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 2255 }
klauss 105:a930035b6556 2256 }
klauss 105:a930035b6556 2257
klauss 105:a930035b6556 2258 cat("/qspi/myip.txt");
klauss 105:a930035b6556 2259
klauss 105:a930035b6556 2260 if( debug_uart3 && !( from_eth ) ) pc.printf("Header ext ");
klauss 105:a930035b6556 2261 if( from_eth ) {
klauss 105:a930035b6556 2262 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Header ext " );
klauss 105:a930035b6556 2263 if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) );
klauss 105:a930035b6556 2264
klauss 105:a930035b6556 2265 else if( udp_query ) {
klauss 105:a930035b6556 2266 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 2267 }
klauss 105:a930035b6556 2268 }
klauss 105:a930035b6556 2269
klauss 105:a930035b6556 2270 cat("/qspi/myext.txt");
klauss 105:a930035b6556 2271
klauss 105:a930035b6556 2272 if( debug_uart3 && !( from_eth ) ) pc.printf("Header port ");
klauss 105:a930035b6556 2273 if( from_eth ) {
klauss 105:a930035b6556 2274 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Header port " );
klauss 105:a930035b6556 2275 if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) );
klauss 105:a930035b6556 2276
klauss 105:a930035b6556 2277 else if( udp_query ) {
klauss 105:a930035b6556 2278 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 2279 }
klauss 105:a930035b6556 2280 }
klauss 105:a930035b6556 2281
klauss 105:a930035b6556 2282 cat("/qspi/mysipport.txt");
klauss 105:a930035b6556 2283
klauss 105:a930035b6556 2284 if( debug_uart3 && !( from_eth ) ) pc.printf("Server IP ");
klauss 105:a930035b6556 2285 if( from_eth ) {
klauss 105:a930035b6556 2286 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Server IP " );
klauss 105:a930035b6556 2287 if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) );
klauss 105:a930035b6556 2288
klauss 105:a930035b6556 2289 else if( udp_query ) {
klauss 105:a930035b6556 2290 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 2291 }
klauss 105:a930035b6556 2292 }
klauss 105:a930035b6556 2293
klauss 105:a930035b6556 2294 cat("/qspi/serverip.txt");
klauss 105:a930035b6556 2295
klauss 105:a930035b6556 2296 if( debug_uart3 && !( from_eth ) ) pc.printf("Server ext ");
klauss 105:a930035b6556 2297 if( from_eth ) {
klauss 105:a930035b6556 2298 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Server ext " );
klauss 105:a930035b6556 2299 if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) );
klauss 105:a930035b6556 2300
klauss 105:a930035b6556 2301 else if( udp_query ) {
klauss 105:a930035b6556 2302 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 2303 }
klauss 105:a930035b6556 2304 }
klauss 105:a930035b6556 2305
klauss 105:a930035b6556 2306 cat("/qspi/peerext.txt");
klauss 105:a930035b6556 2307
klauss 105:a930035b6556 2308 if( debug_uart3 && !( from_eth ) ) pc.printf("Server port ");
klauss 105:a930035b6556 2309 if( from_eth ) {
klauss 105:a930035b6556 2310 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Server port " );
klauss 105:a930035b6556 2311 if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) );
klauss 105:a930035b6556 2312
klauss 105:a930035b6556 2313 else if( udp_query ) {
klauss 105:a930035b6556 2314 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 2315 }
klauss 105:a930035b6556 2316 }
klauss 105:a930035b6556 2317 cat("/qspi/serverport.txt");
klauss 105:a930035b6556 2318
klauss 105:a930035b6556 2319 if( debug_uart3 && !( from_eth ) ) pc.printf("Mascara de rede ");
klauss 105:a930035b6556 2320 if( from_eth ) {
klauss 105:a930035b6556 2321 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Mascara de rede " );
klauss 105:a930035b6556 2322 if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) );
klauss 105:a930035b6556 2323
klauss 105:a930035b6556 2324 else if( udp_query ) {
klauss 105:a930035b6556 2325 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 2326 }
klauss 105:a930035b6556 2327 }
klauss 105:a930035b6556 2328 cat("/qspi/mymask.txt");
klauss 105:a930035b6556 2329
klauss 105:a930035b6556 2330 if( debug_uart3 && !( from_eth ) ) pc.printf("Gateway IP ");
klauss 105:a930035b6556 2331 if( from_eth ) {
klauss 105:a930035b6556 2332 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Gateway IP " );
klauss 105:a930035b6556 2333 if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) );
klauss 105:a930035b6556 2334
klauss 105:a930035b6556 2335 else if( udp_query ) {
klauss 105:a930035b6556 2336 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 2337 }
klauss 105:a930035b6556 2338 }
klauss 105:a930035b6556 2339 cat("/qspi/mygateway.txt");
klauss 105:a930035b6556 2340
klauss 105:a930035b6556 2341 if( debug_uart3 && !( from_eth ) ) pc.printf("UDP Port ");
klauss 105:a930035b6556 2342 if( from_eth ) {
klauss 105:a930035b6556 2343 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "UDP Port " );
klauss 105:a930035b6556 2344 if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) );
klauss 105:a930035b6556 2345
klauss 105:a930035b6556 2346 else if( udp_query ) {
klauss 105:a930035b6556 2347 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 2348 }
klauss 105:a930035b6556 2349 }
klauss 105:a930035b6556 2350
klauss 105:a930035b6556 2351 cat("/qspi/udpport.txt");
klauss 105:a930035b6556 2352
klauss 105:a930035b6556 2353 if( debug_uart3 && !( from_eth ) ) pc.printf("TCP Port ");
klauss 105:a930035b6556 2354 if( from_eth ) {
klauss 105:a930035b6556 2355 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "TCP Port " );
klauss 105:a930035b6556 2356 if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) );
klauss 105:a930035b6556 2357
klauss 105:a930035b6556 2358 else if( udp_query ) {
klauss 105:a930035b6556 2359 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 2360 }
klauss 105:a930035b6556 2361 }
klauss 105:a930035b6556 2362
klauss 105:a930035b6556 2363 cat("/qspi/tcpport.txt");
klauss 105:a930035b6556 2364
klauss 105:a930035b6556 2365 if( debug_uart3 && !( from_eth ) ) pc.printf("FW Server IP ");
klauss 105:a930035b6556 2366 if( from_eth ) {
klauss 105:a930035b6556 2367 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "FW Server IP " );
klauss 105:a930035b6556 2368 if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) );
klauss 105:a930035b6556 2369
klauss 105:a930035b6556 2370 else if( udp_query ) {
klauss 105:a930035b6556 2371 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 2372 }
klauss 105:a930035b6556 2373 }
klauss 105:a930035b6556 2374
klauss 105:a930035b6556 2375 cat("/qspi/fw_ip.txt");
klauss 105:a930035b6556 2376
klauss 105:a930035b6556 2377 if( debug_uart3 && !( from_eth ) ) pc.printf("FW Server Port ");
klauss 105:a930035b6556 2378 if( from_eth ) {
klauss 105:a930035b6556 2379 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "FW Server Port " );
klauss 105:a930035b6556 2380 if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) );
klauss 105:a930035b6556 2381
klauss 105:a930035b6556 2382 else if( udp_query ) {
klauss 105:a930035b6556 2383 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 2384 }
klauss 105:a930035b6556 2385 }
klauss 105:a930035b6556 2386
klauss 105:a930035b6556 2387 cat("/qspi/fw_port.txt");
klauss 105:a930035b6556 2388
klauss 105:a930035b6556 2389 if( debug_uart3 && !( from_eth ) ) pc.printf("Max Ext ");
klauss 105:a930035b6556 2390 if( from_eth ) {
klauss 105:a930035b6556 2391 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Max Ext " );
klauss 105:a930035b6556 2392 if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) );
klauss 105:a930035b6556 2393
klauss 105:a930035b6556 2394 else if( udp_query ) {
klauss 105:a930035b6556 2395 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 2396 }
klauss 105:a930035b6556 2397 }
klauss 105:a930035b6556 2398
klauss 105:a930035b6556 2399 cat("/qspi/maxext.txt");
klauss 105:a930035b6556 2400
klauss 105:a930035b6556 2401 if( debug_uart3 && !( from_eth ) ) pc.printf("Min Ext ");
klauss 105:a930035b6556 2402 if( from_eth ) {
klauss 105:a930035b6556 2403 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Min Ext " );
klauss 105:a930035b6556 2404 if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) );
klauss 105:a930035b6556 2405
klauss 105:a930035b6556 2406 else if( udp_query ) {
klauss 105:a930035b6556 2407 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 2408 }
klauss 105:a930035b6556 2409 }
klauss 105:a930035b6556 2410
klauss 105:a930035b6556 2411 cat("/qspi/minext.txt");
klauss 106:a34fcf9f0e02 2412
klauss 106:a34fcf9f0e02 2413 if( debug_uart3 && !( from_eth ) ) pc.printf("Shift Port ");
klauss 106:a34fcf9f0e02 2414 if( from_eth ) {
klauss 106:a34fcf9f0e02 2415 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Shift Port " );
klauss 106:a34fcf9f0e02 2416 if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) );
klauss 105:a930035b6556 2417
klauss 106:a34fcf9f0e02 2418 else if( udp_query ) {
klauss 106:a34fcf9f0e02 2419 udp_query_send_msg( debug_buf );
klauss 106:a34fcf9f0e02 2420 }
klauss 106:a34fcf9f0e02 2421 }
klauss 106:a34fcf9f0e02 2422
klauss 106:a34fcf9f0e02 2423 cat("/qspi/shift_port.txt");
klauss 106:a34fcf9f0e02 2424
klauss 106:a34fcf9f0e02 2425
klauss 105:a930035b6556 2426 //*------------ formatando a saida ----------------*//
klauss 105:a930035b6556 2427 strcpy( last_cmd, tmp_cmd );
klauss 105:a930035b6556 2428 bufptr = 0;
klauss 105:a930035b6556 2429 for( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0;
klauss 105:a930035b6556 2430
klauss 105:a930035b6556 2431 if( from_eth ) {
klauss 106:a34fcf9f0e02 2432
klauss 105:a930035b6556 2433 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 2434 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "> " );
klauss 105:a930035b6556 2435 if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) );
klauss 105:a930035b6556 2436 } else if( udp_query ) {
klauss 105:a930035b6556 2437 udp_query_send_msg( "> " );
klauss 106:a34fcf9f0e02 2438
klauss 105:a930035b6556 2439 }
klauss 105:a930035b6556 2440 }
klauss 105:a930035b6556 2441 }
klauss 105:a930035b6556 2442
klauss 105:a930035b6556 2443 if (type == 'c' ) {
klauss 105:a930035b6556 2444 // close all files
klauss 105:a930035b6556 2445 if( fip ) fclose( fip );
klauss 105:a930035b6556 2446 if( fmask ) fclose( fmask );
klauss 105:a930035b6556 2447 if( fgate ) fclose( fgate );
klauss 105:a930035b6556 2448 if( fport )fclose( fport );
klauss 105:a930035b6556 2449 if( fsip ) fclose( fsip );
klauss 105:a930035b6556 2450 if( fsport ) fclose( fsport );
klauss 105:a930035b6556 2451 if( fext ) fclose( fext );
klauss 105:a930035b6556 2452 if( fserext ) fclose( fserext );
klauss 105:a930035b6556 2453 if( fudpport ) fclose( fudpport );
klauss 105:a930035b6556 2454 if( ftcpport ) fclose( ftcpport );
klauss 105:a930035b6556 2455 if( fmax ) fclose( fmax );
klauss 105:a930035b6556 2456 if( fmin ) fclose( fmin );
klauss 105:a930035b6556 2457 if( ffwip ) fclose( ffwip );
klauss 105:a930035b6556 2458 if( ffwport) fclose( ffwport );
klauss 106:a34fcf9f0e02 2459 if( fshift_port ) fclose ( fshift_port );
klauss 105:a930035b6556 2460 }
klauss 105:a930035b6556 2461
klauss 105:a930035b6556 2462 if (type == 'i' ) {
klauss 106:a34fcf9f0e02 2463
klauss 105:a930035b6556 2464 // Check if files exist, if not create the files
klauss 105:a930035b6556 2465 //fixme criar um bool pra cada file
klauss 105:a930035b6556 2466 bool exists = true;
klauss 105:a930035b6556 2467
klauss 105:a930035b6556 2468 fip = fopen("/qspi/myip.txt", "r");
klauss 105:a930035b6556 2469 if( fip == NULL) {
klauss 105:a930035b6556 2470 set_ip( __MY_IP__ );
klauss 105:a930035b6556 2471 exists = false;
klauss 105:a930035b6556 2472 }
klauss 105:a930035b6556 2473
klauss 105:a930035b6556 2474 fserext = fopen("/qspi/myext.txt", "r");
klauss 105:a930035b6556 2475 if( fserext == NULL ) {
klauss 105:a930035b6556 2476 set_header_ext( __MY_EXT__ );
klauss 105:a930035b6556 2477 exists = false;
klauss 105:a930035b6556 2478 }
klauss 105:a930035b6556 2479
klauss 105:a930035b6556 2480 fport = fopen("/qspi/mysipport.txt", "r");
klauss 105:a930035b6556 2481 if (fport == NULL) {
klauss 105:a930035b6556 2482 set_header_sip_port( __MY_PORT__ );
klauss 105:a930035b6556 2483 exists = false;
klauss 105:a930035b6556 2484 }
klauss 105:a930035b6556 2485
klauss 105:a930035b6556 2486 fsip = fopen("/qspi/serverip.txt", "r");
klauss 105:a930035b6556 2487 if (fsip == NULL) {
klauss 105:a930035b6556 2488 set_server_ip( __SERVER_IP__ );
klauss 105:a930035b6556 2489 exists = false;
klauss 105:a930035b6556 2490 }
klauss 105:a930035b6556 2491
klauss 105:a930035b6556 2492 fext = fopen("/qspi/peerext.txt", "r");
klauss 105:a930035b6556 2493 if ( fext == NULL ) {
klauss 105:a930035b6556 2494 set_server_ext( __PEER_EXT__ );
klauss 105:a930035b6556 2495 exists = false;
klauss 105:a930035b6556 2496 }
klauss 105:a930035b6556 2497
klauss 105:a930035b6556 2498 fsport = fopen("/qspi/serverport.txt", "r");
klauss 105:a930035b6556 2499 if (fsport == NULL) {
klauss 105:a930035b6556 2500 set_server_port( __SERVER_PORT__ );
klauss 105:a930035b6556 2501 exists = false;
klauss 105:a930035b6556 2502 }
klauss 105:a930035b6556 2503
klauss 105:a930035b6556 2504 fmask = fopen("/qspi/mymask.txt", "r");
klauss 105:a930035b6556 2505 if (fmask == NULL) {
klauss 105:a930035b6556 2506 set_mask( __MY_MSK__ );
klauss 105:a930035b6556 2507 exists = false;
klauss 105:a930035b6556 2508 }
klauss 105:a930035b6556 2509
klauss 105:a930035b6556 2510 fgate = fopen("/qspi/mygateway.txt", "r");
klauss 105:a930035b6556 2511 if (fgate == NULL) {
klauss 105:a930035b6556 2512 set_gateway( __MY_GTW__ );
klauss 105:a930035b6556 2513 exists = false;
klauss 105:a930035b6556 2514 }
klauss 105:a930035b6556 2515
klauss 105:a930035b6556 2516 fudpport = fopen("/qspi/udpport.txt", "r" );
klauss 105:a930035b6556 2517 if( fudpport == NULL ) {
klauss 105:a930035b6556 2518 set_udp_port_listener( UDP_PORT_LISTENER );
klauss 105:a930035b6556 2519 exists = false;
klauss 105:a930035b6556 2520 }
klauss 105:a930035b6556 2521
klauss 105:a930035b6556 2522 ftcpport = fopen("/qspi/tcpport.txt", "r" );
klauss 105:a930035b6556 2523 if( ftcpport == NULL ) {
klauss 105:a930035b6556 2524 set_tcp_port_listener( TCP_PORT_LISTENER );
klauss 105:a930035b6556 2525 exists = false;
klauss 105:a930035b6556 2526 }
klauss 105:a930035b6556 2527
klauss 105:a930035b6556 2528 ffwip = fopen("/qspi/fw_ip.txt", "r" );
klauss 105:a930035b6556 2529 if( ffwip == NULL ) {
klauss 105:a930035b6556 2530 set_fw_ip( __FW_SERVER_IP__ );
klauss 105:a930035b6556 2531 exists = false;
klauss 105:a930035b6556 2532 }
klauss 105:a930035b6556 2533
klauss 105:a930035b6556 2534 ffwport = fopen("/qspi/fw_port.txt", "r" );
klauss 105:a930035b6556 2535 if( ffwport == NULL ) {
klauss 105:a930035b6556 2536 set_fw_port( __FW_SERVER_PORT__ );
klauss 105:a930035b6556 2537 exists = false;
klauss 105:a930035b6556 2538 }
klauss 105:a930035b6556 2539
klauss 105:a930035b6556 2540 fmax = fopen("/qspi/maxext.txt", "r" );
klauss 105:a930035b6556 2541 if( fmax == NULL ) {
klauss 105:a930035b6556 2542 set_max_ext( MAX_EXT );
klauss 105:a930035b6556 2543 exists = false;
klauss 105:a930035b6556 2544 }
klauss 105:a930035b6556 2545
klauss 105:a930035b6556 2546 fmin = fopen("/qspi/minext.txt", "r" );
klauss 105:a930035b6556 2547 if( fmin == NULL ) {
klauss 106:a34fcf9f0e02 2548 if( debug_file ) debug_msg("Don't exist /qspi/minext.txt");
klauss 105:a930035b6556 2549 set_min_ext( MIN_EXT );
klauss 105:a930035b6556 2550 exists = false;
klauss 105:a930035b6556 2551 }
klauss 106:a34fcf9f0e02 2552
klauss 106:a34fcf9f0e02 2553 fshift_port = fopen("/qspi/shift_port.txt", "r" );
klauss 106:a34fcf9f0e02 2554 if( fshift_port == NULL )
klauss 106:a34fcf9f0e02 2555 {
klauss 106:a34fcf9f0e02 2556 if( debug_file ) debug_msg("Don't exist /qspi/shift_port.txt");
klauss 106:a34fcf9f0e02 2557 set_shift_port( SHIFT_PORT );
klauss 106:a34fcf9f0e02 2558 exists = false;
klauss 106:a34fcf9f0e02 2559 }
klauss 106:a34fcf9f0e02 2560
klauss 105:a930035b6556 2561 if( !exists ) {
klauss 105:a930035b6556 2562 if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rDefault configurations set!\n\r");
klauss 105:a930035b6556 2563 if( from_eth ) {
klauss 105:a930035b6556 2564 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Default configurations set!\n\r");
klauss 105:a930035b6556 2565 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 2566 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 2567 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 2568 bufptr = 0;
klauss 105:a930035b6556 2569 for( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0;
klauss 62:07e5bdc9f8f7 2570 }
klauss 19:ab2088e0dec6 2571 }
klauss 105:a930035b6556 2572 }
klauss 105:a930035b6556 2573 reset_leds();
klauss 105:a930035b6556 2574 }
klauss 105:a930035b6556 2575
klauss 105:a930035b6556 2576 if (type == 'r' ) {
klauss 105:a930035b6556 2577 // Just open for read
klauss 106:a34fcf9f0e02 2578
klauss 105:a930035b6556 2579 fip = fopen("/qspi/myip.txt", "r");
klauss 105:a930035b6556 2580 fmask = fopen("/qspi/mymask.txt", "r");
klauss 105:a930035b6556 2581 fgate = fopen("/qspi/mygateway.txt", "r");
klauss 105:a930035b6556 2582 fport = fopen("/qspi/mysipport.txt", "r");
klauss 105:a930035b6556 2583 fsip = fopen("/qspi/serverip.txt", "r");
klauss 105:a930035b6556 2584 fsport = fopen("/qspi/serverport.txt", "r");
klauss 105:a930035b6556 2585 fext = fopen( "/qspi/myext.txt", "r" );
klauss 105:a930035b6556 2586 fserext = fopen( "/qspi/peerext.txt", "r" );
klauss 105:a930035b6556 2587 fudpport = fopen( "/qspi/udpport.txt", "r" );
klauss 105:a930035b6556 2588 ftcpport = fopen( "/qspi/tcpport.txt", "r" );
klauss 105:a930035b6556 2589 ffwip = fopen("/qspi/fw_ip.txt", "r" );
klauss 105:a930035b6556 2590 ffwport = fopen("/qspi/fw_port.txt", "r" );
klauss 105:a930035b6556 2591 fmax = fopen("/qspi/maxext.txt", "r" );
klauss 105:a930035b6556 2592 fmin = fopen("/qspi/minext.txt", "r" );
klauss 106:a34fcf9f0e02 2593 fshift_port = fopen("/qspi/shift_port.txt", "r" );
klauss 106:a34fcf9f0e02 2594
klauss 105:a930035b6556 2595 }
klauss 105:a930035b6556 2596
klauss 105:a930035b6556 2597 if( type == 'w') {
klauss 106:a34fcf9f0e02 2598
klauss 105:a930035b6556 2599 // Create and write the default configs
klauss 105:a930035b6556 2600 set_ip( __MY_IP__ );
klauss 105:a930035b6556 2601
klauss 105:a930035b6556 2602 set_header_sip_port( __MY_PORT__ );
klauss 105:a930035b6556 2603
klauss 105:a930035b6556 2604 set_header_ext( __MY_EXT__ );
klauss 105:a930035b6556 2605
klauss 105:a930035b6556 2606 set_server_ip( __SERVER_IP__ );
klauss 105:a930035b6556 2607
klauss 105:a930035b6556 2608 set_server_ext( __PEER_EXT__ );
klauss 105:a930035b6556 2609
klauss 105:a930035b6556 2610 set_server_port( __SERVER_PORT__ );
klauss 105:a930035b6556 2611
klauss 105:a930035b6556 2612 set_mask( __MY_MSK__ );
klauss 105:a930035b6556 2613
klauss 105:a930035b6556 2614 set_gateway( __MY_GTW__ );
klauss 105:a930035b6556 2615
klauss 105:a930035b6556 2616 set_udp_port_listener( UDP_PORT_LISTENER );
klauss 105:a930035b6556 2617
klauss 105:a930035b6556 2618 set_tcp_port_listener( TCP_PORT_LISTENER );
klauss 105:a930035b6556 2619
klauss 105:a930035b6556 2620 set_fw_ip( __FW_SERVER_IP__ );
klauss 105:a930035b6556 2621
klauss 105:a930035b6556 2622 set_fw_port( __FW_SERVER_PORT__ );
klauss 105:a930035b6556 2623
klauss 105:a930035b6556 2624 set_max_ext( MAX_EXT );
klauss 105:a930035b6556 2625
klauss 105:a930035b6556 2626 set_min_ext( MIN_EXT );
klauss 106:a34fcf9f0e02 2627
klauss 106:a34fcf9f0e02 2628 set_shift_port( SHIFT_PORT );
klauss 105:a930035b6556 2629
klauss 105:a930035b6556 2630 strcpy( last_cmd, tmp_cmd );
klauss 105:a930035b6556 2631
klauss 105:a930035b6556 2632 if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rDefault configurations set!\n\r");
klauss 105:a930035b6556 2633 if( from_eth ) {
klauss 105:a930035b6556 2634 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "\n\rDefault configurations set!\n\r");
klauss 105:a930035b6556 2635 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 2636 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 2637 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 2638 } else if( udp_query ) {
klauss 105:a930035b6556 2639 udp_query_send_msg( debug_buf );
klauss 105:a930035b6556 2640 }
klauss 54:448d57291be6 2641 bufptr = 0;
klauss 104:62646ef786a3 2642 for( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0;
klauss 45:c80574f24dc3 2643 }
klauss 106:a34fcf9f0e02 2644
klauss 105:a930035b6556 2645 }
klauss 105:a930035b6556 2646
klauss 106:a34fcf9f0e02 2647 if (type == 'e')
klauss 106:a34fcf9f0e02 2648 {
klauss 106:a34fcf9f0e02 2649 //Erase configs
klauss 105:a930035b6556 2650 fip = fopen("/qspi/myip.txt", "w");
klauss 105:a930035b6556 2651 fmask = fopen("/qspi/mymask.txt", "w");
klauss 105:a930035b6556 2652 fgate = fopen("/qspi/mygateway.txt", "w");
klauss 105:a930035b6556 2653 fport = fopen("/qspi/mysipport.txt", "w");
klauss 105:a930035b6556 2654 fsip = fopen("/qspi/serverip.txt", "w");
klauss 105:a930035b6556 2655 fsport = fopen("/qspi/serverport.txt", "w");
klauss 105:a930035b6556 2656 fext = fopen( "/qspi/myext.txt", "w" );
klauss 105:a930035b6556 2657 fserext = fopen( "/qspi/peerext.txt", "w" );
klauss 105:a930035b6556 2658 fudpport = fopen( "/qspi/udpport.txt", "w" );
klauss 105:a930035b6556 2659 ftcpport = fopen( "/qspi/tcpport.txt", "w" );
klauss 105:a930035b6556 2660 ffwip = fopen("/qspi/fw_ip.txt", "w" );
klauss 105:a930035b6556 2661 ffwport = fopen("/qspi/fw_port.txt", "w" );
klauss 105:a930035b6556 2662 fmax = fopen("/qspi/maxext.txt", "w" );
klauss 105:a930035b6556 2663 fmin = fopen("/qspi/minext.txt", "w" );
klauss 106:a34fcf9f0e02 2664 fshift_port = fopen("/qspi/shift_port.txt", "w" );
klauss 105:a930035b6556 2665
klauss 106:a34fcf9f0e02 2666 if( fip ) fprintf( fip, "%s\n\r", "" );
klauss 106:a34fcf9f0e02 2667 if( fport ) fprintf( fport, "%i\n\r", 0 );
klauss 106:a34fcf9f0e02 2668 if( fext ) fprintf( fext, "%i\n\r", 0 );
klauss 105:a930035b6556 2669
klauss 106:a34fcf9f0e02 2670 if( fsip ) fprintf( fsip, "%s\n\r", "" );
klauss 106:a34fcf9f0e02 2671 if( fserext ) fprintf( fserext, "%i\n\r", 0 );
klauss 106:a34fcf9f0e02 2672 if( fsport ) fprintf( fsport, "%i\n\r", 0 );
klauss 105:a930035b6556 2673
klauss 106:a34fcf9f0e02 2674 if( fmask ) fprintf( fmask, "%s\n\r","" );
klauss 106:a34fcf9f0e02 2675 if( fgate ) fprintf( fgate, "%s\n\r", "" );
klauss 105:a930035b6556 2676
klauss 106:a34fcf9f0e02 2677 if( fudpport ) fprintf( fudpport, "%i\n\r", 0 );
klauss 106:a34fcf9f0e02 2678 if( ftcpport ) fprintf( ftcpport, "%i\n\r", 0 );
klauss 105:a930035b6556 2679
klauss 106:a34fcf9f0e02 2680 if( ffwip ) fprintf( ffwip, "%s\n\r","" );
klauss 106:a34fcf9f0e02 2681 if( ffwport ) fprintf( ffwport, "%i\n\r",0 );
klauss 105:a930035b6556 2682
klauss 106:a34fcf9f0e02 2683 if( fmax ) fprintf( fmax, "%i\n\r", 0 );
klauss 106:a34fcf9f0e02 2684 if( fmin ) fprintf( fmin, "%i\n\r", 0 );
klauss 106:a34fcf9f0e02 2685
klauss 106:a34fcf9f0e02 2686 if( fshift_port ) fprintf( fshift_port, "%i\n\r", 0 );
klauss 105:a930035b6556 2687
klauss 105:a930035b6556 2688 files('c');
klauss 105:a930035b6556 2689
klauss 105:a930035b6556 2690 if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rErased configurations set!\n\r");
klauss 105:a930035b6556 2691 if( from_eth ) {
klauss 105:a930035b6556 2692 snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "\n\rErased configurations set!\n\r");
klauss 105:a930035b6556 2693 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
klauss 105:a930035b6556 2694 if( tcp_session && !udp_query ) {
klauss 105:a930035b6556 2695 tcp_client.send_all( debug_buf, strlen( debug_buf ) );
klauss 105:a930035b6556 2696 } else if( udp_query ) {
klauss 105:a930035b6556 2697 udp_query_send_msg( debug_buf );
klauss 45:c80574f24dc3 2698 }
klauss 42:480335bdde12 2699 bufptr = 0;
klauss 104:62646ef786a3 2700 for( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0;
klauss 45:c80574f24dc3 2701 }
klauss 106:a34fcf9f0e02 2702
klauss 105:a930035b6556 2703 }
klauss 105:a930035b6556 2704 }
klauss 105:a930035b6556 2705
klauss 105:a930035b6556 2706 void init_fsystem()
klauss 105:a930035b6556 2707 {
klauss 105:a930035b6556 2708 // init file system and check if files exist
klauss 105:a930035b6556 2709 if (!qspifs.isformatted()) {
klauss 105:a930035b6556 2710 qspifs.format();
klauss 105:a930035b6556 2711 if( debug_uart3 && !( from_eth ) ) pc.printf("\n\r******* File system configured!!******* \n\r");
klauss 105:a930035b6556 2712 }
klauss 105:a930035b6556 2713 // check if the files are created
klauss 105:a930035b6556 2714 files('i');
klauss 105:a930035b6556 2715 files('c');
klauss 106:a34fcf9f0e02 2716 pc.printf("\r\n******* File System Ready *******\r\n");
klauss 106:a34fcf9f0e02 2717 debug_file = false;
klauss 105:a930035b6556 2718 }
klauss 105:a930035b6556 2719
klauss 105:a930035b6556 2720 int str2uint ( char * s, unsigned int * val )
klauss 105:a930035b6556 2721 {
klauss 105:a930035b6556 2722 int i = 0;
klauss 105:a930035b6556 2723 unsigned int ret = 0;
klauss 105:a930035b6556 2724 for (;;) {
klauss 105:a930035b6556 2725 if (s[i] < '0') {
klauss 105:a930035b6556 2726 *val = ret;
klauss 105:a930035b6556 2727 return i;
klauss 105:a930035b6556 2728 }
klauss 105:a930035b6556 2729 ret *= 10;
klauss 105:a930035b6556 2730 ret += s[i] - '0';
klauss 105:a930035b6556 2731 i++;
klauss 105:a930035b6556 2732 }
klauss 54:448d57291be6 2733 }