Modularizando o src

Dependencies:   EALib EthernetInterface_vz mbed-rtos mbed

Fork of header_main_colinas_V0-20-09-14 by VZTECH

Revision:
126:1f90756250fb
Parent:
124:c1b6c893e1c3
Child:
127:e7160a463b6c
--- a/prompt.cpp	Wed May 13 21:18:12 2015 +0000
+++ b/prompt.cpp	Wed May 20 19:50:31 2015 +0000
@@ -23,21 +23,21 @@
 {   
     int return_value = 0;
     
-    int udp_bind = udp_client.bind( UDP_PORT_LISTENER );
+    int udp_bind = udp_client.bind ( UDP_PORT_LISTENER );
     
-    udp_client.set_blocking( false, 0 );
+    udp_client.set_blocking ( false, 0 );
     
-    if ( debug_prompt_eth ) debug_msg("udp_client.bind :: %d", udp_bind );
+    if ( debug_prompt_eth ) debug_msg ("udp_client.bind :: %d", udp_bind );
     
     if ( udp_bind == 0 ) return_value |= BIT0;
 
-    int tcp_bind = tcp_server.bind( TCP_PORT_LISTENER );
+    int tcp_bind = tcp_server.bind ( TCP_PORT_LISTENER );
     
-    tcp_server.set_blocking( false, 0 );    
+    tcp_server.set_blocking ( false, 0 );    
 
-    int tcp_listen = tcp_server.listen();
+    int tcp_listen = tcp_server.listen ();
     
-    if ( debug_prompt_eth ) debug_msg("tcp_server.bind :: %d", tcp_bind );
+    if ( debug_prompt_eth ) debug_msg ("tcp_server.bind :: %d", tcp_bind );
     
     if ( tcp_bind == 0 ) return_value |= BIT1;
     
@@ -66,7 +66,8 @@
         flood_timeout.reset();
     }
     
-    if( tcp_timer.read() >= TCP_IDLE_MAX_TIME ) {
+    if( tcp_timer.read() >= TCP_IDLE_MAX_TIME )
+    {
         tcp_alive = false;
         tcp_timer.stop();
         tcp_timer.reset();
@@ -98,20 +99,20 @@
     } 
         else 
     {
-        if( !tcp_server.accept( tcp_client ) )
+        if ( !tcp_server.accept ( tcp_client ) )
         {
             tcp_session = true;
-            tcp_timer.start();
+            tcp_timer.start ();
             last_bufptr = bufptr;
-            for( register int i = 0; i < PROMPT_ETH_BUFFER_SIZE; i++ ) eth_buffer[ i ] = 0;
+            for ( register int i = 0; i < PROMPT_ETH_BUFFER_SIZE; i++ ) eth_buffer [ i ] = 0;
         }
-            if( tcp_session && !udp_query )
+            if ( tcp_session && !udp_query )
         {
-            tcp_client.set_blocking( false, 0 );
-            //for( register int i = 0; i < PROMPT_ETH_BUFFER_SIZE; i++ ) eth_buffer[ i ] = 0;
-            int n = tcp_client.receive( eth_buffer, sizeof( eth_buffer ) - 1 );
-            if( n > 0 ) {
-                tcp_timer.reset();
+            tcp_client.set_blocking ( false, 0 );
+            int n = tcp_client.receive ( eth_buffer, sizeof ( eth_buffer ) - 1 );
+            if( n > 0 )
+            {
+                tcp_timer.reset ();
     
                 if( ( n > 2 ) && ( eth_buffer[ n - 2 ]  == '\r' ) ) eth_buffer[ n - 2 ] = 0;
     
@@ -162,7 +163,6 @@
                 } else if( b == 0x09 ) {
                     // ignore tab
                 } else {
-                    //debug_msg("--%c,%d--%d--", b, bufptr, last_bufptr );
                     __debug_buf__[ bufptr ] = b;
                     bufptr++;
                 }
@@ -286,12 +286,12 @@
         
         else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "rx" ) ){
             miss_match = false;
-            rx = true;
+            show_last_rx = true;
         }
         
         else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "tx" ) ){
             miss_match = false;
-            tx = true;
+            show_last_tx = true;
         }
         
         else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "stats" ) ){
@@ -478,7 +478,8 @@
             send_msg("Overflow messages :: %d", string_msg_overflow );
         }
         
