![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Modularizando o src
Dependencies: EALib EthernetInterface_vz mbed-rtos mbed
Fork of header_main_colinas_V0-20-09-14 by
Diff: prompt.cpp
- Revision:
- 132:05cd37f7e007
- Parent:
- 131:938ab88facae
- Child:
- 133:3d136f5ffd66
--- a/prompt.cpp Tue Jul 21 20:03:35 2015 +0000 +++ b/prompt.cpp Tue Sep 01 17:21:11 2015 +0000 @@ -3,9 +3,16 @@ bool flood_silence = false; bool delayed_flood = false; +int start_ext =0; +int end_ext = 0; +int ext_count = 0; + Timer tcp_timer; bool tcp_alive = false; -bool serial_pc_pending = false; +bool serial_pc_pending = false; + +volatile char b = 0; +uint8_t bufret = 0; char __debug_buf__[ DEBUGBUFSIZE ]; char * debug_buf = __debug_buf__; @@ -13,61 +20,31 @@ char tmp_cmd[ DEBUGBUFSIZE ] = "help"; char last_debug_buf[ DEBUGBUFSIZE ] = "help"; char eth_buffer[ PROMPT_ETH_BUFFER_SIZE ]; -char eth_udp_buffer[ PROMPT_ETH_BUFFER_SIZE ]; +char eth_udp_buffer[ PROMPT_ETH_BUFFER_SIZE ]; char gp_buff[ DEBUGBUFSIZE ]; +uint8_t prompt_write_buffer [ CB_BUFFER_SIZE ]; uint16_t bufptr = 0; uint16_t last_bufptr = 0; -int init_prompt_eth ( void ) -{ - int return_value = 0; - - int udp_bind = udp_client.bind ( UDP_PORT_LISTENER ); - - udp_client.set_blocking ( false, 0 ); - - if ( debug_prompt_eth ) debug_msg ("udp_client.bind :: %d", udp_bind ); - - if ( udp_bind == 0 ) return_value |= BIT0; - - int tcp_bind = tcp_server.bind ( TCP_PORT_LISTENER ); - - tcp_server.set_blocking ( false, 0 ); +Timer flood_timeout; +Timer flood_silence_timer; +uint8_t id_msg = 0x10; - int tcp_listen = tcp_server.listen (); - - if ( debug_prompt_eth ) debug_msg ("tcp_server.bind :: %d", tcp_bind ); - - if ( tcp_bind == 0 ) return_value |= BIT1; - - return ( return_value ); -} - -// main prompt process -char * prompt_process( char * msg_from_cb, int length ) +char * +prompt_process ( char * msg_from_cb, int length ) { - //FIXME dar flush na serial - volatile char b = 0; - static uint8_t bufret = 0; - static Timer flood_timeout; - static Timer flood_silence_timer; - static uint8_t id_msg = 0x10; - static int start_ext, end_ext, ext_count; - bool miss_match = true; - char eth_buffer[ PROMPT_ETH_BUFFER_SIZE ]; - uint8_t write_buffer[ CB_BUFFER_SIZE ]; - + char eth_buffer [ PROMPT_ETH_BUFFER_SIZE ]; + if ( id_msg < 0x11 ) id_msg = 0x11; - - if( flood_timeout.read() > 60 ){ + + if( flood_timeout.read() > 60 ) { pflood = 0; flood_timeout.stop(); flood_timeout.reset(); } - - if( tcp_timer.read() >= TCP_IDLE_MAX_TIME ) - { + + if( tcp_timer.read() >= TCP_IDLE_MAX_TIME ) { tcp_alive = false; tcp_timer.stop(); tcp_timer.reset(); @@ -78,55 +55,54 @@ from_eth = false; tcp_client.close(); return( NULL ); - } - - if( udp_query ) - { - if( msg_from_cb != NULL ) - { + } + + if( udp_query ) { + if( msg_from_cb != NULL ) { last_bufptr = bufptr; if( ( length > 2 ) && ( msg_from_cb[ length - 2 ] == '\r' ) ) msg_from_cb[ length - 2 ] = 0; - + if( ( length > 1 ) && ( msg_from_cb[ length - 1 ] == '\n' ) ) msg_from_cb[ length - 1 ] = 0; if( ( length == 1 ) && msg_from_cb[ 0 ] == 0x0A ) strcpy( msg_from_cb, "\r" ); - + bufptr = strlen( msg_from_cb ); debug_buf = msg_from_cb; from_eth = true; bufret = 1; } - } - else - { - if ( !tcp_server.accept ( tcp_client ) ) - { + } else { + if ( !tcp_server.accept ( tcp_client ) ) { tcp_session = true; tcp_timer.start (); last_bufptr = bufptr; for ( register int i = 0; i < PROMPT_ETH_BUFFER_SIZE; i++ ) eth_buffer [ i ] = 0; } - if ( tcp_session && !udp_query ) - { + if ( tcp_session && !udp_query ) { tcp_client.set_blocking ( false, 0 ); int n = tcp_client.receive ( eth_buffer, sizeof ( eth_buffer ) - 1 ); - if( n > 0 ) - { + if( n > 0 ) { tcp_timer.reset (); - + if( ( n > 2 ) && ( eth_buffer[ n - 2 ] == '\r' ) ) eth_buffer[ n - 2 ] = 0; - + if( ( n > 1 ) && ( eth_buffer[ n - 1 ] == '\n' ) ) eth_buffer[ n - 1 ] = 0; - - if( ( n == 1 ) && eth_buffer[ 0 ] == 0x0A ) strcpy( eth_buffer, "\r" ); - + + if( ( n == 1 ) && eth_buffer[ 0 ] == 0x0A ) strcpy( eth_buffer, "\r> " ); + bufptr = strlen( eth_buffer ); debug_buf = eth_buffer; from_eth = true; bufret = 1; - - if( !( strcmp( eth_buffer, "quit" ) ) ) + + if ( n > 2 ) { + char tmp[] = "> "; + + while ( !( tcp_client.send_all ( tmp, strlen ( tmp ) ) ) ); + } + + if( !( strcmp( eth_buffer, "quit" ) ) ) { tcp_timer.stop(); tcp_timer.reset(); debug_buf = __debug_buf__; @@ -145,14 +121,16 @@ } } - if( ( !from_eth ) && ( !udp_query ) ) - { + if( ( !from_eth ) && ( !udp_query ) ) { if( pc.readable() ) { b = pc.getc(); if( b == 0x0D ) { // enter bufret = 1; - if( from_eth ) serial_pc_pending = true; + if ( debug_uart3 ) serial_pc_pending = true; + + // formatação manual da saída + if ( bufptr > 0 ) serial_pc.printf ( "%s","\r\n> " ); } else { pc.putc( b ); if( b == 0x08 || b == 0x7F ) { @@ -170,27 +148,24 @@ } } } - - if( flood_silence ){ - if( flood_silence_timer.read_ms() > 250 ){ + + if ( flood_silence ) + { + if ( flood_silence_timer.read_ms () > 250 ) + { char cmd[ 16 ] = "flood off"; int str_end = strlen( cmd ); cmd[ str_end ] = 0x0D; cmd[ str_end + 1 ] = 0x00; int port = convert_ext_to_port( ext_count ); - send2callboxes( build_cb_package( ext_count, port, PROMPT, cmd, id_msg++, CB_BUFFER_SIZE - VZ_HEADER_OFFSET, write_buffer ) ); - if( debug_uart3 && !( from_eth ) ) pc.printf("\r\nSilence sent to ext=%d port=%d", ext_count, port ); + + send2callboxes( build_cb_package( ext_count, port, PROMPT, cmd, id_msg++, CB_BUFFER_SIZE - VZ_HEADER_OFFSET, prompt_write_buffer ) ); + + vz_printf ("Silence sent to ext=%d port=%d", ext_count, port ); + + flood_silence_timer.reset(); - if( tcp_session && !udp_query ) { - snprintf( eth_buffer, PROMPT_ETH_BUFFER_SIZE, "\r\nSilence sent to ext=%d port=%d", ext_count, port ); - tcp_client.send_all( eth_buffer, strlen( eth_buffer ) ); - } else if( udp_query ) { - snprintf( eth_buffer, PROMPT_ETH_BUFFER_SIZE, "\r\nSilence sent to ext=%d port=%d", ext_count, port ); - udp_query_send_msg( eth_buffer ); - } - flood_silence_timer.reset(); - // importante para o uso da funçao silence if( ++ext_count > end_ext ) { flood_silence = false; @@ -208,125 +183,178 @@ } } } - - if( delayed_flood ){ + + if ( delayed_flood ) + { tflood.start(); tflood.reset(); floodcount =0; pflood = 1; flood_timeout.start(); delayed_flood = false; - if( debug_uart3 ) pc.printf("\n\rFlood ON\n\r"); - if( from_eth ){ + if( debug_uart3 ) pc.printf("\n\rFlood ON\n\r" ); + if( from_eth ) { snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "Flood On\n\r" ); - //debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; } } + + char * tmp_return = NULL; + + if ( bufret == 1 ) + { + tmp_return = command_process ( debug_buf, bufptr ); + + if( b == 0x0D || bufret == 1 || bufptr > DEBUGBUFSIZE ) { + bufret = 0; + + if( debug_uart3 && !( from_eth ) ) pc.putc(0x0A); + if( debug_uart3 && !( from_eth ) ) pc.putc(0x0D); + if( debug_uart3 && !( from_eth ) ) pc.printf("> " ); + + if( from_eth ) { + if( strlen( debug_buf ) > 0 ) { + + if( debug_buf[ strlen( debug_buf ) - 1 ] == '\r' || debug_buf[ strlen( debug_buf ) - 1 ] == '\n' ) { + strcpy( debug_buf, "> " ); + } else { + strcpy( debug_buf, "\n\r> " ); + } + } else { + + } + + if( tcp_session && !udp_query ) { + tcp_client.send_all( debug_buf, strlen( debug_buf ) ); + } else if( udp_query ) { + + udp_query_send_msg( debug_buf ); + + } + for( register uint16_t i = 0; i < PROMPT_ETH_BUFFER_SIZE; i++ ) eth_buffer[ i ] = 0; + + debug_buf = __debug_buf__; + + bufptr = last_bufptr; + + } else { + bufptr = 0; + last_bufptr = 0; + for( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; + } + } + } + + return ( tmp_return ); +} + +char * +command_process ( char * debug_buf, size_t bufptr ) +{ + bool miss_match = true; + + { + static unsigned int promptcb_last_ext = 0; + static unsigned int promptcb_last_port = 0; + static char promptcb_last_cmd [ 300 ]; - // Prompt commands here - if ( bufret == 1 ) { - static unsigned int promptcb_last_ext = 0; - static unsigned int promptcb_last_port = 0; - static char promptcb_last_cmd[ 300 ]; // removendo espacos em branco no inicio da string uint16_t shift_blank_spaces = 0; - for ( register uint16_t i = 0; i < DEBUGBUFSIZE; i++ ) - { + for ( register uint16_t i = 0; i < DEBUGBUFSIZE; i++ ) { if ( debug_buf [ i ] == 0x20 ) shift_blank_spaces++; - + if ( debug_buf [ i ] != 0x20 ) break; } debug_buf += shift_blank_spaces; strcpy( tmp_cmd, debug_buf ); - if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "." ) ){ + if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "." ) ) { miss_match = false; strcpy( debug_buf, last_cmd ); strcpy( tmp_cmd, debug_buf ); - }else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "+" ) ){ + } else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "+" ) ) { miss_match = false; strcpy( debug_buf, "flood on" ); strcpy( tmp_cmd, debug_buf ); - }else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "-" ) ){ + } else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "-" ) ) { miss_match = false; strcpy( debug_buf, "flood off" ); strcpy( tmp_cmd, debug_buf ); - }else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "++ ", 3 ) ){ + } else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "++ ", 3 ) ) { miss_match = false; delayed_flood = true; int ext = atoi( debug_buf + 3 ); sprintf( debug_buf, "pcb %i flood on", ext ); - }else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "-- ", 3 ) ){ + } else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "-- ", 3 ) ) { miss_match = false; int ext = atoi( debug_buf + 3 ); - if( debug_uart3 ) pc.printf("\n\rFlood OFF\n\r"); - if( from_eth ){ + if( debug_uart3 ) pc.printf("\n\rFlood OFF\n\r" ); + if( from_eth ) { snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "Flood OFF\n\r" ); } pflood = 0; tflood.stop(); flood_timeout.reset(); - sprintf( debug_buf, "pcb %i flood off", ext ); + sprintf( debug_buf, "pcb %i flood off", ext ); } - + //tratamento dos enters - if( !bufptr ){ + if( !bufptr ) { miss_match = false; - }else if( bufptr == 1 ) { + } else if( bufptr == 1 ) { if( debug_buf[ 0 ] == 0x0D || debug_buf[ 0 ] == 0x0D ) miss_match = false; } - - if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "ifconfig" ) ){ + + if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "show_configs" ) ) { miss_match = false; - if( debug_uart3 ) pc.printf("\n\r"); + if( debug_uart3 ) pc.printf("\n\r" ); files('s'); } - - else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "rx" ) ){ + + else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "rx" ) ) { miss_match = false; show_last_rx = true; } - - else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "tx" ) ){ + + else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "tx" ) ) { miss_match = false; show_last_tx = true; } - - else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "stats" ) ){ + + else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "stats" ) ) { miss_match = false; stats = true; - } - else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "reset_stats" ) ){ + } + + else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "reset_stats" ) ) { miss_match = false; r_stats = true; } - - else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "rtp" ) ) { + + else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "rtp" ) ) { miss_match = false; dshow_rtp = true; } - - else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "callrtp" ) ) { + + else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "callrtp" ) ) { miss_match = false; dcallshow_rtp = true; } - - else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "format" ) ){ + + else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "format" ) ) { miss_match = false; - if( from_eth ) - { + if( from_eth ) { char msg[ 32 ]; - snprintf( msg, 32, "Not Allowed\n\r"); - + snprintf( msg, 32, "Not Allowed\n\r" ); + if( tcp_session && !udp_query ) { tcp_client.send_all( msg, strlen( msg ) ); } else if( udp_query ) { udp_query_send_msg( msg ); } } else { - if ( debug_uart3 ) pc.printf("\n\rFormatando o sistema de arquivos... espere o sistema reiniciar\n\r"); + if ( debug_uart3 ) pc.printf("\n\rFormatando o sistema de arquivos... espere o sistema reiniciar\n\r" ); files('e'); files('w'); __disable_irq(); @@ -334,513 +362,552 @@ } } - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "ipset ", 6 )) { + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "ipset ", 6 ) ) + { miss_match = false; - set_ip( debug_buf + 6 ); - files('s'); + cm -> set_header_ip ( debug_buf + 6 ); } - - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "extset ", 7 ) ){ + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "extset ", 7 ) ) + { miss_match = false; - set_header_ext( atoi( debug_buf + 7 ) ); - files('s'); + cm -> set_header_ext ( atoi ( debug_buf + 7 ) ); } - - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "serextset ", 10 ) ){ + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "serextset ", 10 ) ) + { miss_match = false; - set_server_ext( atoi( debug_buf + 10 ) ); - files('s'); + cm -> set_server_ext ( atoi ( debug_buf + 10 ) ); } - - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "shift_port ", 11 ) ){ + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "shift_port ", 11 ) ) + { miss_match = false; - set_shift_port( atoi( debug_buf + 11 ) ); - files('s'); + cm -> set_shift_port( atoi ( debug_buf + 11 ) ); } - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "maskset ",8 ) ){ + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "maskset ", 8 ) ) + { miss_match = false; - set_mask( debug_buf + 8 ); - files('s'); + cm -> set_net_mask ( debug_buf + 8 ); } - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "gatewayset ",11 ) ){ + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "gatewayset ", 11 ) ) + { miss_match = false; - set_gateway( debug_buf + 11 ); - files('s'); + cm -> set_gateway ( debug_buf + 11 ); } - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "msipport ",9 ) ){ + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "msipport ",9 ) ) + { miss_match = false; - set_header_sip_port( atoi( debug_buf + 9 ) ); - files('s'); + cm -> set_header_sip_port ( atoi ( debug_buf + 9 ) ); } - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "serverip ",9 ) ){ - miss_match = false; - set_server_ip( debug_buf + 9 ); - files('s'); - } - - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "maxext ", 7 ) ){ + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "serverip ",9 ) ) + { miss_match = false; - set_max_ext( atoi( debug_buf + 7 ) ); - files('s'); + cm -> set_server_ip ( debug_buf + 9 ); } - - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "minext ", 7 ) ){ + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "maxext ", 7 ) ) + { miss_match = false; - set_min_ext( atoi( debug_buf + 7 ) ); - files('s'); + cm -> set_max_ext ( atoi ( debug_buf + 7 ) ); } - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "ssport ", 7 ) ){ - miss_match = false; - set_server_port( atoi( debug_buf + 7 ) ); - files('s'); - } - - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "fw_ip ", 6 ) ){ + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "minext ", 7 ) ) + { miss_match = false; - set_fw_ip( debug_buf + 6 ); - files('s'); - } - - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "fw_port ", 8 ) ){ - miss_match = false; - set_fw_port( atoi( debug_buf + 8 ) ); - files('s'); + cm -> set_min_ext ( atoi ( debug_buf + 7 ) ); } - else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "dconfig" ) ){ + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "ssport ", 7 ) ) + { miss_match = false; - /* - files('e'); - files('w'); - files('s'); - */ + cm -> set_server_port ( atoi ( debug_buf + 7 ) ); + } + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "fw_ip ", 6 ) ) + { + miss_match = false; + cm -> set_fw_server_ip ( debug_buf + 6 ); + } + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "fw_port ", 8 ) ) + { + miss_match = false; + cm -> set_fw_server_port ( atoi ( debug_buf + 8 ) ); } - else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "reset" ) ) { + else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dconfig" ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rJob is done\n\r"); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "Job is done\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - tcp_client.close(); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + cm -> restore_defaults_settings (); + } + + else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "reset" ) ) + { + miss_match = false; + + vz_printf ( "Job is done" ); + __disable_irq(); + NVIC_SystemReset(); } - - else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "dog" ) ){ + + else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "test" ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf("\n\r MUUUUUUUuuuuUUUUUU - I'm not a dog!!!! \n\r"); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "MUUUUUUUuuuuUUUUUU - I'm not a dog!!!!\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + char msg[] = "This is another test"; + vz_printf ("-->%s<--", msg ); + vz_printf ("-->%d<--", 28 ); } - - else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "request_clock" ) ) { + + else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dog" ) ) + { + miss_match = false; + + vz_printf ( "MUUUUUUUuuuuUUUUUU - I'm not a dog!!!!\n\r" ); + } + + else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "request_clock" ) ) + { miss_match = false; request_clock_now = true; } - - else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "hello" ) ) { + + else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "hello" ) ) + { miss_match = false; show_hello_status = true; } - - else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "date" ) ) { + + else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "date" ) ) + { miss_match = false; - send_msg(" %s %s", __DATE__, __TIME__ ); + vz_printf (" %s %s", __DATE__, __TIME__ ); } - - else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "clock" ) ) { + + else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "clock" ) ) + { miss_match = false; show_current_time = true; } - - else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "overflow" ) ) { + + else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "overflow" ) ) + { miss_match = false; - send_msg("Overflow messages :: %d", string_msg_overflow ); + vz_printf ( "Overflow messages :: %d", string_msg_overflow ); } - - else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "dep" ) ) + + else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dep" ) ) { miss_match = false; + drop_entendi_pkg = !drop_entendi_pkg; - if ( drop_entendi_pkg ) - { - debug_msg ("Entendi pkgs will be droped"); - } - else - { - debug_msg ("Entendi pkgs don't will be droped"); + + if ( drop_entendi_pkg ) { + vz_debug ("Entendi pkgs will be droped" ); + } else { + vz_debug ("Entendi pkgs don't will be droped" ); } } - - else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "dita" ) ) + + else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dita" ) ) { miss_match = false; + drop_invite_to_ast_pkg = !drop_invite_to_ast_pkg; - if ( drop_invite_to_ast_pkg ) - { - debug_msg ("Invite pkgs to ast will be droped"); - } - else - { - debug_msg ("Invite pkgs to ast don't will be droped"); + + if ( drop_invite_to_ast_pkg ) { + vz_debug ("Invite pkgs to ast will be droped" ); + } else { + vz_debug ("Invite pkgs to ast don't will be droped" ); } } - - else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "refresh_on" ) ) + + else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "refresh_on" ) ) { miss_match = false; - send_msg ("Refresh function :: Enable"); + + vz_printf ( "Refresh function :: Enable" ); + do_not_refresh = false; } - - else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "refresh_off" ) ) - { - miss_match = false; - send_msg ("Refresh function :: Disable"); - do_not_refresh = true; - } - - else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "dop" ) ) + + else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "refresh_off" ) ) { miss_match = false; + + vz_printf ( "Refresh function :: Disable" ); + + do_not_refresh = true; + } + + else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dop" ) ) + { + miss_match = false; + drop_ok_pkg = !drop_ok_pkg; - if ( drop_ok_pkg ) - { - debug_msg ("Ok pkgs will be droped"); + + if ( drop_ok_pkg ) { + vz_debug ( "Ok pkgs will be droped" ); + } else { + vz_debug ( "Ok pkgs don't will be droped" ); } - else - { - debug_msg ("Ok pkgs don't will be droped"); - } - } - - else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "dip" ) ) + } + + else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dip" ) ) { miss_match = false; + drop_invite_pkg = !drop_invite_pkg; - if ( drop_invite_pkg ) - { - debug_msg ("invite pkgs from cbx will be droped"); + + if ( drop_invite_pkg ) { + vz_debug ( "invite pkgs from cbx will be droped" ); + } else { + vz_debug ( "invite pkgs from cbx don't will be droped" ); } - else - { - debug_msg ("invite pkgs from cbx don't will be droped"); - } - + } - - else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "drp" ) ) + + else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "drp" ) ) { miss_match = false; + drop_registry_pkg = !drop_registry_pkg; - if ( drop_registry_pkg ) - { - debug_msg ("registrys pkgs from cbx will be droped"); + + if ( drop_registry_pkg ) { + vz_debug ( "registrys pkgs from cbx will be droped" ); + } else { + vz_debug ( "registrys pkgs from cbx don't will be droped" ); } - else - { - debug_msg ("registrys pkgs from cbx don't will be droped"); - } - + } - - else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "rafc" ) ) + + else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "rafc" ) ) { miss_match = false; + received_audio_from_cb = !received_audio_from_cb; - if ( received_audio_from_cb ) - { - debug_msg ("audio pkgs from cbx will printed"); - } - else - { - debug_msg ("audio pkgs from cbx don't will printed"); - } - } - - else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "dap" ) ) - { - miss_match = false; - drop_ack_pkg = !drop_ack_pkg; - if ( drop_ack_pkg ) - { - debug_msg ("ack pkgs will be droped"); + if ( received_audio_from_cb ) { + vz_debug ( "audio pkgs from cbx will printed" ); + } else { + vz_debug ( "audio pkgs from cbx don't will printed" ); } - else - { - debug_msg ("ack pkgs don't will be droped"); - } - + } - else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "drfa" ) ) + else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dap" ) ) { miss_match = false; - drop_rtp_from_ast_pkg = !drop_rtp_from_ast_pkg; - if ( drop_rtp_from_ast_pkg ) - { - debug_msg ("rtp pkgs from ast will be droped"); - } - else - { - debug_msg ("rtp pkgs from ast don't will be droped"); + + drop_ack_pkg = !drop_ack_pkg; + + if ( drop_ack_pkg ) { + vz_debug ( "ack pkgs will be droped" ); + } else { + vz_debug ( "ack pkgs don't will be droped" ); } } - - else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "drfc" ) ) + + else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "drfa" ) ) { miss_match = false; - drop_rtp_from_cbx_pkg = !drop_rtp_from_cbx_pkg; - if ( drop_rtp_from_cbx_pkg ) - { - debug_msg ("rtp pkgs from cbx will be droped"); + + drop_rtp_from_ast_pkg = !drop_rtp_from_ast_pkg; + + if ( drop_rtp_from_ast_pkg ) { + vz_debug ( "rtp pkgs from ast will be droped" ); + } else { + vz_debug ( "rtp pkgs from ast don't will be droped" ); } - else - { - debug_msg ("rtp pkgs from cbx don't will be droped"); - } } - - else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "uptime" ) ) + + else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "drfc" ) ) { miss_match = false; + drop_rtp_from_cbx_pkg = !drop_rtp_from_cbx_pkg; + + if ( drop_rtp_from_cbx_pkg ) { + vz_debug ( "rtp pkgs from cbx will be droped" ); + } else { + vz_debug ( "rtp pkgs from cbx don't will be droped" ); + } + } + + else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "uptime" ) ) + { + miss_match = false; + uint32_t local_uptime = uptime; - uint16_t h = local_uptime / ( 60 * 60 ); + uint16_t h = local_uptime / ( 60 * 60 ); uint16_t m = ( local_uptime - ( h * 60 * 60 ) ) / 60; uint16_t s = ( local_uptime - ( ( h * 60 * 60 ) + m * 60 ) ); - send_msg("\r\n%ih%im%is", h, m, s ); + vz_printf ( "\r\n%ih%im%is", h, m, s ); } - - else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "wake" ) ) { + + else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "wake" ) ) + { miss_match = false; show_wake_all_up_status = true; } - - else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "wake_on" ) ) { + + else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "wake_on" ) ) + { miss_match = false; - send_msg("Function wake_all_up : Enable"); + + vz_printf ( "Function wake_all_up : Enable" ); + wake_all = true; } - else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "wake_off" ) ) { + else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "get_wdt_string" ) ) + { miss_match = false; - send_msg("Function wake_all_up : Disable"); + show_wdt_string = true; + } + + else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "wake_off" ) ) + { + miss_match = false; + + vz_printf ("Function wake_all_up : Disable" ); + wake_all = false; } - - else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "sizes" ) ) { + + else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "ifconfig" ) ) + { + miss_match = false; + + vz_printf ("Configs :: " ); + char buffer[ 128 ]; + + cm -> get_header_ip ( buffer ); + vz_printf ("Header IP :: %s", buffer ); + + vz_printf ("Header ext :: %u", cm -> get_ext () ); + + vz_printf ("Header port :: %u", cm -> get_port () ); + + cm -> get_server_ip ( buffer ); + vz_printf ("Server IP :: %s", buffer ); + + vz_printf ("Server ext :: %u", cm -> get_server_ext () ); + + vz_printf ("Server port :: %u", cm -> get_server_port () ); + + cm -> get_net_mask ( buffer ); + vz_printf ("Mascara de rede :: %s", buffer ); + + cm -> get_gateway ( buffer ); + vz_printf ("Gateway IP :: %s", buffer ); + + vz_printf ("UDP Port :: %u", cm -> get_udp_port_listener () ); + + vz_printf ("TCP Port :: %u", cm -> get_tcp_port_listener () ); + + cm -> get_fw_server_ip ( buffer ); + vz_printf ("FW Server IP :: %s", buffer ); + + vz_printf ("FW Server Port :: %u", cm -> get_fw_server_port () ); + + vz_printf ("Max Ext :: %u", cm -> get_max_ext () ); + + vz_printf ("Min Ext :: %u", cm -> get_min_ext () ); + + vz_printf ("Shift Port :: %u", cm -> get_shift_port () ); + + cm -> get_clock_server_ip ( buffer ); + vz_printf ("Clock Server IP :: %s", buffer ); + +%: ifdef MODE_TEST + vz_printf ("on MODE_TEST" ); +%: endif + } + + else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "sizes" ) ) + { miss_match = false; sizes = true; } - - else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "ftq" ) ){ + + else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "ftq" ) ) + { miss_match = false; - if( debug_uart3 ) pc.printf( "\n\rFTQ ON\n\r" ); - if( from_eth ){ - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "FTQ On\n\r" ); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - } - big_bug_pkg = true; + + vz_printf ( "FTQ On" ); + + big_bug_pkg = true; } - - else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "ktq" ) ){ + + else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "ktq" ) ) + { miss_match = false; - if( debug_uart3 ) pc.printf( "\n\rFTQ!!!\n\r" ); - - if( from_eth ){ - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "FTQ!!!\n\r" ); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - } + + vz_printf ( "FTQ!!!" ); + flood_bug_pkg = !flood_bug_pkg; } - - else if ( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "ls", 2 ) ) + + else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "wdt_pkg_cbx_disable" ) ) + { + miss_match = false; + + vz_printf ( "wdt_pkg_cbx status :: disable" ); + + disable_wdt_from_cbx = true; + } + + else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "wdt_pkg_cbx_enable" ) ) + { + miss_match = false; + + vz_printf ( "wdt_pkg_cbx status :: enable" ); + + disable_wdt_from_cbx = false; + } + + else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "wdt_pkg_cbx_status" ) ) + { + miss_match = false; + + vz_printf ( "wdt_pkg_cbx status :: %s", ( disable_wdt_from_cbx ) ? "disable" : "enable" ); + } + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "ls", 2 ) ) { miss_match = false; reverse_list = false; list = true; - + if ( strlen ( debug_buf ) != 2 ) { - if ( strstr ( ( debug_buf + 2 ), "r" ) ) + if ( strstr ( ( debug_buf + 2 ), "r" ) ) { reverse_list = true; } + - if ( strstr ( ( debug_buf + 2 ), "l" ) ) + if ( strstr ( ( debug_buf + 2 ), "l" ) ) { list = false; long_list = true; } - if ( strstr ( ( debug_buf + 2 ), "t" ) ) + + if ( strstr ( ( debug_buf + 2 ), "t" ) ) { long_list = true; list = false; show_time = true; } + + if ( strstr ( ( debug_buf + 2 ), "i" ) ) + { + long_list = true; + list = false; + show_invites = true; + } } } - - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "drtp ", 5 ) ) { - if (xmemmatch( (uint8_t*)(debug_buf + 5 ), (uint8_t*) "on", 2 ) ) { + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "drtp ", 5 ) ) + { + if ( xmemmatch ( ( uint8_t * )( debug_buf + 5 ), ( uint8_t * ) "on", 2 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rRtp Debug ON\n\r" ); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "Rtp Debug On\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } - } + + vz_printf ( "Rtp Debug On" ); + debug_rtp = true; } - if (xmemmatch( (uint8_t*)( debug_buf + 5 ), (uint8_t*) "off", 3 ) ){ + else if ( xmemmatch ( ( uint8_t * )( debug_buf + 5 ), ( uint8_t * ) "off", 3 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rRtp Debug OFF\n\r" ); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "Rtp Debug Off\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } - } + + vz_printf ( "Rtp Debug Off" ); + debug_rtp = false; } } - - else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "print_v_cb" ) ) { + + else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "print_v_cb" ) ) + { miss_match = false; print_v_cb = true; } - - else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "print_v_call" ) ) { + + else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "print_v_call" ) ) + { miss_match = false; print_v_call = true; } - - else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "tt" ) ){ + + else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "tt" ) ) + { miss_match = false; main_test = !main_test; } - - else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "registra" ) ){ + + else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "registra" ) ) + { miss_match = false; registra = true; } - - else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "show_sip" ) ){ + + else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "registra4" ) ) + { + miss_match = false; + registra4 = true; + } + + else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "show_sip" ) ) + { miss_match = false; show_sip = true; } - - else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "reset_cks" ) ){ + + else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "reset_cks" ) ) + { miss_match = false; reset_cks = true; } - + //replaced by ls - else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "status" ) ){ + else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "status" ) ) + { miss_match = false; list = true; } - - else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "wdt" ) ){ + + else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "wdt" ) ) + { miss_match = false; debug_wdt = true; } - - else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "eth" ) ){ + + else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "eth" ) ) + { miss_match = false; debug_eth = true; } - - else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "deleted" ) ) { + + else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "deleted" ) ) + { miss_match = false; - send_msg("::deleted_sip [ %5i ]::", deleted_sip ); + vz_printf ( "::deleted_sip [ %5i ]::", deleted_sip ); } - - else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "types" ) ) { + + else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "types" ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf - ( - "\n\r" - " hex :: dec :: Type \n\r" - "0x%02x :: %5i :: BOOT\n\r" - "0x%02x :: %5i :: REGISTRY\n\r" - "0x%02x :: %5i :: REGISTRY_ACK\n\r" - "0x%02x :: %5i :: INVITE\n\r" - "0x%02x :: %5i :: INVITE_ACK\n\r" - "0x%02x :: %5i :: AUDIO\n\r" - "0x%02x :: %5i :: TELEMETRY\n\r" - "0x%02x :: %5i :: BOOTLOADER_CBX\n\r" - "0x%02x :: %5i :: CB_BYE\n\r" - "0x%02x :: %5i :: CB_BYE_ACK\n\r" - "0x%02x :: %5i :: PROMPT\n\r" - "0x%02x :: %5i :: FLOOD\n\r" - "0x%02x :: %5i :: FW\n\r" - "0x%02x :: %5i :: FW1\n\r" - "0x%02x :: %5i :: FW2\n\r" - "0x%02x :: %5i :: FW3\n\r" - "0x%02x :: %5i :: FW4\n\r" - "0x%02x :: %5i :: FW5\n\r" - "0x%02x :: %5i :: FW6\n\r" - "0x%02x :: %5i :: CB_STATS\n\r" - "0x%02x :: %5i :: CB_STATS_ACK\n\r" - "0x%02x :: %5i :: DO_NOTHING\n\r\n\r" - - "0x%02x :: %5i :: BROADCAST_EXT\n\r" - "NOTA - Os types TELEMETRY, CB_STATS, e FW1 ate FW6 sao repassados para o servidor como type FW\n\r", - BOOT, BOOT, - REGISTRY, REGISTRY, - REGISTRY_ACK, REGISTRY_ACK, - INVITE, INVITE, - INVITE_ACK, INVITE_ACK, - AUDIO, AUDIO, - TELEMETRY, TELEMETRY, - BOOTLOADER_CBX, BOOTLOADER_CBX, - CB_BYE, CB_BYE, - CB_BYE_ACK, CB_BYE_ACK, - PROMPT, PROMPT, - FLOOD, FLOOD, - FW, FW, - FW1, FW1, - FW2, FW2, - FW3, FW3, - FW4, FW4, - FW5, FW5, - FW6, FW6, - CB_STATS, CB_STATS, - CB_STATS_ACK, CB_STATS_ACK, - DO_NOTHING, DO_NOTHING, - BROADCAST_EXT, BROADCAST_EXT - ); - - if ( from_eth ) - { - snprintf ( debug_buf, PROMPT_ETH_BUFFER_SIZE, - "\n\r" + vz_printf ( " hex :: dec :: Type \n\r" "0x%02x :: %5i :: BOOT\n\r" "0x%02x :: %5i :: REGISTRY\n\r" @@ -864,7 +931,7 @@ "0x%02x :: %5i :: CB_STATS\n\r" "0x%02x :: %5i :: CB_STATS_ACK\n\r" "0x%02x :: %5i :: DO_NOTHING\n\r\n\r" - + "0x%02x :: %5i :: BROADCAST_EXT\n\r" "NOTA - Os types TELEMETRY, CB_STATS, e FW1 ate FW6 sao repassados para o servidor como type FW\n\r", BOOT, BOOT, @@ -891,1126 +958,800 @@ DO_NOTHING, DO_NOTHING, BROADCAST_EXT, BROADCAST_EXT ); - - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } } - - else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "protocol" ) ){ - miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\r| E | E | P | P | C | C | T | [ Seq_num | Audio ] | 14[ Clock | Audio ] | [ TS | Audio ] | ... |\n\r \n\rE = Ext = Ramal\n\r \n\rP = Port = Porta\n\r \n\rC = Checksum\n\r \n\rT = Type = Tipo\n\r \n\rSeq_num = Sequence Number = Numero de sequencia\n\r \n\rClock = 14 bytes to sync\n\r \n\r... = demais CB_BUFFER_SIZE - __VZ_HEADER_OFFSET__ bytes\n\r" ); + else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "protocol" ) ) + { + miss_match = false; + vz_printf ( "| 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" ); + } - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "| E | E | P | P | C | C | T | [ Seq_num | Audio ] | 14[ Clock | Audio ] | [ TS | Audio ] | ... |\n\r \n\rE = Ext = Ramal\n\r \n\rP = Port = Porta\n\r \n\rC = Checksum\n\r \n\rT = Type = Tipo\n\r \n\rSeq_num = Sequence Number = Numero de sequencia\n\r \n\rClock = 14 bytes to sync\n\r \n\r... = demais CB_BUFFER_SIZE - __VZ_HEADER_OFFSET__ bytes\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } - } - - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "flood ", 6 ) ){ - if (xmemmatch( (uint8_t*)(debug_buf+6), (uint8_t*) "on", 2 ) ){ + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "flood ", 6 ) ) + { + if ( xmemmatch ( ( uint8_t * )( debug_buf + 6 ), ( uint8_t * ) "on", 2 ) ) + { miss_match = false; - if( debug_uart3 ) pc.printf("\n\rFlood ON\n\r"); - if( from_eth ){ - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "Flood On\n\r" ); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - } - tflood.start(); - tflood.reset(); + + vz_printf ( "Flood On" ); + + tflood.start (); + tflood.reset (); floodcount =0; pflood = 1; - flood_timeout.start(); + flood_timeout.start (); } - - if (xmemmatch( (uint8_t*)(debug_buf+6), (uint8_t*) "more", 4 ) ){ + else if ( xmemmatch ( ( uint8_t * )( debug_buf + 6 ), ( uint8_t * ) "more", 4 ) ) + { miss_match = false; - if( debug_uart3 ) pc.printf("\n\rFlood ON\n\r"); - if( from_eth ){ - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "Flood On\n\r" ); - //debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - } - tflood.start(); - tflood.reset(); + + vz_printf ( "Flood On" ); + + tflood.start (); + tflood.reset (); floodcount = 0; pflood = 1; } - - if (xmemmatch( (uint8_t*)(debug_buf+6), (uint8_t*) "off", 3 )) { + else if ( xmemmatch ( ( uint8_t * )( debug_buf + 6 ), ( uint8_t * ) "off", 3 ) ) + { miss_match = false; - if( debug_uart3 ) pc.printf("\n\rFlood OFF\n\r"); - if( from_eth ){ - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "Flood Off\n\r" ); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - } + + vz_printf ( "Flood Off" ); + pflood = 0; - tflood.stop(); - flood_timeout.reset(); + tflood.stop (); + flood_timeout.reset (); } + + } + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "silence ", 8 ) ) + { + miss_match = false; - } - - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "silence ", 8 ) ){ - miss_match = false; char *ref, *split; - strcpy( promptcb_last_cmd, debug_buf ); - - if( !( strcmp( debug_buf + 8, "-h" ) && strcmp( debug_buf + 8, "--help" ) ) ) { - if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rUsage :: silence start_ext end_ext | start_ext must be greater than end_ext\n\rObs : ( end_ext - start_ext ) < 50 "); + strcpy ( promptcb_last_cmd, debug_buf ); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "Usage :: silence start_ext end_ext | start_ext must be greater than end_ext\n\rObs : ( end_ext - start_ext ) < 50 "); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + if( !( strcmp ( debug_buf + 8, "-h" ) && strcmp ( debug_buf + 8, "--help" ) ) ) { + vz_printf ( "Usage :: silence start_ext end_ext | start_ext must be greater than end_ext\n\rObs : ( end_ext - start_ext ) < 50 " ); } else { ref = debug_buf; - split = strtok( debug_buf + 8, " " ); + split = strtok ( debug_buf + 8, " " ); - start_ext = atoi( split ); + start_ext = atoi ( split ); - split += strlen( split ) + 1; + split += strlen ( split ) + 1; - end_ext = atoi( split ); + end_ext = atoi ( split ); debug_buf = ref; - if( start_ext < end_ext && ( end_ext - start_ext ) < 50 ) { - if( start_ext % 2 ) start_ext--; - if( !( end_ext % 2 ) ) end_ext++; + if ( start_ext < end_ext && ( end_ext - start_ext ) < 50 ) + { + if ( start_ext % 2 ) start_ext --; + if ( !( end_ext % 2 ) ) end_ext ++; ext_count = start_ext; - flood_silence_timer.start(); + flood_silence_timer.start (); } else { - if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rUsage Error :: silence start_ext end_ext | start_ext must be greater than end_ext\n\rObs : ( end_ext - start_ext ) < 50 "); - - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "Usage Error :: silence start_ext end_ext | start_ext must be greater than end_ext\n\rObs : ( end_ext - start_ext ) < 50 "); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + vz_printf ( "Usage Error :: silence start_ext end_ext | start_ext must be greater than end_ext\n\rObs : ( end_ext - start_ext ) < 50 " ); } + flood_silence = true; } } - - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "debug ",6 ) ){ - if( xmemmatch( (uint8_t*)(debug_buf+6), (uint8_t*) "on",2 )) { + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "debug ", 6 ) ) + { + if ( xmemmatch ( ( uint8_t * )( debug_buf + 6 ), ( uint8_t * ) "on", 2 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rDebug ON\n\r"); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "Debug On\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ( "Debug ON" ); + debug_alive = true; } - if( xmemmatch( (uint8_t*)(debug_buf+6), (uint8_t*) "off",3 )) { + else if ( xmemmatch ( ( uint8_t * )( debug_buf + 6), ( uint8_t * ) "off", 3 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rDebug OFF\n\r"); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "Debug Off\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ( "Debug Off\n\r" ); + debug_alive = false; } - if( xmemmatch( (uint8_t*)(debug_buf+6), (uint8_t*) "show",4 ) ) { + if ( xmemmatch ( ( uint8_t * )( debug_buf + 6 ), ( uint8_t * ) "show", 4 ) ) + { + miss_match = false; + + vz_printf ( "dsip \n\r" + "debug_alive \n\r" + "debug_prompt \n\r" + "debug_vector \n\r" + "debug_cb \n\r" + "debug_main \n\r" + "dcks \n\r" + "debug_cb_rx \n\r" + "debug_cb_tx* \n\r" + "debug_eth_rx* \n\r" + "debug_eth_tx* \n\r" + "debug_file" + ); + } + } + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dsip ", 5 ) ) + { + if ( xmemmatch ( ( uint8_t * )( debug_buf + 5 ), ( uint8_t * ) "on", 2 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rdsip"); - if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rdebug_alive"); - if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rdebug_prompt"); - if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rdebug_vector"); - if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rdebug_cb"); - if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rdebug_main"); - if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rdcks"); - if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rdebug_cb_rx"); - if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rdebug_cb_tx*"); - if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rdebug_eth_rx*"); - if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rdebug_eth_tx*"); - if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rdebug_file"); + + vz_printf ( "Sip Debug On" ); + + debug_sip = true; + } + if ( xmemmatch ( ( uint8_t * )( debug_buf + 5 ), ( uint8_t * ) "off", 3 ) ) + { + miss_match = false; + + vz_printf ( "Sip Debug Off" ); - if( from_eth ) { - 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"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + debug_sip = false; + } + } + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "ddrefresh ", 10 ) ) + { + if ( xmemmatch ( ( uint8_t * )( debug_buf + 10 ), ( uint8_t * ) "on", 2 ) ) + { + miss_match = false; + + vz_printf ( "Don't Refresh Debug On" ); + + debug_dont_refresh = true; + } + else if ( xmemmatch ( ( uint8_t * )( debug_buf + 10 ), ( uint8_t * ) "off",3 ) ) + { + miss_match = false; + + vz_printf ( "Don't Refresh Debug Off" ); + + debug_dont_refresh = false; } } - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dsip ", 5 ) ) + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "drajada ", 8 ) ) { - if (xmemmatch( (uint8_t*)(debug_buf + 5 ), (uint8_t*) "on", 2 ) ) { + if ( xmemmatch ( ( uint8_t * )( debug_buf + 8 ), ( uint8_t * ) "on", 2 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rSip Debug ON\n\r" ); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "Sip Debug On\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } - debug_sip = true; + + vz_printf ( "Debug Rajada on" ); + + debug_resend_invite = true; } - if (xmemmatch( (uint8_t*)(debug_buf + 5 ), (uint8_t*) "off",3 )) { + else if ( xmemmatch ( ( uint8_t * )( debug_buf + 8 ), ( uint8_t * ) "off",3 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rSip Debug OFF\n\r" ); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "Sip Debug Off\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } - debug_sip = false; + + vz_printf ( "Debug Rajada off" ); + + debug_resend_invite = false; } } - + else if ( xmemmatch ( ( uint8_t * ) debug_buf, ( uint8_t * ) "dsqn ", 5 ) ) { - if (xmemmatch( (uint8_t*)(debug_buf + 5 ), (uint8_t*) "on", 2 ) ) + if ( xmemmatch ( ( uint8_t * )( debug_buf + 5 ), ( uint8_t * ) "on", 2 ) ) { miss_match = false; - if ( debug_uart3 and not from_eth ) pc.printf ( "\n\rSequence Number Debug ON\n\r" ); - if ( from_eth ) - { - snprintf ( debug_buf, PROMPT_ETH_BUFFER_SIZE, "Sequence Number Debug On\n\r"); - debug_buf [ strlen ( debug_buf ) - 1 ] = '\0'; - if ( tcp_session and not udp_query ) - { - tcp_client.send_all ( debug_buf, strlen ( debug_buf ) ); - } else if( udp_query ) - { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ( "Sequence Number Debug On" ); + debug_sqn = true; } - - if ( xmemmatch( ( uint8_t * )( debug_buf + 5 ), ( uint8_t * ) "off",3 ) ) + + if ( xmemmatch ( ( uint8_t * )( debug_buf + 5 ), ( uint8_t * ) "off",3 ) ) { miss_match = false; - if ( debug_uart3 and not from_eth ) pc.printf ( "\n\rSequence Number Debug OFF\n\r" ); - if ( from_eth ) - { - snprintf ( debug_buf, PROMPT_ETH_BUFFER_SIZE, "Sequence Number Debug Off\n\r"); - debug_buf [ strlen ( debug_buf ) - 1 ] = '\0'; - if ( tcp_session and not udp_query ) - { - tcp_client.send_all ( debug_buf, strlen ( debug_buf ) ); - } else if ( udp_query ) - { - udp_query_send_msg ( debug_buf ); - } - } + + vz_printf ( "Sequence Number Debug Off" ); + debug_sqn = false; } } - - else if ( xmemmatch ( ( uint8_t * ) debug_buf, ( uint8_t * ) "test_ts ", 8 ) ) + + else if ( xmemmatch ( ( uint8_t * ) debug_buf, ( uint8_t * ) "test_ts ", 8 ) ) { - if (xmemmatch( (uint8_t*)(debug_buf + 8 ), (uint8_t*) "on", 2 ) ) + if ( xmemmatch ( ( uint8_t * )( debug_buf + 8 ), ( uint8_t * ) "on", 2 ) ) { miss_match = false; - if ( debug_uart3 and not from_eth ) pc.printf ( "\n\rTS testing ON\n\r" ); - if ( from_eth ) - { - snprintf ( debug_buf, PROMPT_ETH_BUFFER_SIZE, "TS testing On\n\r"); - debug_buf [ strlen ( debug_buf ) - 1 ] = '\0'; - if ( tcp_session and not udp_query ) - { - tcp_client.send_all ( debug_buf, strlen ( debug_buf ) ); - } else if( udp_query ) - { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ( "TS testing On" ); + test_ts = true; } - - if ( xmemmatch( ( uint8_t * )( debug_buf + 8 ), ( uint8_t * ) "off",3 ) ) + else if ( xmemmatch ( ( uint8_t * )( debug_buf + 8 ), ( uint8_t * ) "off",3 ) ) { miss_match = false; - if ( debug_uart3 and not from_eth ) pc.printf ( "\n\rTS testing OFF\n\r" ); - if ( from_eth ) - { - snprintf ( debug_buf, PROMPT_ETH_BUFFER_SIZE, "TS testing Off\n\r"); - debug_buf [ strlen ( debug_buf ) - 1 ] = '\0'; - if ( tcp_session and not udp_query ) - { - tcp_client.send_all ( debug_buf, strlen ( debug_buf ) ); - } else if ( udp_query ) - { - udp_query_send_msg ( debug_buf ); - } - } + + vz_printf ( "TS testing Off" ); + test_ts = false; } } - - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dhello ", 7 ) ){ - if (xmemmatch( (uint8_t*)(debug_buf + 7 ), (uint8_t*) "on", 2 ) ) { + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dhello ", 7 ) ) + { + if ( xmemmatch ( ( uint8_t * )( debug_buf + 7 ), ( uint8_t * ) "on", 2 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rHello Debug ON\n\r" ); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "Hello Debug On\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ( "Hello Debug On" ); + debug_hello = true; } - if (xmemmatch( (uint8_t*)(debug_buf + 7 ), (uint8_t*) "off",3 )) { + else if ( xmemmatch ( ( uint8_t * )( debug_buf + 7 ), ( uint8_t * ) "off",3 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rHello Debug OFF\n\r" ); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "Hello Debug Off\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ( "Hello Debug Off" ); + debug_hello = false; } } - - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dmissedwdt ", 11 ) ){ - if (xmemmatch( (uint8_t*)(debug_buf + 11 ), (uint8_t*) "on", 2 ) ) { + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dmissedwdt ", 11 ) ) + { + if ( xmemmatch ( ( uint8_t * )( debug_buf + 11 ), ( uint8_t * ) "on", 2 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rWdt missed Debug ON\n\r" ); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "Wdt missed Debug On\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ( "Wdt missed Debug On" ); + dmissed_wdt = true; } - if (xmemmatch( (uint8_t*)(debug_buf + 11 ), (uint8_t*) "off",3 )) { + else if ( xmemmatch ( ( uint8_t * )( debug_buf + 11 ), ( uint8_t * ) "off", 3 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rWdt missed Debug OFF\n\r" ); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "Wdt missed Debug Off\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ( "Wdt missed Debug Off" ); + dmissed_wdt = false; } } - - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dclock ", 7 ) ){ - if (xmemmatch( (uint8_t*)(debug_buf + 7 ), (uint8_t*) "on", 2 ) ) { + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dclock ", 7 ) ) + { + if ( xmemmatch ( ( uint8_t * )( debug_buf + 7 ), ( uint8_t * ) "on", 2 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rClock Debug ON\n\r" ); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "Clock Debug On\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf( "Clock Debug On" ); + debug_clock = true; } - if (xmemmatch( (uint8_t*)(debug_buf + 7 ), (uint8_t*) "off",3 )) { + if ( xmemmatch ( ( uint8_t * )( debug_buf + 7 ), ( uint8_t * ) "off", 3 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rClock Debug OFF\n\r" ); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "Clock Debug Off\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf( "Clock Debug Off" ); + debug_clock = false; } } - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dlength ", 8 ) ){ - if (xmemmatch( (uint8_t*)(debug_buf + 8 ), (uint8_t*) "on", 2 ) ) { + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dprintclock ", 12 ) ) + { + if ( xmemmatch ( ( uint8_t * )( debug_buf + 12 ), ( uint8_t * ) "on", 2 ) ) + { + miss_match = false; + + vz_printf ( "Clock Debug <VZ PKG PRINT> On" ); + + debug_print_clock = true; + } + if ( xmemmatch ( ( uint8_t * )( debug_buf + 12 ), ( uint8_t * ) "off", 3 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rString length debug ON\n\r" ); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "String length debug On\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ( "Clock Debug <VZ PKG PRINT> Off" ); + + debug_print_clock = false; + } + } + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dlength ", 8 ) ) + { + if ( xmemmatch ( ( uint8_t * )( debug_buf + 8 ), ( uint8_t * ) "on", 2 ) ) + { + miss_match = false; + + vz_printf ( "String length debug On" ); + debug_string_length = true; } - if (xmemmatch( (uint8_t*)(debug_buf + 8 ), (uint8_t*) "off",3 )) { + if ( xmemmatch ( ( uint8_t * )( debug_buf + 8 ), ( uint8_t * ) "off", 3 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rString length debug OFF\n\r" ); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "String length debug Off\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ( "String length debug Off" ); + debug_string_length = false; } } - - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dbind ", 6 ) ){ - if (xmemmatch( (uint8_t*)(debug_buf + 6 ), (uint8_t*) "on", 2 ) ) { + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dbind ", 6 ) ) + { + if ( xmemmatch ( ( uint8_t * )( debug_buf + 6 ), ( uint8_t * ) "on", 2 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rUDP Bind Debug ON\n\r" ); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "UDP Bind Debug On\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ( "UDP Bind Debug On" ); + debug_bind = true; } - if (xmemmatch( (uint8_t*)(debug_buf + 6 ), (uint8_t*) "off",3 )) { + else if ( xmemmatch ( ( uint8_t * )( debug_buf + 6 ), ( uint8_t * ) "off",3 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rUDP Bind Debug OFF\n\r" ); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "UDP Bind Debug Off\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ( "UDP Bind Debug Off" ); + debug_bind = false; } } - - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dresetrtp ", 10 ) ) { - if (xmemmatch( (uint8_t*)(debug_buf + 10 ), (uint8_t*) "on", 2 ) ) { + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dresetrtp ", 10 ) ) + { + if ( xmemmatch ( ( uint8_t * )( debug_buf + 10 ), ( uint8_t * ) "on", 2 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rReset RTP Debug ON\n\r" ); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "Reset RTP Debug On\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ( "Reset RTP Debug On" ); + debug_reset_rtp = true; } - if (xmemmatch( (uint8_t*)(debug_buf + 10 ), (uint8_t*) "off",3 )) { + else if ( xmemmatch ( ( uint8_t * )( debug_buf + 10 ), ( uint8_t * ) "off", 3 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rReset RTP Debug OFF\n\r" ); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "Reset RTP Debug Off\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ( "Reset RTP Debug Off" ); + debug_reset_rtp = false; } } - - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "duart ", 6 ) ) { - if (xmemmatch( (uint8_t*)(debug_buf + 6 ), (uint8_t*) "on", 2 ) ) { + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "duart ", 6 ) ) + { + if ( xmemmatch ( ( uint8_t * )( debug_buf + 6 ), ( uint8_t * ) "on", 2 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rEnable UART3 usage\n\r" ); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "Enable UART3 usage\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ( "Enable UART3 usage" ); + debug_uart3 = true; } - if (xmemmatch( (uint8_t*)(debug_buf + 6 ), (uint8_t*) "off",3 )) { + else if ( xmemmatch ( ( uint8_t * )( debug_buf + 6 ), ( uint8_t * ) "off", 3 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rDisable UART3 usage\n\r" ); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "Disable UART3 usage\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ( "Disable UART3 usage" ); + debug_uart3 = false; } } - - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dprint ", 7 ) ){ - if (xmemmatch( (uint8_t*)(debug_buf + 7 ), (uint8_t*) "on", 2 ) ){ + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dprint ", 7 ) ) + { + if ( xmemmatch ( ( uint8_t * )( debug_buf + 7 ), ( uint8_t * ) "on", 2 ) ) + { miss_match = false; - if( debug_uart3 ) pc.printf( "\n\rDebug print On\n\r" ); - if( from_eth ){ - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "Debug print On\n\r" ); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - } + + vz_printf ( "Debug print On" ); + print_values = true; } - if (xmemmatch( (uint8_t*)(debug_buf + 7 ), (uint8_t*) "off",3 )) { + else if ( xmemmatch ( ( uint8_t * )( debug_buf + 7 ), ( uint8_t * ) "off", 3 ) ) + { miss_match = false; - if( debug_uart3 ) pc.printf( "\n\rDebug print Off\n\r" ); - if( from_eth ){ - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "Debug print Off\n\r" ); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - } + + vz_printf ( "Debug print Off" ); + print_values = false; } } - - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dmissed ", 8 ) ) { - if (xmemmatch( (uint8_t*)(debug_buf + 8 ), (uint8_t*) "on", 2 ) ) { + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dmissed ", 8 ) ) + { + if ( xmemmatch ( ( uint8_t * )( debug_buf + 8 ), ( uint8_t * ) "on", 2 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rDebug Missed ON\n\r" ); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "Debug Missed ON\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ( "Debug Missed On" ); + debug_missed = true; } - if (xmemmatch( (uint8_t*)(debug_buf + 8 ), (uint8_t*) "off", 3 )) { + else if ( xmemmatch ( ( uint8_t * )( debug_buf + 8 ), ( uint8_t * ) "off", 3 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rDebug Missed Off\n\r" ); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "Debug Missed Off\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ( "Debug Missed Off" ); + debug_missed = false; } } - - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dreconnect ", 11 ) ) { - if (xmemmatch( (uint8_t*)(debug_buf + 11 ), (uint8_t*) "on", 2 ) ) { + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dreconnect ", 11 ) ) + { + if ( xmemmatch ( ( uint8_t * )( debug_buf + 11 ), ( uint8_t * ) "on", 2 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rReconnecet Debug ON\n\r" ); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "Reconnecet Debug On\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ( "Reconnecet Debug On" ); + debug_reconnect = true; } - if (xmemmatch( (uint8_t*)(debug_buf + 11 ), (uint8_t*) "off", 3 )) { + else if ( xmemmatch ( ( uint8_t * )( debug_buf + 11 ), ( uint8_t * ) "off", 3 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rReconnecet Debug OFF\n\r" ); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "Reconnecet Debug Off\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ( "Reconnecet Debug Off" ); + debug_reconnect = false; } } - - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dmatch ", 7 ) ) { - if (xmemmatch( (uint8_t*)(debug_buf + 7 ), (uint8_t*) "on", 2 ) ) { + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dmatch ", 7 ) ) + { + if ( xmemmatch ( ( uint8_t * )( debug_buf + 7 ), ( uint8_t * ) "on", 2 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rPort Match Debug ON\n\r" ); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "Port Match Debug On\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ( "Port Match Debug On" ); + debug_port_match = true; } - if (xmemmatch( (uint8_t*)(debug_buf + 7 ), (uint8_t*) "off",3 )) { + else if ( xmemmatch ( ( uint8_t * )( debug_buf + 7 ), ( uint8_t * ) "off", 3 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rPort Match Debug OFF\n\r" ); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "Port Match Debug Off\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ( "Port Match Debug Off" ); + debug_port_match = false; } } - - - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dmuted ", 7 ) ) { - if (xmemmatch( (uint8_t*)(debug_buf + 7 ), (uint8_t*) "on", 2 ) ) { + + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dmuted ", 7 ) ) + { + if ( xmemmatch ( ( uint8_t * )( debug_buf + 7 ), ( uint8_t * ) "on", 2 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rMuted Debug ON\n\r" ); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "Muted Debug On\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ( "Muted Debug On" ); + debug_muted = true; } - if (xmemmatch( (uint8_t*)(debug_buf + 7 ), (uint8_t*) "off",3 )) { + else if ( xmemmatch ( ( uint8_t * )( debug_buf + 7 ), ( uint8_t * ) "off", 3 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rMuted Debug OFF\n\r" ); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "Muted Debug Off\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ( "Muted Debug Off" ); + debug_muted = false; } } - - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dwdt ", 5 ) ) { - if (xmemmatch( (uint8_t*)(debug_buf + 5 ), (uint8_t*) "on", 2 ) ) { + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dwdt ", 5 ) ) + { + if ( xmemmatch ( ( uint8_t * )( debug_buf + 5 ), ( uint8_t * ) "on", 2 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rWdt Debug ON\n\r" ); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "Wdt Debug On\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ( "Wdt Debug On" ); + wdt_show = true; } - if (xmemmatch( (uint8_t*)(debug_buf + 5 ), (uint8_t*) "off",3 )) { + if ( xmemmatch ( ( uint8_t * )( debug_buf + 5 ), ( uint8_t * ) "off",3 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rWdt Debug OFF\n\r" ); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "Wdt Debug Off\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ( "Wdt Debug Off" ); + wdt_show = false; } } - - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "drefresh ", 9 ) ) { - if (xmemmatch( (uint8_t*)(debug_buf + 9 ), (uint8_t*) "on", 2 ) ) { + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "drefresh ", 9 ) ) + { + if ( xmemmatch ( ( uint8_t * )( debug_buf + 9 ), ( uint8_t * ) "on", 2 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rRefresh Debug ON\n\r" ); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "Refresh Debug On\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ( "Refresh Debug On" ); + debug_refresh= true; } - if (xmemmatch( (uint8_t*)(debug_buf + 9 ), (uint8_t*) "off",3 )) { + if ( xmemmatch ( ( uint8_t * )( debug_buf + 9 ), ( uint8_t * ) "off",3 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rRefresh Debug OFF\n\r" ); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "Refresh Debug Off\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ( "Refresh Debug Off" ); + debug_refresh = false; } } - - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dping ", 6 ) ) { - if (xmemmatch( (uint8_t*)(debug_buf + 6 ), (uint8_t*) "on", 2 ) ) { + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dping ", 6 ) ) + { + if ( xmemmatch ( ( uint8_t * )( debug_buf + 6 ), ( uint8_t * ) "on", 2 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rPing Debug ON\n\r" ); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "Ping Debug On\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ( "Ping Debug On" ); + debug_ping = true; } - if (xmemmatch( (uint8_t*)(debug_buf + 6 ), (uint8_t*) "off",3 )) { + if ( xmemmatch ( ( uint8_t * )( debug_buf + 6 ), ( uint8_t * ) "off", 3 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rPing Debug OFF\n\r" ); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "Ping Debug Off\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ( "Ping Debug Off" ); + debug_ping= false; } } - - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dwu ", 4 ) ) { - if (xmemmatch( (uint8_t*)(debug_buf + 4 ), (uint8_t*) "on", 2 ) ) { + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dwu ", 4 ) ) + { + if ( xmemmatch ( ( uint8_t * )( debug_buf + 4 ), ( uint8_t * ) "on", 2 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rWake Up Debug ON\n\r" ); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "Wake Up Debug On\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ( "Wake Up Debug On" ); + debug_wake = true; } - if (xmemmatch( (uint8_t*)(debug_buf + 4 ), (uint8_t*) "off",3 )) { + if ( xmemmatch ( ( uint8_t * )( debug_buf + 4 ), ( uint8_t * ) "off", 3 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rWake Up Debug OFF\n\r" ); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "Wake Up Debug Off\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ( "Wake Up Debug Off" ); + debug_wake = false; } } - - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "tcp_alive ", 10 ) ) { - if (xmemmatch( (uint8_t*)(debug_buf + 10 ), (uint8_t*) "on", 2 ) ) { + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "tcp_alive ", 10 ) ) + { + if ( xmemmatch ( ( uint8_t * )( debug_buf + 10 ), ( uint8_t * ) "on", 2 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rTCP don't drop mode on\n\r" ); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "TCP don't drop mode on\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ( "TCP don't drop mode on" ); + tcp_alive = true; } - if (xmemmatch( (uint8_t*)(debug_buf + 10 ), (uint8_t*) "off",3 )) { + else if ( xmemmatch ( ( uint8_t * )( debug_buf + 10 ), ( uint8_t * ) "off", 3 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rTCP don't drop mode off\n\r" ); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "TCP don't drop mode off\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ( "TCP don't drop mode off" ); + tcp_alive = false; } } - - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "daging ",7 ) ) { - if (xmemmatch( (uint8_t*)(debug_buf + 7 ), (uint8_t*) "on", 2 ) ) { + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "daging ",7 ) ) + { + if ( xmemmatch ( ( uint8_t * )( debug_buf + 7 ), ( uint8_t * ) "on", 2 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rAging Debug ON\n\r" ); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "Aging Debug On\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ( "Aging Debug On" ); + debug_aging = true; } - if (xmemmatch( (uint8_t*)(debug_buf + 7 ), (uint8_t*) "off",3 )) { + else if ( xmemmatch ( ( uint8_t * )( debug_buf + 7 ), ( uint8_t * ) "off",3 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rAging Debug OFF\n\r" ); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "Aging Debug Off\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ( "Aging Debug Off" ); + debug_aging = false; } } - - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dcpld ", 6 ) ) { - if (xmemmatch( (uint8_t*)(debug_buf + 6 ), (uint8_t*) "on", 2 ) ) { + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dcpld ", 6 ) ) + { + if ( xmemmatch ( ( uint8_t * )( debug_buf + 6 ), ( uint8_t * ) "on", 2 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rDCPLD Debug ON\n\r" ); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "DCPLD Debug On\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ( "DCPLD Debug On" ); + debug_cpld = true; debug_cb_rx = true; debug_cb_tx = true; } - if (xmemmatch( (uint8_t*)(debug_buf + 6 ), (uint8_t*) "off",3 ) ) { + else if ( xmemmatch ( ( uint8_t * )( debug_buf + 6 ), ( uint8_t * ) "off",3 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rDCPLD Debug OFF\n\r" ); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "DCPLD Debug Off\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ( "DCPLD Debug Off" ); + debug_cpld = false; debug_cb_rx = false; debug_cb_tx = false; } } - - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dtxshow ", 8 ) ) { - if (xmemmatch( (uint8_t*)(debug_buf + 8 ), (uint8_t*) "on", 2 ) ) { + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dtxshow ", 8 ) ) + { + if ( xmemmatch ( ( uint8_t * )( debug_buf + 8 ), ( uint8_t * ) "on", 2 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rDCPLD Show TX Debug ON\n\r" ); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "DCPLD Show TX Debug On\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ( "DCPLD Show TX Debug On" ); + debug_show_tx_cpld = true; } - if (xmemmatch( (uint8_t*)(debug_buf + 8 ), (uint8_t*) "off",3 ) ) { + else if ( xmemmatch ( ( uint8_t * )( debug_buf + 8 ), ( uint8_t * ) "off",3 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rDCPLD Show TX Debug OFF\n\r" ); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "DCPLD Show TX Debug Off\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ( "DCPLD Show TX Debug Off" ); + debug_show_tx_cpld = false; } } - - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dshowcpld ", 10 ) ) { - if (xmemmatch( (uint8_t*)(debug_buf + 10 ), (uint8_t*) "on", 2 ) ) { + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dshowcpld ", 10 ) ) + { + if ( xmemmatch ( ( uint8_t * )( debug_buf + 10 ), ( uint8_t * ) "on", 2 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rDCPLD Show Debug ON\n\r" ); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "DCPLD Show Debug On\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ( "DCPLD Show Debug On" ); + debug_show_tx_cpld = true; debug_show_rx_cpld = true; } - if (xmemmatch( (uint8_t*)(debug_buf + 10 ), (uint8_t*) "off",3 ) ) { + else if ( xmemmatch ( ( uint8_t * )( debug_buf + 10 ), ( uint8_t * ) "off", 3 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rDCPLD Show Debug OFF\n\r" ); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "DCPLD Show Debug Off\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + vz_printf ( "DCPLD Show Debug Off" ); + debug_show_tx_cpld = false; debug_show_rx_cpld = false; } } - + - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "drxshow ", 8 ) ) { - if (xmemmatch( (uint8_t*)(debug_buf + 8 ), (uint8_t*) "on", 2 ) ) { + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "drxshow ", 8 ) ) + { + if ( xmemmatch ( ( uint8_t * )( debug_buf + 8 ), ( uint8_t * ) "on", 2 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rDCPLD Show RX Debug ON\n\r" ); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "DCPLD Show RX Debug On\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ( "DCPLD Show RX Debug On" ); + debug_show_rx_cpld = true; } - if (xmemmatch( (uint8_t*)(debug_buf + 8 ), (uint8_t*) "off",3 ) ) { + else if ( xmemmatch ( ( uint8_t * )( debug_buf + 8 ), ( uint8_t * ) "off",3 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rDCPLD Show RX Debug OFF\n\r" ); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "DCPLD Show RX Debug Off\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ( "DCPLD Show RX Debug Off" ); + debug_show_rx_cpld = false; } } - - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dcks_err ", 9 ) ){ - if (xmemmatch( (uint8_t*)(debug_buf + 9 ), (uint8_t*) "on", 2 ) ) { + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dcks_err ", 9 ) ) + { + if ( xmemmatch ( ( uint8_t * )( debug_buf + 9 ), ( uint8_t * ) "on", 2 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rCKS_ERR Debug ON\n\r" ); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "CKS_ERR Debug On\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ( "CKS_ERR Debug On" ); + debug_cks_err = true; } - if (xmemmatch( (uint8_t*)(debug_buf + 9 ), (uint8_t*) "off", 3 ) ) { + else if ( xmemmatch ( ( uint8_t * )( debug_buf + 9 ), ( uint8_t *) "off", 3 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rCKS_ERR Debug OFF\n\r" ); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "CKS_ERR Debug off\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ( "CKS_ERR Debug Off" ); + debug_cks_err = false; } } - - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dinvite ", 8 ) ){ - if( xmemmatch( (uint8_t*)(debug_buf + 8 ), (uint8_t*) "on", 2 ) ) { + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * )"dinvite ", 8 ) ) + { + if ( xmemmatch ( ( uint8_t * )( debug_buf + 8 ), ( uint8_t * ) "on", 2 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rInvite Debug ON\n\r" ); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "Invite Debug On\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ( "Invite Debug ON" ); + debug_invite = true; } - if( xmemmatch( (uint8_t*)(debug_buf + 8 ), (uint8_t*) "off",3 )) { + else if ( xmemmatch ( ( uint8_t * )( debug_buf + 8 ), ( uint8_t * ) "off",3 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rInvite Debug OFF\n\r" ); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "Invite Debug Off\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } - debug_invite = 0; + + vz_printf ( "Invite Debug ON" ); + + debug_invite = false; } } - - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dparallel ", 10 ) ) { - if( xmemmatch( ( uint8_t * )( debug_buf + 10 ), ( uint8_t * )"on", 2 ) ) { + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dparallel ", 10 ) ) + { + if ( xmemmatch ( ( uint8_t * )( debug_buf + 10 ), ( uint8_t * )"on", 2 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rParallel Write Debug ON\n\r" ); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "\n\rParallel Write Debug ON\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ( "Parallel Write Debug On" ); + dparallel = true; } - if( xmemmatch( ( uint8_t * )( debug_buf + 10 ), ( uint8_t *)"off", 3 )) { + else if ( xmemmatch ( ( uint8_t * )( debug_buf + 10 ), ( uint8_t *)"off", 3 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rParallel Write Debug OFF\n\r" ); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "\n\rParallel Write Debug Off\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ( "Parallel Write Debug Off" ); + dparallel = false; } - } - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dtelos ", 7 ) ) { - if (xmemmatch( (uint8_t*)( debug_buf + 7 ), (uint8_t*) "on", 2 ) ) { + } + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dtelos ", 7 ) ) + { + if ( xmemmatch ( ( uint8_t * )( debug_buf + 7 ), ( uint8_t * ) "on", 2 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rTelemetry Debug ON\n\r" ); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "\n\rTelemetry Debug On\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ( "Telemetry Debug On" ); + debug_telemetry = true; } - if (xmemmatch( (uint8_t*)(debug_buf + 7 ), (uint8_t*) "off", 3 )) { + else if ( xmemmatch ( ( uint8_t * )( debug_buf + 7 ), ( uint8_t * ) "off", 3 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rTelemetry Debug OFF\n\r" ); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "\n\rTelemetry Debug Off\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ( "Telemetry Debug Off" ); + debug_telemetry = false; } } - - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dcks ", 5 ) ) + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dcks ", 5 ) ) { - if (xmemmatch( (uint8_t*)(debug_buf + 5 ), (uint8_t*) "on",2 ) ){ + if ( xmemmatch ( ( uint8_t * )( debug_buf + 5 ), ( uint8_t * ) "on", 2 ) ) + { miss_match = false; - if( debug_uart3 ) pc.printf( "\n\rCKS Debug ON\n\r" ); - if( from_eth ){ - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "CKS Debug On\n\r" ); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - } + + vz_printf ( "CKS Debug On" ); + debug_cks = true; } - if (xmemmatch( (uint8_t*)(debug_buf + 5 ), (uint8_t*) "off",3 )) { + else if ( xmemmatch ( ( uint8_t * )( debug_buf + 5 ), ( uint8_t * )"off",3 ) ) + { miss_match = false; - if( debug_uart3 ) pc.printf( "\n\rCKS Debug OFF\n\r" ); - if( from_eth ){ - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "CKS Debug Off\n\r" ); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - } + + vz_printf ( "CKS Debug Off" ); + debug_cks = false; } } - - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "cc ", 3 ) ) + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "cc ", 3 ) ) { miss_match = false; + int ext,port; char *split, *ref, *cmd; @@ -2022,547 +1763,459 @@ ext = atoi ( split ); port = ext; - - split += strlen( split ) + 1; + + split += strlen ( split ) + 1; cmd = split; promptcb_last_ext = ext; promptcb_last_port = port; - strcpy( promptcb_last_cmd, cmd ); - - for ( register int i = strlen( cmd ); i < DEBUGBUFSIZE; i++ ) cmd [ i ] = 0; + strcpy ( promptcb_last_cmd, cmd ); - if ( debug_uart3 && !( from_eth ) ) pc.printf("\r\next=%d port=%d cmd=%s", ext, port, cmd ); - - send2callboxes( build_cb_package( ext, port, PROMPT, cmd, id_msg++, CB_BUFFER_SIZE - VZ_HEADER_OFFSET, write_buffer ) ); - - if ( debug_uart3 && !( from_eth ) ) pc.printf("\n\rComando enviado"); + for ( register int i = strlen ( cmd ); i < DEBUGBUFSIZE; i++ ) cmd [ i ] = 0; - if( from_eth ) { - char eth_msg[ 512 ]; - snprintf( eth_msg, 512 - 1, "\r\next=%d port=%d cmd=%s\r\nComando enviado\n\r> ", ext, port, cmd ); - if( tcp_session && !udp_query ) { - tcp_client.send_all( eth_msg, strlen( eth_msg ) ); - } else if( udp_query ) { - udp_query_send_msg( eth_msg ); - } - } + send2callboxes( build_cb_package( ext, port, PROMPT, cmd, id_msg++, CB_BUFFER_SIZE - VZ_HEADER_OFFSET, prompt_write_buffer ) ); + + vz_printf ( "ext=%d port=%d cmd=%s\r\nComando enviado", ext, port, cmd ); debug_buf = ref; + bufptr = 0; - for( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; + + for ( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf [ i ] = 0; } - - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "bc ", 3 ) ) + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "bc ", 3 ) ) { miss_match = false; - strcat( debug_buf, "\r" ); - + strcat ( debug_buf, "\r" ); + char * cmd = debug_buf + 3; for ( register int i = strlen( cmd ); i < DEBUGBUFSIZE; i++ ) cmd [ i ] = 0; - if ( debug_uart3 && !( from_eth ) ) pc.printf("\r\next=%x port=%x cmd=%s", BROADCAST_EXT, BROADCAST_EXT, cmd ); - - send2callboxes ( build_cb_package( BROADCAST_EXT, BROADCAST_EXT, PROMPT, cmd, id_msg++, CB_BUFFER_SIZE - VZ_HEADER_OFFSET, write_buffer ) ); + send2callboxes ( build_cb_package ( BROADCAST_EXT, BROADCAST_EXT, PROMPT, cmd, id_msg++, CB_BUFFER_SIZE - VZ_HEADER_OFFSET, prompt_write_buffer ) ); - if ( debug_uart3 && !( from_eth ) ) pc.printf("\n\rComando enviado"); - - if( from_eth ) { - char eth_msg[ 512 ]; - snprintf( eth_msg, 512 - 1, "\r\next=%x port=%x cmd=%s\r\nComando enviado\n\r> ", BROADCAST_EXT, BROADCAST_EXT, cmd ); - if( tcp_session && !udp_query ) { - tcp_client.send_all( eth_msg, strlen( eth_msg ) ); - } else if( udp_query ) { - udp_query_send_msg( eth_msg ); - } - } + vz_printf ( "ext=%x port=%x cmd=%s\r\nComando enviado", BROADCAST_EXT, BROADCAST_EXT, cmd ); bufptr = 0; - for( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf [ i ] = 0; + + for ( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf [ i ] = 0; } - - - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "pcb ", 4 )) { + + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "pcb ", 4 ) ) + { miss_match = false; + int ext,port; char *split, *ref, *cmd; ref = debug_buf; - strcat( debug_buf, "\r" ); + strcat ( debug_buf, "\r" ); - split = strtok( debug_buf + 4, " " ); - ext = atoi( split ); + split = strtok ( debug_buf + 4, " " ); + ext = atoi ( split ); - port = convert_ext_to_port( ext ); - split += strlen( split ) + 1; + port = convert_ext_to_port ( ext ); + split += strlen ( split ) + 1; cmd = split; promptcb_last_ext = ext; promptcb_last_port = port; - strcpy( promptcb_last_cmd, cmd ); + strcpy ( promptcb_last_cmd, cmd ); - for( register int i = strlen( cmd ); i < DEBUGBUFSIZE; i++ ) cmd[ i ] = 0; + for ( register int i = strlen ( cmd ); i < DEBUGBUFSIZE; i++ ) cmd [ i ] = 0; - if( debug_uart3 && !( from_eth ) ) pc.printf("\r\next=%d port=%d cmd=%s", ext, port, cmd ); - send2callboxes( build_cb_package( ext, port, PROMPT, cmd, id_msg++, CB_BUFFER_SIZE - VZ_HEADER_OFFSET, write_buffer ) ); - if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rComando enviado"); + send2callboxes( build_cb_package( ext, port, PROMPT, cmd, id_msg++, CB_BUFFER_SIZE - VZ_HEADER_OFFSET, prompt_write_buffer ) ); + + vz_printf ( "ext=%d port=%d cmd=%s\r\nComando enviado", ext, port, cmd ); + + debug_buf = ref; + + bufptr = 0; + + for ( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf [ i ] = 0; + } - if( from_eth ) { - char eth_msg[ 512 ]; - snprintf( eth_msg, 512 - 1, "\r\next=%d port=%d cmd=%s\r\nComando enviado\n\r> ", ext, port, cmd ); - if( tcp_session && !udp_query ) { - tcp_client.send_all( eth_msg, strlen( eth_msg ) ); - } else if( udp_query ) { - udp_query_send_msg( eth_msg ); - } - } + else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "pend_all" ) ) + { + miss_match = false; + + char cmd_msg [ CB_BUFFER_SIZE ] = "pend\r"; + + for ( register int i = strlen ( cmd_msg ); i < CB_BUFFER_SIZE; i++ ) cmd_msg [ i ] = 0; - debug_buf = ref; + send2callboxes ( build_cb_package ( BROADCAST_EXT, BROADCAST_EXT, PROMPT, cmd_msg, id_msg++, CB_BUFFER_SIZE - VZ_HEADER_OFFSET, prompt_write_buffer ) ); + + vz_printf ( "ext=%x port=%x cmd=%s\r\nComando enviado", BROADCAST_EXT, BROADCAST_EXT, cmd_msg ); + bufptr = 0; - for( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; + + for ( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf [ i ] = 0; } - - else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "pend_all" ) ) + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "bye ", 4 ) ) { miss_match = false; - char cmd_msg [ CB_BUFFER_SIZE ] = "pend\r"; - - for( register int i = strlen( cmd_msg ); i < CB_BUFFER_SIZE; i++ ) cmd_msg [ i ] = 0; - - if( debug_uart3 and !( from_eth ) ) pc.printf("\r\next=%x port=%x cmd=%s", BROADCAST_EXT, BROADCAST_EXT, cmd_msg ); - - send2callboxes ( build_cb_package ( BROADCAST_EXT, BROADCAST_EXT, PROMPT, cmd_msg, id_msg++, CB_BUFFER_SIZE - VZ_HEADER_OFFSET, write_buffer ) ); - - if ( debug_uart3 and !( from_eth ) ) pc.printf ("\n\rComando enviado"); - - if( from_eth ) - { - char eth_msg [ 512 ]; - snprintf ( eth_msg, 512 - 1, "\r\next=%x port=%x cmd=%s\r\nComando enviado\n\r> ", BROADCAST_EXT, BROADCAST_EXT, cmd_msg ); - if( tcp_session and !udp_query ) - { - tcp_client.send_all ( eth_msg, strlen( eth_msg ) ); - } - else if( udp_query ) - { - udp_query_send_msg( eth_msg ); - } - } - - bufptr = 0; - for ( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf [ i ] = 0; - } - - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "bye ", 4 ) ) - { - miss_match = false; int ext,port; char * ref; ref = debug_buf; - strcat( debug_buf, "\r" ); + strcat ( debug_buf, "\r" ); - ext = atoi( strtok( debug_buf + 4, " " ) ); + ext = atoi ( strtok ( debug_buf + 4, " " ) ); port = ext; promptcb_last_ext = ext; promptcb_last_port = port; - + char msg [ CB_BUFFER_SIZE ] = ""; - + for ( register int i = 0; i < CB_BUFFER_SIZE; i ++ ) msg [ i ] = 0; - - strcpy( msg, "bye" ); - if ( debug_uart3 && !( from_eth ) ) pc.printf("\r\nSend BYE to ext=%d port=%d", ext, port ); - - send2callboxes ( build_cb_package( ext, port, CB_BYE, msg, ( id_msg++ & ~BIT7 ), CB_BUFFER_SIZE - VZ_HEADER_OFFSET, write_buffer ) ); - - if ( debug_uart3 && !( from_eth ) ) pc.printf("\n\rComando enviado"); + strcpy ( msg, "bye" ); - if( from_eth ) { - char eth_msg[ 512 ]; - snprintf( eth_msg, 512 - 1, "\r\nSend BYE to ext=%d port=%d\r\nComando enviado\n\r> ", ext, port ); - if( tcp_session && !udp_query ) { - tcp_client.send_all( eth_msg, strlen( eth_msg ) ); - } else if( udp_query ) { - udp_query_send_msg( eth_msg ); - } - } + send2callboxes ( build_cb_package ( ext, port, CB_BYE, msg, ( id_msg++ & ~BIT7 ), CB_BUFFER_SIZE - VZ_HEADER_OFFSET, prompt_write_buffer ) ); + + vz_printf ( "Send BYE to ext=%d port=%d\r\nComando enviado", ext, port ); debug_buf = ref; + bufptr = 0; - for( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; + + for ( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf [ i ] = 0; } - - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "end_call ", 9 ) ) + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "end_call ", 9 ) ) { miss_match = false; + char * ref; ref = debug_buf; - end_call_ext = atoi( strtok( debug_buf + 9, " " ) ); + end_call_ext = atoi ( strtok ( debug_buf + 9, " " ) ); + end_call = true; debug_buf = ref; + bufptr = 0; - for ( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; - - if ( debug_uart3 and not ( from_eth ) ) pc.printf ("\r\nkill call :: %u", end_call_ext ); - if ( from_eth ) - { - char eth_msg [ 512 ]; - snprintf ( eth_msg, 512 - 1, "\r\nkill call :: %u\r\n> ", end_call_ext ); - if ( tcp_session and !udp_query ) - { - tcp_client.send_all ( eth_msg, strlen ( eth_msg ) ); - } - else if ( udp_query ) - { - udp_query_send_msg ( eth_msg ); - } - } + for ( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf [ i ] = 0; + + vz_printf( "kill call :: %u\r\n> ", end_call_ext ); } - - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "msg", 3 ) ) + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "msg", 3 ) ) { miss_match = false; - + char * ref = debug_buf; - + if ( ( strlen ( debug_buf ) == strlen ( "msg" ) ) or ( strstr ( debug_buf + 4, "help" ) not_eq ( NULL ) ) ) { - send_msg("\r\nusage msg < ext> <msg_id> <type>\r\n"); - } - else - { - + vz_printf ("usage msg < ext> <msg_id> <type>" ); + } else { + char * split = strtok ( debug_buf + 4, " " ); int ext = atoi ( split ); int port = ext; - + // <msg_id> split += strlen ( split ) + 1; split = strtok( NULL, " " ); - + int seq_num = ( strncasecmp ( split, "0x", 2 ) ) ? atoi ( split ) : ( int ) strtol ( split + 2, NULL, 16 ); - + // <type> split += strlen ( split ) + 1; - split = strtok( NULL, " " ); - + split = strtok ( NULL, " " ); + uint8_t num_type = 0; - - char type[ 16 ]; - + + char type [ 16 ]; + strncpy ( type, split, sizeof ( type ) - 1 ); - + if ( not ( strcasecmp ( type, "REGISTRY" ) ) ) num_type = REGISTRY; - + else if ( not ( strcasecmp ( type, "INVITE" ) ) ) num_type = INVITE; - + else if ( not ( strcasecmp ( type, "BOOT" ) ) ) num_type = BOOT; - + else if ( not ( strcasecmp ( type, "TELEMETRY" ) ) ) num_type = TELEMETRY; - + else if ( not ( strcasecmp ( type, "bye" ) ) ) num_type = CB_BYE; - + else if ( not ( strcasecmp ( type, "PROMPT" ) ) ) num_type = PROMPT; - + char cmd [ 32 ] = ""; - - if ( num_type not_eq PROMPT ) for( register int i = 0; i < 32; i++ ) cmd[ i ] = 0; - + + if ( num_type not_eq PROMPT ) for( register int i = 0; i < 32; i++ ) cmd [ i ] = 0; + else strcpy ( cmd, "ping\r" ); - - if ( debug_uart3 and !( from_eth ) ) pc.printf ("\r\next=%d port=%d msg_id=%#x type=%#x", ext, port, seq_num, num_type ); - - send2callboxes( build_cb_package( ext, port, num_type, cmd, seq_num, CB_BUFFER_SIZE - VZ_HEADER_OFFSET, write_buffer ) ); - - if ( debug_uart3 and !( from_eth ) ) pc.printf ("\n\rComando enviado"); + + send2callboxes( build_cb_package( ext, port, num_type, cmd, seq_num, CB_BUFFER_SIZE - VZ_HEADER_OFFSET, prompt_write_buffer ) ); - if ( from_eth ) - { - char eth_msg [ 512 ]; - snprintf ( eth_msg, 512 - 1, "\r\next=%d port=%d msg_id=%#x type=%#x\r\n> ", ext, port, seq_num, num_type ); - if ( tcp_session and !udp_query ) - { - tcp_client.send_all ( eth_msg, strlen ( eth_msg ) ); - } - else if ( udp_query ) - { - udp_query_send_msg ( eth_msg ); - } - } + vz_printf ( "ext=%d port=%d msg_id=%#x type=%#x", ext, port, seq_num, num_type ); } - + debug_buf = ref; + bufptr = 0; - for( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf [ i ] = 0; + + for ( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf [ i ] = 0; } - - - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "pcc ", 4 )) { + + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "pcc ", 4 ) ) + { miss_match = false; + int ext,port; char *split, *ref, *cmd; ref = debug_buf; - strcat( debug_buf, "\r" ); + strcat ( debug_buf, "\r" ); - split = strtok( debug_buf + 4, " " ); - ext = atoi( split ); + split = strtok ( debug_buf + 4, " " ); + ext = atoi ( split ); - split += strlen( split ) + 1; - split = strtok( NULL, " " ); - port = atoi( split ); + split += strlen ( split ) + 1; + split = strtok ( NULL, " " ); + port = atoi ( split ); - split += strlen( split ) + 1; + split += strlen ( split ) + 1; cmd = split; promptcb_last_ext = ext; promptcb_last_port = port; - strcpy( promptcb_last_cmd, cmd ); - - for( register int i = strlen( cmd ); i < DEBUGBUFSIZE; i++ ) cmd[ i ] = 0; - - if( debug_uart3 && !( from_eth ) ) pc.printf("\r\next=%d port=%d cmd=%s", ext, port, cmd ); - send2callboxes( build_cb_package( ext, port, PROMPT, cmd, id_msg++, CB_BUFFER_SIZE - VZ_HEADER_OFFSET, write_buffer ) ); - if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rComando enviado"); + strcpy ( promptcb_last_cmd, cmd ); - if( from_eth ) { - char eth_msg[ 512 ]; - snprintf( eth_msg, 512 - 1, "\r\next=%d port=%d cmd=%s\r\nComando enviado\n\r", ext, port, cmd ); - if( tcp_session && !udp_query ) { - tcp_client.send_all( eth_msg, strlen( eth_msg ) ); - } else if( udp_query ) { - udp_query_send_msg( eth_msg ); - } - } + for ( register int i = strlen( cmd ); i < DEBUGBUFSIZE; i++ ) cmd [ i ] = 0; + + send2callboxes ( build_cb_package( ext, port, PROMPT, cmd, id_msg++, CB_BUFFER_SIZE - VZ_HEADER_OFFSET, prompt_write_buffer ) ); + + vz_printf ( "ext=%d port=%d cmd=%s\r\nComando enviado", ext, port, cmd ); debug_buf = ref; + bufptr = 0; - for( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; + + for ( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf [ i ] = 0; } - - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "print_cb ", 9 )) { + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "print_cb ", 9 ) ) + { miss_match = false; char *split; - - split = strtok( debug_buf + 9, " " ); + + split = strtok ( debug_buf + 9, " " ); if( 0 == ( strcasecmp( split, "all" ) ) ) { print_cb_all = true; - } - else - { + } else { print_cb_var = true; - print_this_cb = atoi( split ); + print_this_cb = atoi ( split ); } - + bufptr = 0; - for( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; + for ( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf [ i ] = 0; } - - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "drop_ack ", 9 )) { + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "drop_ack ", 9 ) ) + { miss_match = false; char *split; - + split = strtok( debug_buf + 9, " " ); - + drop_this_amount_of_ack_to_ast = atoi( split ); - - send_msg("Will be droped %d acks", drop_this_amount_of_ack_to_ast ); - - bufptr = 0; - for( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; - } - - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "frtp ", 5 )) { - miss_match = false; - char *split; - - split = strtok( debug_buf + 5, " " ); - frtp = true; - frtp_target = atoi( split ); - + + vz_printf ("Will be droped %d acks", drop_this_amount_of_ack_to_ast ); + bufptr = 0; for( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; } - - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "rrtp ", 5 )) { + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "frtp ", 5 ) ) + { + miss_match = false; + char *split; + + split = strtok ( debug_buf + 5, " " ); + frtp = true; + frtp_target = atoi ( split ); + + bufptr = 0; + for ( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf [ i ] = 0; + } + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "rrtp ", 5 ) ) + { miss_match = false; char *split; - - split = strtok( debug_buf + 5, " " ); + + split = strtok ( debug_buf + 5, " " ); rescue_rtp = true; - rescue_rtp_target = atoi( split ); - - split += strlen( split ) + 1; + rescue_rtp_target = atoi ( split ); + + split += strlen ( split ) + 1; split = strtok( NULL, " " ); - rescue_rtp_value = atoi( split ); - + rescue_rtp_value = atoi ( split ); + bufptr = 0; - for( register uint16_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; + for ( register uint16_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf [ i ] = 0; } - - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "print_hex_cb ", 13 )) { + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "print_hex_cb ", 13 ) ) + { miss_match = false; char *split; - - split = strtok( debug_buf + 13, " " ); - if( 0 == ( strcasecmp( split, "all" ) ) ) + + split = strtok ( debug_buf + 13, " " ); + if( 0 == ( strcasecmp ( split, "all" ) ) ) { print_hex_cb_all = true; - } - else - { + } else { print_hex_cb_var = true; - print_hex_this_cb = atoi( split ); + print_hex_this_cb = atoi ( split ); } - + bufptr = 0; - for( register uint16_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; + for ( register uint16_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf [ i ] = 0; } - - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "print_sip ", 10 )) { + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * )"print_sip ", 10 ) ) + { miss_match = false; + char *split; - - split = strtok( debug_buf + 10, " " ); - if( 0 == ( strcasecmp( split, "all" ) ) ) + + split = strtok ( debug_buf + 10, " " ); + if ( 0 == ( strcasecmp ( split, "all" ) ) ) { print_sip_all = true; - } - else - { + } else { print_sip_var = true; - print_this_sip = atoi( split ); + print_this_sip = atoi ( split ); } - + bufptr = 0; - for( register uint16_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; + for ( register uint16_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf [ i ] = 0; } - - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "print_hex_sip ", 14 )) { - miss_match = false; - char *split; - - split = strtok( debug_buf + 14, " " ); - if( 0 == ( strcasecmp( split, "all" ) ) ) - { - print_hex_sip_all = true; - } - else - { - print_hex_sip_var = true; - print_hex_this_sip = atoi( split ); - } - - bufptr = 0; - for( register uint16_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; - } - - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "print_call ", 11 ) ) + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * )"print_hex_sip ", 14 ) ) { miss_match = false; char *split; - - split = strtok( debug_buf + 11, " " ); - if( 0 == ( strcasecmp( split, "all" ) ) ) + + split = strtok ( debug_buf + 14, " " ); + if ( 0 == ( strcasecmp ( split, "all" ) ) ) { - print_call_all = true; + print_hex_sip_all = true; + } else { + print_hex_sip_var = true; + print_hex_this_sip = atoi ( split ); } - else - { - print_call_var = true; - print_this_call = atoi( split ); - } - + bufptr = 0; - for( register uint16_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; + for ( register uint16_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf [ i ] = 0; } - - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "print_hex_call ", 15 ) ) - { - miss_match = false; - char *split; - - split = strtok( debug_buf + 15, " " ); - if( 0 == ( strcasecmp( split, "all" ) ) ) - { - print_hex_call_all = true; - } - else - { - print_hex_call_var = true; - print_hex_this_call = atoi( split ); - } - - bufptr = 0; - for( register uint16_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; - } - - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "print_rtp ", 10 ) ) + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * )"print_call ", 11 ) ) { miss_match = false; char *split; - - split = strtok( debug_buf + 10, " " ); - if( 0 == ( strcasecmp( split, "all" ) ) ) - { - print_rtp_all = true; - } - else + + split = strtok ( debug_buf + 11, " " ); + if ( 0 == ( strcasecmp ( split, "all" ) ) ) { - print_rtp_var = true; - print_this_rtp = atoi( split ); + print_call_all = true; + } else { + print_call_var = true; + print_this_call = atoi ( split ); } - + bufptr = 0; - for( register uint16_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; + for ( register uint16_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf [ i ] = 0; } - - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "print_hex_rtp ", 14 ) ) + + else if ( xmemmatch ( ( uint8_t *)debug_buf, ( uint8_t * ) "print_hex_call ", 15 ) ) + { + miss_match = false; + + char *split; + + split = strtok( debug_buf + 15, " " ); + if ( 0 == ( strcasecmp ( split, "all" ) ) ) + { + print_hex_call_all = true; + } else { + print_hex_call_var = true; + print_hex_this_call = atoi ( split ); + } + + bufptr = 0; + for ( register uint16_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf [ i ] = 0; + } + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "print_rtp ", 10 ) ) { miss_match = false; char *split; + + split = strtok ( debug_buf + 10, " " ); + if ( 0 == ( strcasecmp ( split, "all" ) ) ) + { + print_rtp_all = true; + } else { + print_rtp_var = true; + print_this_rtp = atoi ( split ); + } + + bufptr = 0; + for ( register uint16_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf [ i ] = 0; + } + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "print_hex_rtp ", 14 ) ) + { + miss_match = false; - split = strtok( debug_buf + 14, " " ); - if( 0 == ( strcasecmp( split, "all" ) ) ) + char *split; + + split = strtok ( debug_buf + 14, " " ); + if ( 0 == ( strcasecmp ( split, "all" ) ) ) { print_hex_rtp_all = true; - } - else - { + } else { print_hex_rtp_var = true; - print_hex_this_rtp = atoi( split ); + print_hex_this_rtp = atoi ( split ); } - + bufptr = 0; - for( register uint16_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; + for ( register uint16_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf [ i ] = 0; } - - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "log ", 4 )) { + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "log ", 4 ) ) + { miss_match = false; - - char * split = strtok( debug_buf + 4, " " ); - + + char * split = strtok ( debug_buf + 4, " " ); + { print_cb_var = true; - print_this_cb = atoi( split ); + print_this_cb = atoi ( split ); print_sip_var = true; print_this_sip = print_this_cb; print_call_var = true; @@ -2570,730 +2223,318 @@ print_rtp_var = true; print_this_rtp = print_this_cb; } - + bufptr = 0; - for( register uint16_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; + for ( register uint16_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf [ i ] = 0; } - - - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "rush ", 5 )) { + + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "rush ", 5 ) ) + { miss_match = false; + int ext,port; - char *split, *ref, cmd[ 32 ]; + char *split, *ref, cmd [ 32 ]; ref = debug_buf; - strcat( debug_buf, "\r" ); + strcat ( debug_buf, "\r" ); - split = strtok( debug_buf + 5, " " ); - ext = atoi( split ); + split = strtok ( debug_buf + 5, " " ); + ext = atoi ( split ); - split += strlen( split ) + 1; - split = strtok( NULL, " " ); - port = atoi( split ); + split += strlen ( split ) + 1; + split = strtok ( NULL, " " ); + port = atoi ( split ); - strcpy( cmd, "ping\r\n" ); + strcpy ( cmd, "ping\r\n" ); promptcb_last_ext = ext; promptcb_last_port = port; - strcpy( promptcb_last_cmd, cmd ); - strcat( cmd, "\r\r\r\n" ); - - for( register uint8_t i = 0; i < 3; i++ ) { - if( debug_uart3 && !( from_eth ) ) pc.printf("\r\next=%d port=%d cmd=%s", ext, port, cmd ); - send2callboxes( build_cb_package( ext, port, PROMPT, cmd, id_msg++, CB_BUFFER_SIZE - VZ_HEADER_OFFSET, write_buffer ) ); - if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rComando enviado"); + strcpy ( promptcb_last_cmd, cmd ); + strcat ( cmd, "\r\r\r\n" ); - if( from_eth ) { - char eth_msg[ 512 ]; - snprintf( eth_msg, 512 - 1, "\r\next=%d port=%d cmd=%s\r\nComando enviado\n\r", ext, port, cmd ); - if( tcp_session && !udp_query ) { - tcp_client.send_all( eth_msg, strlen( eth_msg ) ); - } else if( udp_query ) { - udp_query_send_msg( eth_msg ); - } - } + for ( register uint8_t i = 0; i < 3; i++ ) + { + + send2callboxes ( build_cb_package ( ext, port, PROMPT, cmd, id_msg++, CB_BUFFER_SIZE - VZ_HEADER_OFFSET, prompt_write_buffer ) ); + + vz_printf ( "ext=%d port=%d cmd=%s\r\nComando enviado", ext, port, cmd ); } debug_buf = ref; bufptr = 0; - for( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; - } - - - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "_",4 )) { - miss_match = false; - debug_buf[ bufptr++ ] = 0x0D; - debug_buf[ bufptr++ ] = 0x00; - - if( debug_uart3 ) pc.printf("\r\next=%d port=%d\r\ncmd=%s\r\n",promptcb_last_ext, promptcb_last_port, debug_buf + 4 ); - send2callboxes( build_cb_package( promptcb_last_ext, promptcb_last_port, PROMPT, debug_buf + 4, id_msg++, CB_BUFFER_SIZE - VZ_HEADER_OFFSET, write_buffer ) ); - if( debug_uart3 ) pc.printf("\n\rComando enviado\n\r"); + for ( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf [ i ] = 0; } - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "cks",3 )) { + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "_", 4 ) ) + { + miss_match = false; + debug_buf [ bufptr++ ] = 0x0D; + debug_buf [ bufptr++ ] = 0x00; + + send2callboxes ( build_cb_package( promptcb_last_ext, promptcb_last_port, PROMPT, debug_buf + 4, id_msg++, CB_BUFFER_SIZE - VZ_HEADER_OFFSET, prompt_write_buffer ) ); + + vz_printf ( "ext=%d port=%d\r\ncmd=%s\r\nComando enviado",promptcb_last_ext, promptcb_last_port, debug_buf + 4 ); + } + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "cks",3 ) ) + { miss_match = false; pcks_s = true; } - else if (xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "showcb",6 )) { + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "showcb",6 ) ) + { miss_match = false; pshowcb = true; } - - else if (xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "debug_main ", 11 )) { - if (xmemmatch( (uint8_t*)( debug_buf + 11 ), (uint8_t*) "on", 2 )) { + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "debug_main ", 11 ) ) + { + if ( xmemmatch ( ( uint8_t * )( debug_buf + 11 ), ( uint8_t * ) "on", 2 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf("\r\nDebug Main ON"); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "Debug Main On\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ( "Debug Main On" ); + debug_main = true; } - if (xmemmatch( (uint8_t*)( debug_buf + 11 ), (uint8_t*) "off", 3 )) { + else if ( xmemmatch ( ( uint8_t * )( debug_buf + 11 ), ( uint8_t * ) "off", 3 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf("\r\nDebug Main OFF"); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "Debug Main Off\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ( "Debug Main Off" ); + debug_main = 0; } } - - else if (xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dout ", 5 ) ) { - if (xmemmatch( (uint8_t*)( debug_buf + 5 ), (uint8_t*) "on", 2 ) ) { + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dout ", 5 ) ) + { + if ( xmemmatch ( ( uint8_t * )( debug_buf + 5 ), ( uint8_t * ) "on", 2 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf("\r\nOut Debug ON"); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "Out Debug On\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ( "Out Debug On" ); + debug_out_of_range = true; } - if (xmemmatch( (uint8_t*)( debug_buf + 5 ), (uint8_t*) "off", 3 ) ) { + else if ( xmemmatch ( ( uint8_t * )( debug_buf + 5 ), ( uint8_t * ) "off", 3 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf("\r\nOut Debug OFF"); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "Out Debug Off\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ( "Out Debug Off" ); + debug_out_of_range = false; } } - - else if (xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dboot ", 6 ) ) { - if (xmemmatch( (uint8_t*)( debug_buf + 6 ), (uint8_t*) "on", 2 ) ) { + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dboot ", 6 ) ) + { + if ( xmemmatch ( ( uint8_t * )( debug_buf + 6 ), ( uint8_t * ) "on", 2 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf("\r\nBoot Debug ON"); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "Boot Debug On\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ( "Boot Debug On" ); + debug_boot = true; } - if (xmemmatch( (uint8_t*)( debug_buf + 6 ), (uint8_t*) "off", 3 ) ) { + else if ( xmemmatch ( ( uint8_t * )( debug_buf + 6 ), ( uint8_t * ) "off", 3 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf("\r\nBoot Debug OFF"); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "Boot Debug Off\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ( "Boot Debug Off" ); + debug_boot = false; } } - - else if (xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dbloader ", 9 ) ) { - if (xmemmatch( (uint8_t*)( debug_buf + 9 ), (uint8_t*) "on", 2 ) ) { + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dbloader ", 9 ) ) + { + if ( xmemmatch ( ( uint8_t * )( debug_buf + 9 ), ( uint8_t * ) "on", 2 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rBootloader Debug ON\n\r" ); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "Bootloader Debug On\n\r" ); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ( "Bootloader Debug On" ); + debug_bootloader = true; } - if (xmemmatch( (uint8_t*)( debug_buf + 9 ), (uint8_t*) "off", 3 ) ) { + else if ( xmemmatch ( ( uint8_t * )( debug_buf + 9 ), ( uint8_t * ) "off", 3 ) ) { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rBootloader Debug OFF\n\r"); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "Bootloader Debug Off\n\r" ); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ( "Bootloader Debug Off" ); + debug_bootloader = false; } } - - else if (xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "dpower" ) ) + + else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dpower" ) ) { miss_match = false; - if ( !pwr_src_status ) { - if ( debug_uart3 && !( from_eth ) ) pc.printf("\n\rMain power is UP\n\r"); - if ( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "Main power is UP\n\r" ); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + if ( !power_source_status ) + { + vz_printf ( "Main power is UP" ); } else { - if ( debug_uart3 && !( from_eth ) ) pc.printf("\n\rMain power is DOWN\n\r"); - if ( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "Main power is DOWN\n\r" ); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + vz_printf ( "Main power is DOWN" ); } } - - else if (xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dfw ", 4 ) ) { - if (xmemmatch( (uint8_t*)( debug_buf + 4 ), (uint8_t*) "on", 2 ) ) { + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dfw ", 4 ) ) + { + if ( xmemmatch ( ( uint8_t * )( debug_buf + 4 ), ( uint8_t * ) "on", 2 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf("\r\nFW Debug ON"); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "FW Debug On\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ( "FW Debug On" ); + debug_fw = true; } - if (xmemmatch( (uint8_t*)( debug_buf + 4 ), (uint8_t*) "off", 3 ) ) { + else if ( xmemmatch ( ( uint8_t * )( debug_buf + 4 ), ( uint8_t * ) "off", 3 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf("\r\nFW Debug OFF"); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "FW Debug Off\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ( "FW Debug Off" ); + debug_fw = false; } } - - else if (xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dfwp ", 5 ) ) { - if (xmemmatch( (uint8_t*)( debug_buf + 5 ), (uint8_t*) "on", 2 ) ) { + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dfwp ", 5 ) ) + { + if ( xmemmatch ( ( uint8_t * )( debug_buf + 5 ), ( uint8_t * ) "on", 2 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf("\r\nFWPrint Debug ON"); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "FWPrint Debug On\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ("FWPrint Debug On" ); + debug_fw_print = true; } - if (xmemmatch( (uint8_t*)( debug_buf + 5 ), (uint8_t*) "off", 3 ) ) { + else if ( xmemmatch ( ( uint8_t * )( debug_buf + 5 ), ( uint8_t * ) "off", 3 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf("\r\nFWPrint Debug OFF"); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "FWPrint Debug Off\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ("FWPrint Debug Off" ); + debug_fw_print = false; } } - - else if (xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "drx ", 4 )) { - if (xmemmatch( (uint8_t*)( debug_buf + 4 ), (uint8_t*) "on",2 )) { + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "drx ", 4 ) ) + { + if ( xmemmatch ( ( uint8_t * )( debug_buf + 4 ), ( uint8_t * ) "on", 2 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf("\tDebug Cbx Rx ON"); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "\tDebug Cbx On Rx on\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ( "Debug Cbx Rx On" ); + debug_cb_rx = true; } - if (xmemmatch( (uint8_t*)( debug_buf + 4 ), (uint8_t*) "off",3 )) { + else if ( xmemmatch ( ( uint8_t * )( debug_buf + 4 ), ( uint8_t * ) "off", 3 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf("\tDebug Cbx Rx OFF"); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "\tDebug Cbx On Rx off\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ( "Debug Cbx Rx Off" ); + debug_cb_rx = false; } } - - else if (xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dtx ", 4 )) { - if (xmemmatch( (uint8_t*)( debug_buf + 4 ), (uint8_t*) "on",2 )) { + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dtx ", 4 ) ) + { + if ( xmemmatch ( ( uint8_t * )( debug_buf + 4 ), ( uint8_t * ) "on", 2 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf("\tDebug Cbx Tx ON"); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "\tDebug Cbx Tx on\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ( "Debug Cbx Tx On" ); + debug_cb_tx = true; } - if (xmemmatch( (uint8_t*)( debug_buf + 4 ), (uint8_t*) "off",3 )) { + else if ( xmemmatch ( ( uint8_t * )( debug_buf + 4 ), ( uint8_t * ) "off", 3 ) ) + { + miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf("\tDebug Cbx Tx OFF"); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "\tDebug Cbx Tx off\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ( "Debug Cbx Tx Off" ); + debug_cb_tx = false; } } - - else if (xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "debug_file ", 11 )) { - if (xmemmatch( (uint8_t*)( debug_buf + 11 ), (uint8_t*) "on",2 )) { + + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "debug_file ", 11 ) ) + { + if ( xmemmatch ( ( uint8_t * )( debug_buf + 11 ), ( uint8_t * ) "on", 2 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf("\tDebug File ON"); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "\tDebug File On\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ( "Debug File On" ); + debug_file = true; } - if (xmemmatch( (uint8_t*)( debug_buf + 11 ), (uint8_t*) "off",3 )) { + else if ( xmemmatch ( ( uint8_t * )( debug_buf + 11 ), ( uint8_t * ) "off", 3 ) ) + { miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf("Debug File OFF"); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "Debug File Off\n\r"); - debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + + vz_printf ( "Debug File Off" ); + debug_file = false; } } - - else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "help" )) { - miss_match = false; - if( debug_uart3 && !( from_eth ) ) pc.printf("\n\r****************************PROMPT HELP******************\n\r"); - if( from_eth ) { - snprintf( debug_buf,PROMPT_ETH_BUFFER_SIZE, "\n\r****************************PROMPT HELP******************\n\r" ); - if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); - - else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } - - if( debug_uart3 && !( from_eth ) ) pc.printf("ifconfig - mostra o arquivo de configuracao do sistema\n\r"); - if( from_eth ) { - snprintf( debug_buf,PROMPT_ETH_BUFFER_SIZE, "ifconfig - mostra o arquivo de configuracao do sistema\n\r" ); - if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); - - else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } - if( debug_uart3 && !( from_eth ) ) pc.printf("dconfig - volta as configuracoes do sistema para o padrao de fabrica\n\r"); - if( from_eth ) { - snprintf( debug_buf,PROMPT_ETH_BUFFER_SIZE, "dconfig - volta as configuracoes do sistema para o padrao de fabrica\n\r" ); - if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); - - else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } - if( debug_uart3 && !( from_eth ) ) pc.printf("callme [ramal porta] - envia o pedido de ligacao para o callbox com o ramal e porta indicada\n\r"); - if( from_eth ) { - 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" ); - if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); - - else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } - if( debug_uart3 && !( from_eth ) ) pc.printf("pcb ramal comando - envia o <comando> para o cbx <ramal> e <porta = ramal sem a centane> executar\n\r"); - if( from_eth ) { - snprintf( debug_buf,PROMPT_ETH_BUFFER_SIZE, "pcb ramal comando - envia o <comando> para o cbx <ramal> e <porta = ramal sem a centane> executar\n\r" ); - if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); - - else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } - if( debug_uart3 && !( from_eth ) ) pc.printf("pcc ramal porta comando - envia o <comando> para o cbx <ramal> e <porta> executar\n\r"); - if( from_eth ) { - snprintf( debug_buf,PROMPT_ETH_BUFFER_SIZE, "pcc ramal porta comando - envia o <comando> para o cbx <ramal> e <porta> executar\n\r" ); - if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); - - else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } - if( debug_uart3 && !( from_eth ) ) pc.printf("cc ramal comando - envia o <comando> para o cbx <ramal> e <porta = ramal> executar\n\r"); - if( from_eth ) { - snprintf( debug_buf,PROMPT_ETH_BUFFER_SIZE, "cc ramal comando - envia o <comando> para o cbx <ramal> e <porta = ramal> executar\n\r" ); - if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); - - else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } - if( debug_uart3 && !( from_eth ) ) pc.printf("format - formata o sistema de arquivos\n\r"); - if( debug_uart3 && !( from_eth ) ) pc.printf("reset - resta o sistema\n\r"); - if( from_eth ) { - snprintf( debug_buf,PROMPT_ETH_BUFFER_SIZE, "reset - resta o sistema\n\r" ); - if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); - - else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } - if( debug_uart3 && !( from_eth ) ) pc.printf("ipset [ip] - Configura o IP da cabeceira\n\r"); - if( from_eth ) { - snprintf( debug_buf,PROMPT_ETH_BUFFER_SIZE, "ipset [ip] - Configura o IP da cabeceira\n\r" ); - if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); - - else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } - if( debug_uart3 && !( from_eth ) ) pc.printf("extset [ext] - Configura a ext da cabeceira\n\r"); - if( from_eth ) { - snprintf( debug_buf,PROMPT_ETH_BUFFER_SIZE, "extset [ext] - Configura a ext da cabeceira\n\r" ); - if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); - - else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } - if( debug_uart3 && !( from_eth ) ) pc.printf("msipport [port] - Configura a porta SIP da cabeceira\n\r"); - if( from_eth ) { - snprintf( debug_buf,PROMPT_ETH_BUFFER_SIZE, "msipport [port] - Configura a porta SIP da cabeceira\n\r" ); - if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); - - else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } - if( debug_uart3 && !( from_eth ) ) pc.printf("serverip [ip] - Configura o ip do servidor asterisk\n\r"); - if( from_eth ) { - snprintf( debug_buf,PROMPT_ETH_BUFFER_SIZE, "serverip [ip] - Configura o ip do servidor asterisk\n\r" ); - if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); - - else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } - if( debug_uart3 && !( from_eth ) ) pc.printf("serextset [ext] - Configura a server ext da cabeceira\n\r"); - if( from_eth ) { - snprintf( debug_buf,PROMPT_ETH_BUFFER_SIZE, "serextset [ext] - Configura a server ext da cabeceira\n\r" ); - if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); - - else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } - if( debug_uart3 && !( from_eth ) ) pc.printf("ssport [port] - Configura a porta SIP do servidor asterisk\n\r"); - if( from_eth ) { - snprintf( debug_buf,PROMPT_ETH_BUFFER_SIZE, "ssport [port] - Configura a porta SIP do servidor asterisk\n\r" ); - if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); - - else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } - if( debug_uart3 && !( from_eth ) ) pc.printf("maskset [mask] - Configura a mascara da cabeceira\n\r"); - if( from_eth ) { - snprintf( debug_buf,PROMPT_ETH_BUFFER_SIZE, "maskset [mask] - Configura a mascara da cabeceira\n\r" ); - if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); - - else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } - if( debug_uart3 && !( from_eth ) ) pc.printf("gatewayset [gateway] - Configura o gateway da cabeceira\n\r"); - if( from_eth ) { - snprintf( debug_buf,PROMPT_ETH_BUFFER_SIZE, "gatewayset [gateway] - Configura o gateway da cabeceira\n\r" ); - if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); - - else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } - - if( debug_uart3 && !( from_eth ) ) pc.printf("fw_ip - Configura o IP do servidor de fw\n\r"); - if( from_eth ) { - snprintf( debug_buf,PROMPT_ETH_BUFFER_SIZE, "fw_ip - Configura o IP do servidor de fw\n\r" ); - if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); - - else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } - if( debug_uart3 && !( from_eth ) ) pc.printf("fw_port - Configura a porta do servidor de fw\n\r"); - if( from_eth ) { - snprintf( debug_buf,PROMPT_ETH_BUFFER_SIZE, "fw_port - Configura a porta do servidor de fw\n\r" ); - if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); - - else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } - if( debug_uart3 && !( from_eth ) ) pc.printf("maxext - Configura o maior ramal possivel de ser registrado nesse ramo\n\r"); - if( from_eth ) { - snprintf( debug_buf,PROMPT_ETH_BUFFER_SIZE, "maxext - Configura o maior ramal possivel de ser registrado nesse ramo\n\r" ); - if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); - - else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } - - if( debug_uart3 && !( from_eth ) ) pc.printf("minext - Configura o menor ramal possivel de ser registrado nesse ramo\n\r"); - if( from_eth ) { - snprintf( debug_buf,PROMPT_ETH_BUFFER_SIZE, "minext - Configura o menor ramal possivel de ser registrado nesse ramo\n\r" ); - if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); - - else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } - - if( debug_uart3 && !( from_eth ) ) pc.printf("showcb - lista os Cbx registrados na header\n\r"); - if( from_eth ) { - snprintf( debug_buf,PROMPT_ETH_BUFFER_SIZE, "showcb - lista os Cbx registrados na header\n\r" ); - if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); - - else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } - if( debug_uart3 && !( from_eth ) ) pc.printf("cks - exibe estatisticas de check sum\n\r"); - if( from_eth ) { - snprintf( debug_buf,PROMPT_ETH_BUFFER_SIZE, "cks - exibe estatisticas de check sum\n\r" ); - if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); - - else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } - if( debug_uart3 && !( from_eth ) ) pc.printf("reset_cks - reseta estatisticas de check sum\n\r"); - if( from_eth ) { - snprintf( debug_buf,PROMPT_ETH_BUFFER_SIZE, "reset_cks - reseta estatisticas de check sum\n\r" ); - if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); - - else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } - - if( debug_uart3 && !( from_eth ) ) pc.printf(". - executa o comando anterior novamente\n\r"); - if( from_eth ) { - snprintf( debug_buf,PROMPT_ETH_BUFFER_SIZE, ". - executa o comando anterior novamente\n\r" ); - if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); - - else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } - if( debug_uart3 && !( from_eth ) ) pc.printf("debug [on|off|show] - seleciona debugs gerais | lista de debugs \n\r"); - if( from_eth ) { - snprintf( debug_buf,PROMPT_ETH_BUFFER_SIZE, "debug [on|off|show] - seleciona debugs gerais | lista de debugs \n\r" ); - if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); - - else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } - if( debug_uart3 && !( from_eth ) ) pc.printf("{ flood [ on | off ] | [+|-] } - simula envio de pacotes de audio\n\r"); - if( from_eth ) { - snprintf( debug_buf,PROMPT_ETH_BUFFER_SIZE, "{ flood [ on | off ] | [+|-] } - simula envio de pacotes de audio\n\r"); - if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); - - else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } - - if( debug_uart3 && !( from_eth ) ) pc.printf("silence <start_ext end_ext> - envia comando de flood off para os ramais no intervalo end_ext - start_ext\n\r"); - if( from_eth ) { - 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"); - if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); - - else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "help" )) { + miss_match = false; + + vz_printf ( "**************************** PROMPT HELP ****************************" ); + vz_printf ( "ifconfig - mostra o arquivo de configuracao do sistema" ); + vz_printf ( "dconfig - volta as configuracoes do sistema para o padrao de fabrica" ); + vz_printf ( "callme [ramal porta] - envia o pedido de ligacao para o callbox com o ramal e porta indicada" ); + vz_printf ( "pcb ramal comando - envia o <comando> para o cbx <ramal> e <porta = ramal sem a centane> executar" ); + vz_printf ( "pcc ramal porta comando - envia o <comando> para o cbx <ramal> e <porta> executar" ); + vz_printf ( "cc ramal comando - envia o <comando> para o cbx <ramal> e <porta = ramal> executar" ); + + serial_pc.printf("format - formata o sistema de arquivos" ); + + vz_printf ( "reset - resta o sistema" ); + vz_printf ( "ipset [ip] - Configura o IP da cabeceira" ); + vz_printf ( "extset [ext] - Configura a ext da cabeceira" ); + vz_printf ( "msipport [port] - Configura a porta SIP da cabeceira" ); + vz_printf ( "serverip [ip] - Configura o ip do servidor asterisk" ); + vz_printf ( "serextset [ext] - Configura a server ext da cabeceira" ); + vz_printf ( "ssport [port] - Configura a porta SIP do servidor asterisk" ); + vz_printf ( "maskset [mask] - Configura a mascara da cabeceira" ); + vz_printf ( "gatewayset [gateway] - Configura o gateway da cabeceira" ); + vz_printf ( "fw_ip - Configura o IP do servidor de fw" ); + vz_printf ( "fw_port - Configura a porta do servidor de fw" ); + vz_printf ( "maxext - Configura o maior ramal possivel de ser registrado nesse ramo" ); + vz_printf ( "minext - Configura o menor ramal possivel de ser registrado nesse ramo" ); + vz_printf ( "showcb - lista os Cbx registrados na header" ); + vz_printf ( "cks - exibe estatisticas de check sum" ); + vz_printf ( "reset_cks - reseta estatisticas de check sum" ); + vz_printf ( ". - executa o comando anterior novamente" ); + vz_printf ( "debug [on|off|show] - seleciona debugs gerais | lista de debugs" ); + vz_printf ( "{ flood [ on | off ] | [+|-] } - simula envio de pacotes de audio" ); + vz_printf ( "silence <start_ext end_ext> - envia comando de flood off para os ramais no intervalo end_ext - start_ext" ); + vz_printf ( "-- ext - Header flood off, ext flood off" ); + vz_printf ( "++ ext - Header flood on, ext flood on" ); + vz_printf ( "rx - Exibe ultimo pacote recebido dos CBx" ); + vz_printf ( "tx - Exibe ultimo pacote enviado para os CBx" ); + vz_printf ( "ls | status - Exibe uma lista ordenada por ext do CBx registrados na Header" ); + vz_printf ( "types - Lista os types usados no protocolo de comunicacao Header -- CBx" ); + vz_printf ( "protocol - Exibe formato do pacote seguindo o protocolo de comunicacao Header -- CBx" ); + vz_printf ( "PROMPT VERSION: V%d -- %s - %s", PVERSION, __DATE__, __TIME__); + + strcpy ( last_cmd, tmp_cmd ); + + bufptr = 0; + + for ( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf [ i ] = 0; + } - if( debug_uart3 && !( from_eth ) ) pc.printf("++ ext - Header flood on, ext flood on\n\r"); - if( from_eth ) { - snprintf( debug_buf,PROMPT_ETH_BUFFER_SIZE, "++ ext - Header flood on, ext flood on\n\r"); - if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); - - else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } - - if( debug_uart3 && !( from_eth ) ) pc.printf("-- ext - Header flood off, ext flood off\n\r"); - if( from_eth ) { - snprintf( debug_buf,PROMPT_ETH_BUFFER_SIZE, "++ ext - Header flood on, ext flood on\n\r"); - if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); - - else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } - - if( debug_uart3 && !( from_eth ) ) pc.printf("rx - Exibe ultimo pacote recebido dos CBx\n\r"); - if( from_eth ) { - snprintf( debug_buf,PROMPT_ETH_BUFFER_SIZE, "rx - Exibe ultimo pacote recebido dos CBx\n\r"); - if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); - - else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } - if( debug_uart3 && !( from_eth ) ) pc.printf("tx - Exibe ultimo pacote enviado para os CBx\n\r"); - if( from_eth ) { - snprintf( debug_buf,PROMPT_ETH_BUFFER_SIZE, "tx - Exibe ultimo pacote enviado para os CBx\n\r"); - if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); - - else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } - if( debug_uart3 && !( from_eth ) ) pc.printf("ls | status - Exibe uma lista ordenada por ext do CBx registrados na Header\n\r"); - if( from_eth ) { - snprintf( debug_buf,PROMPT_ETH_BUFFER_SIZE, "ls | status - Exibe uma lista ordenada por ext do CBx registrados na Header\n\r"); - if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); - - else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } - if( debug_uart3 && !( from_eth ) ) pc.printf("types - Lista os types usados no protocolo de comunicacao Header -- CBx\n\r"); - if( from_eth ) { - snprintf( debug_buf,PROMPT_ETH_BUFFER_SIZE, "types - Lista os types usados no protocolo de comunicacao Header -- CBx\n\r"); - if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); - - else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } - if( debug_uart3 && !( from_eth ) ) pc.printf("protocol - Exibe formato do pacote seguindo o protocolo de comunicacao Header -- CBx\n\r"); - if( from_eth ) { - snprintf( debug_buf,PROMPT_ETH_BUFFER_SIZE, "protocol - Exibe formato do pacote seguindo o protocolo de comunicacao Header -- CBx\n\r"); - if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); - - else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } - - if( debug_uart3 && !( from_eth ) ) pc.printf("PROMPT VERSION: V%d -- %s - %s\n\r", PVERSION, __DATE__, __TIME__ ); - if( from_eth ) { - snprintf( debug_buf,PROMPT_ETH_BUFFER_SIZE, "PROMPT VERSION: V%d -- %s - %s\n\r", PVERSION, __DATE__, __TIME__); - if( tcp_session && !udp_query ) { - while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } - //*------------ formatando a saida ----------------*// - strcpy( last_cmd, tmp_cmd ); - bufptr = 0; - for( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; - - if( from_eth ) { - if( tcp_session && !udp_query ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "> " ); - if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); - } else if( udp_query ) { - udp_query_send_msg( "> " ); - } - } - } - - else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "callme ", 7 )) { + else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "callme ", 7 ) ) + { miss_match = false; int ext,port; char cmd[ 16 ]; @@ -3313,94 +2554,24 @@ cmd[ tmp + 1 ] = 0x00; strcpy( promptcb_last_cmd, cmd ); - if( debug_uart3 && !( from_eth ) ) pc.printf("\r\next=%d port=%d\r\ncmd=%s\r\n", ext, port, cmd ); - - if( debug_uart3 && !( from_eth ) ) pc.printf("\n\r--------------------------------------------------------\n\r"); - for( uint16_t i = 0; i < strlen( cmd ) ; i++ ) if( debug_uart3 && !( from_eth ) ) pc.printf( "%02x ", cmd[ i ] ); - - send2callboxes( build_cb_package( ext, port, PROMPT, cmd, id_msg++, CB_BUFFER_SIZE - VZ_HEADER_OFFSET, write_buffer ) ); - if( debug_uart3 && !( from_eth ) ) pc.printf("\n\r--------------------------------------------------------\n\r"); - for( uint16_t i = 0; i < 300 ; i++ ) { - if( debug_uart3 && !( from_eth ) ) pc.printf( "%02x ", write_buffer[ i ] ); - if( i != 0 && !( ( i + 1 ) % 30 ) ) if( debug_uart3 && !( from_eth ) ) pc.printf("\n\r"); - } - - if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rComando enviado\n\r"); - - if( from_eth ) { - char eth_msg[ 512 ]; - snprintf( eth_msg, 512 - 1, "\r\next=%d port=%d\r\ncmd=%s\r\n\n\rComando enviado\n\r", ext, port, cmd ); - if( tcp_session && !udp_query ) { - tcp_client.send_all( eth_msg, strlen( eth_msg ) ); - } else if( udp_query ) { - udp_query_send_msg( eth_msg ); - } - } + send2callboxes( build_cb_package( ext, port, PROMPT, cmd, id_msg++, CB_BUFFER_SIZE - VZ_HEADER_OFFSET, prompt_write_buffer ) ); + + vz_printf ( "ext=%d port=%d\r\ncmd=%s\r\n\n\rComando enviado\n\r", ext, port, cmd ); bufptr = 0; - for( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; + for ( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf [ i ] = 0; } - if( miss_match ) { - if( debug_uart3 && !( from_eth ) ) pc.printf("\n\r> %s: command not found\n\r", debug_buf ); - if( from_eth ) { - snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "> %s: command not found\n ", debug_buf ); - if( tcp_session && !udp_query ) { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - udp_query_send_msg( debug_buf ); - } - } + if ( miss_match ) + { + vz_printf ( "> %s: command not found", debug_buf ); + } else { - if( from_eth && strlen( debug_buf ) > 2 ) strcpy( last_cmd, tmp_cmd ); + if ( from_eth && strlen ( debug_buf ) > 2 ) strcpy ( last_cmd, tmp_cmd ); - else if( strlen( debug_buf ) > 2 ) strcpy( last_cmd, tmp_cmd ); + else if ( strlen ( debug_buf ) > 2 ) strcpy ( last_cmd, tmp_cmd ); } } - if( b == 0x0D || bufret == 1 || bufptr > DEBUGBUFSIZE ) { - bufret = 0; - - if( debug_uart3 && !( from_eth ) ) pc.putc(0x0A); - if( debug_uart3 && !( from_eth ) ) pc.putc(0x0D); - if( debug_uart3 && !( from_eth ) ) pc.printf("> "); - - if( from_eth ) - { - if( strlen( debug_buf ) > 0 ) - { - - if( debug_buf[ strlen( debug_buf ) - 1 ] == '\r' || debug_buf[ strlen( debug_buf ) - 1 ] == '\n' ) - { - strcpy( debug_buf, "> " ); - } else { - strcpy( debug_buf, "\n\r> " ); - } - }else{ - - } - - if( tcp_session && !udp_query ) - { - tcp_client.send_all( debug_buf, strlen( debug_buf ) ); - } else if( udp_query ) { - - udp_query_send_msg( debug_buf ); - - } - for( register uint16_t i = 0; i < PROMPT_ETH_BUFFER_SIZE; i++ ) eth_buffer[ i ] = 0; - - debug_buf = __debug_buf__; - - bufptr = last_bufptr; - - } - else - { - bufptr = 0; - last_bufptr = 0; - for( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; - } - } return( NULL ); -}//fim prompt_process \ No newline at end of file +} \ No newline at end of file