VZTECH / Mbed 2 deprecated main_src

Dependencies:   EALib EthernetInterface_vz mbed-rtos mbed

Fork of header_main_colinas_V0-20-09-14 by VZTECH

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers prompt.cpp Source File

prompt.cpp

00001 #include "prompt.h"
00002 
00003 bool flood_silence = false;
00004 bool delayed_flood = false;
00005 
00006 int start_ext =0;
00007 int end_ext = 0;
00008 int ext_count = 0;
00009 
00010 Timer tcp_timer;
00011 bool tcp_alive = false;
00012 bool serial_pc_pending = false;
00013 
00014 volatile char b = 0;
00015 uint8_t bufret = 0;
00016 
00017 char __debug_buf__[ DEBUGBUFSIZE ];
00018 char * debug_buf = __debug_buf__;
00019 char last_cmd[ DEBUGBUFSIZE ];
00020 char tmp_cmd[ DEBUGBUFSIZE ] = "help";
00021 char last_debug_buf[ DEBUGBUFSIZE ] = "help";
00022 char eth_udp_buffer[ PROMPT_ETH_BUFFER_SIZE ];
00023 char gp_buff[ DEBUGBUFSIZE ];
00024 uint8_t prompt_write_buffer [ CB_BUFFER_SIZE ];
00025 
00026 uint16_t bufptr = 0;
00027 uint16_t last_bufptr = 0;
00028 
00029 Timer flood_timeout;
00030 Timer flood_silence_timer;
00031 uint8_t id_msg = 0x10;
00032 
00033 char * 
00034 prompt_process ( char * msg_from_cb, int length )
00035 {
00036     char eth_buffer [ PROMPT_ETH_BUFFER_SIZE ];
00037 
00038     if ( id_msg < 0x11 ) id_msg = 0x11;
00039 
00040     if( flood_timeout.read() > 60 ) {
00041         pflood = false;
00042         flood_timeout.stop();
00043         flood_timeout.reset();
00044     }
00045 
00046     if( tcp_timer.read() >= TCP_IDLE_MAX_TIME ) {
00047         tcp_alive = false;
00048         tcp_timer.stop();
00049         tcp_timer.reset();
00050         tcp_session = false;
00051         debug_buf = __debug_buf__;
00052         bufptr = last_bufptr;
00053         bufret = 0;
00054         from_eth = false;
00055         tcp_client.close();
00056         return( NULL );
00057     }
00058 
00059     if( udp_query ) {
00060         if( msg_from_cb != NULL ) {
00061             last_bufptr = bufptr;
00062             if( ( length > 2 ) && ( msg_from_cb[ length - 2 ]  == '\r' ) ) msg_from_cb[ length - 2 ] = 0;
00063 
00064             if( ( length > 1 ) && ( msg_from_cb[ length - 1 ]  == '\n' ) ) msg_from_cb[ length - 1 ] = 0;
00065 
00066             if( ( length == 1 ) && msg_from_cb[ 0 ] == 0x0A ) strcpy( msg_from_cb, "\r" );
00067 
00068             bufptr = strlen( msg_from_cb );
00069             debug_buf = msg_from_cb;
00070             from_eth = true;
00071             bufret = 1;
00072         }
00073     } else {
00074         if ( !tcp_server.accept ( tcp_client ) ) {
00075             tcp_session = true;
00076             tcp_timer.start ();
00077             last_bufptr = bufptr;
00078             for ( register int i = 0; i < PROMPT_ETH_BUFFER_SIZE; i++ ) eth_buffer [ i ] = 0;
00079         }
00080         if ( tcp_session && !udp_query ) {
00081             tcp_client.set_blocking ( false, 0 );
00082             int n = tcp_client.receive ( eth_buffer, sizeof ( eth_buffer ) - 1 );
00083             if( n > 0 ) {
00084                 tcp_timer.reset ();
00085 
00086                 if( ( n > 2 ) && ( eth_buffer[ n - 2 ]  == '\r' ) ) eth_buffer[ n - 2 ] = 0;
00087 
00088                 if( ( n > 1 ) && ( eth_buffer[ n - 1 ]  == '\n' ) ) eth_buffer[ n - 1 ] = 0;
00089 
00090                 if( ( n == 1 ) && eth_buffer[ 0 ] == 0x0A ) strcpy( eth_buffer, "\r> " );
00091 
00092                 bufptr = strlen( eth_buffer );
00093                 debug_buf = eth_buffer;
00094                 from_eth = true;
00095                 bufret = 1;
00096                 
00097                 if ( n > 2 ) 
00098                 {
00099                     char tmp[] = "> ";
00100                 
00101                     while ( !( tcp_client.send_all ( tmp, strlen ( tmp ) ) ) );
00102                 }
00103 
00104                 if( !( strcmp( eth_buffer, "quit" ) ) ) {
00105                     tcp_timer.stop();
00106                     tcp_timer.reset();
00107                     debug_buf = __debug_buf__;
00108                     bufptr = last_bufptr;
00109                     from_eth = false;
00110                     tcp_session = false;
00111                     tcp_client.close();
00112                     bufret = 0;
00113                     return( NULL );
00114                 }
00115             } else {
00116                 debug_buf = __debug_buf__;
00117                 bufptr = last_bufptr;
00118                 from_eth = false;
00119             }
00120         }
00121     }
00122 
00123     if( ( !from_eth ) && ( !udp_query ) ) {
00124         if( pc.readable() ) {
00125             b = pc.getc();
00126             if( b == 0x0D ) {
00127                 // enter
00128                 bufret = 1;
00129                 if ( debug_uart3 ) serial_pc_pending = true;
00130                 
00131                 // formatação manual da saída
00132                 if ( bufptr > 0 ) serial_pc.printf ( "%s","\r\n> " );
00133             } else {
00134                 pc.putc( b );
00135                 if( b == 0x08 || b == 0x7F ) {
00136                     // BS | DEL
00137                     if( bufptr > 0 ) {
00138                         __debug_buf__[ --bufptr ] = 0;
00139                     }
00140                 } else if( b == 0x09 ) {
00141                     // ignore tab
00142                 } else {
00143                     __debug_buf__[ bufptr ] = b;
00144                     bufptr++;
00145                 }
00146                 last_bufptr = bufptr;
00147             }
00148         }
00149     }
00150 
00151     if ( flood_silence )
00152     {
00153         if ( flood_silence_timer.read_ms () > 250 )
00154         {
00155             char cmd[ 16 ] = "flood off";
00156             int str_end = strlen( cmd );
00157             cmd[ str_end ] = 0x0D;
00158             cmd[ str_end + 1 ] = 0x00;
00159 
00160             int port = convert_ext_to_port( ext_count );
00161             
00162             send2callboxes( build_cb_package( ext_count, port, PROMPT, cmd, id_msg++, CB_BUFFER_SIZE - VZ_HEADER_OFFSET, prompt_write_buffer ) );
00163             
00164             vz_printf ("Silence sent to ext=%d port=%d", ext_count, port );
00165         
00166             flood_silence_timer.reset();
00167 
00168             // importante para o uso da funçao silence
00169             if( ++ext_count > end_ext ) {
00170                 flood_silence = false;
00171                 flood_silence_timer.stop();
00172                 flood_silence_timer.reset();
00173 
00174                 if( debug_uart3 && !( from_eth ) ) pc.printf("\r\n> " );
00175                 if( tcp_session && !udp_query ) {
00176                     snprintf( eth_buffer, PROMPT_ETH_BUFFER_SIZE, "\r\n> " );
00177                     tcp_client.send_all( eth_buffer, strlen( eth_buffer ) );
00178                 } else if( udp_query ) {
00179                     snprintf( eth_buffer, PROMPT_ETH_BUFFER_SIZE, "\r\n> " );
00180                     udp_query_send_msg( eth_buffer );
00181                 }
00182             }
00183         }
00184     }
00185 
00186     if ( delayed_flood ) 
00187     {
00188         tflood.start();
00189         tflood.reset();
00190         floodcount =0;
00191         pflood = true;
00192         flood_timeout.start();
00193         delayed_flood = false;
00194         if( debug_uart3 ) pc.printf("\n\rFlood ON\n\r" );
00195         if( from_eth ) {
00196             snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "Flood On\n\r" );
00197         }
00198     }
00199 
00200     char * tmp_return = NULL;
00201     
00202     if ( bufret == 1 ) 
00203     {
00204         tmp_return = command_process ( debug_buf, bufptr );
00205     
00206         if( b == 0x0D || bufret == 1 || bufptr > DEBUGBUFSIZE ) {
00207             bufret = 0;
00208     
00209             if( debug_uart3 && !( from_eth ) ) pc.putc(0x0A);
00210             if( debug_uart3 && !( from_eth ) ) pc.putc(0x0D);
00211             if( debug_uart3 && !( from_eth ) ) pc.printf("> " );
00212     
00213             if( from_eth ) {
00214                 if( strlen( debug_buf ) > 0 ) {
00215     
00216                     if( debug_buf[ strlen( debug_buf ) - 1 ] == '\r' || debug_buf[ strlen( debug_buf ) - 1 ] == '\n' ) {
00217                         strcpy( debug_buf, "> " );
00218                     } else {
00219                         strcpy( debug_buf, "\n\r> " );
00220                     }
00221                 } else {
00222     
00223                 }
00224     
00225                 if( tcp_session && !udp_query ) {
00226                     tcp_client.send_all( debug_buf, strlen( debug_buf ) );
00227                 } else if( udp_query ) {
00228     
00229                     udp_query_send_msg( debug_buf );
00230     
00231                 }
00232                 for( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0;
00233     
00234                 debug_buf = __debug_buf__;
00235     
00236                 bufptr = last_bufptr;
00237     
00238             } else {
00239                 bufptr = 0;
00240                 last_bufptr = 0;
00241                 for( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0;
00242             }
00243         }
00244     }
00245     
00246     return ( tmp_return );
00247 }
00248     
00249 char * 
00250 command_process ( char * debug_buf, size_t bufptr )
00251 {   
00252     bool miss_match = true;
00253     
00254     static unsigned int promptcb_last_ext = 0;
00255     static unsigned int promptcb_last_port = 0;
00256     static char promptcb_last_cmd [ 300 ];
00257     
00258     // removendo espacos em branco no inicio da string
00259     uint16_t shift_blank_spaces = 0;
00260     for ( register uint16_t i = 0; i < DEBUGBUFSIZE; i++ ) {
00261         if ( debug_buf [ i ] == 0x20 ) shift_blank_spaces++;
00262 
00263         if ( debug_buf [ i ] != 0x20 ) break;
00264     }
00265     debug_buf += shift_blank_spaces;
00266 
00267     strcpy( tmp_cmd, debug_buf );
00268     if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "." ) ) {
00269         miss_match = false;
00270         strcpy( debug_buf, last_cmd );
00271         strcpy( tmp_cmd, debug_buf );
00272     } else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "+" ) ) {
00273         miss_match = false;
00274         strcpy( debug_buf, "flood on" );
00275         strcpy( tmp_cmd, debug_buf );
00276     } else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "-" ) ) {
00277         miss_match = false;
00278         strcpy( debug_buf, "flood off" );
00279         strcpy( tmp_cmd, debug_buf );
00280     } else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "++ ", 3 ) ) {
00281         miss_match = false;
00282         delayed_flood = true;
00283         int ext = atoi( debug_buf + 3 );
00284         sprintf( debug_buf, "pcb %i flood on", ext );
00285     } else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "-- ", 3 ) ) {
00286         miss_match = false;
00287         int ext = atoi( debug_buf + 3 );
00288         if( debug_uart3 ) pc.printf("\n\rFlood OFF\n\r" );
00289         if( from_eth ) {
00290             snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "Flood OFF\n\r" );
00291         }
00292         pflood = false;
00293         tflood.stop();
00294         flood_timeout.reset();
00295         sprintf( debug_buf, "pcb %i flood off", ext );
00296     }
00297 
00298     //tratamento dos enters
00299     if( !bufptr ) {
00300         miss_match = false;
00301     } else if( bufptr == 1 ) {
00302         if( debug_buf [ 0 ] == '\r' || debug_buf [ 0 ] == '\n' ) miss_match = false;
00303     }
00304 
00305         if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "show_configs" ) )
00306     {
00307         miss_match = false;
00308         
00309         if( debug_uart3 ) pc.printf("\n\r" );
00310         
00311         files('s');
00312     }
00313 
00314     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "rx" ) ) {
00315         miss_match = false;
00316         show_last_rx = true;
00317     }
00318 
00319     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "tx" ) ) {
00320         miss_match = false;
00321         show_last_tx = true;
00322     }
00323 
00324     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "stats" ) ) {
00325         miss_match = false;
00326         stats = true;
00327     } 
00328     
00329     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "reset_stats" ) ) {
00330         miss_match = false;
00331         r_stats = true;
00332     }
00333 
00334     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "rtp" ) )
00335     {
00336         miss_match = false;
00337         dshow_rtp = true;
00338     }
00339 
00340     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "callrtp" ) ) {
00341         miss_match = false;
00342         dcallshow_rtp = true;
00343     }
00344 
00345     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "format" ) ) {
00346         miss_match = false;
00347 
00348         if( from_eth ) {
00349             vz_printf ( "Not Allowed" );
00350         } else {
00351             if ( debug_uart3 ) pc.printf("\n\rFormatando o sistema de arquivos... espere o sistema reiniciar\n\r" );
00352             files('e');
00353             files('w');
00354             __disable_irq();
00355             NVIC_SystemReset();
00356         }
00357     }
00358 
00359     // nao apresentou comportamento esperado
00360     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "ipset ", 6 ) )
00361     {
00362         miss_match = false;
00363         cm -> set_header_ip ( debug_buf + 6 );
00364     }
00365 
00366     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "extset ", 7 ) ) 
00367     {
00368         miss_match = false;
00369         cm -> set_header_ext ( atoi ( debug_buf + 7 ) );
00370     }
00371 
00372     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "serextset ", 10 ) )
00373     {
00374         miss_match = false;
00375         cm -> set_server_ext ( atoi ( debug_buf + 10 ) );
00376     }
00377 
00378     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "shift_port ", 11 ) )
00379     {
00380         miss_match = false;
00381         cm -> set_shift_port( atoi ( debug_buf + 11 ) );
00382     }
00383 
00384     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "maskset ", 8 ) )
00385     {
00386         miss_match = false;
00387         cm -> set_net_mask ( debug_buf + 8 );
00388     }
00389 
00390     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "gatewayset ", 11 ) )
00391     {
00392         miss_match = false;
00393         cm -> set_gateway ( debug_buf + 11 );
00394     }
00395 
00396     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "msipport ",9 ) ) 
00397     {
00398         miss_match = false;
00399         cm -> set_header_sip_port ( atoi ( debug_buf + 9 ) );
00400     }
00401 
00402     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "serverip ",9 ) )
00403     {
00404         miss_match = false;
00405         cm -> set_server_ip ( debug_buf + 9 );
00406     }
00407 
00408     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "maxext ", 7 ) )
00409     {
00410         miss_match = false;
00411         cm -> set_max_ext ( atoi ( debug_buf + 7 ) );
00412     }
00413 
00414     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "minext ", 7 ) ) 
00415     {
00416         miss_match = false;
00417         cm -> set_min_ext ( atoi ( debug_buf + 7 ) );
00418     }
00419 
00420     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "ssport ", 7 ) )
00421     {
00422         miss_match = false;
00423         cm -> set_server_port ( atoi ( debug_buf + 7 ) );
00424     }
00425 
00426     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "fw_ip ", 6 ) )
00427     {
00428         miss_match = false;
00429         cm -> set_fw_server_ip ( debug_buf + 6 );
00430     }
00431 
00432     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "fw_port ", 8 ) )
00433     {
00434         miss_match = false;
00435         cm -> set_fw_server_port ( atoi ( debug_buf + 8 ) );
00436     }
00437     
00438     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "set_acceptable_delay ", 21 ) )
00439     {
00440         miss_match = false;
00441         cm -> set_acceptable_delay ( atoi ( debug_buf + 21 ) );
00442     }
00443     
00444     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "set_cbx_detach_mode ", 20 ) )
00445     {
00446         miss_match = false;
00447         
00448         bool new_cbx_detach_mode;
00449         
00450         char * tmp = NULL;
00451         
00452         if ( ( tmp = strstr ( ( debug_buf + 20 ), "true" ) ) != NULL ) new_cbx_detach_mode = true;
00453         
00454         else if ( ( tmp = strstr ( ( debug_buf + 20 ), "false" ) ) != NULL ) new_cbx_detach_mode = false;
00455         
00456         if ( tmp != NULL ) cm -> set_cbx_detach_mode ( new_cbx_detach_mode );
00457         
00458         else vz_printf ("Usage: set_cbx_detach_mode < true | false >");
00459     }
00460     
00461     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "set_cbx_wake_mode ", 18 ) )
00462     {
00463         miss_match = false;
00464         
00465         bool new_cbx_wake_mode;
00466         
00467         char * tmp = NULL;
00468         
00469         if ( ( tmp = strstr ( ( debug_buf + 18 ), "true" ) ) != NULL ) new_cbx_wake_mode = true;
00470         
00471         else if ( ( tmp = strstr ( ( debug_buf + 18 ), "false" ) ) != NULL ) new_cbx_wake_mode = false;
00472         
00473         if ( tmp != NULL ) cm -> set_cbx_wake_mode ( new_cbx_wake_mode );
00474         
00475         else vz_printf ("Usage: set_cbx_wake_mode < true | false >");
00476     }
00477     
00478     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "set_cbx_mode ", 13 ) )
00479     {
00480         miss_match = false;
00481         
00482         int tmp = 0;
00483         
00484         uint8_t new_cbx_mode = 0;
00485         
00486         char * ref = debug_buf + 13;
00487         
00488         while ( *ref == 0x20 ) ref++;
00489         
00490         if ( ( tmp = strcasecmp ( ref, "fibra" ) ) == 0 ) new_cbx_mode = u8_FIBRA_MODE;
00491         
00492         else if ( ( tmp = strcasecmp ( ref, "radio" ) ) == 0 ) new_cbx_mode = u8_RADIO_MODE;
00493         
00494         else if ( ( tmp = strcasecmp ( ref, "custom" ) ) == 0 ) new_cbx_mode = u8_CUSTOM_MODE;
00495         
00496         if ( tmp == 0 ) cm -> set_cbx_mode ( new_cbx_mode );
00497         
00498         else vz_printf ( "Usage: set_cbx_wake_mode < fibra | radio | custom >" );
00499     }
00500     
00501 
00502     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dconfig" ) )
00503     {
00504         miss_match = false;
00505         cm -> restore_defaults_settings ();
00506     }
00507 
00508     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "reset" ) )
00509     {
00510         miss_match = false;
00511         
00512         if ( tcp_session and from_eth ) tcp_client.close ();
00513         
00514         vz_printf ( "Job is done" );
00515         
00516         __disable_irq ();
00517         
00518         NVIC_SystemReset ();
00519     }
00520     
00521     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "test" ) )
00522     {
00523         miss_match = false;
00524         char msg[] = "This is another test";
00525         vz_printf ("-->%s<--", msg );
00526         vz_printf ("-->%d<--", 28 );
00527     }
00528 
00529     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dog" ) )
00530     {
00531         miss_match = false;
00532         
00533         vz_printf ( "MUUUUUUUuuuuUUUUUU - I'm not a dog!!!!" );
00534     }
00535     
00536     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "get_acceptable_delay" ) )
00537     {
00538         miss_match = false;
00539         
00540         vz_printf ( "get_acceptable_delay :: %u", cm -> get_acceptable_delay () );
00541     }
00542     
00543     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "get_cbx_detach_mode" ) )
00544     {
00545         miss_match = false;
00546         
00547         vz_printf ( "get_cbx_detach_mode :: %s", ( cm -> get_cbx_detach_mode () ) ? "true" : "false" );
00548     }
00549     
00550     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "get_cbx_wake_mode" ) )
00551     {
00552         miss_match = false;
00553         
00554         vz_printf ( "get_cbx_wake_mode :: %s", ( cm -> get_cbx_wake_mode () ) ? "true" : "false" );
00555     }
00556     
00557     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "get_cbx_mode" ) )
00558     {
00559         miss_match = false;
00560         
00561         char mode_buffer [ 32 ] = "";
00562         
00563         uint8_t u8mode = cm -> get_cbx_mode ();
00564         
00565         if ( u8mode == u8_FIBRA_MODE ) strcpy ( mode_buffer, "Fibra Fibra" );
00566         
00567         else if ( u8mode == u8_RADIO_MODE ) strcpy ( mode_buffer, "Fibra RADIO" );
00568         
00569         else strcpy ( mode_buffer, "Custom" );
00570         
00571         vz_printf ( "get_cbx_mode :: %s", mode_buffer );
00572     }
00573     
00574     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "show_mode" ) )
00575     {
00576         miss_match = false;
00577         
00578         vz_printf ( "get_cbx_detach_mode :: %s", ( cm -> get_cbx_detach_mode () ) ? "true" : "false" );
00579         
00580         vz_printf ( "get_cbx_wake_mode :: %s", ( cm -> get_cbx_wake_mode () ) ? "true" : "false" );
00581         
00582         char mode_buffer [ 32 ] = "";
00583         
00584         uint8_t u8mode = cm -> get_cbx_mode ();
00585         
00586         if ( u8mode == u8_FIBRA_MODE ) strcpy ( mode_buffer, "Fibra Fibra" );
00587         
00588         else if ( u8mode == u8_RADIO_MODE ) strcpy ( mode_buffer, "Fibra RADIO" );
00589         
00590         else strcpy ( mode_buffer, "Custom" );
00591         
00592         vz_printf ( "get_cbx_mode :: %s", mode_buffer );
00593     }
00594     
00595     
00596 
00597     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "request_clock" ) )
00598     {
00599         miss_match = false;
00600         request_clock_now = true;
00601     }
00602 
00603     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "hello" ) )
00604     {
00605         miss_match = false;
00606         show_hello_status = true;
00607     }
00608 
00609     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "date" ) )
00610     {
00611         miss_match = false;
00612         vz_printf (" %s %s", __DATE__, __TIME__ );
00613     }
00614 
00615     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "clock" ) )
00616     {
00617         miss_match = false;
00618         show_current_time = true;
00619     }
00620 
00621     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "overflow" ) )
00622     {
00623         miss_match = false;
00624         vz_printf ( "Overflow messages :: %d", string_msg_overflow );
00625     }
00626 
00627     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dep" ) )
00628     {
00629         miss_match = false;
00630         
00631         drop_entendi_pkg = !drop_entendi_pkg;
00632         
00633         if ( drop_entendi_pkg ) {
00634             vz_debug ("Entendi pkgs will be droped" );
00635         } else {
00636             vz_debug ("Entendi pkgs don't will be droped" );
00637         }
00638     }
00639 
00640     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dita" ) )
00641     {
00642         miss_match = false;
00643         
00644         drop_invite_to_ast_pkg = !drop_invite_to_ast_pkg;
00645         
00646         if ( drop_invite_to_ast_pkg ) {
00647             vz_debug ("Invite pkgs to ast will be droped" );
00648         } else {
00649             vz_debug ("Invite pkgs to ast don't will be droped" );
00650         }
00651     }
00652 
00653     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "refresh_on" ) )
00654     {
00655         miss_match = false;
00656         
00657         vz_printf ( "Refresh function :: Enable" );
00658         
00659         do_not_refresh = false;
00660     }
00661 
00662     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "refresh_off" ) )
00663     {
00664         miss_match = false;
00665         
00666         vz_printf ( "Refresh function :: Disable" );
00667         
00668         do_not_refresh = true;
00669     }
00670     
00671     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "refresh_status" ) )
00672     {
00673         miss_match = false;
00674         
00675         vz_printf ( "Refresh function :: %s", ( do_not_refresh == true ) ? "Disable" : "Enable" );
00676     }
00677 
00678     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dop" ) )
00679     {
00680         miss_match = false;
00681         
00682         drop_ok_pkg = !drop_ok_pkg;
00683         
00684         if ( drop_ok_pkg ) {
00685             vz_debug ( "Ok pkgs will be droped" );
00686         } else {
00687             vz_debug ( "Ok pkgs don't will be droped" );
00688         }
00689     }
00690 
00691     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dip" ) )
00692     {
00693         miss_match = false;
00694         
00695         drop_invite_pkg = !drop_invite_pkg;
00696         
00697         if ( drop_invite_pkg ) {
00698             vz_debug ( "invite pkgs from cbx will be droped" );
00699         } else {
00700             vz_debug ( "invite pkgs from cbx don't will be droped" );
00701         }
00702 
00703     }
00704 
00705     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "drp" ) )
00706     {
00707         miss_match = false;
00708         
00709         drop_registry_pkg = !drop_registry_pkg;
00710         
00711         if ( drop_registry_pkg ) {
00712             vz_debug ( "registrys pkgs from cbx will be droped" );
00713         } else {
00714             vz_debug ( "registrys pkgs from cbx don't will be droped" );
00715         }
00716 
00717     }
00718 
00719     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "rafc" ) )
00720     {
00721         miss_match = false;
00722         
00723         received_audio_from_cb = !received_audio_from_cb;
00724         
00725         if ( received_audio_from_cb ) {
00726             vz_debug ( "audio pkgs from cbx will printed" );
00727         } else {
00728             vz_debug ( "audio pkgs from cbx don't will printed" );
00729         }
00730 
00731     }
00732 
00733     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dap" ) )
00734     {
00735         miss_match = false;
00736         
00737         drop_ack_pkg = !drop_ack_pkg;
00738         
00739         if ( drop_ack_pkg ) {
00740             vz_debug ( "ack pkgs will be droped" );
00741         } else {
00742             vz_debug ( "ack pkgs don't will be droped" );
00743         }
00744     }
00745 
00746     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "drfa" ) )
00747     {
00748         miss_match = false;
00749         
00750         drop_rtp_from_ast_pkg = !drop_rtp_from_ast_pkg;
00751         
00752         if ( drop_rtp_from_ast_pkg ) {
00753             vz_debug ( "rtp pkgs from ast will be droped" );
00754         } else {
00755             vz_debug ( "rtp pkgs from ast don't will be droped" );
00756         }
00757     }
00758 
00759     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "drfc" ) )
00760     {
00761         miss_match = false;
00762         
00763         drop_rtp_from_cbx_pkg = !drop_rtp_from_cbx_pkg;
00764         
00765         if ( drop_rtp_from_cbx_pkg ) {
00766             vz_debug ( "rtp pkgs from cbx will be droped" );
00767         } else {
00768             vz_debug ( "rtp pkgs from cbx don't will be droped" );
00769         }
00770     }
00771 
00772     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "uptime" ) )
00773     {
00774         miss_match = false;
00775 
00776         uint32_t local_uptime = uptime;
00777         uint16_t h = local_uptime / ( 60 * 60 );
00778         uint16_t m = ( local_uptime - ( h * 60 * 60 ) ) / 60;
00779         uint16_t s = ( local_uptime - ( ( h * 60 * 60 ) + m * 60 ) );
00780        vz_printf ( "\r\n%ih%im%is", h, m, s );
00781     }
00782 
00783     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "wake" ) )
00784     {
00785         miss_match = false;
00786         show_wake_all_up_status = true;
00787     }
00788 
00789     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "wake_on" ) )
00790     {
00791         miss_match = false;
00792         
00793         vz_printf ( "Function wake_all_up : Enable" );
00794         
00795         wake_all = true;
00796         
00797         wake_all_disable = false;
00798     }
00799     
00800     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "wake_off" ) )
00801     {
00802         miss_match = false;
00803         
00804         vz_printf ("Function wake_all_up : Disable" );
00805         
00806         wake_all = false;
00807         
00808         wake_all_disable = true;
00809     }
00810     
00811     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "get_wdt_string" ) )
00812     {
00813         miss_match = false;
00814         show_wdt_string = true;
00815     }
00816 
00817     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "ifconfig" ) ) 
00818     {
00819         miss_match = false;
00820         
00821         vz_printf ("Configs :: " );
00822         char buffer[ 128 ];
00823 
00824         cm -> get_header_ip ( buffer );
00825         vz_printf ("Header IP :: %s", buffer );
00826 
00827         vz_printf ("Header ext :: %u", cm -> get_ext () );
00828 
00829         vz_printf ("Header port :: %u", cm -> get_port () );
00830 
00831         cm -> get_server_ip ( buffer );
00832         vz_printf ("Server IP :: %s", buffer );
00833 
00834         vz_printf ("Server ext :: %u", cm -> get_server_ext () );
00835 
00836         vz_printf ("Server port :: %u", cm -> get_server_port () );
00837 
00838         cm -> get_net_mask ( buffer );
00839         vz_printf ("Mascara de rede :: %s", buffer );
00840 
00841         cm -> get_gateway ( buffer );
00842         vz_printf ("Gateway IP :: %s", buffer );
00843 
00844         vz_printf ("UDP Port :: %u", cm -> get_udp_port_listener () );
00845 
00846         vz_printf ("TCP Port :: %u", cm -> get_tcp_port_listener () );
00847 
00848         cm -> get_fw_server_ip ( buffer );
00849         vz_printf ("FW Server IP :: %s", buffer );
00850 
00851         vz_printf ("FW Server Port :: %u", cm -> get_fw_server_port () );
00852 
00853         vz_printf ("Max Ext :: %u", cm -> get_max_ext () );
00854 
00855         vz_printf ("Min Ext :: %u", cm -> get_min_ext () );
00856 
00857         vz_printf ("Shift Port :: %u", cm -> get_shift_port () );
00858         
00859         cm -> get_clock_server_ip ( buffer );
00860         vz_printf ("Clock Server IP :: %s", buffer );
00861         
00862 %: ifdef MODE_TEST
00863         vz_printf ("on MODE_TEST" );
00864 %: endif            
00865     }
00866 
00867     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "sizes" ) )
00868     {
00869         miss_match = false;
00870         sizes = true;
00871     }
00872 
00873     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "ftq" ) )
00874     {
00875         miss_match = false;
00876         
00877         vz_printf ( "FTQ On" );
00878         
00879         big_bug_pkg = true;
00880     }
00881 
00882     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "ktq" ) )
00883     {
00884         miss_match = false;
00885         
00886         vz_printf ( "FTQ!!!" );
00887 
00888         flood_bug_pkg = !flood_bug_pkg;
00889     }
00890 
00891     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "wdt_pkg_cbx_disable" ) )
00892     {
00893         miss_match = false;
00894         
00895         vz_printf ( "wdt_pkg_cbx status :: disable" );
00896         
00897         disable_wdt_from_cbx = true;
00898     }
00899 
00900     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "wdt_pkg_cbx_enable" ) )
00901     {
00902         miss_match = false;
00903         
00904         vz_printf ( "wdt_pkg_cbx status :: enable" );
00905         
00906         disable_wdt_from_cbx = false;
00907     }
00908 
00909     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "wdt_pkg_cbx_status" ) )
00910     {
00911         miss_match = false;
00912         
00913         vz_printf ( "wdt_pkg_cbx status :: %s", ( disable_wdt_from_cbx ) ? "disable" : "enable" );
00914     }
00915 
00916     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "ls", 2 ) )
00917     {
00918         miss_match = false;
00919         reverse_list = false;
00920         list = true;
00921 
00922         if ( strlen ( debug_buf ) != 2 )
00923         {
00924             if ( strstr ( ( debug_buf + 2 ), "r" ) ) 
00925             {
00926                 reverse_list = true;
00927             }
00928 
00929             
00930             if ( strstr ( ( debug_buf + 2 ), "l" ) ) 
00931             {
00932                 list = false;
00933                 long_list = true;
00934             }
00935             
00936             if ( strstr ( ( debug_buf + 2 ), "t" ) ) 
00937             {
00938                 long_list = true;
00939                 list = false;
00940                 show_time = true;
00941             }
00942             
00943             if ( strstr ( ( debug_buf + 2 ), "i" ) ) 
00944             {
00945                 long_list = true;
00946                 list = false;
00947                 show_invites = true;
00948             }
00949         }
00950     }
00951 
00952     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "drtp ", 5 ) )
00953     {
00954         if ( xmemmatch ( ( uint8_t * )( debug_buf + 5 ), ( uint8_t * ) "on", 2 ) )
00955         {
00956             miss_match = false;
00957             
00958             vz_printf ( "Rtp Debug On" );
00959             
00960             debug_rtp = true;
00961         }
00962         else if ( xmemmatch ( ( uint8_t * )( debug_buf + 5 ), ( uint8_t * ) "off", 3 ) )
00963         {
00964             miss_match = false;
00965             
00966             vz_printf ( "Rtp Debug Off" );
00967             
00968             debug_rtp = false;
00969         }
00970     }
00971 
00972     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "print_v_cb" ) ) 
00973     {
00974         miss_match = false;
00975         print_v_cb = true;
00976     }
00977 
00978     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "print_v_call" ) ) 
00979     {
00980         miss_match = false;
00981         print_v_call = true;
00982     }
00983 
00984     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "tt" ) ) 
00985     {
00986         miss_match = false;
00987         main_test = !main_test;
00988     }
00989     
00990     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "ttt" ) ) 
00991     {
00992         miss_match = false;
00993         main_test_mean = !main_test_mean;
00994     }
00995 
00996     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "registra" ) ) 
00997     {
00998         miss_match = false;
00999         registra = true;
01000     }
01001 
01002     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "registra4" ) ) 
01003     {
01004         miss_match = false;
01005         registra4 = true;
01006     }
01007 
01008     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "show_sip" ) ) 
01009     {
01010         miss_match = false;
01011         show_sip = true;
01012     }
01013 
01014     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "reset_cks" ) ) 
01015     {
01016         miss_match = false;
01017         reset_cks = true;
01018     }
01019 
01020     //replaced by ls
01021     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "status" ) ) 
01022     {
01023         miss_match = false;
01024         list = true;
01025     }
01026 
01027     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "wdt" ) ) 
01028     {
01029         miss_match = false;
01030         debug_wdt = true;
01031     }
01032 
01033     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "eth" ) ) 
01034     {
01035         miss_match = false;
01036         debug_eth = true;
01037     }
01038 
01039     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "deleted" ) ) 
01040     {
01041         miss_match = false;
01042         vz_printf ( "::deleted_sip [ %5i ]::", deleted_sip );
01043     }
01044     
01045     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "help_setup" ) ) 
01046     {
01047         miss_match = false;
01048     
01049         vz_printf ( "ifconfig                        - mostra o arquivo de configuracao do sistema" );
01050         vz_printf ( "dconfig                         - volta as configuracoes do sistema para o padrao de fabrica" );
01051         vz_printf ( "ipset [ip]                      - Configura o IP da cabeceira" );
01052         vz_printf ( "extset [ext]                    - Configura a ext da cabeceira" );
01053         vz_printf ( "msipport [port]                 - Configura a porta SIP da cabeceira" );
01054         vz_printf ( "serverip [ip]                   - Configura o ip do servidor asterisk" );
01055         vz_printf ( "serextset [ext]                 - Configura a server ext da cabeceira" );
01056         vz_printf ( "ssport [port]                   - Configura a porta SIP do servidor asterisk" );
01057         vz_printf ( "maskset [mask]                  - Configura a mascara da cabeceira" );
01058         vz_printf ( "gatewayset [gateway]            - Configura o gateway da cabeceira" );
01059         vz_printf ( "fw_ip                           - Configura o IP do servidor de fw" );
01060         vz_printf ( "fw_port                         - Configura a porta do servidor de fw" );                
01061         vz_printf ( "maxext                          - Configura o maior ramal possivel de ser registrado nesse ramo" );
01062         vz_printf ( "minext                          - Configura o menor ramal possivel de ser registrado nesse ramo" );
01063         serial_pc.printf("format                          - formata o sistema de arquivos" );
01064     }
01065     
01066     
01067     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "help_debug" ) ) 
01068     {
01069         miss_match = false;
01070             
01071         vz_printf ( "debug [on|off|show]             - seleciona debugs gerais | lista de debugs" );
01072     }
01073     
01074     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "help_command_to_cbx" ) ) 
01075     {
01076         miss_match = false;
01077         
01078         vz_printf ( "callme [ramal porta]            - envia o pedido de ligacao para o callbox com o ramal e porta indicada" );
01079         vz_printf ( "pcb ramal comando               - envia o <comando> para o cbx <ramal> e <porta = ramal sem a centane> executar" );
01080         vz_printf ( "pcc ramal porta comando         - envia o <comando> para o cbx <ramal> e <porta> executar" );
01081         vz_printf ( "cc ramal comando                - envia o <comando> para o cbx <ramal> e <porta = ramal> executar" );
01082         vz_printf ( "silence <start_ext end_ext>     - envia comando de flood off para os ramais no intervalo end_ext - start_ext" );
01083         vz_printf ( "-- ext                          - Header flood off, ext flood off" );
01084         vz_printf ( "++ ext                          - Header flood on, ext flood on" );
01085     }
01086     
01087     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "help_protocol" ) ) 
01088     {
01089         miss_match = false;
01090         
01091         vz_printf ( "types                           - Lista os types usados no protocolo de comunicacao Header -- CBx" );
01092         vz_printf ( "protocol                        - Exibe formato do pacote seguindo o protocolo de comunicacao Header -- CBx" );
01093         
01094     }
01095     
01096     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "help_cbx_list" ) ) 
01097     {
01098         miss_match = false;
01099         
01100         vz_printf ( "ls [lrti] | status              - Exibe uma lista ordenada por ext do CBx registrados na Header" );
01101         vz_printf ( "showcb                          - lista os Cbx registrados na header" );
01102         vz_printf ( "show_sip                        - lista os Cbx registrados na header com suas portas SIP" );
01103     }
01104     
01105     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "help_io" ) ) 
01106     {
01107         miss_match = false;
01108         
01109         vz_printf ( "cks                             - exibe estatisticas de check sum" );
01110         vz_printf ( "reset_cks                       - reseta estatisticas de check sum" );
01111         vz_printf ( "stats                           - exibe estatisticas de pacotes recidos" );
01112         vz_printf ( "reset_stats                     - reseta estatisticas de pacotes recidos" );
01113         vz_printf ( "{ [+|-] | flood [ on | off ] }  - simula envio de pacotes de audio" );
01114         vz_printf ( "rx                              - Exibe ultimo pacote recebido dos CBx" );
01115         vz_printf ( "tx                              - Exibe ultimo pacote enviado para os CBx" );
01116     }
01117     
01118     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "types" ) ) 
01119     {
01120         miss_match = false;
01121 
01122         vz_printf (
01123                 "  hex  ::   dec  :: Type \n\r"
01124                 "0x%02x   :: %5i  :: BOOT\n\r"
01125                 "0x%02x   :: %5i  :: REGISTRY\n\r"
01126                 "0x%02x   :: %5i  :: REGISTRY_ACK\n\r"
01127                 "0x%02x   :: %5i  :: INVITE\n\r"
01128                 "0x%02x   :: %5i  :: INVITE_ACK\n\r"
01129                 "0x%02x   :: %5i  :: AUDIO\n\r"
01130                 "0x%02x   :: %5i  :: TELEMETRY\n\r"
01131                 "0x%02x   :: %5i  :: BOOTLOADER_CBX\n\r"
01132                 "0x%02x   :: %5i  :: CB_BYE\n\r"
01133                 "0x%02x   :: %5i  :: CB_BYE_ACK\n\r"
01134                 "0x%02x   :: %5i  :: PROMPT\n\r"
01135                 "0x%02x   :: %5i  :: FLOOD\n\r"
01136                 "0x%02x   :: %5i  :: FW\n\r"
01137                 "0x%02x   :: %5i  :: FW1\n\r"
01138                 "0x%02x   :: %5i  :: FW2\n\r"
01139                 "0x%02x   :: %5i  :: FW3\n\r"
01140                 "0x%02x   :: %5i  :: FW4\n\r"
01141                 "0x%02x   :: %5i  :: FW5\n\r"
01142                 "0x%02x   :: %5i  :: FW6\n\r"
01143                 "0x%02x   :: %5i  :: CB_STATS\n\r"
01144                 "0x%02x   :: %5i  :: CB_STATS_ACK\n\r"
01145                 "0x%02x   :: %5i  :: DO_NOTHING\n\r\n\r"
01146 
01147                 "0x%02x :: %5i  :: BROADCAST_EXT\n\r"
01148                 "NOTA - Os types TELEMETRY, CB_STATS, e FW1 ate FW6 sao repassados para o servidor como type FW\n\r",
01149                 BOOT, BOOT,
01150                 REGISTRY, REGISTRY,
01151                 REGISTRY_ACK, REGISTRY_ACK,
01152                 INVITE, INVITE,
01153                 INVITE_ACK, INVITE_ACK,
01154                 AUDIO, AUDIO,
01155                 TELEMETRY, TELEMETRY,
01156                 BOOTLOADER_CBX, BOOTLOADER_CBX,
01157                 CB_BYE, CB_BYE,
01158                 CB_BYE_ACK, CB_BYE_ACK,
01159                 PROMPT, PROMPT,
01160                 FLOOD, FLOOD,
01161                 FW, FW,
01162                 FW1, FW1,
01163                 FW2, FW2,
01164                 FW3, FW3,
01165                 FW4, FW4,
01166                 FW5, FW5,
01167                 FW6, FW6,
01168                 CB_STATS, CB_STATS,
01169                 CB_STATS_ACK, CB_STATS_ACK,
01170                 DO_NOTHING, DO_NOTHING,
01171                 BROADCAST_EXT, BROADCAST_EXT
01172             );
01173     }
01174 
01175     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "protocol" ) )
01176     {
01177         miss_match = false;
01178         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" );
01179     }
01180 
01181     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "flood ", 6 ) )
01182     {
01183         if ( xmemmatch ( ( uint8_t * )( debug_buf + 6 ), ( uint8_t * ) "on", 2 ) ) 
01184         {
01185             miss_match = false;
01186             
01187             vz_printf ( "Flood On" );
01188             
01189             tflood.start ();
01190             tflood.reset ();
01191             floodcount =0;
01192             pflood = true;
01193             flood_timeout.start ();
01194         }
01195         else if ( xmemmatch ( ( uint8_t * )( debug_buf + 6 ), ( uint8_t * ) "more", 4 ) ) 
01196         {
01197             miss_match = false;
01198             
01199             vz_printf ( "Flood On" );
01200             
01201             tflood.start ();
01202             tflood.reset ();
01203             floodcount = 0;
01204             pflood = true;
01205         }
01206         else if ( xmemmatch ( ( uint8_t * )( debug_buf + 6 ), ( uint8_t * ) "off", 3 ) )
01207         {
01208             miss_match = false;
01209             
01210             vz_printf ( "Flood Off" );
01211             
01212             pflood = false;
01213             tflood.stop ();
01214             flood_timeout.reset ();
01215         }
01216 
01217     }
01218 
01219     // precisa ser refatorado pra mandar pro ramo inteiro, dado a lista de cbx
01220     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "silence ", 8 ) )
01221     {
01222         miss_match = false;
01223         
01224         char *ref, *split;
01225 
01226         strcpy ( promptcb_last_cmd, debug_buf );
01227 
01228         if( !( strcmp ( debug_buf + 8, "-h" ) && strcmp ( debug_buf + 8, "--help" ) ) ) {
01229             vz_printf ( "Usage: silence start_ext end_ext | start_ext must be greater than end_ext\n\rObs : ( end_ext - start_ext ) < 50 " );
01230         } else {
01231             ref = debug_buf;
01232 
01233             split = strtok ( debug_buf + 8, " " );
01234 
01235             start_ext = atoi ( split );
01236 
01237             split += strlen ( split ) + 1;
01238 
01239             end_ext = atoi ( split );
01240 
01241             debug_buf = ref;
01242 
01243             if ( start_ext < end_ext && ( end_ext - start_ext ) < 50 )
01244             {
01245                 if ( start_ext % 2 ) start_ext --;
01246                 if ( !( end_ext % 2 ) ) end_ext ++;
01247 
01248                 ext_count = start_ext;
01249                 flood_silence_timer.start ();
01250             } else {
01251                 vz_printf ( "Usage Error : silence start_ext end_ext | start_ext must be greater than end_ext\n\rObs : ( end_ext - start_ext ) < 50 " );
01252             }
01253             
01254             flood_silence = true;
01255         }
01256     }
01257 
01258     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "debug ", 6 ) )
01259     {
01260         if ( xmemmatch ( ( uint8_t * )( debug_buf + 6 ), ( uint8_t * ) "on", 2 ) )
01261         {
01262             miss_match = false;
01263             
01264             vz_printf ( "Debug ON" );
01265             
01266             debug_alive = true;
01267         }
01268         else if ( xmemmatch ( ( uint8_t * )( debug_buf + 6), ( uint8_t * ) "off", 3 ) )
01269         {
01270             miss_match = false;
01271             
01272             vz_printf ( "Debug Off\n\r" );
01273             
01274             debug_alive = false;
01275         }
01276         if ( xmemmatch ( ( uint8_t * )( debug_buf + 6 ), ( uint8_t * ) "show", 4 ) ) 
01277         {
01278             miss_match = false;
01279             
01280             vz_printf ( "dsip \n\r"
01281                         "debug_alive \n\r"
01282                         "debug_prompt \n\r"
01283                         "debug_vector \n\r"
01284                         "debug_cb \n\r"
01285                         "debug_main \n\r"
01286                         "dcks \n\r"
01287                         "debug_cb_rx \n\r"
01288                         "debug_cb_tx* \n\r"
01289                         "debug_eth_rx* \n\r"
01290                         "debug_eth_tx* \n\r"
01291                         "debug_file" 
01292             );
01293         }
01294     }
01295 
01296     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dsip ", 5 ) ) 
01297     {
01298         if ( xmemmatch ( ( uint8_t * )( debug_buf + 5 ), ( uint8_t * ) "on", 2 ) ) 
01299         {
01300             miss_match = false;
01301             
01302             vz_printf ( "Sip Debug On" );
01303             
01304             debug_sip = true;
01305         }
01306         else if ( xmemmatch ( ( uint8_t * )( debug_buf + 5 ), ( uint8_t * ) "off", 3 ) )
01307         {
01308             miss_match = false;
01309             
01310             vz_printf ( "Sip Debug Off" );
01311             
01312             debug_sip = false;
01313         }
01314     }
01315     
01316     
01317     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "flood_", 6 ) ) 
01318     {
01319         if ( xmemmatch ( ( uint8_t * )( debug_buf + 6 ), ( uint8_t * ) "enable", 6 ) ) 
01320         {
01321             miss_match = false;
01322             
01323             vz_printf ( "Flood Packages Enable" );
01324             
01325             enable_flood = true;
01326         }
01327         else if ( xmemmatch ( ( uint8_t * )( debug_buf + 6 ), ( uint8_t * ) "disable", 7 ) )
01328         {
01329             miss_match = false;
01330             
01331             vz_printf ( "Flood Packages Disable" );
01332             
01333             enable_flood = false;
01334         }
01335         else if ( xmemmatch ( ( uint8_t * )( debug_buf + 6 ), ( uint8_t * ) "status", 6 ) )
01336         {
01337             miss_match = false;
01338             
01339             vz_printf ( "Flood Packages %s", ( enable_flood ) ? "Enable" : "Disable" );
01340         }
01341     }
01342 
01343     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "ddrefresh ", 10 ) )
01344     {
01345         if ( xmemmatch ( ( uint8_t * )( debug_buf + 10 ), ( uint8_t * ) "on", 2 ) ) 
01346         {
01347             miss_match = false;
01348             
01349             vz_printf ( "Don't Refresh Debug On" );
01350             
01351             debug_dont_refresh = true;
01352         }
01353         else if ( xmemmatch ( ( uint8_t * )( debug_buf + 10 ), ( uint8_t * ) "off",3 ) )
01354         {
01355             miss_match = false;
01356         
01357             vz_printf ( "Don't Refresh Debug Off" );
01358                 
01359             debug_dont_refresh = false;
01360         }
01361     }
01362     
01363     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "drajada ", 8 ) ) 
01364     {
01365         if ( xmemmatch ( ( uint8_t * )( debug_buf + 8 ), ( uint8_t * ) "on", 2 ) )
01366         {
01367             miss_match = false;
01368             
01369             vz_printf ( "Debug Rajada on" );
01370             
01371             debug_resend_invite = true;
01372         }
01373         else if ( xmemmatch ( ( uint8_t * )( debug_buf + 8 ), ( uint8_t * ) "off",3 ) )
01374         {
01375             miss_match = false;
01376             
01377             vz_printf ( "Debug Rajada off" );
01378             
01379             debug_resend_invite = false;
01380         }
01381     }
01382 
01383     else if ( xmemmatch ( ( uint8_t * ) debug_buf, ( uint8_t * ) "dsqn ", 5 ) )
01384     {
01385         if ( xmemmatch ( ( uint8_t * )( debug_buf + 5 ), ( uint8_t * ) "on", 2 ) )
01386         {
01387             miss_match = false;
01388             
01389             vz_printf ( "Sequence Number Debug On" );
01390             
01391             debug_sqn = true;
01392         }
01393 
01394         if ( xmemmatch ( ( uint8_t * )( debug_buf + 5 ), ( uint8_t * ) "off",3 ) ) 
01395         {
01396             miss_match = false;
01397             
01398             vz_printf ( "Sequence Number Debug Off" );
01399             
01400             debug_sqn = false;
01401         }
01402     }
01403 
01404     else if ( xmemmatch ( ( uint8_t * ) debug_buf, ( uint8_t * ) "test_ts ", 8 ) ) 
01405     {
01406         if ( xmemmatch ( ( uint8_t * )( debug_buf + 8 ), ( uint8_t * ) "on", 2 ) ) 
01407         {
01408             miss_match = false;
01409             
01410             vz_printf ( "TS testing On" );
01411             
01412             test_ts = true;
01413         }
01414         else if ( xmemmatch ( ( uint8_t * )( debug_buf + 8 ), ( uint8_t * ) "off",3 ) ) 
01415         {
01416             miss_match = false;
01417          
01418             vz_printf ( "TS testing Off" );
01419             
01420             test_ts = false;
01421         }
01422     }
01423 
01424     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dhello ", 7 ) ) 
01425     {
01426         if ( xmemmatch ( ( uint8_t * )( debug_buf + 7 ), ( uint8_t * ) "on", 2 ) ) 
01427         {
01428             miss_match = false;
01429             
01430             vz_printf ( "Hello Debug On" );
01431             
01432             debug_hello = true;
01433         }
01434         else if ( xmemmatch ( ( uint8_t * )( debug_buf + 7 ), ( uint8_t * ) "off",3 ) ) 
01435         {
01436             miss_match = false;
01437             
01438             vz_printf ( "Hello Debug Off" );
01439             
01440             debug_hello = false;
01441         }
01442     }
01443 
01444     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dmissedwdt ", 11 ) ) 
01445     {
01446         if ( xmemmatch ( ( uint8_t * )( debug_buf + 11 ), ( uint8_t * ) "on", 2 ) )
01447         {
01448             miss_match = false;
01449             
01450             vz_printf ( "Wdt missed Debug On" );
01451             
01452             dmissed_wdt = true;
01453         }
01454         else if ( xmemmatch ( ( uint8_t * )( debug_buf + 11 ), ( uint8_t * ) "off", 3 ) ) 
01455         {
01456             miss_match = false;
01457             
01458             vz_printf ( "Wdt missed Debug Off" );
01459             
01460             dmissed_wdt = false;
01461         }
01462     }
01463 
01464     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dclock ", 7 ) )
01465     {
01466         if ( xmemmatch ( ( uint8_t * )( debug_buf + 7 ), ( uint8_t * ) "on", 2 ) )
01467         {
01468             miss_match = false;
01469             
01470             vz_printf( "Clock Debug On" );
01471             
01472             debug_clock = true;
01473         }
01474         if ( xmemmatch ( ( uint8_t * )( debug_buf + 7 ), ( uint8_t * ) "off", 3 ) )
01475         {
01476             miss_match = false;
01477             
01478             vz_printf( "Clock Debug Off" );
01479             
01480             debug_clock = false;
01481         }
01482     }
01483     
01484     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dprintclock ", 12 ) ) 
01485     {
01486         if ( xmemmatch ( ( uint8_t * )( debug_buf + 12 ), ( uint8_t * ) "on", 2 ) ) 
01487         {
01488             miss_match = false;
01489             
01490             vz_printf ( "Clock Debug <VZ PKG PRINT> On" );
01491             
01492             debug_print_clock = true;
01493         }
01494         if ( xmemmatch ( ( uint8_t * )( debug_buf + 12 ), ( uint8_t * ) "off", 3 ) )
01495         {
01496             miss_match = false;
01497             
01498             vz_printf ( "Clock Debug <VZ PKG PRINT> Off" );
01499             
01500             debug_print_clock = false;
01501         }
01502     }
01503 
01504     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dlength ", 8 ) ) 
01505     {
01506         if ( xmemmatch ( ( uint8_t * )( debug_buf + 8 ), ( uint8_t * ) "on", 2 ) ) 
01507         {
01508             miss_match = false;
01509             
01510             vz_printf ( "String length debug On" );
01511             
01512             debug_string_length = true;
01513         }
01514         if ( xmemmatch ( ( uint8_t * )( debug_buf + 8 ), ( uint8_t * ) "off", 3 ) )
01515         {
01516             miss_match = false;
01517             
01518             vz_printf ( "String length debug Off" );
01519             
01520             debug_string_length = false;
01521         }
01522     }
01523 
01524     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dbind ", 6 ) )
01525     {
01526         if ( xmemmatch ( ( uint8_t * )( debug_buf + 6 ), ( uint8_t * ) "on", 2 ) )
01527         {
01528             miss_match = false;
01529             
01530             vz_printf ( "UDP Bind Debug On" );
01531             
01532             debug_bind = true;
01533         }
01534         else if ( xmemmatch ( ( uint8_t * )( debug_buf + 6 ), ( uint8_t * ) "off",3 ) )
01535         {
01536             miss_match = false;
01537             
01538             vz_printf ( "UDP Bind Debug Off" );
01539             
01540             debug_bind = false;
01541         }
01542     }
01543 
01544     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dresetrtp ", 10 ) )
01545     {
01546         if ( xmemmatch ( ( uint8_t * )( debug_buf + 10 ), ( uint8_t * ) "on", 2 ) )
01547         {
01548             miss_match = false;
01549             
01550             vz_printf ( "Reset RTP Debug On" );
01551             
01552             debug_reset_rtp = true;
01553         }
01554         else if ( xmemmatch ( ( uint8_t * )( debug_buf + 10 ), ( uint8_t * ) "off", 3 ) )
01555         {
01556             miss_match = false;
01557             
01558             vz_printf ( "Reset RTP Debug Off" );
01559             
01560             debug_reset_rtp = false;
01561         }
01562     }
01563 
01564     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "duart ", 6 ) )
01565     {
01566         if ( xmemmatch ( ( uint8_t * )( debug_buf + 6 ), ( uint8_t * ) "on", 2 ) )
01567         {
01568             miss_match = false;
01569             
01570             vz_printf ( "Enable UART3 usage" );
01571             
01572             debug_uart3 = true;
01573         }
01574         else if ( xmemmatch ( ( uint8_t * )( debug_buf + 6 ), ( uint8_t * ) "off", 3 ) )
01575         {
01576             miss_match = false;
01577             
01578             vz_printf ( "Disable UART3 usage" );
01579             
01580             debug_uart3 = false;
01581         }
01582     }
01583 
01584     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dprint ", 7 ) )
01585     {
01586         if ( xmemmatch ( ( uint8_t * )( debug_buf + 7 ), ( uint8_t * ) "on", 2 ) )
01587         {
01588             miss_match = false;
01589             
01590             vz_printf ( "Debug print On" );
01591             
01592             print_values = true;
01593         }
01594         else if ( xmemmatch ( ( uint8_t * )( debug_buf + 7 ), ( uint8_t * ) "off", 3 ) ) 
01595         {
01596             miss_match = false;
01597             
01598             vz_printf ( "Debug print Off" );
01599             
01600             print_values = false;
01601         }
01602     }
01603 
01604     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dmissed ", 8 ) )
01605     {
01606         if ( xmemmatch ( ( uint8_t * )( debug_buf + 8 ), ( uint8_t * ) "on", 2 ) )
01607         {
01608             miss_match = false;
01609             
01610             vz_printf ( "Debug Missed On" );
01611             
01612             debug_missed = true;
01613         }
01614         else if ( xmemmatch ( ( uint8_t * )( debug_buf + 8 ), ( uint8_t * ) "off", 3 ) )
01615         {
01616             miss_match = false;
01617             
01618             vz_printf ( "Debug Missed Off" );
01619             
01620             debug_missed = false;
01621         }
01622     }
01623 
01624     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dreconnect ", 11 ) )
01625     {
01626         if ( xmemmatch ( ( uint8_t * )( debug_buf + 11 ), ( uint8_t * ) "on", 2 ) )
01627         {
01628             miss_match = false;
01629             
01630             vz_printf ( "Reconnecet Debug On" );
01631             
01632             debug_reconnect = true;
01633         }
01634         else if ( xmemmatch ( ( uint8_t * )( debug_buf + 11 ), ( uint8_t * ) "off", 3 ) )
01635         {
01636             miss_match = false;
01637             
01638             vz_printf ( "Reconnecet Debug Off" );
01639             
01640             debug_reconnect = false;
01641         }
01642     }
01643     
01644     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dpair ", 6 ) )
01645     {
01646         if ( xmemmatch ( ( uint8_t * )( debug_buf + 6 ), ( uint8_t * ) "on", 2 ) )
01647         {
01648             miss_match = false;
01649             
01650             vz_printf ( "Pair Debug On" );
01651             
01652             debug_pair = true;
01653         }
01654         else if ( xmemmatch ( ( uint8_t * )( debug_buf + 6 ), ( uint8_t * ) "off", 3 ) )
01655         {
01656             miss_match = false;
01657             
01658             vz_printf ( "Pair Debug Off" );
01659             
01660             debug_pair = false;
01661         }
01662     }
01663 
01664     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dmatch ", 7 ) )
01665     {
01666         if ( xmemmatch ( ( uint8_t * )( debug_buf + 7 ), ( uint8_t * ) "on", 2 ) )
01667         {
01668             miss_match = false;
01669             
01670             vz_printf ( "Port Match Debug On" );
01671             
01672             debug_port_match = true;
01673         }
01674         else if ( xmemmatch ( ( uint8_t * )( debug_buf + 7 ), ( uint8_t * ) "off", 3 ) )
01675         {
01676             miss_match = false;
01677             
01678             vz_printf ( "Port Match Debug Off" );
01679             
01680             debug_port_match = false;
01681         }
01682     }
01683 
01684 
01685     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dmuted ", 7 ) )
01686     {
01687         if ( xmemmatch ( ( uint8_t * )( debug_buf + 7 ), ( uint8_t * ) "on", 2 ) )
01688         {
01689             miss_match = false;
01690             
01691             vz_printf ( "Muted Debug On" );
01692             
01693             debug_muted = true;
01694         }
01695         else if ( xmemmatch ( ( uint8_t * )( debug_buf + 7 ), ( uint8_t * ) "off", 3 ) )
01696         {
01697             miss_match = false;
01698             
01699             vz_printf ( "Muted Debug Off" );
01700             
01701             debug_muted = false;
01702         }
01703     }
01704 
01705     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dwdt ", 5 ) )
01706     {
01707         if ( xmemmatch ( ( uint8_t * )( debug_buf + 5 ), ( uint8_t * ) "on", 2 ) ) 
01708         {
01709             miss_match = false;
01710             
01711             vz_printf ( "Wdt Debug On" );
01712             
01713             wdt_show = true;
01714         }
01715         if ( xmemmatch ( ( uint8_t * )( debug_buf + 5 ), ( uint8_t * ) "off",3 ) ) 
01716         {
01717             miss_match = false;
01718             
01719             vz_printf ( "Wdt Debug Off" );
01720     
01721             wdt_show = false;
01722         }
01723     }
01724 
01725     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "drefresh ", 9 ) ) 
01726     {
01727         if ( xmemmatch ( ( uint8_t * )( debug_buf + 9 ), ( uint8_t * ) "on", 2 ) )
01728         {
01729             miss_match = false;
01730             
01731             vz_printf ( "Refresh Debug On" );
01732             
01733             debug_refresh= true;
01734         }
01735         if ( xmemmatch ( ( uint8_t * )( debug_buf + 9 ), ( uint8_t * ) "off",3 ) )
01736         {
01737             miss_match = false;
01738             
01739             vz_printf ( "Refresh Debug Off" );
01740                 
01741             debug_refresh = false;
01742         }
01743     }
01744 
01745     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dping ", 6 ) )
01746     {
01747         if ( xmemmatch ( ( uint8_t * )( debug_buf + 6 ), ( uint8_t * ) "on", 2 ) )
01748         {
01749             miss_match = false;
01750             
01751             vz_printf ( "Ping Debug On" );
01752             
01753             debug_ping = true;
01754         }
01755         if ( xmemmatch ( ( uint8_t * )( debug_buf + 6 ), ( uint8_t * ) "off", 3 ) )
01756         {
01757             miss_match = false;
01758             
01759             vz_printf ( "Ping Debug Off" );
01760                 
01761             debug_ping= false;
01762         }
01763     }
01764 
01765     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dwu ", 4 ) )
01766     {
01767         if ( xmemmatch ( ( uint8_t * )( debug_buf + 4 ), ( uint8_t * ) "on", 2 ) )
01768         {
01769             miss_match = false;
01770             
01771             vz_printf ( "Wake Up Debug On" );
01772             
01773             debug_wake = true;
01774         }
01775         if ( xmemmatch ( ( uint8_t * )( debug_buf + 4 ), ( uint8_t * ) "off", 3 ) ) 
01776         {
01777             miss_match = false;
01778             
01779             vz_printf ( "Wake Up Debug Off" );
01780             
01781             debug_wake = false;
01782         }
01783     }
01784 
01785     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "tcp_alive ", 10 ) ) 
01786     {
01787         if ( xmemmatch ( ( uint8_t * )( debug_buf + 10 ), ( uint8_t * ) "on", 2 ) )
01788         {
01789             miss_match = false;
01790             
01791             vz_printf ( "TCP don't drop mode on" );
01792             
01793             tcp_alive = true;
01794         }
01795         else if ( xmemmatch ( ( uint8_t * )( debug_buf + 10 ), ( uint8_t * ) "off", 3 ) )
01796         {
01797             miss_match = false;
01798             
01799             vz_printf ( "TCP don't drop mode off" );
01800             
01801             tcp_alive = false;
01802         }
01803     }
01804 
01805     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "daging ",7 ) ) 
01806     {
01807         if ( xmemmatch ( ( uint8_t * )( debug_buf + 7 ), ( uint8_t * ) "on", 2 ) ) 
01808         {
01809             miss_match = false;
01810             
01811             vz_printf ( "Aging Debug On" );
01812             
01813             debug_aging = true;
01814         }
01815         else if ( xmemmatch ( ( uint8_t * )( debug_buf + 7 ), ( uint8_t * ) "off",3 ) ) 
01816         {
01817             miss_match = false;
01818             
01819             vz_printf ( "Aging Debug Off" );
01820             
01821             debug_aging = false;
01822         }
01823     }
01824 
01825     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dcpld ", 6 ) ) 
01826     {
01827         if ( xmemmatch ( ( uint8_t * )( debug_buf + 6 ), ( uint8_t * ) "on", 2 ) ) 
01828         {
01829             miss_match = false;
01830             
01831             vz_printf ( "DCPLD Debug On" );
01832             
01833             debug_cpld = true;
01834             debug_cb_rx = true;
01835             debug_cb_tx = true;
01836         }
01837         else if ( xmemmatch ( ( uint8_t * )( debug_buf + 6 ), ( uint8_t * ) "off",3 ) ) 
01838         {
01839             miss_match = false;
01840             
01841             vz_printf ( "DCPLD Debug Off" );
01842             
01843             debug_cpld = false;
01844             debug_cb_rx = false;
01845             debug_cb_tx = false;
01846         }
01847     }
01848 
01849     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dtxshow ", 8 ) ) 
01850     {
01851         if ( xmemmatch ( ( uint8_t * )( debug_buf + 8 ), ( uint8_t * ) "on", 2 ) ) 
01852         {
01853             miss_match = false;
01854             
01855             vz_printf ( "DCPLD Show TX Debug On" );
01856             
01857             debug_show_tx_cpld = true;
01858         }
01859         else if ( xmemmatch ( ( uint8_t * )( debug_buf + 8 ), ( uint8_t * ) "off",3 ) ) 
01860         {
01861             miss_match = false;
01862             
01863             vz_printf ( "DCPLD Show TX Debug Off" );
01864             
01865             debug_show_tx_cpld = false;
01866         }
01867     }
01868 
01869     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dshowcpld ", 10 ) )
01870     {
01871         if ( xmemmatch ( ( uint8_t * )( debug_buf + 10 ), ( uint8_t * ) "on", 2 ) ) 
01872         {
01873             miss_match = false;
01874             
01875             vz_printf ( "DCPLD Show Debug On" );
01876             
01877             debug_show_tx_cpld = true;
01878             debug_show_rx_cpld = true;
01879         }
01880         else if ( xmemmatch ( ( uint8_t * )( debug_buf + 10 ), ( uint8_t * ) "off", 3 ) ) 
01881         {
01882             miss_match = false;
01883             vz_printf ( "DCPLD Show Debug Off" );
01884             
01885             debug_show_tx_cpld = false;
01886             debug_show_rx_cpld = false;
01887         }
01888     }
01889 
01890 
01891     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "drxshow ", 8 ) )
01892     {
01893         if ( xmemmatch ( ( uint8_t * )( debug_buf + 8 ), ( uint8_t * ) "on", 2 ) )
01894         {
01895             miss_match = false;
01896             
01897             vz_printf ( "DCPLD Show RX Debug On" );
01898             
01899             debug_show_rx_cpld = true;
01900         }
01901         else if ( xmemmatch ( ( uint8_t * )( debug_buf + 8 ), ( uint8_t * ) "off",3 ) )
01902         {
01903             miss_match = false;
01904             
01905             vz_printf ( "DCPLD Show RX Debug Off" );
01906             
01907             debug_show_rx_cpld = false;
01908         }
01909     }
01910 
01911     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dcks_err ", 9 ) )
01912     {
01913         if ( xmemmatch ( ( uint8_t * )( debug_buf + 9 ), ( uint8_t * ) "on", 2 ) ) 
01914         {
01915             miss_match = false;
01916             
01917             vz_printf ( "CKS_ERR Debug On" );
01918             
01919             debug_cks_err = true;
01920         }
01921         else if ( xmemmatch ( ( uint8_t * )( debug_buf + 9 ), ( uint8_t *) "off", 3 ) )
01922         {
01923             miss_match = false;
01924             
01925             vz_printf ( "CKS_ERR Debug Off" );
01926             
01927             debug_cks_err = false;
01928         }
01929     }
01930 
01931     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * )"dinvite ", 8 ) )
01932     {
01933         if ( xmemmatch ( ( uint8_t * )( debug_buf + 8 ), ( uint8_t * ) "on", 2 ) )
01934         {
01935             miss_match = false;
01936             
01937             vz_printf ( "Invite Debug ON" );
01938             
01939             debug_invite = true;
01940         }
01941         else if ( xmemmatch ( ( uint8_t * )( debug_buf + 8 ), ( uint8_t * ) "off",3 ) )
01942         {
01943             miss_match = false;
01944             
01945             vz_printf ( "Invite Debug ON" );
01946             
01947             debug_invite = false;
01948         }
01949     }
01950 
01951     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dparallel ", 10 ) )
01952     {
01953         if ( xmemmatch ( ( uint8_t * )( debug_buf + 10 ), ( uint8_t * )"on", 2 ) )
01954         {
01955             miss_match = false;
01956             
01957             vz_printf ( "Parallel Write Debug On" );
01958             
01959             dparallel = true;
01960         }
01961         else if ( xmemmatch ( ( uint8_t * )( debug_buf + 10 ), ( uint8_t *)"off", 3 ) )
01962         {
01963             miss_match = false;
01964             
01965             vz_printf ( "Parallel Write Debug Off" );
01966     
01967             dparallel = false;
01968         }
01969     } 
01970     
01971     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dtelos ", 7 ) ) 
01972     {
01973         if ( xmemmatch ( ( uint8_t * )( debug_buf + 7 ), ( uint8_t * ) "on", 2 ) )
01974         {
01975             miss_match = false;
01976             
01977             vz_printf ( "Telemetry Debug On" );
01978             
01979             debug_telemetry = true;
01980         }
01981         else if ( xmemmatch ( ( uint8_t * )( debug_buf + 7 ), ( uint8_t * ) "off", 3 ) )
01982         {
01983             miss_match = false;
01984             
01985             vz_printf ( "Telemetry Debug Off" );
01986             
01987             debug_telemetry = false;
01988         }
01989     }
01990 
01991     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dcks ", 5 ) )
01992     {
01993         if ( xmemmatch ( ( uint8_t * )( debug_buf + 5 ), ( uint8_t * ) "on", 2 ) ) 
01994         {
01995             miss_match = false;
01996             
01997             vz_printf ( "CKS Debug On" );
01998             
01999             debug_cks = true;
02000         }
02001         else if ( xmemmatch ( ( uint8_t * )( debug_buf + 5 ), ( uint8_t * )"off",3 ) )
02002         {
02003             miss_match = false;
02004             
02005             vz_printf ( "CKS Debug Off" );
02006             
02007             debug_cks = false;
02008         }
02009     }
02010 
02011     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "cc ", 3 ) )
02012     {
02013         miss_match = false;
02014         
02015         int ext,port;
02016         char *split, *ref, *cmd;
02017 
02018         ref = debug_buf;
02019 
02020         strcat ( debug_buf, "\r" );
02021 
02022         split = strtok ( debug_buf + 3, " " );
02023         ext = atoi ( split );
02024 
02025         port = ext;
02026 
02027         split += strlen ( split ) + 1;
02028         cmd = split;
02029 
02030         promptcb_last_ext = ext;
02031         promptcb_last_port = port;
02032 
02033         strcpy ( promptcb_last_cmd, cmd );
02034 
02035         for ( register int i = strlen ( cmd ); i < DEBUGBUFSIZE; i++ ) cmd [ i ] = 0;
02036 
02037         send2callboxes( build_cb_package( ext, port, PROMPT, cmd, id_msg++, CB_BUFFER_SIZE - VZ_HEADER_OFFSET, prompt_write_buffer ) );
02038         
02039         vz_printf ( "ext=%d port=%d cmd=%s\r\nComando enviado", ext, port, cmd );
02040 
02041         debug_buf = ref;
02042         
02043         bufptr = 0;
02044         
02045         for ( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf [ i ] = 0;
02046     }
02047 
02048     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "bc ", 3 ) )
02049     {
02050         miss_match = false;
02051 
02052         strcat ( debug_buf, "\r" );
02053 
02054         char * cmd = debug_buf + 3;
02055 
02056         for ( register int i = strlen( cmd ); i < DEBUGBUFSIZE; i++ ) cmd [ i ] = 0;
02057 
02058         send2callboxes ( build_cb_package ( BROADCAST_EXT, BROADCAST_EXT, PROMPT, cmd, id_msg++, CB_BUFFER_SIZE - VZ_HEADER_OFFSET, prompt_write_buffer ) );
02059         
02060         vz_printf ( "ext=%x port=%x cmd=%s\r\nComando enviado", BROADCAST_EXT, BROADCAST_EXT, cmd );
02061 
02062         bufptr = 0;
02063         
02064         for ( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf [ i ] = 0;
02065     }
02066 
02067 
02068     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "pcb ", 4 ) )
02069     {
02070         miss_match = false;
02071         
02072         int ext,port;
02073         char *split, *ref, *cmd;
02074 
02075         ref = debug_buf;
02076 
02077         strcat ( debug_buf, "\r" );
02078 
02079         split = strtok ( debug_buf + 4, " " );
02080         ext = atoi ( split );
02081 
02082         port = convert_ext_to_port ( ext );
02083         split += strlen ( split ) + 1;
02084         cmd = split;
02085 
02086         promptcb_last_ext = ext;
02087         promptcb_last_port = port;
02088 
02089         strcpy ( promptcb_last_cmd, cmd );
02090 
02091         for ( register int i = strlen ( cmd ); i < DEBUGBUFSIZE; i++ ) cmd [ i ] = 0;
02092 
02093         send2callboxes( build_cb_package( ext, port, PROMPT, cmd, id_msg++, CB_BUFFER_SIZE - VZ_HEADER_OFFSET, prompt_write_buffer ) );
02094         
02095         vz_printf ( "ext=%d port=%d cmd=%s\r\nComando enviado", ext, port, cmd );
02096         
02097         debug_buf = ref;
02098         
02099         bufptr = 0;
02100         
02101         for ( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf [ i ] = 0;
02102     }
02103 
02104     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "pend_all" ) )
02105     {
02106         miss_match = false;
02107 
02108         char cmd_msg [ CB_BUFFER_SIZE ] = "pend\r";
02109 
02110         for ( register int i = strlen ( cmd_msg ); i < CB_BUFFER_SIZE; i++ ) cmd_msg [ i ] = 0;
02111 
02112         send2callboxes ( build_cb_package ( BROADCAST_EXT, BROADCAST_EXT, PROMPT, cmd_msg, id_msg++, CB_BUFFER_SIZE - VZ_HEADER_OFFSET, prompt_write_buffer ) );
02113         
02114         vz_printf ( "ext=%x port=%x cmd=%s\r\nComando enviado", BROADCAST_EXT, BROADCAST_EXT, cmd_msg );
02115         
02116         bufptr = 0;
02117         
02118         for ( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf [ i ] = 0;
02119     }
02120 
02121     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "bye ", 4 ) )
02122     {
02123         miss_match = false;
02124         
02125         int ext,port;
02126         char * ref;
02127 
02128         ref = debug_buf;
02129 
02130         strcat ( debug_buf, "\r" );
02131 
02132         ext = atoi ( strtok ( debug_buf + 4, " " ) );
02133 
02134         port = ext;
02135 
02136         promptcb_last_ext = ext;
02137         promptcb_last_port = port;
02138 
02139         char msg [ CB_BUFFER_SIZE ] = "";
02140 
02141         for ( register int i = 0; i < CB_BUFFER_SIZE; i ++ ) msg [ i ] = 0;
02142 
02143         strcpy ( msg, "bye" );
02144 
02145         send2callboxes ( build_cb_package ( ext, port, CB_BYE, msg, ( id_msg++ & ~BIT7 ), CB_BUFFER_SIZE - VZ_HEADER_OFFSET, prompt_write_buffer ) );
02146 
02147         vz_printf ( "Send BYE to ext=%d port=%d\r\nComando enviado", ext, port );
02148 
02149         debug_buf = ref;
02150         
02151         bufptr = 0;
02152         
02153         for ( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf [ i ] = 0;
02154     }
02155 
02156     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "end_call ", 9 ) )
02157     {
02158         miss_match = false;
02159         
02160         char * ref;
02161 
02162         ref = debug_buf;
02163 
02164         end_call_ext = atoi ( strtok ( debug_buf + 9, " " ) );
02165         
02166         end_call = true;
02167 
02168         debug_buf = ref;
02169         
02170         bufptr = 0;
02171         
02172         for ( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf [ i ] = 0;
02173 
02174         vz_printf( "kill call :: %u\r\n> ", end_call_ext );
02175     }
02176     
02177     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "pair", 4 ) )
02178     {
02179         miss_match = false;
02180         
02181         char * ref = debug_buf;
02182         
02183         char * split = strtok ( debug_buf + 4, " " );
02184         
02185         u16Who_is_your_pair = atoi ( split );
02186         
02187         boolWho_is_your_pair = true;
02188         
02189         debug_buf = ref;
02190         
02191         bufptr = 0;
02192         
02193         for ( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf [ i ] = 0;
02194     }
02195     
02196     
02197     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "registra", 8 ) )
02198     {
02199         miss_match = false;
02200         
02201         char * ref = debug_buf;
02202         
02203         char * split = strtok ( debug_buf + 9, " " );
02204         
02205         ext_to_be_registered = atoi ( split );
02206         
02207         need_registry_someone = true;
02208         
02209         debug_buf = ref;
02210     }
02211 
02212     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "msg", 3 ) )
02213     {
02214         miss_match = false;
02215 
02216         char * ref = debug_buf;
02217 
02218         if ( ( strlen ( debug_buf ) == strlen ( "msg" ) ) or ( strstr ( debug_buf + 4, "help" ) not_eq ( NULL ) ) )
02219         {
02220            vz_printf ("usage: msg < ext > < msg_id > < type >" );
02221         } else {
02222 
02223             char * split = strtok ( debug_buf + 4, " " );
02224             int ext = atoi ( split );
02225             int port = ext;
02226 
02227             // <msg_id>
02228             split += strlen ( split ) + 1;
02229             split = strtok( NULL, " " );
02230 
02231             int seq_num = ( strncasecmp ( split, "0x", 2 )  ) ? atoi ( split ) : ( int ) strtol ( split + 2, NULL, 16 );
02232 
02233             // <type>
02234             split += strlen ( split ) + 1;
02235             split = strtok ( NULL, " " );
02236 
02237             uint8_t num_type = 0;
02238 
02239             char type [ 16 ];
02240 
02241             strncpy ( type, split, sizeof ( type ) - 1 );
02242 
02243             if ( not ( strcasecmp ( type, "REGISTRY" ) ) ) num_type = REGISTRY;
02244 
02245             else if ( not ( strcasecmp ( type, "INVITE" ) ) ) num_type = INVITE;
02246 
02247             else if ( not ( strcasecmp ( type, "BOOT" ) ) ) num_type = BOOT;
02248 
02249             else if ( not ( strcasecmp ( type, "TELEMETRY" ) ) ) num_type = TELEMETRY;
02250 
02251             else if ( not ( strcasecmp ( type, "bye" ) ) ) num_type = CB_BYE;
02252 
02253             else if ( not ( strcasecmp ( type, "PROMPT" ) ) ) num_type = PROMPT;
02254 
02255             char cmd [ 32 ] = "";
02256 
02257             if ( num_type not_eq PROMPT ) for( register int i = 0; i < 32; i++ ) cmd [ i ] = 0;
02258 
02259             else strcpy ( cmd, "ping\r" );
02260 
02261             send2callboxes( build_cb_package( ext, port, num_type, cmd, seq_num, CB_BUFFER_SIZE - VZ_HEADER_OFFSET, prompt_write_buffer ) );
02262             
02263             vz_printf ( "ext=%d port=%d msg_id=%#x type=%#x", ext, port, seq_num, num_type );
02264         }
02265 
02266         debug_buf = ref;
02267         
02268         bufptr = 0;
02269         
02270         for ( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf [ i ] = 0;
02271     }
02272     
02273     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "simula", 6 ) )
02274     {
02275         miss_match = false;
02276 
02277         char * ref = debug_buf;
02278 
02279         if ( ( strlen ( debug_buf ) == strlen ( "simula" ) ) or ( strstr ( debug_buf + 6, "help" ) not_eq ( NULL ) ) )
02280         {
02281            vz_printf ("usage: simula < ext > < msg_id > < type>" );
02282         } else {
02283             simulate = true;
02284             
02285             char * split = strtok ( debug_buf + 6, " " );
02286             ext_to_simulate = atoi ( split );
02287             port_to_simulate = ext_to_simulate;
02288 
02289             // <msg_id>
02290             split += strlen ( split ) + 1;
02291             split = strtok( NULL, " " );
02292 
02293             seq_num_to_simulate = ( strncasecmp ( split, "0x", 2 )  ) ? atoi ( split ) : ( int ) strtol ( split + 2, NULL, 16 );
02294 
02295             // <type>
02296             split += strlen ( split ) + 1;
02297             split = strtok ( NULL, " " );
02298 
02299             num_type_to_simulate = 0;
02300 
02301             char type [ 16 ];
02302 
02303             strncpy ( type, split, sizeof ( type ) - 1 );
02304 
02305             if ( not ( strcasecmp ( type, "REGISTRY" ) ) ) num_type_to_simulate = REGISTRY;
02306 
02307             else if ( not ( strcasecmp ( type, "INVITE" ) ) ) num_type_to_simulate = INVITE;
02308 
02309             else if ( not ( strcasecmp ( type, "BOOT" ) ) ) num_type_to_simulate = BOOT;
02310 
02311             else if ( not ( strcasecmp ( type, "TELEMETRY" ) ) ) num_type_to_simulate = TELEMETRY;
02312 
02313             else if ( not ( strcasecmp ( type, "bye" ) ) ) num_type_to_simulate = CB_BYE;
02314 
02315             else if ( not ( strcasecmp ( type, "PROMPT" ) ) ) num_type_to_simulate = PROMPT;
02316             
02317             vz_printf ( "ext=%d port=%d msg_id=%#x type=%#x", ext_to_simulate, port_to_simulate, seq_num_to_simulate, num_type_to_simulate );
02318         }
02319 
02320         debug_buf = ref;
02321         
02322         bufptr = 0;
02323         
02324         for ( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf [ i ] = 0;
02325     }
02326     
02327 
02328     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "pcc ", 4 ) ) 
02329     {
02330         miss_match = false;
02331         
02332         int ext,port;
02333         char *split, *ref, *cmd;
02334 
02335         ref = debug_buf;
02336 
02337         strcat ( debug_buf, "\r" );
02338 
02339         split = strtok ( debug_buf + 4, " " );
02340         ext = atoi ( split );
02341 
02342         split += strlen ( split ) + 1;
02343         split = strtok ( NULL, " " );
02344         port = atoi ( split );
02345 
02346         split += strlen ( split ) + 1;
02347         cmd = split;
02348 
02349         promptcb_last_ext = ext;
02350         promptcb_last_port = port;
02351 
02352         strcpy ( promptcb_last_cmd, cmd );
02353 
02354         for ( register int i = strlen( cmd ); i < DEBUGBUFSIZE; i++ ) cmd [ i ] = 0;
02355         
02356         send2callboxes ( build_cb_package( ext, port, PROMPT, cmd, id_msg++, CB_BUFFER_SIZE - VZ_HEADER_OFFSET, prompt_write_buffer ) );
02357         
02358         vz_printf ( "ext=%d port=%d cmd=%s\r\nComando enviado", ext, port, cmd );
02359 
02360         debug_buf = ref;
02361         
02362         bufptr = 0;
02363         
02364         for ( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf [ i ] = 0;
02365     }
02366 
02367     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "print_cb ", 9 ) )
02368     {
02369         miss_match = false;
02370         char *split;
02371 
02372         split = strtok ( debug_buf + 9, " " );
02373         if( 0 == ( strcasecmp( split, "all" ) ) )
02374         {
02375             print_cb_all = true;
02376         } else {
02377             print_cb_var = true;
02378             print_this_cb = atoi ( split );
02379         }
02380 
02381         bufptr = 0;
02382         for ( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf [ i ] = 0;
02383     }
02384 
02385     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "drop_ack ", 9 ) )
02386     {
02387         miss_match = false;
02388         char *split;
02389 
02390         split = strtok( debug_buf + 9, " " );
02391 
02392         drop_this_amount_of_ack_to_ast = atoi( split );
02393 
02394         vz_printf ("Will be droped %d acks", drop_this_amount_of_ack_to_ast );
02395 
02396         bufptr = 0;
02397         for( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0;
02398     }
02399 
02400     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "frtp ", 5 ) )
02401     {
02402         miss_match = false;
02403         char *split;
02404 
02405         split = strtok ( debug_buf + 5, " " );
02406         frtp = true;
02407         frtp_target = atoi ( split );
02408 
02409         bufptr = 0;
02410         for ( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf [ i ] = 0;
02411     }
02412 
02413     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "rrtp ", 5 ) )
02414     {
02415         miss_match = false;
02416         char *split;
02417 
02418         split = strtok ( debug_buf + 5, " " );
02419         rescue_rtp = true;
02420         rescue_rtp_target = atoi ( split );
02421 
02422         split += strlen ( split ) + 1;
02423         split = strtok( NULL, " " );
02424         rescue_rtp_value = atoi ( split );
02425 
02426         bufptr = 0;
02427         for ( register uint16_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf [ i ] = 0;
02428     }
02429 
02430     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "print_hex_cb ", 13 ) )
02431     {
02432         miss_match = false;
02433         char *split;
02434 
02435         split = strtok ( debug_buf + 13, " " );
02436         if( 0 == ( strcasecmp ( split, "all" ) ) )
02437         {
02438             print_hex_cb_all = true;
02439         } else {
02440             print_hex_cb_var = true;
02441             print_hex_this_cb = atoi ( split );
02442         }
02443 
02444         bufptr = 0;
02445         for ( register uint16_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf [ i ] = 0;
02446     }
02447 
02448     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * )"print_sip ", 10 ) )
02449     {
02450         miss_match = false;
02451         
02452         char *split;
02453 
02454         split = strtok ( debug_buf + 10, " " );
02455         if ( 0 == ( strcasecmp ( split, "all" ) ) ) 
02456         {
02457             print_sip_all = true;
02458         } else {
02459             print_sip_var = true;
02460             print_this_sip = atoi ( split );
02461         }
02462 
02463         bufptr = 0;
02464         for ( register uint16_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf [ i ] = 0;
02465     }
02466 
02467     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * )"print_hex_sip ", 14 ) )
02468     {
02469         miss_match = false;
02470         char *split;
02471 
02472         split = strtok ( debug_buf + 14, " " );
02473         if ( 0 == ( strcasecmp ( split, "all" ) ) )
02474         {
02475             print_hex_sip_all = true;
02476         } else {
02477             print_hex_sip_var = true;
02478             print_hex_this_sip = atoi ( split );
02479         }
02480 
02481         bufptr = 0;
02482         for ( register uint16_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf [ i ] = 0;
02483     }
02484 
02485     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * )"print_call ", 11 ) )
02486     {
02487         miss_match = false;
02488         char *split;
02489 
02490         split = strtok ( debug_buf + 11, " " );
02491         if ( 0 == ( strcasecmp ( split, "all" ) ) )
02492         {
02493             print_call_all = true;
02494         } else {
02495             print_call_var = true;
02496             print_this_call = atoi ( split );
02497         }
02498 
02499         bufptr = 0;
02500         for ( register uint16_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf [ i ] = 0;
02501     }
02502 
02503     else if ( xmemmatch ( ( uint8_t *)debug_buf, ( uint8_t * ) "print_hex_call ", 15 ) )
02504     {
02505         miss_match = false;
02506         
02507         char *split;
02508 
02509         split = strtok( debug_buf + 15, " " );
02510         if ( 0 == ( strcasecmp ( split, "all" ) ) )
02511         {
02512             print_hex_call_all = true;
02513         } else {
02514             print_hex_call_var = true;
02515             print_hex_this_call = atoi ( split );
02516         }
02517 
02518         bufptr = 0;
02519         for ( register uint16_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf [ i ] = 0;
02520     }
02521 
02522     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "print_rtp ", 10 ) ) 
02523     {
02524         miss_match = false;
02525         char *split;
02526 
02527         split = strtok ( debug_buf + 10, " " );
02528         if ( 0 == ( strcasecmp ( split, "all" ) ) )
02529         {
02530             print_rtp_all = true;
02531         } else {
02532             print_rtp_var = true;
02533             print_this_rtp = atoi ( split );
02534         }
02535 
02536         bufptr = 0;
02537         for ( register uint16_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf [ i ] = 0;
02538     }
02539 
02540     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "print_hex_rtp ", 14 ) )
02541     {
02542         miss_match = false;
02543         
02544         char *split;
02545 
02546         split = strtok ( debug_buf + 14, " " );
02547         if ( 0 == ( strcasecmp ( split, "all" ) ) )
02548         {
02549             print_hex_rtp_all = true;
02550         } else {
02551             print_hex_rtp_var = true;
02552             print_hex_this_rtp = atoi ( split );
02553         }
02554 
02555         bufptr = 0;
02556         for ( register uint16_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf [ i ] = 0;
02557     }
02558 
02559     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "log ", 4 ) )
02560     {
02561         miss_match = false;
02562 
02563         char * split = strtok ( debug_buf + 4, " " );
02564 
02565         {
02566             print_cb_var = true;
02567             print_this_cb = atoi ( split );
02568             print_sip_var = true;
02569             print_this_sip = print_this_cb;
02570             print_call_var = true;
02571             print_this_call = print_this_cb;
02572             print_rtp_var = true;
02573             print_this_rtp = print_this_cb;
02574         }
02575 
02576         bufptr = 0;
02577         for ( register uint16_t i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf [ i ] = 0;
02578     }
02579 
02580 
02581     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "rush ", 5 ) ) 
02582     {
02583         miss_match = false;
02584         
02585         int ext,port;
02586         char *split, *ref, cmd [ 32 ];
02587 
02588         ref = debug_buf;
02589 
02590         strcat ( debug_buf, "\r" );
02591 
02592         split = strtok ( debug_buf + 5, " " );
02593         ext = atoi ( split );
02594 
02595         split += strlen ( split ) + 1;
02596         split = strtok ( NULL, " " );
02597         port = atoi ( split );
02598 
02599         strcpy ( cmd, "ping\r\n" );
02600 
02601         promptcb_last_ext = ext;
02602         promptcb_last_port = port;
02603 
02604         strcpy ( promptcb_last_cmd, cmd );
02605         strcat ( cmd, "\r\r\r\n" );
02606 
02607         for ( register uint8_t i = 0; i < 3; i++ )
02608         {
02609             
02610             send2callboxes ( build_cb_package ( ext, port, PROMPT, cmd, id_msg++, CB_BUFFER_SIZE - VZ_HEADER_OFFSET, prompt_write_buffer ) );
02611             
02612             vz_printf ( "ext=%d port=%d cmd=%s\r\nComando enviado", ext, port, cmd );
02613         }
02614 
02615         debug_buf = ref;
02616         bufptr = 0;
02617         for ( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf [ i ] = 0;
02618     }
02619 
02620 
02621     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "_", 4 ) )
02622     {
02623         miss_match = false;
02624         
02625         debug_buf [ bufptr++ ] = 0x0D;
02626         debug_buf [ bufptr++ ] = 0x00;
02627 
02628         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 ) );
02629         
02630         vz_printf ( "ext=%d port=%d\r\ncmd=%s\r\nComando enviado",promptcb_last_ext, promptcb_last_port, debug_buf + 4 );
02631     }
02632 
02633     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "cks",3 ) )
02634     {
02635         miss_match = false;
02636         pcks_s = true;
02637     }
02638 
02639     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "showcb",6 ) )
02640     {
02641         miss_match = false;
02642         pshowcb = true;
02643     }
02644 
02645     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "debug_main ", 11 ) )
02646     {
02647         if ( xmemmatch ( ( uint8_t * )( debug_buf + 11 ), ( uint8_t * ) "on", 2 ) )
02648         {
02649             miss_match = false;
02650             
02651             vz_printf ( "Debug Main On" );
02652             
02653             debug_main = true;
02654         }
02655         else if ( xmemmatch ( ( uint8_t * )( debug_buf + 11 ), ( uint8_t * ) "off", 3 ) )
02656         {
02657             miss_match = false;
02658             
02659             vz_printf ( "Debug Main Off" );
02660             
02661             debug_main = 0;
02662         }
02663     }
02664 
02665     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dout ", 5 ) )
02666     {
02667         if ( xmemmatch ( ( uint8_t * )( debug_buf + 5 ), ( uint8_t * ) "on", 2 ) )
02668         {
02669             miss_match = false;
02670 
02671             vz_printf ( "Out Debug On" );
02672 
02673             debug_out_of_range = true;
02674         }
02675         else if ( xmemmatch ( ( uint8_t * )( debug_buf + 5 ), ( uint8_t * ) "off", 3 ) )
02676         {
02677             miss_match = false;
02678             
02679             vz_printf ( "Out Debug Off" );
02680             
02681             debug_out_of_range = false;
02682         }
02683     }
02684 
02685     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dboot ", 6 ) )
02686     {
02687         if ( xmemmatch ( ( uint8_t * )( debug_buf + 6 ), ( uint8_t * ) "on", 2 ) )
02688         {
02689             miss_match = false;
02690             
02691             vz_printf ( "Boot Debug On" );
02692             
02693             debug_boot = true;
02694         }
02695         else if ( xmemmatch ( ( uint8_t * )( debug_buf + 6 ), ( uint8_t * ) "off", 3 ) )
02696         {
02697             miss_match = false;
02698             
02699             vz_printf ( "Boot Debug Off" );
02700             
02701             debug_boot = false;
02702         }
02703     }
02704     
02705     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dnewcall ", 9 ) )
02706     {
02707         if ( xmemmatch ( ( uint8_t * )( debug_buf + 9 ), ( uint8_t * ) "on", 2 ) )
02708         {
02709             miss_match = false;
02710             
02711             vz_printf ( "Allocation VZ_Call Debug On" );
02712             
02713             debug_alloc_vz_call = true;
02714         }
02715         else if ( xmemmatch ( ( uint8_t * )( debug_buf + 9 ), ( uint8_t * ) "off", 3 ) )
02716         {
02717             miss_match = false;
02718             
02719             vz_printf ( "Allocation VZ_Call Debug Off" );
02720             
02721             debug_alloc_vz_call = false;
02722         }
02723     }
02724 
02725     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dbloader ", 9 ) )
02726     {
02727         if ( xmemmatch ( ( uint8_t * )( debug_buf + 9 ), ( uint8_t * ) "on", 2 ) )
02728         {
02729             miss_match = false;
02730             
02731             vz_printf ( "Bootloader Debug On" );
02732             
02733             debug_bootloader = true;
02734         }
02735         else if ( xmemmatch ( ( uint8_t * )( debug_buf + 9 ), ( uint8_t * ) "off", 3 ) ) {
02736             miss_match = false;
02737             
02738             vz_printf ( "Bootloader Debug Off" );
02739                 
02740             debug_bootloader = false;
02741         }
02742     }
02743 
02744     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dpower" ) )
02745     {
02746         miss_match = false;
02747         
02748         if ( !power_source_status )
02749         {
02750             vz_printf ( "Main power is UP" );
02751         } else {
02752             vz_printf ( "Main power is DOWN" );
02753         }
02754     }
02755 
02756     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dfw ", 4 ) )
02757     {
02758         if ( xmemmatch ( ( uint8_t * )( debug_buf + 4 ), ( uint8_t * ) "on", 2 ) )
02759         {
02760             miss_match = false;
02761             
02762             vz_printf ( "FW Debug On" );
02763             
02764             debug_fw = true;
02765         }
02766         else if ( xmemmatch ( ( uint8_t * )( debug_buf + 4 ), ( uint8_t * ) "off", 3 ) ) 
02767         {
02768             miss_match = false;
02769             
02770             vz_printf ( "FW Debug Off" );
02771                 
02772             debug_fw = false;
02773         }
02774     }
02775 
02776     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dfwp ", 5 ) )
02777     {
02778         if ( xmemmatch ( ( uint8_t * )( debug_buf + 5 ), ( uint8_t * ) "on", 2 ) )
02779         {
02780             miss_match = false;
02781             
02782             vz_printf ("FWPrint Debug On" );
02783             
02784             debug_fw_print = true;
02785         }
02786         else if ( xmemmatch ( ( uint8_t * )( debug_buf + 5 ), ( uint8_t * ) "off", 3 ) )
02787         {
02788             miss_match = false;
02789             
02790             vz_printf ("FWPrint Debug Off" );
02791             
02792             debug_fw_print = false;
02793         }
02794     }
02795 
02796     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "drx ", 4 ) )
02797     {
02798         if ( xmemmatch ( ( uint8_t * )( debug_buf + 4 ), ( uint8_t * ) "on", 2 ) ) 
02799         {
02800             miss_match = false;
02801             
02802             vz_printf ( "Debug Cbx Rx On" );
02803             
02804             debug_cb_rx = true;
02805         }
02806         else if ( xmemmatch ( ( uint8_t * )( debug_buf + 4 ), ( uint8_t * ) "off", 3 ) )
02807         {
02808             miss_match = false;
02809             
02810             vz_printf ( "Debug Cbx Rx Off" );
02811             
02812             debug_cb_rx = false;
02813         }
02814     }
02815 
02816     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "dtx ", 4 ) )
02817     {
02818         if ( xmemmatch ( ( uint8_t * )( debug_buf + 4 ), ( uint8_t * ) "on", 2 ) )
02819         {
02820             miss_match = false;
02821             
02822             vz_printf ( "Debug Cbx Tx On" );
02823             
02824             debug_cb_tx = true;
02825         }
02826         else if ( xmemmatch ( ( uint8_t * )( debug_buf + 4 ), ( uint8_t * ) "off", 3 ) )
02827         {
02828             
02829             miss_match = false;
02830             
02831             vz_printf ( "Debug Cbx Tx Off" );
02832             
02833             debug_cb_tx = false;
02834         }
02835     }
02836 
02837     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "debug_file ", 11 ) )
02838     {
02839         if ( xmemmatch ( ( uint8_t * )( debug_buf + 11 ), ( uint8_t * ) "on", 2 ) )
02840         {
02841             miss_match = false;
02842         
02843             vz_printf ( "Debug File On" );
02844             
02845             debug_file = true;
02846         }
02847         else if ( xmemmatch ( ( uint8_t * )( debug_buf + 11 ), ( uint8_t * ) "off", 3 ) )
02848         {
02849             miss_match = false;
02850             
02851             vz_printf ( "Debug File Off" );
02852             
02853             debug_file = false;
02854         }
02855     }
02856 
02857     else if ( xstrmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "help" ) )
02858     {
02859         miss_match = false;
02860         
02861         vz_printf ( "**************************** PROMPT HELP ****************************" );
02862         vz_printf ( "help_setup" );
02863         vz_printf ( "help_debug" );
02864         vz_printf ( "help_command_to_cbx" );
02865         vz_printf ( "help_protocol" );
02866         vz_printf ( "help_cbx_list" );
02867         vz_printf ( "help_io" );
02868         
02869         vz_printf ( "reset - resta o sistema" );
02870         vz_printf ( "PROMPT VERSION: V%d -- %s - %s", PVERSION, __DATE__, __TIME__);
02871         
02872         strcpy ( last_cmd, tmp_cmd );
02873         
02874         bufptr = 0;
02875         
02876         for ( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf [ i ] = 0;
02877     }
02878 
02879     else if ( xmemmatch ( ( uint8_t * )debug_buf, ( uint8_t * ) "callme ", 7 ) )
02880     {
02881         miss_match = false;
02882         int ext,port;
02883         char cmd[ 16 ];
02884 
02885         ext = atoi( debug_buf + 7 );
02886         port = convert_ext_to_port ( ext );
02887 
02888         strcpy( cmd, ( ext % 2 ) ? "call init B" : "call init A" );
02889 
02890         if( ext % 2 ) ext--;
02891 
02892         promptcb_last_ext = ext;
02893         promptcb_last_port = port;
02894 
02895         int tmp = strlen( cmd );
02896         cmd[ tmp ] = 0x0D;
02897         cmd[ tmp + 1 ] = 0x00;
02898         strcpy( promptcb_last_cmd, cmd );
02899 
02900         send2callboxes( build_cb_package( ext, port, PROMPT, cmd, id_msg++, CB_BUFFER_SIZE - VZ_HEADER_OFFSET, prompt_write_buffer ) );
02901         
02902         vz_printf ( "ext=%d port=%d\r\ncmd=%s\r\n\n\rComando enviado\n\r", ext, port, cmd );
02903 
02904         bufptr = 0;
02905         for ( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf [ i ] = 0;
02906     }
02907 
02908     if ( miss_match )
02909     {
02910         vz_printf ( "> %s: command not found", debug_buf );    
02911         
02912     } else {
02913         if ( from_eth && strlen ( debug_buf ) > 2 ) strcpy ( last_cmd, tmp_cmd );
02914 
02915         else if ( strlen ( debug_buf ) > 2 ) strcpy ( last_cmd, tmp_cmd );
02916     }
02917     
02918     return( NULL );
02919 }