-        else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "dep" ) ){
+        else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "dep" ) )
+        {
             miss_match = false;
             drop_entendi_pkg = !drop_entendi_pkg;
             if ( drop_entendi_pkg )
@@ -491,7 +492,8 @@
             }
         }
         
-        else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "dita" ) ){
+        else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "dita" ) )
+        {
             miss_match = false;
             drop_invite_to_ast_pkg = !drop_invite_to_ast_pkg;
             if ( drop_invite_to_ast_pkg )
@@ -503,8 +505,23 @@
                 debug_msg ("Invite pkgs to ast don't will be droped");    
             }
         }
-
-        else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "dop" ) ){
+        
+        else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "refresh_on" ) ) 
+        {
+            miss_match = false;
+            send_msg ("Refresh function :: Enable");
+            do_not_refresh = false;
+        }
+        
+        else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "refresh_off" ) ) 
+        {
+            miss_match = false;
+            send_msg ("Refresh function :: Disable");
+            do_not_refresh = true;
+        }
+        
+        else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "dop" ) )
+        {
             miss_match = false;
             drop_ok_pkg = !drop_ok_pkg;
             if ( drop_ok_pkg )
@@ -517,7 +534,8 @@
             }
         }        
         
-        else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "dip" ) ){
+        else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "dip" ) )
+        {
             miss_match = false;
             drop_invite_pkg = !drop_invite_pkg;
             if ( drop_invite_pkg )
@@ -531,7 +549,8 @@
             
         }
         
-        else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "drp" ) ){
+        else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "drp" ) )
+        {
             miss_match = false;
             drop_registry_pkg = !drop_registry_pkg;
             if ( drop_registry_pkg )
@@ -545,7 +564,8 @@
             
         }
         
-        else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "rafc" ) ){
+        else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "rafc" ) )
+        {
             miss_match = false;
             received_audio_from_cb = !received_audio_from_cb;
             if ( received_audio_from_cb )
@@ -559,7 +579,8 @@
             
         }
         
-        else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "dap" ) ){
+        else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "dap" ) )
+        {
             miss_match = false;
             drop_ack_pkg = !drop_ack_pkg;
             if ( drop_ack_pkg )
@@ -573,7 +594,8 @@
             
         }
 
-        else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "drfa" ) ){
+        else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "drfa" ) )
+        {
             miss_match = false;
             drop_rtp_from_ast_pkg = !drop_rtp_from_ast_pkg;
             if ( drop_rtp_from_ast_pkg )
@@ -586,7 +608,8 @@
             }
         }
         
-        else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "drfc" ) ){
+        else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "drfc" ) )
+        {
             miss_match = false;
             drop_rtp_from_cbx_pkg = !drop_rtp_from_cbx_pkg;
             if ( drop_rtp_from_cbx_pkg )
@@ -599,9 +622,15 @@
             }   
         }
         
