Modularizando o src

Dependencies:   EALib EthernetInterface_vz mbed-rtos mbed

Fork of header_main_colinas_V0-20-09-14 by VZTECH

Committer:
klauss
Date:
Thu Feb 19 14:31:42 2015 +0000
Revision:
102:98c7155e8bea
Parent:
100:09a23fcd3bdf
Child:
103:e3cabfc2f533
implementado correcoes de ;   - tamanho de variaveis usadas no cks e no stats;   - limapando o buffer de envio de cmd para os cbx, usando o delimitador de string \r ( oxod )

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