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 Apr 23 13:57:54 2015 +0000
Revision:
115:a1e1e2e60a2c
Parent:
114:472502b31a12
Child:
116:39a41ebb675c
implementando retrys wip

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