-        else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "uptime" ) ) {
+        else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "uptime" ) )
+        {
             miss_match = false;
-            send_msg(" %d", uptime );
+            
+            uint32_t local_uptime = uptime;
+            uint16_t h = local_uptime / ( 60 * 60 ); 
+            uint16_t m = ( local_uptime - ( h * 60 * 60 ) ) / 60;
+            uint16_t s = ( local_uptime - ( ( h * 60 * 60 ) + m * 60 ) );
+            send_msg("\r\n%ih%im%is", h, m, s );
         }
         
         else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "wake" ) ) {
@@ -755,10 +784,113 @@
         else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "types" ) ) {
             miss_match = false;
 
-            if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rhex  :: dec :: Type \n\r0x00 :: 0   :: boot \n\r0x02 :: 2   :: registry \n\r0x04 :: 4   :: invite \n\r0x08 :: 8   :: audio \n\r0x10 :: 16  :: telemetry \n\r0x20 :: 32  :: cb_bye \n\r0x01 :: 1   :: prompt \n\r0x40 :: 64  :: flood \n\r" );
+            if( debug_uart3 && !( from_eth ) ) pc.printf
+            ( 
+                "\n\r"
+                "  hex  ::   dec  :: Type \n\r"
+                "0x%02x   :: %5i  :: BOOT\n\r"
+                "0x%02x   :: %5i  :: REGISTRY\n\r"
+                "0x%02x   :: %5i  :: REGISTRY_ACK\n\r"
+                "0x%02x   :: %5i  :: INVITE\n\r"
+                "0x%02x   :: %5i  :: INVITE_ACK\n\r"
+                "0x%02x   :: %5i  :: AUDIO\n\r"
+                "0x%02x   :: %5i  :: TELEMETRY\n\r"
+                "0x%02x   :: %5i  :: BOOTLOADER_CBX\n\r"
+                "0x%02x   :: %5i  :: CB_BYE\n\r"
+                "0x%02x   :: %5i  :: CB_BYE_ACK\n\r"
+                "0x%02x   :: %5i  :: PROMPT\n\r"
+                "0x%02x   :: %5i  :: FLOOD\n\r"
+                "0x%02x   :: %5i  :: FW\n\r"
+                "0x%02x   :: %5i  :: FW1\n\r"
+                "0x%02x   :: %5i  :: FW2\n\r"
+                "0x%02x   :: %5i  :: FW3\n\r"
+                "0x%02x   :: %5i  :: FW4\n\r"
+                "0x%02x   :: %5i  :: FW5\n\r"
+                "0x%02x   :: %5i  :: FW6\n\r"
+                "0x%02x   :: %5i  :: CB_STATS\n\r"
+                "0x%02x   :: %5i  :: CB_STATS_ACK\n\r"
+                "0x%02x   :: %5i  :: DO_NOTHING\n\r\r\n"
+                
+                "0x%02x :: %5i  :: BROADCAST_EXT\n\r",
+                BOOT, BOOT,
+                REGISTRY, REGISTRY,
+                REGISTRY_ACK, REGISTRY_ACK,
+                INVITE, INVITE,
+                INVITE_ACK, INVITE_ACK,
+                AUDIO, AUDIO,
+                TELEMETRY, TELEMETRY,
+                BOOTLOADER_CBX, BOOTLOADER_CBX,
+                CB_BYE, CB_BYE,
+                CB_BYE_ACK, CB_BYE_ACK,
+                PROMPT, PROMPT,
+                FLOOD, FLOOD,
+                FW, FW,
+                FW1, FW1,
+                FW2, FW2,
+                FW3, FW3,
+                FW4, FW4,
+                FW5, FW5,
+                FW6, FW6,
+                CB_STATS, CB_STATS,
+                CB_STATS_ACK, CB_STATS_ACK,
+                DO_NOTHING, DO_NOTHING,
+                BROADCAST_EXT, BROADCAST_EXT
+            );
 
-            if( from_eth ) {
-                snprintf( debug_buf, PROMPT_ETH_BUFFER_SIZE, "hex  :: dec :: Type \n\r0x00 :: 0   :: boot \n\r0x02 :: 2   :: registry \n\r0x04 :: 4   :: invite \n\r0x08 :: 8   :: audio \n\r0x10 :: 16  :: telemetry \n\r0x20 :: 32  :: cb_bye \n\r0x01 :: 1   :: prompt \n\r0x40 :: 64  :: flood\n\r");
+            if ( from_eth )
+            {
+                snprintf ( debug_buf, PROMPT_ETH_BUFFER_SIZE, 
+                    "\n\r"
+                    "  hex  ::   dec  :: Type \n\r"
+                    "0x%02x   :: %5i  :: BOOT\n\r"
+                    "0x%02x   :: %5i  :: REGISTRY\n\r"
+                    "0x%02x   :: %5i  :: REGISTRY_ACK\n\r"
+                    "0x%02x   :: %5i  :: INVITE\n\r"
+                    "0x%02x   :: %5i  :: INVITE_ACK\n\r"
+                    "0x%02x   :: %5i  :: AUDIO\n\r"
+                    "0x%02x   :: %5i  :: TELEMETRY\n\r"
+                    "0x%02x   :: %5i  :: BOOTLOADER_CBX\n\r"
+                    "0x%02x   :: %5i  :: CB_BYE\n\r"
+                    "0x%02x   :: %5i  :: CB_BYE_ACK\n\r"
+                    "0x%02x   :: %5i  :: PROMPT\n\r"
+                    "0x%02x   :: %5i  :: FLOOD\n\r"
+                    "0x%02x   :: %5i  :: FW\n\r"
+                    "0x%02x   :: %5i  :: FW1\n\r"
+                    "0x%02x   :: %5i  :: FW2\n\r"
+                    "0x%02x   :: %5i  :: FW3\n\r"
+                    "0x%02x   :: %5i  :: FW4\n\r"
+                    "0x%02x   :: %5i  :: FW5\n\r"
+                    "0x%02x   :: %5i  :: FW6\n\r"
+                    "0x%02x   :: %5i  :: CB_STATS\n\r"
+                    "0x%02x   :: %5i  :: CB_STATS_ACK\n\r"
+                    "0x%02x   :: %5i  :: DO_NOTHING\n\r\r\n"
+                    
+                    "0x%02x :: %5i  :: BROADCAST_EXT\n\r",
+                    BOOT, BOOT,
+                    REGISTRY, REGISTRY,
+                    REGISTRY_ACK, REGISTRY_ACK,
+                    INVITE, INVITE,
+                    INVITE_ACK, INVITE_ACK,
+                    AUDIO, AUDIO,
+                    TELEMETRY, TELEMETRY,
+                    BOOTLOADER_CBX, BOOTLOADER_CBX,
+                    CB_BYE, CB_BYE,
+                    CB_BYE_ACK, CB_BYE_ACK,
+                    PROMPT, PROMPT,
+                    FLOOD, FLOOD,
+                    FW, FW,
+                    FW1, FW1,
+                    FW2, FW2,
+                    FW3, FW3,
+                    FW4, FW4,
+                    FW5, FW5,
+                    FW6, FW6,
+                    CB_STATS, CB_STATS,
+                    CB_STATS_ACK, CB_STATS_ACK,
+                    DO_NOTHING, DO_NOTHING,
+                    BROADCAST_EXT, BROADCAST_EXT
+                );
+                
                 debug_buf[ strlen( debug_buf ) - 1 ] = '\0';
                 if( tcp_session && !udp_query ) {
                     tcp_client.send_all( debug_buf, strlen( debug_buf ) );
@@ -936,7 +1068,8 @@
             }
         }
         
-        else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dsip ", 5 ) ){
+        else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dsip ", 5 ) )
+        {
             if (xmemmatch( (uint8_t*)(debug_buf + 5 ), (uint8_t*) "on", 2 ) ) {
                 miss_match = false;
                 if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rSip Debug ON\n\r" );
@@ -967,6 +1100,87 @@
             }
         }
         
+        else if ( xmemmatch ( ( uint8_t * ) debug_buf, ( uint8_t * ) "dsqn ", 5 ) )
+        {
+            if (xmemmatch( (uint8_t*)(debug_buf + 5 ), (uint8_t*) "on", 2 ) )
+            {
+                miss_match = false;
+                if ( debug_uart3 and not from_eth ) pc.printf ( "\n\rSequence Number Debug ON\n\r" );
+                if ( from_eth )
+                {
+                    snprintf ( debug_buf, PROMPT_ETH_BUFFER_SIZE, "Sequence Number Debug On\n\r");
+                    debug_buf [ strlen ( debug_buf ) - 1 ] = '\0';
+                    if ( tcp_session and not udp_query )
+                    {
+                        tcp_client.send_all ( debug_buf, strlen ( debug_buf ) );
+                    } else if( udp_query )
+                    {
+                        udp_query_send_msg( debug_buf );
+                    }
+                }
+                debug_sqn = true;
+            }
+            
+            if ( xmemmatch( ( uint8_t * )( debug_buf + 5 ), ( uint8_t * ) "off",3 ) )
+            {
+                miss_match = false;
+                if ( debug_uart3 and not from_eth ) pc.printf ( "\n\rSequence Number Debug OFF\n\r" );
+                if ( from_eth )
+                {
+                    snprintf ( debug_buf, PROMPT_ETH_BUFFER_SIZE, "Sequence Number Debug Off\n\r");
+                    debug_buf [ strlen ( debug_buf ) - 1 ] = '\0';
+                    if ( tcp_session and not udp_query )
+                    {
+                        tcp_client.send_all ( debug_buf, strlen ( debug_buf ) );
+                    } else if ( udp_query )
+                    {
+                        udp_query_send_msg ( debug_buf );
+                    }
+                }
+                debug_sqn = false;
+            }
+        }
+        
+        else if ( xmemmatch ( ( uint8_t * ) debug_buf, ( uint8_t * ) "test_ts ", 8 ) )
+        {
+            if (xmemmatch( (uint8_t*)(debug_buf + 8 ), (uint8_t*) "on", 2 ) )
+            {
+                miss_match = false;
+                if ( debug_uart3 and not from_eth ) pc.printf ( "\n\rTS testing ON\n\r" );
+                if ( from_eth )
+                {
+                    snprintf ( debug_buf, PROMPT_ETH_BUFFER_SIZE, "TS testing On\n\r");
+                    debug_buf [ strlen ( debug_buf ) - 1 ] = '\0';
+                    if ( tcp_session and not udp_query )
+                    {
+                        tcp_client.send_all ( debug_buf, strlen ( debug_buf ) );
+                    } else if( udp_query )
+                    {
+                        udp_query_send_msg( debug_buf );
+                    }
+                }
+                test_ts = true;
+            }
+            
+            if ( xmemmatch( ( uint8_t * )( debug_buf + 8 ), ( uint8_t * ) "off",3 ) )
+            {
+                miss_match = false;
+                if ( debug_uart3 and not from_eth ) pc.printf ( "\n\rTS testing OFF\n\r" );
+                if ( from_eth )
+                {
+                    snprintf ( debug_buf, PROMPT_ETH_BUFFER_SIZE, "TS testing Off\n\r");
+                    debug_buf [ strlen ( debug_buf ) - 1 ] = '\0';
+                    if ( tcp_session and not udp_query )
+                    {
+                        tcp_client.send_all ( debug_buf, strlen ( debug_buf ) );
+                    } else if ( udp_query )
+                    {
+                        udp_query_send_msg ( debug_buf );
+                    }
+                }
+                test_ts = false;
+            }
+        }
         
         else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dhello ", 7 ) ){
             if (xmemmatch( (uint8_t*)(debug_buf + 7 ), (uint8_t*) "on", 2 ) ) {
@@ -1801,10 +2015,10 @@
 
             ref = debug_buf;
 
-            strcat( debug_buf, "\r" );
+            strcat ( debug_buf, "\r" );
 
-            split = strtok( debug_buf + 3, " " );
-            ext = atoi( split );
+            split = strtok ( debug_buf + 3, " " );
+            ext = atoi ( split );
 
             port = ext;
             
@@ -1918,20 +2132,24 @@
             
             char cmd_msg [ CB_BUFFER_SIZE ] = "pend\r";
             
-            for( register int i = strlen( cmd_msg ); i < DEBUGBUFSIZE; i++ ) cmd_msg [ i ] = 0;
+            for( register int i = strlen( cmd_msg ); i < CB_BUFFER_SIZE; i++ ) cmd_msg [ i ] = 0;
 
-            if( debug_uart3 && !( from_eth ) ) pc.printf("\r\next=%x port=%x cmd=%s", BROADCAST_EXT, BROADCAST_EXT, cmd_msg );
+            if( debug_uart3 and !( from_eth ) ) pc.printf("\r\next=%x port=%x cmd=%s", BROADCAST_EXT, BROADCAST_EXT, cmd_msg );
             
-            send2callboxes( build_cb_package( BROADCAST_EXT, BROADCAST_EXT, PROMPT, cmd_msg, id_msg++, CB_BUFFER_SIZE - VZ_HEADER_OFFSET, write_buffer ) );
+            send2callboxes ( build_cb_package ( BROADCAST_EXT, BROADCAST_EXT, PROMPT, cmd_msg, id_msg++, CB_BUFFER_SIZE - VZ_HEADER_OFFSET, write_buffer ) );
             
-            if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rComando enviado");
+            if ( debug_uart3 and !( from_eth ) ) pc.printf ("\n\rComando enviado");
 
-            if( from_eth ) {
-                char eth_msg[ 512 ];
-                snprintf( eth_msg, 512 - 1, "\r\next=%x port=%x cmd=%s\r\nComando enviado\n\r> ", BROADCAST_EXT, BROADCAST_EXT, cmd_msg );
-                if( tcp_session && !udp_query ) {
-                    tcp_client.send_all( eth_msg, strlen( eth_msg ) );
-                } else if( udp_query ) {
+            if( from_eth )
+            {
+                char eth_msg [ 512 ];
+                snprintf ( eth_msg, 512 - 1, "\r\next=%x port=%x cmd=%s\r\nComando enviado\n\r> ", BROADCAST_EXT, BROADCAST_EXT, cmd_msg );
+                if( tcp_session and !udp_query )
+                {
+                    tcp_client.send_all ( eth_msg, strlen( eth_msg ) );
+                } 
+                    else if( udp_query )
+                {
                     udp_query_send_msg( eth_msg );
                 }
             }
@@ -1992,9 +2210,103 @@
 
             debug_buf = ref;
             bufptr = 0;
-            for( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0;
+            for ( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0;
+            
+            if ( debug_uart3 and not ( from_eth ) ) pc.printf ("\r\nkill call :: %u", end_call_ext );
+            
+            if ( from_eth )
+            {
+                char eth_msg [ 512 ];
+                snprintf ( eth_msg, 512 - 1, "\r\nkill call :: %u\r\n> ", end_call_ext );
+                if ( tcp_session and !udp_query )
+                {
+                    tcp_client.send_all ( eth_msg, strlen ( eth_msg ) );
+                }
+                    else if ( udp_query )
+                {
+                    udp_query_send_msg ( eth_msg );
+                }
+            }
         }
         
+        else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "msg", 3 ) )
+        {
+            miss_match = false;
+            
+            char * ref = debug_buf;
+            
+            if ( ( strlen ( debug_buf ) == strlen ( "msg" ) ) or ( strstr ( debug_buf + 4, "help" ) not_eq ( NULL ) ) )
+            {
+                send_msg("\r\nusage msg <   ext> <msg_id> <type>\r\n");    
+            }
+                else
+            {
+                
+                char * split = strtok ( debug_buf + 4, " " );
+                int ext = atoi ( split );
+                int port = ext;
+                
+                // <msg_id>
+                split += strlen ( split ) + 1;
+                split = strtok( NULL, " " );
+        
+                int seq_num = ( strncasecmp ( split, "0x", 2 )  ) ? atoi ( split ) : ( int ) strtol ( split + 2, NULL, 16 );
+                
+                // <type>
+                split += strlen ( split ) + 1;
+                split = strtok( NULL, " " );
+                            
+                uint8_t num_type = 0;
+                
+                char type[ 16 ];
+                
+                strncpy ( type, split, sizeof ( type ) - 1 );
+                
+                if ( not ( strcasecmp ( type, "REGISTRY" ) ) ) num_type = REGISTRY;
+                
+                else if ( not ( strcasecmp ( type, "INVITE" ) ) ) num_type = INVITE;
+                
+                else if ( not ( strcasecmp ( type, "BOOT" ) ) ) num_type = BOOT;
+                
+                else if ( not ( strcasecmp ( type, "TELEMETRY" ) ) ) num_type = TELEMETRY;
+                
+                else if ( not ( strcasecmp ( type, "bye" ) ) ) num_type = CB_BYE;
+                
+                else if ( not ( strcasecmp ( type, "PROMPT" ) ) ) num_type = PROMPT;
+            
+                char cmd [ 32 ] = "";
+                
+                if ( num_type not_eq PROMPT ) for( register int i = 0; i < 32; i++ ) cmd[ i ] = 0;
+                
+                else strcpy ( cmd, "ping\r" );
+    
+                if ( debug_uart3 and !( from_eth ) ) pc.printf ("\r\next=%d port=%d msg_id=%#x type=%#x", ext, port, seq_num, num_type );
+        
+                send2callboxes( build_cb_package( ext, port, num_type, cmd, seq_num, CB_BUFFER_SIZE - VZ_HEADER_OFFSET, write_buffer ) );
+        
+                if ( debug_uart3 and !( from_eth ) ) pc.printf ("\n\rComando enviado");
+                
+                if ( from_eth )
+                {
+                    char eth_msg [ 512 ];
+                    snprintf ( eth_msg, 512 - 1, "\r\next=%d port=%d msg_id=%#x type=%#x\r\n> ", ext, port, seq_num, num_type );
+                    if ( tcp_session and !udp_query )
+                    {
+                        tcp_client.send_all ( eth_msg, strlen ( eth_msg ) );
+                    }
+                        else if ( udp_query )
+                    {
+                        udp_query_send_msg ( eth_msg );
+                    }
+                }
+            }
+    
+            debug_buf = ref;
+            bufptr = 0;
+            for( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf [ i ] = 0;
+        }
+        
+        
         else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "pcc ", 4 )) {
             miss_match = false;
             int ext,port;