![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Modularizando o src
Dependencies: EALib EthernetInterface_vz mbed-rtos mbed
Fork of header_main_colinas_V0-20-09-14 by
main_app_functions.cpp@121:ee02790d00b7, 2015-05-08 (annotated)
- Committer:
- klauss
- Date:
- Fri May 08 04:15:23 2015 +0000
- Revision:
- 121:ee02790d00b7
- Parent:
- 120:770f00554b1e
- Child:
- 122:480c44b0e205
compiling
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
klauss | 121:ee02790d00b7 | 1 | #include "main_app_functions.h" |
klauss | 121:ee02790d00b7 | 2 | |
klauss | 121:ee02790d00b7 | 3 | inline void reset_leds() { led1 = led2 = 1; led3 = led4 = 0; } |
klauss | 121:ee02790d00b7 | 4 | |
klauss | 121:ee02790d00b7 | 5 | int header_app_init ( void ) |
klauss | 121:ee02790d00b7 | 6 | { |
klauss | 121:ee02790d00b7 | 7 | |
klauss | 121:ee02790d00b7 | 8 | send_msg ( "" ); |
klauss | 121:ee02790d00b7 | 9 | |
klauss | 121:ee02790d00b7 | 10 | if ( debug_app_init ) send_msg ( "init_wdt() :: %s", ( init_wdt() == 0 ) ? "Ok" : "Failure" ); |
klauss | 121:ee02790d00b7 | 11 | |
klauss | 121:ee02790d00b7 | 12 | if ( debug_app_init ) send_msg ( "config_lpc() :: %s", ( config_lpc() == 0 ) ? "Ok" : "Failure" ); |
klauss | 121:ee02790d00b7 | 13 | |
klauss | 121:ee02790d00b7 | 14 | if ( debug_app_init ) send_msg ( "start_cpld() :: %s", ( start_cpld() == 0 ) ? "Ok" : "Failure" ); |
klauss | 121:ee02790d00b7 | 15 | |
klauss | 121:ee02790d00b7 | 16 | if( sdram_init() == 1 ) { |
klauss | 121:ee02790d00b7 | 17 | send_msg("******* Failed to initialize SDRAM *******"); |
klauss | 121:ee02790d00b7 | 18 | return 1; |
klauss | 121:ee02790d00b7 | 19 | } else { |
klauss | 121:ee02790d00b7 | 20 | send_msg("******* Success to initialize SDRAM *******"); |
klauss | 121:ee02790d00b7 | 21 | } |
klauss | 121:ee02790d00b7 | 22 | |
klauss | 121:ee02790d00b7 | 23 | int init_fsystem_ret = init_fsystem(); |
klauss | 121:ee02790d00b7 | 24 | if( init_fsystem_ret & BIT0 ) |
klauss | 121:ee02790d00b7 | 25 | { |
klauss | 121:ee02790d00b7 | 26 | send_msg("******* File system configured!!*******"); |
klauss | 121:ee02790d00b7 | 27 | } |
klauss | 121:ee02790d00b7 | 28 | |
klauss | 121:ee02790d00b7 | 29 | if( init_fsystem_ret & BIT1 ) |
klauss | 121:ee02790d00b7 | 30 | { |
klauss | 121:ee02790d00b7 | 31 | send_msg("******* File System Ready *******"); |
klauss | 121:ee02790d00b7 | 32 | } |
klauss | 121:ee02790d00b7 | 33 | |
klauss | 121:ee02790d00b7 | 34 | { |
klauss | 121:ee02790d00b7 | 35 | char s[ 32 ]; |
klauss | 121:ee02790d00b7 | 36 | mbed_mac_address( s ); |
klauss | 121:ee02790d00b7 | 37 | send_msg( "::Mac::%02x:%02x:%02x:%02x:%02x:%02x:: ", s[0],s[1],s[2],s[3],s[4],s[5] ); |
klauss | 121:ee02790d00b7 | 38 | } |
klauss | 121:ee02790d00b7 | 39 | |
klauss | 121:ee02790d00b7 | 40 | short int eth_status = __init_eth__ (); |
klauss | 121:ee02790d00b7 | 41 | if( eth_status ) { |
klauss | 121:ee02790d00b7 | 42 | send_msg("******* Cannot connect to eth *******"); |
klauss | 121:ee02790d00b7 | 43 | } else { |
klauss | 121:ee02790d00b7 | 44 | send_msg("******* Connection eth - ok *******"); |
klauss | 121:ee02790d00b7 | 45 | int init_prompt_eth_ret = init_prompt_eth(); |
klauss | 121:ee02790d00b7 | 46 | |
klauss | 121:ee02790d00b7 | 47 | if ( init_prompt_eth_ret == BIT0 ) send_msg("******* Prompt eth UDP Ready *******"); |
klauss | 121:ee02790d00b7 | 48 | |
klauss | 121:ee02790d00b7 | 49 | if ( init_prompt_eth_ret == BIT1 ) send_msg("******* Prompt eth TCP Ready *******"); |
klauss | 121:ee02790d00b7 | 50 | |
klauss | 121:ee02790d00b7 | 51 | if ( debug_app_init ) send_msg ( "init_prompt_eth() :: %s", ( init_prompt_eth_ret == ( BIT0 | BIT1 ) ) ? "Ok" : "Failure" ); |
klauss | 121:ee02790d00b7 | 52 | |
klauss | 121:ee02790d00b7 | 53 | if ( debug_app_init ) send_msg ( "init_external_wdt() :: %s", ( init_external_wdt() == 0 ) ? "Ok" : "Failure" ); |
klauss | 121:ee02790d00b7 | 54 | |
klauss | 121:ee02790d00b7 | 55 | if ( debug_app_init ) send_msg ( "init_bl() :: %s", ( init_bl() == 0 ) ? "Ok" : "Failure" ); |
klauss | 121:ee02790d00b7 | 56 | |
klauss | 121:ee02790d00b7 | 57 | if ( debug_app_init ) send_msg ( "init_clock () :: %s", ( init_clock () == 0 ) ? "Ok" : "Failure" ); |
klauss | 121:ee02790d00b7 | 58 | } |
klauss | 121:ee02790d00b7 | 59 | |
klauss | 121:ee02790d00b7 | 60 | sync_timer.start(); |
klauss | 121:ee02790d00b7 | 61 | |
klauss | 121:ee02790d00b7 | 62 | led_sync_timer.start(); |
klauss | 121:ee02790d00b7 | 63 | |
klauss | 121:ee02790d00b7 | 64 | ext = 0; |
klauss | 121:ee02790d00b7 | 65 | |
klauss | 121:ee02790d00b7 | 66 | port = 0; |
klauss | 121:ee02790d00b7 | 67 | |
klauss | 121:ee02790d00b7 | 68 | buffer_from_cb_ptr = ( uint8_t * )RXBuffer; |
klauss | 121:ee02790d00b7 | 69 | |
klauss | 121:ee02790d00b7 | 70 | data = NULL; |
klauss | 121:ee02790d00b7 | 71 | |
klauss | 121:ee02790d00b7 | 72 | type = DO_NOTHING; |
klauss | 121:ee02790d00b7 | 73 | |
klauss | 121:ee02790d00b7 | 74 | v_cb = new Vector(); |
klauss | 121:ee02790d00b7 | 75 | if( v_cb == NULL ) { |
klauss | 121:ee02790d00b7 | 76 | while( v_cb == NULL ) { |
klauss | 121:ee02790d00b7 | 77 | Vector * v_cb = new Vector(); |
klauss | 121:ee02790d00b7 | 78 | if( sync_timer.read() > 5 ) { |
klauss | 121:ee02790d00b7 | 79 | if( debug_memory ) send_msg("Call_Box vector allocation fail"); |
klauss | 121:ee02790d00b7 | 80 | sync_timer.reset(); |
klauss | 121:ee02790d00b7 | 81 | } |
klauss | 121:ee02790d00b7 | 82 | } |
klauss | 121:ee02790d00b7 | 83 | } |
klauss | 121:ee02790d00b7 | 84 | |
klauss | 121:ee02790d00b7 | 85 | if ( debug_app_init ) send_msg ( "v_cb :: %s", ( v_cb != NULL ) ? "Ok" : "Failure" ); |
klauss | 121:ee02790d00b7 | 86 | |
klauss | 121:ee02790d00b7 | 87 | v_call = new Vector(); |
klauss | 121:ee02790d00b7 | 88 | if( v_call == NULL ) { |
klauss | 121:ee02790d00b7 | 89 | while( v_call == NULL ) { |
klauss | 121:ee02790d00b7 | 90 | Vector * v_call = new Vector(); |
klauss | 121:ee02790d00b7 | 91 | if( sync_timer.read() > 5 ) { |
klauss | 121:ee02790d00b7 | 92 | if( debug_memory ) send_msg("Call vector allocation fail"); |
klauss | 121:ee02790d00b7 | 93 | sync_timer.reset(); |
klauss | 121:ee02790d00b7 | 94 | } |
klauss | 121:ee02790d00b7 | 95 | } |
klauss | 121:ee02790d00b7 | 96 | } |
klauss | 121:ee02790d00b7 | 97 | |
klauss | 121:ee02790d00b7 | 98 | if ( debug_app_init ) send_msg ( "v_call :: %s", ( v_call != NULL ) ? "Ok" : "Failure" ); |
klauss | 121:ee02790d00b7 | 99 | |
klauss | 121:ee02790d00b7 | 100 | ts = new Timeslice(); |
klauss | 121:ee02790d00b7 | 101 | if( ts == NULL ) { |
klauss | 121:ee02790d00b7 | 102 | memory_is_over = true; |
klauss | 121:ee02790d00b7 | 103 | if( debug_memory ) send_msg("TS allocation fail"); |
klauss | 121:ee02790d00b7 | 104 | } |
klauss | 121:ee02790d00b7 | 105 | |
klauss | 121:ee02790d00b7 | 106 | if ( debug_app_init ) send_msg ( "TS :: %s", ( ts != NULL ) ? "Ok" : "Failure" ); |
klauss | 121:ee02790d00b7 | 107 | |
klauss | 121:ee02790d00b7 | 108 | for( register uint16_t i = 0; i < CB_BUFFER_SIZE; i++ ) { |
klauss | 121:ee02790d00b7 | 109 | cb_rx_buffer[ i ] = 0; |
klauss | 121:ee02790d00b7 | 110 | cb_tx_buffer[ i ] = 0; |
klauss | 121:ee02790d00b7 | 111 | } |
klauss | 121:ee02790d00b7 | 112 | |
klauss | 121:ee02790d00b7 | 113 | reset_leds(); |
klauss | 121:ee02790d00b7 | 114 | |
klauss | 121:ee02790d00b7 | 115 | udp_timer.start(); |
klauss | 121:ee02790d00b7 | 116 | |
klauss | 121:ee02790d00b7 | 117 | if ( debug_app_init ) send_msg ( "init_fw_handler() :: %s", ( init_fw_handler() == 0 ) ? "Ok" : "Failure" ); |
klauss | 121:ee02790d00b7 | 118 | |
klauss | 121:ee02790d00b7 | 119 | if ( debug_app_init ) send_msg ( "init_ranges() :: %s", ( init_ranges() == 0 ) ? "Ok" : "Failure" ); |
klauss | 121:ee02790d00b7 | 120 | |
klauss | 121:ee02790d00b7 | 121 | if ( debug_app_init ) send_msg ( "init_refresh() :: %s", ( init_refresh() == 0 ) ? "Ok" : "Failure" ); |
klauss | 121:ee02790d00b7 | 122 | |
klauss | 121:ee02790d00b7 | 123 | if ( debug_app_init ) send_msg ( "init_sync_refresh() :: %s", ( init_sync_refresh() == 0 ) ? "Ok" : "Failure" ); |
klauss | 121:ee02790d00b7 | 124 | |
klauss | 121:ee02790d00b7 | 125 | count = 0; |
klauss | 121:ee02790d00b7 | 126 | |
klauss | 121:ee02790d00b7 | 127 | max_registered_cbx = 0; |
klauss | 121:ee02790d00b7 | 128 | |
klauss | 121:ee02790d00b7 | 129 | wake_all = false; |
klauss | 121:ee02790d00b7 | 130 | |
klauss | 121:ee02790d00b7 | 131 | pkg_wdt = RX_CB_IDLE; |
klauss | 121:ee02790d00b7 | 132 | |
klauss | 121:ee02790d00b7 | 133 | eth_wdt = ETH_CONNECT_TIMEOUT; |
klauss | 121:ee02790d00b7 | 134 | |
klauss | 121:ee02790d00b7 | 135 | invite_retry_timer.start(); |
klauss | 121:ee02790d00b7 | 136 | |
klauss | 121:ee02790d00b7 | 137 | if ( debug_app_init ) send_msg ( "hex_init() :: %s", ( hex_init() == 0 ) ? "Ok" : "Failure" ); |
klauss | 121:ee02790d00b7 | 138 | |
klauss | 121:ee02790d00b7 | 139 | reset_leds(); |
klauss | 121:ee02790d00b7 | 140 | |
klauss | 121:ee02790d00b7 | 141 | lpc_low_level_input_counter = 0; |
klauss | 121:ee02790d00b7 | 142 | |
klauss | 121:ee02790d00b7 | 143 | send_msg ( "" ); |
klauss | 121:ee02790d00b7 | 144 | |
klauss | 121:ee02790d00b7 | 145 | return ( 0 ); |
klauss | 121:ee02790d00b7 | 146 | } |
klauss | 121:ee02790d00b7 | 147 | |
klauss | 121:ee02790d00b7 | 148 | |
klauss | 121:ee02790d00b7 | 149 | int try_reconnect_with_eth ( void ) |
klauss | 121:ee02790d00b7 | 150 | { |
klauss | 121:ee02790d00b7 | 151 | eth_status = __init_eth__(); |
klauss | 121:ee02790d00b7 | 152 | |
klauss | 121:ee02790d00b7 | 153 | if( eth_status ) { |
klauss | 121:ee02790d00b7 | 154 | send_msg("******* Cannot connect to eth *******"); |
klauss | 121:ee02790d00b7 | 155 | } else { |
klauss | 121:ee02790d00b7 | 156 | send_msg("******* Connection eth - ok *******"); |
klauss | 121:ee02790d00b7 | 157 | int init_prompt_eth_ret = init_prompt_eth(); |
klauss | 121:ee02790d00b7 | 158 | |
klauss | 121:ee02790d00b7 | 159 | if ( init_prompt_eth_ret == BIT0 ) send_msg("******* Prompt eth UDP Ready *******"); |
klauss | 121:ee02790d00b7 | 160 | |
klauss | 121:ee02790d00b7 | 161 | if ( init_prompt_eth_ret == BIT1 ) send_msg("******* Prompt eth TCP Ready *******"); |
klauss | 121:ee02790d00b7 | 162 | |
klauss | 121:ee02790d00b7 | 163 | if ( debug_app_init ) send_msg ( "init_prompt_eth() :: %s", ( init_prompt_eth_ret == ( BIT0 | BIT1 ) ) ? "Ok" : "Failure" ); |
klauss | 121:ee02790d00b7 | 164 | |
klauss | 121:ee02790d00b7 | 165 | if ( debug_app_init ) send_msg ( "init_external_wdt() :: %s", ( init_external_wdt() == 0 ) ? "Ok" : "Failure" ); |
klauss | 121:ee02790d00b7 | 166 | |
klauss | 121:ee02790d00b7 | 167 | if ( debug_app_init ) send_msg ( "init_bl() :: %s", ( init_bl() == 0 ) ? "Ok" : "Failure" ); |
klauss | 121:ee02790d00b7 | 168 | |
klauss | 121:ee02790d00b7 | 169 | if ( debug_app_init ) send_msg ( "init_clock() :: %s", ( init_clock() == 0 ) ? "Ok" : "Failure" ); |
klauss | 121:ee02790d00b7 | 170 | } |
klauss | 121:ee02790d00b7 | 171 | |
klauss | 121:ee02790d00b7 | 172 | return eth_status; |
klauss | 121:ee02790d00b7 | 173 | } |
klauss | 121:ee02790d00b7 | 174 | |
klauss | 121:ee02790d00b7 | 175 | |
klauss | 121:ee02790d00b7 | 176 | int show_stats ( void ) |
klauss | 121:ee02790d00b7 | 177 | { |
klauss | 121:ee02790d00b7 | 178 | char str[ 200 ]; |
klauss | 121:ee02790d00b7 | 179 | int snprintf_ret = snprintf( str, 200, "" |
klauss | 121:ee02790d00b7 | 180 | "\n\rReceived Pkgs::\n\r " |
klauss | 121:ee02790d00b7 | 181 | "Boot :: %u\n\r " |
klauss | 121:ee02790d00b7 | 182 | "Registry :: %u\n\r " |
klauss | 121:ee02790d00b7 | 183 | "Invite :: %u\n\r " |
klauss | 121:ee02790d00b7 | 184 | "Audio :: %u\n\r " |
klauss | 121:ee02790d00b7 | 185 | "Telemetry :: %u\n\r " |
klauss | 121:ee02790d00b7 | 186 | "CB_stats :: %u\n\r " |
klauss | 121:ee02790d00b7 | 187 | "CB_bye :: %u\n\r " |
klauss | 121:ee02790d00b7 | 188 | "Prompt :: %u\n\r " |
klauss | 121:ee02790d00b7 | 189 | "Flood :: %u\n\r " |
klauss | 121:ee02790d00b7 | 190 | "Flood :: %u\n\r " |
klauss | 121:ee02790d00b7 | 191 | "Bootloader_cbx :: %u\n\r", |
klauss | 121:ee02790d00b7 | 192 | boot_counter, |
klauss | 121:ee02790d00b7 | 193 | registry_counter, |
klauss | 121:ee02790d00b7 | 194 | invite_counter, |
klauss | 121:ee02790d00b7 | 195 | audio_counter, |
klauss | 121:ee02790d00b7 | 196 | telemetry_counter, |
klauss | 121:ee02790d00b7 | 197 | cb_stats_counter, |
klauss | 121:ee02790d00b7 | 198 | cb_bye_counter, |
klauss | 121:ee02790d00b7 | 199 | prompt_counter, |
klauss | 121:ee02790d00b7 | 200 | flood_counter, |
klauss | 121:ee02790d00b7 | 201 | flood_counter, |
klauss | 121:ee02790d00b7 | 202 | bootloader_cbx_counter |
klauss | 121:ee02790d00b7 | 203 | ); |
klauss | 121:ee02790d00b7 | 204 | send_msg( str ); |
klauss | 121:ee02790d00b7 | 205 | |
klauss | 121:ee02790d00b7 | 206 | if ( debug_string_length ) debug_msg("str.length ( %d )", snprintf_ret ); |
klauss | 121:ee02790d00b7 | 207 | return ( snprintf_ret ); |
klauss | 121:ee02790d00b7 | 208 | } |
klauss | 121:ee02790d00b7 | 209 | |
klauss | 121:ee02790d00b7 | 210 | |
klauss | 121:ee02790d00b7 | 211 | int reset_stats ( void ) |
klauss | 121:ee02790d00b7 | 212 | { |
klauss | 121:ee02790d00b7 | 213 | boot_counter = 0; |
klauss | 121:ee02790d00b7 | 214 | registry_counter = 0; |
klauss | 121:ee02790d00b7 | 215 | invite_counter = 0; |
klauss | 121:ee02790d00b7 | 216 | audio_counter = 0; |
klauss | 121:ee02790d00b7 | 217 | telemetry_counter = 0; |
klauss | 121:ee02790d00b7 | 218 | cb_bye_counter = 0; |
klauss | 121:ee02790d00b7 | 219 | prompt_counter = 0; |
klauss | 121:ee02790d00b7 | 220 | flood_counter = 0; |
klauss | 121:ee02790d00b7 | 221 | bootloader_cbx_counter = 0; |
klauss | 121:ee02790d00b7 | 222 | cb_stats_counter = 0; |
klauss | 121:ee02790d00b7 | 223 | fw_counter = 0; |
klauss | 121:ee02790d00b7 | 224 | |
klauss | 121:ee02790d00b7 | 225 | return ( 0 ); |
klauss | 121:ee02790d00b7 | 226 | } |
klauss | 121:ee02790d00b7 | 227 | |
klauss | 121:ee02790d00b7 | 228 | int show_cb_list ( Vector * v_cb ) |
klauss | 121:ee02790d00b7 | 229 | { |
klauss | 121:ee02790d00b7 | 230 | uint8_t missed_cb = ( ( max_ext - min_ext ) + 1 ) - v_cb->size(); |
klauss | 121:ee02790d00b7 | 231 | |
klauss | 121:ee02790d00b7 | 232 | if( ( max_ext % 2 ) == 0 ) missed_cb++; |
klauss | 121:ee02790d00b7 | 233 | |
klauss | 121:ee02790d00b7 | 234 | if( min_ext % 2 ) missed_cb++; |
klauss | 121:ee02790d00b7 | 235 | |
klauss | 121:ee02790d00b7 | 236 | if( min_ext == 0 && max_ext == 0 ) missed_cb = 0; |
klauss | 121:ee02790d00b7 | 237 | |
klauss | 121:ee02790d00b7 | 238 | send_msg("Registered %d[ %d ] CBx ( %d - %d ) - Missed %d -- Remain_timeslices :: %d :: v_call->size() :: %d", v_cb->size(), max_registered_cbx, min_ext, max_ext, missed_cb, ts->remain_timeslices(), v_call->size() ); |
klauss | 121:ee02790d00b7 | 239 | if( v_cb->size() == 1 ) { |
klauss | 121:ee02790d00b7 | 240 | send_msg(" %d ", ( ( Call_Box * )v_cb->get_element( 0 ) )->get_ext() ); |
klauss | 121:ee02790d00b7 | 241 | } else if( v_cb->size() > 1 ) { |
klauss | 121:ee02790d00b7 | 242 | char str[ 1024 ]; |
klauss | 121:ee02790d00b7 | 243 | int ext_list[ MAX_CB_IN_A_BRANCH ]; |
klauss | 121:ee02790d00b7 | 244 | register int i = 0; |
klauss | 121:ee02790d00b7 | 245 | for( ; i < v_cb->size(); i++ ) { |
klauss | 121:ee02790d00b7 | 246 | ext_list[ i ] = ( ( Call_Box * )v_cb->get_element( i ) )->get_ext(); |
klauss | 121:ee02790d00b7 | 247 | } |
klauss | 121:ee02790d00b7 | 248 | |
klauss | 121:ee02790d00b7 | 249 | qsort( ext_list, v_cb->size(), sizeof( int ), ls_comp ); |
klauss | 121:ee02790d00b7 | 250 | |
klauss | 121:ee02790d00b7 | 251 | char aux[ 16 ]; |
klauss | 121:ee02790d00b7 | 252 | strcpy( str, "\r\n> " ); |
klauss | 121:ee02790d00b7 | 253 | for( i = 0; i < v_cb->size() - 1; i++ ) { |
klauss | 121:ee02790d00b7 | 254 | sprintf( aux, "%i, ", ext_list[ i ] ); |
klauss | 121:ee02790d00b7 | 255 | strcat( str, aux ); |
klauss | 121:ee02790d00b7 | 256 | if( ( i != 0 ) && !( ( i + 1 ) % 16 ) ) strcat( str, "\r\n> " ); |
klauss | 121:ee02790d00b7 | 257 | } |
klauss | 121:ee02790d00b7 | 258 | sprintf( aux, "%i ", ext_list[ i ] ); |
klauss | 121:ee02790d00b7 | 259 | strcat( str, aux ); |
klauss | 121:ee02790d00b7 | 260 | send_msg( "%s", str ); |
klauss | 121:ee02790d00b7 | 261 | } |
klauss | 121:ee02790d00b7 | 262 | |
klauss | 121:ee02790d00b7 | 263 | return ( 0 ); |
klauss | 121:ee02790d00b7 | 264 | } |
klauss | 121:ee02790d00b7 | 265 | |
klauss | 121:ee02790d00b7 | 266 | int show_cb_long_list ( Vector * v_cb ) |
klauss | 121:ee02790d00b7 | 267 | { |
klauss | 121:ee02790d00b7 | 268 | uint8_t missed_cb = ( ( max_ext - min_ext ) + 1 ) - v_cb->size(); |
klauss | 121:ee02790d00b7 | 269 | |
klauss | 121:ee02790d00b7 | 270 | if( ( max_ext % 2 ) == 0 ) missed_cb++; |
klauss | 121:ee02790d00b7 | 271 | |
klauss | 121:ee02790d00b7 | 272 | if( min_ext % 2 ) missed_cb++; |
klauss | 121:ee02790d00b7 | 273 | |
klauss | 121:ee02790d00b7 | 274 | if( min_ext == 0 && max_ext == 0 ) missed_cb = 0; |
klauss | 121:ee02790d00b7 | 275 | |
klauss | 121:ee02790d00b7 | 276 | { |
klauss | 121:ee02790d00b7 | 277 | int ext_list[ MAX_CB_IN_A_BRANCH ]; |
klauss | 121:ee02790d00b7 | 278 | |
klauss | 121:ee02790d00b7 | 279 | if( v_cb->size() >= 1 ) { |
klauss | 121:ee02790d00b7 | 280 | for( register int i = 0; i < v_cb->size(); i++ ) |
klauss | 121:ee02790d00b7 | 281 | { |
klauss | 121:ee02790d00b7 | 282 | ext_list[ i ] = ( ( Call_Box * )v_cb->get_element( i ) )->get_ext(); |
klauss | 121:ee02790d00b7 | 283 | } |
klauss | 121:ee02790d00b7 | 284 | qsort( ext_list, v_cb->size(), sizeof( int ), ls_comp ); |
klauss | 121:ee02790d00b7 | 285 | } |
klauss | 121:ee02790d00b7 | 286 | |
klauss | 121:ee02790d00b7 | 287 | send_msg("Registered %d[ %d ] CBx ( %d - %d ) - Missed %d -- Remain_timeslices :: %d :: v_call->size() :: %d", v_cb->size(), max_registered_cbx, min_ext, max_ext, missed_cb, ts->remain_timeslices(), v_call->size() ); |
klauss | 121:ee02790d00b7 | 288 | |
klauss | 121:ee02790d00b7 | 289 | for( register uint8_t i = 0; i < v_cb->size(); i++ ) { |
klauss | 121:ee02790d00b7 | 290 | |
klauss | 121:ee02790d00b7 | 291 | Call_Box * cb = find_CB( v_cb, ext_list[ i ] ); |
klauss | 121:ee02790d00b7 | 292 | |
klauss | 121:ee02790d00b7 | 293 | if( cb != NULL ) |
klauss | 121:ee02790d00b7 | 294 | { |
klauss | 121:ee02790d00b7 | 295 | char cb_status[ 32 ]; |
klauss | 121:ee02790d00b7 | 296 | char cb_sip_status[ 32 ]; |
klauss | 121:ee02790d00b7 | 297 | switch ( cb -> get_status () ) |
klauss | 121:ee02790d00b7 | 298 | { |
klauss | 121:ee02790d00b7 | 299 | case cb_idle : { |
klauss | 121:ee02790d00b7 | 300 | strcpy( cb_status, "cb_idle" ); |
klauss | 121:ee02790d00b7 | 301 | break; |
klauss | 121:ee02790d00b7 | 302 | } |
klauss | 121:ee02790d00b7 | 303 | case cb_ringing : { |
klauss | 121:ee02790d00b7 | 304 | strcpy( cb_status, "cb_ringing" ); |
klauss | 121:ee02790d00b7 | 305 | break; |
klauss | 121:ee02790d00b7 | 306 | } |
klauss | 121:ee02790d00b7 | 307 | case cb_trying : { |
klauss | 121:ee02790d00b7 | 308 | strcpy( cb_status,"cb_trying" ); |
klauss | 121:ee02790d00b7 | 309 | break; |
klauss | 121:ee02790d00b7 | 310 | } |
klauss | 121:ee02790d00b7 | 311 | case cb_on_call : { |
klauss | 121:ee02790d00b7 | 312 | strcpy( cb_status, "cb_on_call" ); |
klauss | 121:ee02790d00b7 | 313 | break; |
klauss | 121:ee02790d00b7 | 314 | } |
klauss | 121:ee02790d00b7 | 315 | case cb_busy : { |
klauss | 121:ee02790d00b7 | 316 | strcpy( cb_status, "cb_busy" ); |
klauss | 121:ee02790d00b7 | 317 | break; |
klauss | 121:ee02790d00b7 | 318 | } |
klauss | 121:ee02790d00b7 | 319 | case cb_denied : { |
klauss | 121:ee02790d00b7 | 320 | strcpy( cb_status, "cb_denied" ); |
klauss | 121:ee02790d00b7 | 321 | break; |
klauss | 121:ee02790d00b7 | 322 | } |
klauss | 121:ee02790d00b7 | 323 | case cb_bootloader : { |
klauss | 121:ee02790d00b7 | 324 | strcpy( cb_status, "cb_bootloader" ); |
klauss | 121:ee02790d00b7 | 325 | break; |
klauss | 121:ee02790d00b7 | 326 | } |
klauss | 121:ee02790d00b7 | 327 | } |
klauss | 121:ee02790d00b7 | 328 | |
klauss | 121:ee02790d00b7 | 329 | switch( cb -> get_sip_status () ) |
klauss | 121:ee02790d00b7 | 330 | { |
klauss | 121:ee02790d00b7 | 331 | case sip_idle : { |
klauss | 121:ee02790d00b7 | 332 | strcpy( cb_sip_status, "sip_idle" ); |
klauss | 121:ee02790d00b7 | 333 | break; |
klauss | 121:ee02790d00b7 | 334 | } |
klauss | 121:ee02790d00b7 | 335 | case sip_waiting_trying : { |
klauss | 121:ee02790d00b7 | 336 | strcpy( cb_sip_status, "sip_waiting_trying" ); |
klauss | 121:ee02790d00b7 | 337 | break; |
klauss | 121:ee02790d00b7 | 338 | } |
klauss | 121:ee02790d00b7 | 339 | case sip_trying : { |
klauss | 121:ee02790d00b7 | 340 | strcpy( cb_sip_status, "sip_trying" ); |
klauss | 121:ee02790d00b7 | 341 | break; |
klauss | 121:ee02790d00b7 | 342 | } |
klauss | 121:ee02790d00b7 | 343 | case sip_ringing : { |
klauss | 121:ee02790d00b7 | 344 | strcpy( cb_sip_status, "sip_ringing" ); |
klauss | 121:ee02790d00b7 | 345 | break; |
klauss | 121:ee02790d00b7 | 346 | } |
klauss | 121:ee02790d00b7 | 347 | case sip_busy : { |
klauss | 121:ee02790d00b7 | 348 | strcpy( cb_sip_status, "sip_busy" ); |
klauss | 121:ee02790d00b7 | 349 | break; |
klauss | 121:ee02790d00b7 | 350 | } |
klauss | 121:ee02790d00b7 | 351 | case sip_ok : { |
klauss | 121:ee02790d00b7 | 352 | strcpy( cb_sip_status, "sip_ok" ); |
klauss | 121:ee02790d00b7 | 353 | break; |
klauss | 121:ee02790d00b7 | 354 | } |
klauss | 121:ee02790d00b7 | 355 | case sip_on_call : { |
klauss | 121:ee02790d00b7 | 356 | strcpy( cb_sip_status, "sip_on_call" ); |
klauss | 121:ee02790d00b7 | 357 | break; |
klauss | 121:ee02790d00b7 | 358 | } |
klauss | 121:ee02790d00b7 | 359 | case sip_denied : { |
klauss | 121:ee02790d00b7 | 360 | strcpy( cb_sip_status, "sip_denied" ); |
klauss | 121:ee02790d00b7 | 361 | break; |
klauss | 121:ee02790d00b7 | 362 | } |
klauss | 121:ee02790d00b7 | 363 | } |
klauss | 121:ee02790d00b7 | 364 | |
klauss | 121:ee02790d00b7 | 365 | char cbx_to_string[ 254 ]; |
klauss | 121:ee02790d00b7 | 366 | snprintf ( cbx_to_string, sizeof ( cbx_to_string ), |
klauss | 121:ee02790d00b7 | 367 | "Ext :: %i :: Port :: %i :: Status -- %s - %s", |
klauss | 121:ee02790d00b7 | 368 | cb->get_ext(), cb->get_port(), cb_status, cb_sip_status |
klauss | 121:ee02790d00b7 | 369 | ); |
klauss | 121:ee02790d00b7 | 370 | |
klauss | 121:ee02790d00b7 | 371 | if( cb->get_timeslice() != 0 ) |
klauss | 121:ee02790d00b7 | 372 | { |
klauss | 121:ee02790d00b7 | 373 | char aux[ 32 ]; |
klauss | 121:ee02790d00b7 | 374 | snprintf ( aux, sizeof ( aux ), " -- on TimeSlice :: %i", cb->get_timeslice() ); |
klauss | 121:ee02790d00b7 | 375 | strcat( cbx_to_string, aux ); |
klauss | 121:ee02790d00b7 | 376 | } |
klauss | 121:ee02790d00b7 | 377 | send_msg( cbx_to_string ); |
klauss | 121:ee02790d00b7 | 378 | } |
klauss | 121:ee02790d00b7 | 379 | } |
klauss | 121:ee02790d00b7 | 380 | } |
klauss | 121:ee02790d00b7 | 381 | |
klauss | 121:ee02790d00b7 | 382 | return ( 0 ); |
klauss | 121:ee02790d00b7 | 383 | } |
klauss | 121:ee02790d00b7 | 384 | |
klauss | 121:ee02790d00b7 | 385 | int show_cb ( Vector * v_cb ) |
klauss | 121:ee02790d00b7 | 386 | { |
klauss | 121:ee02790d00b7 | 387 | send_msg("Registered %d ( of %d ) CBx ( %d - %d ) -- Remain_timeslices :: %d :: v_call->size() :: %d", v_cb->size(), max_registered_cbx, min_ext, max_ext, ts->remain_timeslices(), v_call->size() ); |
klauss | 121:ee02790d00b7 | 388 | for( register uint8_t i = 0; i < v_cb->size(); i++ ) { |
klauss | 121:ee02790d00b7 | 389 | Call_Box * cb = ( Call_Box * )v_cb->get_element( i ); |
klauss | 121:ee02790d00b7 | 390 | char cb_status[ 32 ]; |
klauss | 121:ee02790d00b7 | 391 | char cb_sip_status[ 32 ]; |
klauss | 121:ee02790d00b7 | 392 | switch ( cb -> get_status () ) |
klauss | 121:ee02790d00b7 | 393 | { |
klauss | 121:ee02790d00b7 | 394 | case cb_idle : { |
klauss | 121:ee02790d00b7 | 395 | strcpy( cb_status, "cb_idle" ); |
klauss | 121:ee02790d00b7 | 396 | break; |
klauss | 121:ee02790d00b7 | 397 | } |
klauss | 121:ee02790d00b7 | 398 | case cb_ringing : { |
klauss | 121:ee02790d00b7 | 399 | strcpy( cb_status, "cb_ringing" ); |
klauss | 121:ee02790d00b7 | 400 | break; |
klauss | 121:ee02790d00b7 | 401 | } |
klauss | 121:ee02790d00b7 | 402 | case cb_trying : { |
klauss | 121:ee02790d00b7 | 403 | strcpy( cb_status,"cb_trying" ); |
klauss | 121:ee02790d00b7 | 404 | break; |
klauss | 121:ee02790d00b7 | 405 | } |
klauss | 121:ee02790d00b7 | 406 | case cb_on_call : { |
klauss | 121:ee02790d00b7 | 407 | strcpy( cb_status, "cb_on_call" ); |
klauss | 121:ee02790d00b7 | 408 | break; |
klauss | 121:ee02790d00b7 | 409 | } |
klauss | 121:ee02790d00b7 | 410 | case cb_busy : { |
klauss | 121:ee02790d00b7 | 411 | strcpy( cb_status, "cb_busy" ); |
klauss | 121:ee02790d00b7 | 412 | break; |
klauss | 121:ee02790d00b7 | 413 | } |
klauss | 121:ee02790d00b7 | 414 | case cb_denied : { |
klauss | 121:ee02790d00b7 | 415 | strcpy( cb_status, "cb_denied" ); |
klauss | 121:ee02790d00b7 | 416 | break; |
klauss | 121:ee02790d00b7 | 417 | } |
klauss | 121:ee02790d00b7 | 418 | case cb_bootloader : { |
klauss | 121:ee02790d00b7 | 419 | strcpy( cb_status, "cb_bootloader" ); |
klauss | 121:ee02790d00b7 | 420 | break; |
klauss | 121:ee02790d00b7 | 421 | } |
klauss | 121:ee02790d00b7 | 422 | } |
klauss | 121:ee02790d00b7 | 423 | switch( cb -> get_sip_status () ) { |
klauss | 121:ee02790d00b7 | 424 | case sip_idle : { |
klauss | 121:ee02790d00b7 | 425 | strcpy( cb_sip_status, "sip_idle" ); |
klauss | 121:ee02790d00b7 | 426 | break; |
klauss | 121:ee02790d00b7 | 427 | } |
klauss | 121:ee02790d00b7 | 428 | case sip_waiting_trying : { |
klauss | 121:ee02790d00b7 | 429 | strcpy( cb_sip_status, "sip_waiting_trying" ); |
klauss | 121:ee02790d00b7 | 430 | break; |
klauss | 121:ee02790d00b7 | 431 | } |
klauss | 121:ee02790d00b7 | 432 | case sip_trying : { |
klauss | 121:ee02790d00b7 | 433 | strcpy( cb_sip_status, "sip_trying" ); |
klauss | 121:ee02790d00b7 | 434 | break; |
klauss | 121:ee02790d00b7 | 435 | } |
klauss | 121:ee02790d00b7 | 436 | case sip_ringing : { |
klauss | 121:ee02790d00b7 | 437 | strcpy( cb_sip_status, "sip_ringing" ); |
klauss | 121:ee02790d00b7 | 438 | break; |
klauss | 121:ee02790d00b7 | 439 | } |
klauss | 121:ee02790d00b7 | 440 | case sip_busy : { |
klauss | 121:ee02790d00b7 | 441 | strcpy( cb_sip_status, "sip_busy" ); |
klauss | 121:ee02790d00b7 | 442 | break; |
klauss | 121:ee02790d00b7 | 443 | } |
klauss | 121:ee02790d00b7 | 444 | case sip_ok : { |
klauss | 121:ee02790d00b7 | 445 | strcpy( cb_sip_status, "sip_ok" ); |
klauss | 121:ee02790d00b7 | 446 | break; |
klauss | 121:ee02790d00b7 | 447 | } |
klauss | 121:ee02790d00b7 | 448 | case sip_on_call : { |
klauss | 121:ee02790d00b7 | 449 | strcpy( cb_sip_status, "sip_on_call" ); |
klauss | 121:ee02790d00b7 | 450 | break; |
klauss | 121:ee02790d00b7 | 451 | } |
klauss | 121:ee02790d00b7 | 452 | case sip_denied : { |
klauss | 121:ee02790d00b7 | 453 | strcpy( cb_sip_status, "sip_denied" ); |
klauss | 121:ee02790d00b7 | 454 | break; |
klauss | 121:ee02790d00b7 | 455 | } |
klauss | 121:ee02790d00b7 | 456 | } |
klauss | 121:ee02790d00b7 | 457 | |
klauss | 121:ee02790d00b7 | 458 | char cbx_to_string[ 254 ]; |
klauss | 121:ee02790d00b7 | 459 | snprintf ( cbx_to_string, sizeof ( cbx_to_string ), |
klauss | 121:ee02790d00b7 | 460 | "Ext :: %i :: Port :: %i :: Status -- %s - %s", |
klauss | 121:ee02790d00b7 | 461 | cb->get_ext(), cb->get_port(), cb_status, cb_sip_status |
klauss | 121:ee02790d00b7 | 462 | ); |
klauss | 121:ee02790d00b7 | 463 | |
klauss | 121:ee02790d00b7 | 464 | if( cb->get_timeslice() != 0 ) |
klauss | 121:ee02790d00b7 | 465 | { |
klauss | 121:ee02790d00b7 | 466 | char aux[ 32 ]; |
klauss | 121:ee02790d00b7 | 467 | snprintf ( aux, sizeof ( aux ), " -- on TimeSlice :: %i", cb->get_timeslice() ); |
klauss | 121:ee02790d00b7 | 468 | strcat( cbx_to_string, aux ); |
klauss | 121:ee02790d00b7 | 469 | } |
klauss | 121:ee02790d00b7 | 470 | |
klauss | 121:ee02790d00b7 | 471 | |
klauss | 121:ee02790d00b7 | 472 | send_msg( cbx_to_string ); |
klauss | 121:ee02790d00b7 | 473 | } |
klauss | 121:ee02790d00b7 | 474 | |
klauss | 121:ee02790d00b7 | 475 | return ( 0 ); |
klauss | 121:ee02790d00b7 | 476 | } |
klauss | 121:ee02790d00b7 | 477 | |
klauss | 121:ee02790d00b7 | 478 | int show_cb_sip ( Vector * v_cb ) |
klauss | 121:ee02790d00b7 | 479 | { |
klauss | 121:ee02790d00b7 | 480 | send_msg(":: Sip :: %u", v_cb->size() ); |
klauss | 121:ee02790d00b7 | 481 | for( register uint8_t i = 0; i < v_cb->size(); i++ ) { |
klauss | 121:ee02790d00b7 | 482 | Call_Box * cb = ( Call_Box * )v_cb->get_element( i ); |
klauss | 121:ee02790d00b7 | 483 | |
klauss | 121:ee02790d00b7 | 484 | send_msg ( |
klauss | 121:ee02790d00b7 | 485 | "ext :: %d -- port :: %d -- timer %d [%s] ", |
klauss | 121:ee02790d00b7 | 486 | cb -> get_sip_ext(), |
klauss | 121:ee02790d00b7 | 487 | cb -> get_sip_port (), |
klauss | 121:ee02790d00b7 | 488 | cb -> get_timer (), |
klauss | 121:ee02790d00b7 | 489 | ( cb -> get_overflow_flag () ) ? "Overflow" : "Ok" |
klauss | 121:ee02790d00b7 | 490 | ); |
klauss | 121:ee02790d00b7 | 491 | } |
klauss | 121:ee02790d00b7 | 492 | |
klauss | 121:ee02790d00b7 | 493 | return ( 0 ); |
klauss | 121:ee02790d00b7 | 494 | } |
klauss | 121:ee02790d00b7 | 495 | |
klauss | 121:ee02790d00b7 | 496 | int show_sizes ( void ) |
klauss | 121:ee02790d00b7 | 497 | { |
klauss | 121:ee02790d00b7 | 498 | sizes = false; |
klauss | 121:ee02790d00b7 | 499 | send_msg("CB_New (%u) -- CB_Delete (%u)", cb_new_counter, cb_delete_counter ); |
klauss | 121:ee02790d00b7 | 500 | send_msg("SIP_New (%u) -- SIP_Delete (%u)", sip_new_counter, sip_delete_counter ); |
klauss | 121:ee02790d00b7 | 501 | send_msg("RTP_header_New (%u) -- RTP_header_Delete (%u)", rtp_header_new_counter, rtp_header_delete_counter ); |
klauss | 121:ee02790d00b7 | 502 | send_msg("RTP_body_New (%u) -- RTP_body_Delete (%u)", rtp_body_new_counter, rtp_body_delete_counter ); |
klauss | 121:ee02790d00b7 | 503 | send_msg("Call_New (%u) -- Call_Delete (%u)", call_new_counter, call_delete_counter ); |
klauss | 121:ee02790d00b7 | 504 | send_msg("lpc_low_level_input_counter :: %d", lpc_low_level_input_counter ); |
klauss | 121:ee02790d00b7 | 505 | send_msg("Memory is %s", ( memory_is_over ) ? "Over" : "Ok" ); |
klauss | 121:ee02790d00b7 | 506 | send_msg("Missed_Pkg :: %d ::", missed_pkg ); |
klauss | 121:ee02790d00b7 | 507 | send_msg("Sizeof Sip :: %u", sizeof( Sip ) ); |
klauss | 121:ee02790d00b7 | 508 | send_msg("Sizeof Call_Box :: %u", sizeof ( Call_Box ) ); |
klauss | 121:ee02790d00b7 | 509 | send_msg("Sizeof VZ_call :: %u", sizeof( VZ_call ) ); |
klauss | 121:ee02790d00b7 | 510 | send_msg("Sizeof RTP :: %u", sizeof( RTP ) ); |
klauss | 121:ee02790d00b7 | 511 | send_msg("Sizeof RTP_Header :: %u", sizeof( RTP_Header ) ); |
klauss | 121:ee02790d00b7 | 512 | send_msg("Sizeof RTP_Body :: %u", sizeof( RTP_Body ) ); |
klauss | 121:ee02790d00b7 | 513 | send_msg("Sizeof Vector :: %u", sizeof( Vector ) ); |
klauss | 121:ee02790d00b7 | 514 | send_msg("Sizeof Timeslice :: %u", sizeof( Timeslice ) ); |
klauss | 121:ee02790d00b7 | 515 | send_msg("Sizeof Watchdog :: %u", sizeof( Watchdog ) ); |
klauss | 121:ee02790d00b7 | 516 | |
klauss | 121:ee02790d00b7 | 517 | return ( 0 ); |
klauss | 121:ee02790d00b7 | 518 | } |
klauss | 121:ee02790d00b7 | 519 | |
klauss | 121:ee02790d00b7 | 520 | int check_udp_packages_pending ( Vector * v_cb ) |
klauss | 121:ee02790d00b7 | 521 | { |
klauss | 121:ee02790d00b7 | 522 | fd_set fdSet; |
klauss | 121:ee02790d00b7 | 523 | FD_ZERO(&fdSet); |
klauss | 121:ee02790d00b7 | 524 | |
klauss | 121:ee02790d00b7 | 525 | for( register uint8_t i = 0; i < v_cb->size(); i++ ) { |
klauss | 121:ee02790d00b7 | 526 | Call_Box * cb = (Call_Box *)v_cb->get_element( i ); |
klauss | 121:ee02790d00b7 | 527 | FD_SET( cb->get_sip_socket_fd(), &fdSet); |
klauss | 121:ee02790d00b7 | 528 | } |
klauss | 121:ee02790d00b7 | 529 | |
klauss | 121:ee02790d00b7 | 530 | /* Recepcao de pacotes UDP para atualizacao de callboxes */ |
klauss | 121:ee02790d00b7 | 531 | FD_SET( udp_bl_client.get_fd(), &fdSet); |
klauss | 121:ee02790d00b7 | 532 | |
klauss | 121:ee02790d00b7 | 533 | /* Recepcao de pacotes UDP para "tickagem" do watchdog */ |
klauss | 121:ee02790d00b7 | 534 | FD_SET( udp_wdt_client.get_fd(), &fdSet); |
klauss | 121:ee02790d00b7 | 535 | |
klauss | 121:ee02790d00b7 | 536 | // adiciona o socket de comandos prompt-UDP-ETH |
klauss | 121:ee02790d00b7 | 537 | FD_SET( udp_client.get_fd(), &fdSet ); |
klauss | 121:ee02790d00b7 | 538 | |
klauss | 121:ee02790d00b7 | 539 | // adiciona o socket de pedido de clock para o servidor |
klauss | 121:ee02790d00b7 | 540 | FD_SET( clock_sock.get_fd(), &fdSet ); |
klauss | 121:ee02790d00b7 | 541 | |
klauss | 121:ee02790d00b7 | 542 | struct timeval t; |
klauss | 121:ee02790d00b7 | 543 | t.tv_sec = 0; |
klauss | 121:ee02790d00b7 | 544 | t.tv_usec = 0; |
klauss | 121:ee02790d00b7 | 545 | int ret = lwip_select( FD_SETSIZE, &fdSet, NULL, NULL, &t ); |
klauss | 121:ee02790d00b7 | 546 | |
klauss | 121:ee02790d00b7 | 547 | if ((udp_bl_timer.read() > 30) and (bl_start_flag)) { |
klauss | 121:ee02790d00b7 | 548 | udp_bl_timer.stop(); |
klauss | 121:ee02790d00b7 | 549 | udp_bl_timer.reset(); |
klauss | 121:ee02790d00b7 | 550 | bl_start_flag = 0; |
klauss | 121:ee02790d00b7 | 551 | if (bl_ts != 0) { |
klauss | 121:ee02790d00b7 | 552 | ts->return_timeslice( bl_ts ); |
klauss | 121:ee02790d00b7 | 553 | bl_ts = 0; |
klauss | 121:ee02790d00b7 | 554 | } |
klauss | 121:ee02790d00b7 | 555 | if (bl_cb != NULL) { |
klauss | 121:ee02790d00b7 | 556 | bl_cb -> set_timeslice( 0 ); |
klauss | 121:ee02790d00b7 | 557 | bl_cb -> cb_set_status ( cb_idle ); |
klauss | 121:ee02790d00b7 | 558 | bl_cb = NULL; |
klauss | 121:ee02790d00b7 | 559 | } |
klauss | 121:ee02790d00b7 | 560 | } |
klauss | 121:ee02790d00b7 | 561 | |
klauss | 121:ee02790d00b7 | 562 | if ( ret > 0 ) |
klauss | 121:ee02790d00b7 | 563 | { |
klauss | 121:ee02790d00b7 | 564 | for( register uint8_t i = 0; i < v_cb->size(); i++ ) { |
klauss | 121:ee02790d00b7 | 565 | Call_Box * cb = (Call_Box *)v_cb->get_element( i ); |
klauss | 121:ee02790d00b7 | 566 | int fd = cb->get_sip_socket_fd(); |
klauss | 121:ee02790d00b7 | 567 | if( FD_ISSET( fd, &fdSet ) ) { |
klauss | 121:ee02790d00b7 | 568 | int rcv = cb->sip_udp_incomming_pkg(); |
klauss | 121:ee02790d00b7 | 569 | } |
klauss | 121:ee02790d00b7 | 570 | } |
klauss | 121:ee02790d00b7 | 571 | |
klauss | 121:ee02790d00b7 | 572 | /* Tratamento dos pacotes de bootloader vindo do servidor */ |
klauss | 121:ee02790d00b7 | 573 | if( FD_ISSET( udp_bl_client.get_fd(), &fdSet ) ) { |
klauss | 121:ee02790d00b7 | 574 | if( udp_bl_client.receiveFrom( udp_bl_server, bl_recv_buffer, sizeof( bl_recv_buffer ) ) > 0 ) { |
klauss | 121:ee02790d00b7 | 575 | uint16_t cnt = 0; |
klauss | 121:ee02790d00b7 | 576 | if (debug_bootloader) { |
klauss | 121:ee02790d00b7 | 577 | pc.printf("\r\nPACOTE SRV->HDR {"); |
klauss | 121:ee02790d00b7 | 578 | for (cnt = 0;cnt < UDP_BL_SIZE;cnt++) { |
klauss | 121:ee02790d00b7 | 579 | if ((cnt % 30) == 0) { |
klauss | 121:ee02790d00b7 | 580 | pc.printf("\r\n "); |
klauss | 121:ee02790d00b7 | 581 | pc.printf(hex16(cnt)); |
klauss | 121:ee02790d00b7 | 582 | pc.printf(" : "); |
klauss | 121:ee02790d00b7 | 583 | } |
klauss | 121:ee02790d00b7 | 584 | pc.printf(hex8(bl_recv_buffer[cnt])); |
klauss | 121:ee02790d00b7 | 585 | pc.printf(", "); |
klauss | 121:ee02790d00b7 | 586 | } |
klauss | 121:ee02790d00b7 | 587 | pc.printf("\r\n}"); |
klauss | 121:ee02790d00b7 | 588 | } |
klauss | 121:ee02790d00b7 | 589 | bl_peer = ((uint8_t)bl_recv_buffer[0])*256 + (uint8_t)bl_recv_buffer[1]; |
klauss | 121:ee02790d00b7 | 590 | bl_send_buffer[0] = bl_recv_buffer[0]; |
klauss | 121:ee02790d00b7 | 591 | bl_send_buffer[1] = bl_recv_buffer[1]; |
klauss | 121:ee02790d00b7 | 592 | for (cnt = 2;cnt < UDP_BL_SIZE;cnt++) { |
klauss | 121:ee02790d00b7 | 593 | bl_send_buffer[cnt] = 0; |
klauss | 121:ee02790d00b7 | 594 | } |
klauss | 121:ee02790d00b7 | 595 | |
klauss | 121:ee02790d00b7 | 596 | if ((bl_ts == 0) and !(bl_start_flag)) { |
klauss | 121:ee02790d00b7 | 597 | bl_ts = ts->get_timeslice(); |
klauss | 121:ee02790d00b7 | 598 | } |
klauss | 121:ee02790d00b7 | 599 | |
klauss | 121:ee02790d00b7 | 600 | /* caso nao haja timeslice disponivel informar servidor */ |
klauss | 121:ee02790d00b7 | 601 | if ((bl_ts == 0) and !(bl_start_flag)) { |
klauss | 121:ee02790d00b7 | 602 | strncpy(bl_send_buffer + 2,"cbxdead\x00",8); |
klauss | 121:ee02790d00b7 | 603 | int udp_bl_client_ret = udp_bl_client.sendTo( udp_bl_server, bl_send_buffer, strlen( bl_send_buffer ) ); |
klauss | 121:ee02790d00b7 | 604 | |
klauss | 121:ee02790d00b7 | 605 | if ( udp_bl_client_ret != strlen( bl_send_buffer ) ) |
klauss | 121:ee02790d00b7 | 606 | { |
klauss | 121:ee02790d00b7 | 607 | // TODO implementar os reconnects do bl |
klauss | 121:ee02790d00b7 | 608 | } |
klauss | 121:ee02790d00b7 | 609 | } else { |
klauss | 121:ee02790d00b7 | 610 | |
klauss | 121:ee02790d00b7 | 611 | /* pacote para verificar se o callbox esta disponivel */ |
klauss | 121:ee02790d00b7 | 612 | if (!(strncmp(bl_recv_buffer + 2,"avaiable?",9))) { |
klauss | 121:ee02790d00b7 | 613 | bl_start_flag = 1; |
klauss | 121:ee02790d00b7 | 614 | udp_bl_timer.start(); |
klauss | 121:ee02790d00b7 | 615 | udp_bl_timer.reset(); |
klauss | 121:ee02790d00b7 | 616 | strncpy(bl_send_buffer + 2,"cbxalive\x00",9); |
klauss | 121:ee02790d00b7 | 617 | if (debug_bootloader) { |
klauss | 121:ee02790d00b7 | 618 | pc.printf("\r\nPACOTE HDR->SRV {"); |
klauss | 121:ee02790d00b7 | 619 | for (cnt = 0;cnt < UDP_BL_SIZE;cnt++) { |
klauss | 121:ee02790d00b7 | 620 | if ((cnt % 30) == 0) { |
klauss | 121:ee02790d00b7 | 621 | pc.printf("\r\n "); |
klauss | 121:ee02790d00b7 | 622 | pc.printf(hex16(cnt)); |
klauss | 121:ee02790d00b7 | 623 | pc.printf(" : "); |
klauss | 121:ee02790d00b7 | 624 | } |
klauss | 121:ee02790d00b7 | 625 | pc.printf(hex8(bl_send_buffer[cnt])); |
klauss | 121:ee02790d00b7 | 626 | pc.printf(", "); |
klauss | 121:ee02790d00b7 | 627 | } |
klauss | 121:ee02790d00b7 | 628 | pc.printf("\r\n}"); |
klauss | 121:ee02790d00b7 | 629 | } |
klauss | 121:ee02790d00b7 | 630 | udp_bl_client.sendTo( udp_bl_server, bl_send_buffer, strlen( bl_send_buffer ) ); |
klauss | 121:ee02790d00b7 | 631 | } |
klauss | 121:ee02790d00b7 | 632 | |
klauss | 121:ee02790d00b7 | 633 | /* pacote para indicar o termino do processo de atualizacao */ |
klauss | 121:ee02790d00b7 | 634 | else if (!(strncmp(bl_recv_buffer + 2,"finished",8))) { |
klauss | 121:ee02790d00b7 | 635 | bl_start_flag = 0; |
klauss | 121:ee02790d00b7 | 636 | if (bl_ts != 0) { |
klauss | 121:ee02790d00b7 | 637 | ts->return_timeslice( bl_ts ); |
klauss | 121:ee02790d00b7 | 638 | bl_ts = 0; |
klauss | 121:ee02790d00b7 | 639 | } |
klauss | 121:ee02790d00b7 | 640 | if (bl_cb != NULL) { |
klauss | 121:ee02790d00b7 | 641 | bl_cb->set_timeslice( 0 ); |
klauss | 121:ee02790d00b7 | 642 | bl_cb -> cb_set_status( cb_idle ); |
klauss | 121:ee02790d00b7 | 643 | bl_cb = NULL; |
klauss | 121:ee02790d00b7 | 644 | } |
klauss | 121:ee02790d00b7 | 645 | } |
klauss | 121:ee02790d00b7 | 646 | |
klauss | 121:ee02790d00b7 | 647 | /* pacotes a serem repassados para o callbox */ |
klauss | 121:ee02790d00b7 | 648 | else if (bl_start_flag) { |
klauss | 121:ee02790d00b7 | 649 | uint16_t bl_cnt = 0; |
klauss | 121:ee02790d00b7 | 650 | udp_bl_timer.reset(); |
klauss | 121:ee02790d00b7 | 651 | /* pacote de ERASE enviado para o cbx */ |
klauss | 121:ee02790d00b7 | 652 | /* neste momento a cabeceira sabe que o servidor se comunicou com o callbox */ |
klauss | 121:ee02790d00b7 | 653 | if (!(strncmp(bl_recv_buffer + 2,"\x45",1))) { |
klauss | 121:ee02790d00b7 | 654 | bl_cb = find_CB( v_cb, bl_peer ); |
klauss | 121:ee02790d00b7 | 655 | if (bl_cb != NULL) { |
klauss | 121:ee02790d00b7 | 656 | bl_cb->set_timeslice( bl_ts ); |
klauss | 121:ee02790d00b7 | 657 | bl_cb -> cb_set_status ( cb_bootloader ); |
klauss | 121:ee02790d00b7 | 658 | } |
klauss | 121:ee02790d00b7 | 659 | } |
klauss | 121:ee02790d00b7 | 660 | /* pacote de OK enviado para o cbx */ |
klauss | 121:ee02790d00b7 | 661 | /* neste momento a cabeceira desaloca o timeslice do callbox */ |
klauss | 121:ee02790d00b7 | 662 | if (!(strncmp(bl_recv_buffer + 2,"\x4f\x00\x00\x00",4))) { |
klauss | 121:ee02790d00b7 | 663 | ts->return_timeslice( bl_ts ); |
klauss | 121:ee02790d00b7 | 664 | bl_ts = 0; |
klauss | 121:ee02790d00b7 | 665 | if (bl_cb != NULL) { |
klauss | 121:ee02790d00b7 | 666 | bl_cb->set_timeslice( 0 ); |
klauss | 121:ee02790d00b7 | 667 | } |
klauss | 121:ee02790d00b7 | 668 | } |
klauss | 121:ee02790d00b7 | 669 | bl_cbx_buffer[0] = bl_ts; |
klauss | 121:ee02790d00b7 | 670 | for (bl_cnt = 0; bl_cnt < BL_SIZE; bl_cnt++) { |
klauss | 121:ee02790d00b7 | 671 | bl_cbx_buffer[bl_cnt + 1] = bl_recv_buffer[bl_cnt + 2]; |
klauss | 121:ee02790d00b7 | 672 | } |
klauss | 121:ee02790d00b7 | 673 | if (debug_bootloader) { |
klauss | 121:ee02790d00b7 | 674 | pc.printf("\r\nPACOTE HDR->CBX {"); |
klauss | 121:ee02790d00b7 | 675 | for (cnt = 0;cnt < BL_SIZE + 1;cnt++) { |
klauss | 121:ee02790d00b7 | 676 | if ((cnt % 30) == 0) { |
klauss | 121:ee02790d00b7 | 677 | pc.printf("\r\n "); |
klauss | 121:ee02790d00b7 | 678 | pc.printf(hex16(cnt)); |
klauss | 121:ee02790d00b7 | 679 | pc.printf(" : "); |
klauss | 121:ee02790d00b7 | 680 | } |
klauss | 121:ee02790d00b7 | 681 | pc.printf(hex8(bl_cbx_buffer[cnt])); |
klauss | 121:ee02790d00b7 | 682 | pc.printf(", "); |
klauss | 121:ee02790d00b7 | 683 | } |
klauss | 121:ee02790d00b7 | 684 | pc.printf("\r\n}"); |
klauss | 121:ee02790d00b7 | 685 | } |
klauss | 121:ee02790d00b7 | 686 | if (bl_cb != NULL) { |
klauss | 121:ee02790d00b7 | 687 | bl_port = bl_cb->get_port(); |
klauss | 121:ee02790d00b7 | 688 | } else { |
klauss | 121:ee02790d00b7 | 689 | bl_port = bl_peer; |
klauss | 121:ee02790d00b7 | 690 | } |
klauss | 121:ee02790d00b7 | 691 | send2callboxes( build_cb_package( bl_peer, bl_port, BOOTLOADER_CBX,bl_cbx_buffer, 0, BL_SIZE + 1, write_buffer) ); |
klauss | 121:ee02790d00b7 | 692 | } |
klauss | 121:ee02790d00b7 | 693 | } |
klauss | 121:ee02790d00b7 | 694 | } |
klauss | 121:ee02790d00b7 | 695 | } |
klauss | 121:ee02790d00b7 | 696 | |
klauss | 121:ee02790d00b7 | 697 | // verifica o socket do prompt-UDP-ETH |
klauss | 121:ee02790d00b7 | 698 | if( FD_ISSET( udp_client.get_fd(), &fdSet ) ) { |
klauss | 121:ee02790d00b7 | 699 | char to_prompt_process[ PROMPT_UDP_COMMAND_SIZE ]; |
klauss | 121:ee02790d00b7 | 700 | for( register int i = 0; i < PROMPT_UDP_COMMAND_SIZE; i++ ) to_prompt_process[ i ] = 0; |
klauss | 121:ee02790d00b7 | 701 | |
klauss | 121:ee02790d00b7 | 702 | int prompt_process_msg_rcv = udp_client.receiveFrom( udp_server, to_prompt_process, ( sizeof( to_prompt_process ) - 1 ) ); |
klauss | 121:ee02790d00b7 | 703 | |
klauss | 121:ee02790d00b7 | 704 | to_prompt_process[ prompt_process_msg_rcv ] = 0; |
klauss | 121:ee02790d00b7 | 705 | if( prompt_process_msg_rcv == -1 ) |
klauss | 121:ee02790d00b7 | 706 | { |
klauss | 121:ee02790d00b7 | 707 | if( debug_reconnect ) send_msg("Reconnect Prompt Process"); |
klauss | 121:ee02790d00b7 | 708 | reconnect_udp_prompt_process(); |
klauss | 121:ee02790d00b7 | 709 | miss_prompt_udp_rcv_pkg++; |
klauss | 121:ee02790d00b7 | 710 | } |
klauss | 121:ee02790d00b7 | 711 | else if( prompt_process_msg_rcv > 0 ) |
klauss | 121:ee02790d00b7 | 712 | { |
klauss | 121:ee02790d00b7 | 713 | udp_query = true; |
klauss | 121:ee02790d00b7 | 714 | prompt_process( to_prompt_process, prompt_process_msg_rcv ); |
klauss | 121:ee02790d00b7 | 715 | } |
klauss | 121:ee02790d00b7 | 716 | } |
klauss | 121:ee02790d00b7 | 717 | |
klauss | 121:ee02790d00b7 | 718 | // verifica o socket do watchdog |
klauss | 121:ee02790d00b7 | 719 | if( FD_ISSET( udp_wdt_client.get_fd(), &fdSet ) ) { |
klauss | 121:ee02790d00b7 | 720 | char wake_msg[ 768 ]; |
klauss | 121:ee02790d00b7 | 721 | Endpoint udp_wdt_server; |
klauss | 121:ee02790d00b7 | 722 | |
klauss | 121:ee02790d00b7 | 723 | int wake_msg_rcv = udp_wdt_client.receiveFrom( udp_wdt_server, wake_msg, sizeof( wake_msg ) ); |
klauss | 121:ee02790d00b7 | 724 | |
klauss | 121:ee02790d00b7 | 725 | if( wake_msg_rcv == -1 ) |
klauss | 121:ee02790d00b7 | 726 | { |
klauss | 121:ee02790d00b7 | 727 | if( debug_reconnect ) send_msg("Reconnect Extern wdt"); |
klauss | 121:ee02790d00b7 | 728 | reconnect_extern_wdt_socket(); |
klauss | 121:ee02790d00b7 | 729 | miss_wdt_send_pkg++; |
klauss | 121:ee02790d00b7 | 730 | } |
klauss | 121:ee02790d00b7 | 731 | else if( wake_msg_rcv > 0 ) |
klauss | 121:ee02790d00b7 | 732 | { |
klauss | 121:ee02790d00b7 | 733 | if( !( strncmp( wake_msg, "alive", 5 ) ) ) { |
klauss | 121:ee02790d00b7 | 734 | // Just ckeck but not set 'alive?' |
klauss | 121:ee02790d00b7 | 735 | // 'alive*' - force wdt tick right now |
klauss | 121:ee02790d00b7 | 736 | // Ckecking and set 'alive' |
klauss | 121:ee02790d00b7 | 737 | bool question_alive = ( wake_msg[ 5 ] == '?' ); |
klauss | 121:ee02790d00b7 | 738 | if( wake_msg[ 5 ] == '*' ) wdt.kick(); |
klauss | 121:ee02790d00b7 | 739 | |
klauss | 121:ee02790d00b7 | 740 | snprintf( wake_msg, ( 768 - 1 ),"wdt:%u,%u,%u,%c,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u:", |
klauss | 121:ee02790d00b7 | 741 | uptime, |
klauss | 121:ee02790d00b7 | 742 | invite_counter, |
klauss | 121:ee02790d00b7 | 743 | external_wdt, |
klauss | 121:ee02790d00b7 | 744 | ( wdt.WatchdogCausedReset() ) ? '1' : '0', |
klauss | 121:ee02790d00b7 | 745 | cb_new_counter, |
klauss | 121:ee02790d00b7 | 746 | v_cb->size(), |
klauss | 121:ee02790d00b7 | 747 | ts->remain_timeslices(), |
klauss | 121:ee02790d00b7 | 748 | sip_socket_send_failure, |
klauss | 121:ee02790d00b7 | 749 | v_call->size(), |
klauss | 121:ee02790d00b7 | 750 | pkg_cksok, |
klauss | 121:ee02790d00b7 | 751 | pkg_ckserr, |
klauss | 121:ee02790d00b7 | 752 | pkg_zero, |
klauss | 121:ee02790d00b7 | 753 | out_of_range, |
klauss | 121:ee02790d00b7 | 754 | missed_pkg, |
klauss | 121:ee02790d00b7 | 755 | delayed_pkg_to_cb, |
klauss | 121:ee02790d00b7 | 756 | cpld_pkg_tx_counter, |
klauss | 121:ee02790d00b7 | 757 | cpld_pkg_rx_counter, |
klauss | 121:ee02790d00b7 | 758 | eth_wdt, |
klauss | 121:ee02790d00b7 | 759 | pkg_wdt, |
klauss | 121:ee02790d00b7 | 760 | miss_fw_send_pkg, |
klauss | 121:ee02790d00b7 | 761 | miss_prompt_udp_send_pkg, |
klauss | 121:ee02790d00b7 | 762 | miss_sip_registry_send_pkg, |
klauss | 121:ee02790d00b7 | 763 | miss_sip_invite_send_pkg, |
klauss | 121:ee02790d00b7 | 764 | miss_sip_bye_send_pkg, |
klauss | 121:ee02790d00b7 | 765 | miss_sip_unregistry_send_pkg, |
klauss | 121:ee02790d00b7 | 766 | miss_sip_ok_send_pkg, |
klauss | 121:ee02790d00b7 | 767 | miss_sip_rcv_bye_send_pkg, |
klauss | 121:ee02790d00b7 | 768 | miss_wdt_send_pkg, |
klauss | 121:ee02790d00b7 | 769 | miss_prompt_udp_send_pkg, |
klauss | 121:ee02790d00b7 | 770 | miss_ftp_udp_send_pkg, |
klauss | 121:ee02790d00b7 | 771 | miss_prompt_udp_rcv_pkg, |
klauss | 121:ee02790d00b7 | 772 | miss_closk_send_pkg |
klauss | 121:ee02790d00b7 | 773 | ); |
klauss | 121:ee02790d00b7 | 774 | |
klauss | 121:ee02790d00b7 | 775 | wake_msg[ 768 - 1 ] = 0; |
klauss | 121:ee02790d00b7 | 776 | int send = udp_wdt_client.sendTo( udp_wdt_server, wake_msg, strlen( wake_msg ) ); |
klauss | 121:ee02790d00b7 | 777 | if( send != strlen( wake_msg ) ) |
klauss | 121:ee02790d00b7 | 778 | { |
klauss | 121:ee02790d00b7 | 779 | if( debug_reconnect ) debug_msg("Reconnect Extern wdt (%d, %d)", send, strlen( wake_msg ) ); |
klauss | 121:ee02790d00b7 | 780 | reconnect_extern_wdt_socket(); |
klauss | 121:ee02790d00b7 | 781 | miss_wdt_send_pkg++; |
klauss | 121:ee02790d00b7 | 782 | } |
klauss | 121:ee02790d00b7 | 783 | |
klauss | 121:ee02790d00b7 | 784 | if( ( (!question_alive) && ( cb_new_counter <= MAX_CB_IN_A_BRANCH ) && ( cb_new_counter >= 2 ) ) ) { |
klauss | 121:ee02790d00b7 | 785 | external_wdt = EXTERN_WDT_IDLE; |
klauss | 121:ee02790d00b7 | 786 | } |
klauss | 121:ee02790d00b7 | 787 | } else if( !( strncmp( wake_msg, "reset", 5 ) ) ) { |
klauss | 121:ee02790d00b7 | 788 | external_wdt = 0; |
klauss | 121:ee02790d00b7 | 789 | |
klauss | 121:ee02790d00b7 | 790 | sprintf( wake_msg, "rst:%u:", uptime ); |
klauss | 121:ee02790d00b7 | 791 | int send = udp_wdt_client.sendTo( udp_wdt_server, wake_msg, strlen( wake_msg ) ); |
klauss | 121:ee02790d00b7 | 792 | if( send != strlen( wake_msg ) ) |
klauss | 121:ee02790d00b7 | 793 | { |
klauss | 121:ee02790d00b7 | 794 | if( debug_reconnect ) send_msg("Reconnect Extern wdt"); |
klauss | 121:ee02790d00b7 | 795 | reconnect_extern_wdt_socket(); |
klauss | 121:ee02790d00b7 | 796 | miss_wdt_send_pkg++; |
klauss | 121:ee02790d00b7 | 797 | } |
klauss | 121:ee02790d00b7 | 798 | } |
klauss | 121:ee02790d00b7 | 799 | } |
klauss | 121:ee02790d00b7 | 800 | } |
klauss | 121:ee02790d00b7 | 801 | |
klauss | 121:ee02790d00b7 | 802 | if( FD_ISSET( clock_sock.get_fd(), &fdSet ) ) |
klauss | 121:ee02790d00b7 | 803 | { |
klauss | 121:ee02790d00b7 | 804 | update_clock (); |
klauss | 121:ee02790d00b7 | 805 | } |
klauss | 121:ee02790d00b7 | 806 | } |
klauss | 121:ee02790d00b7 | 807 | |
klauss | 121:ee02790d00b7 | 808 | return ( ret ); |
klauss | 121:ee02790d00b7 | 809 | } |
klauss | 121:ee02790d00b7 | 810 | |
klauss | 121:ee02790d00b7 | 811 | int show_cb_content ( void ) |
klauss | 121:ee02790d00b7 | 812 | { |
klauss | 121:ee02790d00b7 | 813 | Call_Box * cb = find_CB ( v_cb, print_this_cb ); |
klauss | 121:ee02790d00b7 | 814 | if ( cb != NULL ) |
klauss | 121:ee02790d00b7 | 815 | { |
klauss | 121:ee02790d00b7 | 816 | cb -> print_yourself (); |
klauss | 121:ee02790d00b7 | 817 | } |
klauss | 121:ee02790d00b7 | 818 | else |
klauss | 121:ee02790d00b7 | 819 | { |
klauss | 121:ee02790d00b7 | 820 | if( print_values ) |
klauss | 121:ee02790d00b7 | 821 | { |
klauss | 121:ee02790d00b7 | 822 | debug_msg ("Objeto CBx ( %d ) nao encontrado", print_this_cb ); |
klauss | 121:ee02790d00b7 | 823 | } |
klauss | 121:ee02790d00b7 | 824 | else |
klauss | 121:ee02790d00b7 | 825 | { |
klauss | 121:ee02790d00b7 | 826 | send_msg ("Objeto CBx ( %d ) nao encontrado", print_this_cb ); |
klauss | 121:ee02790d00b7 | 827 | } |
klauss | 121:ee02790d00b7 | 828 | } |
klauss | 121:ee02790d00b7 | 829 | |
klauss | 121:ee02790d00b7 | 830 | return ( 0 ); |
klauss | 121:ee02790d00b7 | 831 | } |
klauss | 121:ee02790d00b7 | 832 | |
klauss | 121:ee02790d00b7 | 833 | int show_cb_content_all ( void ) |
klauss | 121:ee02790d00b7 | 834 | { |
klauss | 121:ee02790d00b7 | 835 | if ( v_cb -> size () == 0 ) |
klauss | 121:ee02790d00b7 | 836 | { |
klauss | 121:ee02790d00b7 | 837 | send_msg("known CBx :: 0"); |
klauss | 121:ee02790d00b7 | 838 | } |
klauss | 121:ee02790d00b7 | 839 | |
klauss | 121:ee02790d00b7 | 840 | for ( register uint8_t i = 0; i < v_cb->size(); i++ ) |
klauss | 121:ee02790d00b7 | 841 | { |
klauss | 121:ee02790d00b7 | 842 | Call_Box * cb = (Call_Box *)v_cb->get_element( i ); |
klauss | 121:ee02790d00b7 | 843 | |
klauss | 121:ee02790d00b7 | 844 | if ( cb != NULL ) |
klauss | 121:ee02790d00b7 | 845 | { |
klauss | 121:ee02790d00b7 | 846 | cb -> print_yourself (); |
klauss | 121:ee02790d00b7 | 847 | } |
klauss | 121:ee02790d00b7 | 848 | else |
klauss | 121:ee02790d00b7 | 849 | { |
klauss | 121:ee02790d00b7 | 850 | if ( print_values ) debug_msg ("Objeto CBx ( %d ) nao encontrado", i ); |
klauss | 121:ee02790d00b7 | 851 | } |
klauss | 121:ee02790d00b7 | 852 | } |
klauss | 121:ee02790d00b7 | 853 | |
klauss | 121:ee02790d00b7 | 854 | return ( 0 ); |
klauss | 121:ee02790d00b7 | 855 | } |
klauss | 121:ee02790d00b7 | 856 | |
klauss | 121:ee02790d00b7 | 857 | int show_rtp ( void ) |
klauss | 121:ee02790d00b7 | 858 | { |
klauss | 121:ee02790d00b7 | 859 | send_msg(":: RTP :: %u", v_cb->size() ); |
klauss | 121:ee02790d00b7 | 860 | |
klauss | 121:ee02790d00b7 | 861 | int ext_list[ MAX_CB_IN_A_BRANCH ]; |
klauss | 121:ee02790d00b7 | 862 | |
klauss | 121:ee02790d00b7 | 863 | if( v_cb->size() >= 1 ) { |
klauss | 121:ee02790d00b7 | 864 | for( register int i = 0; i < v_cb->size(); i++ ) |
klauss | 121:ee02790d00b7 | 865 | { |
klauss | 121:ee02790d00b7 | 866 | ext_list[ i ] = ( ( Call_Box * )v_cb->get_element( i ) )->get_ext(); |
klauss | 121:ee02790d00b7 | 867 | } |
klauss | 121:ee02790d00b7 | 868 | qsort( ext_list, v_cb->size(), sizeof( int ), ls_comp ); |
klauss | 121:ee02790d00b7 | 869 | } |
klauss | 121:ee02790d00b7 | 870 | |
klauss | 121:ee02790d00b7 | 871 | for ( register uint8_t i = 0; i < v_cb->size(); i++ ) |
klauss | 121:ee02790d00b7 | 872 | { |
klauss | 121:ee02790d00b7 | 873 | Call_Box * cb = find_CB( v_cb, ext_list[ i ] ); |
klauss | 121:ee02790d00b7 | 874 | if( cb != NULL ) |
klauss | 121:ee02790d00b7 | 875 | { |
klauss | 121:ee02790d00b7 | 876 | send_msg("CBX ( %d, %d ) - SIP ( %d, %d ) - RTP ( %d )", |
klauss | 121:ee02790d00b7 | 877 | cb -> get_ext (), |
klauss | 121:ee02790d00b7 | 878 | cb -> get_port (), |
klauss | 121:ee02790d00b7 | 879 | cb -> get_sip_ext (), |
klauss | 121:ee02790d00b7 | 880 | cb -> get_sip_port (), |
klauss | 121:ee02790d00b7 | 881 | cb -> get_rtp_port () |
klauss | 121:ee02790d00b7 | 882 | ); |
klauss | 121:ee02790d00b7 | 883 | } |
klauss | 121:ee02790d00b7 | 884 | } |
klauss | 121:ee02790d00b7 | 885 | |
klauss | 121:ee02790d00b7 | 886 | return ( 0 ); |
klauss | 121:ee02790d00b7 | 887 | } |
klauss | 121:ee02790d00b7 | 888 | |
klauss | 121:ee02790d00b7 | 889 | int fuck_rtp ( Vector * v_cb ) |
klauss | 121:ee02790d00b7 | 890 | { |
klauss | 121:ee02790d00b7 | 891 | Call_Box * cb = find_CB( v_cb, frtp_target ); |
klauss | 121:ee02790d00b7 | 892 | if ( cb != NULL ) |
klauss | 121:ee02790d00b7 | 893 | { |
klauss | 121:ee02790d00b7 | 894 | cb -> set_rtp_port ( -1008789032 ); |
klauss | 121:ee02790d00b7 | 895 | } |
klauss | 121:ee02790d00b7 | 896 | else |
klauss | 121:ee02790d00b7 | 897 | { |
klauss | 121:ee02790d00b7 | 898 | debug_msg("frtp fail"); |
klauss | 121:ee02790d00b7 | 899 | } |
klauss | 121:ee02790d00b7 | 900 | |
klauss | 121:ee02790d00b7 | 901 | return ( 0 ); |
klauss | 121:ee02790d00b7 | 902 | } |
klauss | 121:ee02790d00b7 | 903 | |
klauss | 121:ee02790d00b7 | 904 | int show_hex_cb_content ( void ) |
klauss | 121:ee02790d00b7 | 905 | { |
klauss | 121:ee02790d00b7 | 906 | uint8_t * ptr = ( uint8_t * ) find_CB ( v_cb, print_hex_this_cb ); |
klauss | 121:ee02790d00b7 | 907 | |
klauss | 121:ee02790d00b7 | 908 | if ( ptr != NULL ) |
klauss | 121:ee02790d00b7 | 909 | { |
klauss | 121:ee02790d00b7 | 910 | send_msg ("Values :: %p\r\n", ( void *) ptr ); |
klauss | 121:ee02790d00b7 | 911 | for ( register int i = 0; i < sizeof( Call_Box ); i++ ) |
klauss | 121:ee02790d00b7 | 912 | { |
klauss | 121:ee02790d00b7 | 913 | if( debug_uart3 ) pc.printf("%x", *ptr++ ); |
klauss | 121:ee02790d00b7 | 914 | |
klauss | 121:ee02790d00b7 | 915 | if ( ( i % 32 ) == 0 ) |
klauss | 121:ee02790d00b7 | 916 | { |
klauss | 121:ee02790d00b7 | 917 | if( i != 0 ) |
klauss | 121:ee02790d00b7 | 918 | { |
klauss | 121:ee02790d00b7 | 919 | if( debug_uart3 ) pc.printf("\n\r> "); |
klauss | 121:ee02790d00b7 | 920 | } |
klauss | 121:ee02790d00b7 | 921 | else |
klauss | 121:ee02790d00b7 | 922 | { |
klauss | 121:ee02790d00b7 | 923 | if( debug_uart3 ) pc.printf(" "); |
klauss | 121:ee02790d00b7 | 924 | } |
klauss | 121:ee02790d00b7 | 925 | } |
klauss | 121:ee02790d00b7 | 926 | else |
klauss | 121:ee02790d00b7 | 927 | { |
klauss | 121:ee02790d00b7 | 928 | if( debug_uart3 ) pc.printf(" "); |
klauss | 121:ee02790d00b7 | 929 | } |
klauss | 121:ee02790d00b7 | 930 | } |
klauss | 121:ee02790d00b7 | 931 | if ( debug_uart3 ) pc.printf("\n\r> "); |
klauss | 121:ee02790d00b7 | 932 | |
klauss | 121:ee02790d00b7 | 933 | if ( tcp_session ) { |
klauss | 121:ee02790d00b7 | 934 | char aux[ ( sizeof( Call_Box ) * 3 ) + 3 ]; |
klauss | 121:ee02790d00b7 | 935 | |
klauss | 121:ee02790d00b7 | 936 | for ( register int i = 0; i < ( sizeof( Call_Box ) * 3 ) + 3 ; i++ ) aux [ i ] = 0; |
klauss | 121:ee02790d00b7 | 937 | |
klauss | 121:ee02790d00b7 | 938 | uint8_t * ptr = ( uint8_t * ) find_CB ( v_cb, print_hex_this_cb ); |
klauss | 121:ee02790d00b7 | 939 | |
klauss | 121:ee02790d00b7 | 940 | for ( register int i = 0; i < sizeof( Call_Box ); i++ ) |
klauss | 121:ee02790d00b7 | 941 | { |
klauss | 121:ee02790d00b7 | 942 | char tmp[ 16 ]; |
klauss | 121:ee02790d00b7 | 943 | sprintf( tmp, "%x ", *ptr++ ); |
klauss | 121:ee02790d00b7 | 944 | strcat( aux, tmp ); |
klauss | 121:ee02790d00b7 | 945 | } |
klauss | 121:ee02790d00b7 | 946 | |
klauss | 121:ee02790d00b7 | 947 | strcat( aux, "\n\r\0" ); |
klauss | 121:ee02790d00b7 | 948 | tcp_client.send_all( ( char *)aux, strlen( (char * )aux ) ); |
klauss | 121:ee02790d00b7 | 949 | tcp_client.send_all( "\r\n> ", strlen( "\r\n> " ) ); |
klauss | 121:ee02790d00b7 | 950 | } |
klauss | 121:ee02790d00b7 | 951 | } |
klauss | 121:ee02790d00b7 | 952 | else |
klauss | 121:ee02790d00b7 | 953 | { |
klauss | 121:ee02790d00b7 | 954 | if ( print_values ) debug_msg ("Objeto CBx ( %d ) nao encontrado", print_this_cb ); |
klauss | 121:ee02790d00b7 | 955 | } |
klauss | 121:ee02790d00b7 | 956 | |
klauss | 121:ee02790d00b7 | 957 | return ( 0 ); |
klauss | 121:ee02790d00b7 | 958 | } |
klauss | 121:ee02790d00b7 | 959 | |
klauss | 121:ee02790d00b7 | 960 | int show_hex_cb_content_all () |
klauss | 121:ee02790d00b7 | 961 | { |
klauss | 121:ee02790d00b7 | 962 | if ( v_cb -> size () == 0 ) |
klauss | 121:ee02790d00b7 | 963 | { |
klauss | 121:ee02790d00b7 | 964 | send_msg("known CBx :: 0"); |
klauss | 121:ee02790d00b7 | 965 | } |
klauss | 121:ee02790d00b7 | 966 | |
klauss | 121:ee02790d00b7 | 967 | for ( register uint8_t j = 0; j < v_cb->size(); j++ ) |
klauss | 121:ee02790d00b7 | 968 | { |
klauss | 121:ee02790d00b7 | 969 | uint8_t * ptr = ( uint8_t * ) v_cb->get_element( j ); |
klauss | 121:ee02790d00b7 | 970 | |
klauss | 121:ee02790d00b7 | 971 | if ( ptr != NULL ) |
klauss | 121:ee02790d00b7 | 972 | { |
klauss | 121:ee02790d00b7 | 973 | send_msg ("Values :: %p\r\n", ( void *) ptr ); |
klauss | 121:ee02790d00b7 | 974 | for ( register int i = 0; i < sizeof( Call_Box ); i++ ) |
klauss | 121:ee02790d00b7 | 975 | { |
klauss | 121:ee02790d00b7 | 976 | if( debug_uart3 ) pc.printf("%x", *ptr++ ); |
klauss | 121:ee02790d00b7 | 977 | |
klauss | 121:ee02790d00b7 | 978 | if ( ( i % 32 ) == 0 ) |
klauss | 121:ee02790d00b7 | 979 | { |
klauss | 121:ee02790d00b7 | 980 | if( i != 0 ) |
klauss | 121:ee02790d00b7 | 981 | { |
klauss | 121:ee02790d00b7 | 982 | if( debug_uart3 ) pc.printf("\n\r> "); |
klauss | 121:ee02790d00b7 | 983 | } |
klauss | 121:ee02790d00b7 | 984 | else |
klauss | 121:ee02790d00b7 | 985 | { |
klauss | 121:ee02790d00b7 | 986 | if( debug_uart3 ) pc.printf(" "); |
klauss | 121:ee02790d00b7 | 987 | } |
klauss | 121:ee02790d00b7 | 988 | } |
klauss | 121:ee02790d00b7 | 989 | else |
klauss | 121:ee02790d00b7 | 990 | { |
klauss | 121:ee02790d00b7 | 991 | if( debug_uart3 ) pc.printf(" "); |
klauss | 121:ee02790d00b7 | 992 | } |
klauss | 121:ee02790d00b7 | 993 | } |
klauss | 121:ee02790d00b7 | 994 | if ( debug_uart3 ) pc.printf("\n\r> "); |
klauss | 121:ee02790d00b7 | 995 | |
klauss | 121:ee02790d00b7 | 996 | if ( tcp_session ) { |
klauss | 121:ee02790d00b7 | 997 | char aux[ ( sizeof( Call_Box ) * 3 ) + 3 ]; |
klauss | 121:ee02790d00b7 | 998 | |
klauss | 121:ee02790d00b7 | 999 | for ( register int i = 0; i < ( sizeof( Call_Box ) * 3 ) + 3 ; i++ ) aux [ i ] = 0; |
klauss | 121:ee02790d00b7 | 1000 | |
klauss | 121:ee02790d00b7 | 1001 | uint8_t * ptr = ( uint8_t * ) v_cb->get_element( j ); |
klauss | 121:ee02790d00b7 | 1002 | |
klauss | 121:ee02790d00b7 | 1003 | for ( register int i = 0; i < sizeof( Call_Box ); i++ ) |
klauss | 121:ee02790d00b7 | 1004 | { |
klauss | 121:ee02790d00b7 | 1005 | char tmp[ 16 ]; |
klauss | 121:ee02790d00b7 | 1006 | sprintf( tmp, "%x ", *ptr++ ); |
klauss | 121:ee02790d00b7 | 1007 | strcat( aux, tmp ); |
klauss | 121:ee02790d00b7 | 1008 | } |
klauss | 121:ee02790d00b7 | 1009 | |
klauss | 121:ee02790d00b7 | 1010 | strcat( aux, "\n\r\0" ); |
klauss | 121:ee02790d00b7 | 1011 | tcp_client.send_all( ( char *)aux, strlen( (char * )aux ) ); |
klauss | 121:ee02790d00b7 | 1012 | tcp_client.send_all( "\r\n> ", strlen( "\r\n> " ) ); |
klauss | 121:ee02790d00b7 | 1013 | } |
klauss | 121:ee02790d00b7 | 1014 | } |
klauss | 121:ee02790d00b7 | 1015 | else |
klauss | 121:ee02790d00b7 | 1016 | { |
klauss | 121:ee02790d00b7 | 1017 | if ( print_values ) |
klauss | 121:ee02790d00b7 | 1018 | { |
klauss | 121:ee02790d00b7 | 1019 | debug_msg ("Objeto CBx ( %d ) nao encontrado", j ); |
klauss | 121:ee02790d00b7 | 1020 | } |
klauss | 121:ee02790d00b7 | 1021 | else |
klauss | 121:ee02790d00b7 | 1022 | { |
klauss | 121:ee02790d00b7 | 1023 | send_msg ("Objeto CBx ( %d ) nao encontrado", j ); |
klauss | 121:ee02790d00b7 | 1024 | } |
klauss | 121:ee02790d00b7 | 1025 | } |
klauss | 121:ee02790d00b7 | 1026 | } |
klauss | 121:ee02790d00b7 | 1027 | |
klauss | 121:ee02790d00b7 | 1028 | return ( 0 ); |
klauss | 121:ee02790d00b7 | 1029 | } |
klauss | 121:ee02790d00b7 | 1030 | |
klauss | 121:ee02790d00b7 | 1031 | |
klauss | 121:ee02790d00b7 | 1032 | int show_cB_sip ( void ) |
klauss | 121:ee02790d00b7 | 1033 | { |
klauss | 121:ee02790d00b7 | 1034 | Call_Box * cb = find_CB ( v_cb, print_this_sip ); |
klauss | 121:ee02790d00b7 | 1035 | |
klauss | 121:ee02790d00b7 | 1036 | if ( cb != NULL ) |
klauss | 121:ee02790d00b7 | 1037 | { |
klauss | 121:ee02790d00b7 | 1038 | if( cb -> sip_print_yourself () == -1 ) |
klauss | 121:ee02790d00b7 | 1039 | { |
klauss | 121:ee02790d00b7 | 1040 | if( print_values ) |
klauss | 121:ee02790d00b7 | 1041 | { |
klauss | 121:ee02790d00b7 | 1042 | debug_msg("Sip param of %d equals NULL", print_this_sip ); |
klauss | 121:ee02790d00b7 | 1043 | } |
klauss | 121:ee02790d00b7 | 1044 | else |
klauss | 121:ee02790d00b7 | 1045 | { |
klauss | 121:ee02790d00b7 | 1046 | send_msg("Sip param of %d equals NULL", print_this_sip ); |
klauss | 121:ee02790d00b7 | 1047 | } |
klauss | 121:ee02790d00b7 | 1048 | } |
klauss | 121:ee02790d00b7 | 1049 | } |
klauss | 121:ee02790d00b7 | 1050 | else |
klauss | 121:ee02790d00b7 | 1051 | { |
klauss | 121:ee02790d00b7 | 1052 | if ( print_values ) |
klauss | 121:ee02790d00b7 | 1053 | { |
klauss | 121:ee02790d00b7 | 1054 | debug_msg ("Objeto CBx ( %d ) nao encontrado", print_this_cb ); |
klauss | 121:ee02790d00b7 | 1055 | } |
klauss | 121:ee02790d00b7 | 1056 | else |
klauss | 121:ee02790d00b7 | 1057 | { |
klauss | 121:ee02790d00b7 | 1058 | send_msg ("Objeto CBx ( %d ) nao encontrado", print_this_cb ); |
klauss | 121:ee02790d00b7 | 1059 | } |
klauss | 121:ee02790d00b7 | 1060 | } |
klauss | 121:ee02790d00b7 | 1061 | |
klauss | 121:ee02790d00b7 | 1062 | return ( 0 ); |
klauss | 121:ee02790d00b7 | 1063 | } |
klauss | 121:ee02790d00b7 | 1064 | int show_cB_sip_all ( void ) |
klauss | 121:ee02790d00b7 | 1065 | { |
klauss | 121:ee02790d00b7 | 1066 | if ( v_cb -> size () == 0 ) |
klauss | 121:ee02790d00b7 | 1067 | { |
klauss | 121:ee02790d00b7 | 1068 | send_msg("known CBx :: 0"); |
klauss | 121:ee02790d00b7 | 1069 | } |
klauss | 121:ee02790d00b7 | 1070 | |
klauss | 121:ee02790d00b7 | 1071 | for ( register uint8_t i = 0; i < v_cb->size(); i++ ) |
klauss | 121:ee02790d00b7 | 1072 | { |
klauss | 121:ee02790d00b7 | 1073 | Call_Box * cb = (Call_Box *)v_cb->get_element( i ); |
klauss | 121:ee02790d00b7 | 1074 | |
klauss | 121:ee02790d00b7 | 1075 | if ( cb != NULL ) |
klauss | 121:ee02790d00b7 | 1076 | { |
klauss | 121:ee02790d00b7 | 1077 | if ( cb -> sip_print_yourself () == -1 ) |
klauss | 121:ee02790d00b7 | 1078 | { |
klauss | 121:ee02790d00b7 | 1079 | if ( print_values ) |
klauss | 121:ee02790d00b7 | 1080 | { |
klauss | 121:ee02790d00b7 | 1081 | debug_msg ("Sip param of %d equals NULL", print_this_sip ); |
klauss | 121:ee02790d00b7 | 1082 | } |
klauss | 121:ee02790d00b7 | 1083 | else |
klauss | 121:ee02790d00b7 | 1084 | { |
klauss | 121:ee02790d00b7 | 1085 | send_msg ("Sip param of %d equals NULL", print_this_sip ); |
klauss | 121:ee02790d00b7 | 1086 | } |
klauss | 121:ee02790d00b7 | 1087 | } |
klauss | 121:ee02790d00b7 | 1088 | } |
klauss | 121:ee02790d00b7 | 1089 | else |
klauss | 121:ee02790d00b7 | 1090 | { |
klauss | 121:ee02790d00b7 | 1091 | if( print_values ) |
klauss | 121:ee02790d00b7 | 1092 | { |
klauss | 121:ee02790d00b7 | 1093 | debug_msg ("CBx %d not found", print_this_sip ); |
klauss | 121:ee02790d00b7 | 1094 | } |
klauss | 121:ee02790d00b7 | 1095 | else |
klauss | 121:ee02790d00b7 | 1096 | { |
klauss | 121:ee02790d00b7 | 1097 | send_msg ("CBx %d not found", print_this_sip ); |
klauss | 121:ee02790d00b7 | 1098 | } |
klauss | 121:ee02790d00b7 | 1099 | } |
klauss | 121:ee02790d00b7 | 1100 | } |
klauss | 121:ee02790d00b7 | 1101 | return ( 0 ); |
klauss | 121:ee02790d00b7 | 1102 | } |
klauss | 121:ee02790d00b7 | 1103 | |
klauss | 121:ee02790d00b7 | 1104 | int show_cB_hex_sip ( void ) |
klauss | 121:ee02790d00b7 | 1105 | { |
klauss | 121:ee02790d00b7 | 1106 | uint8_t * ptr = NULL; |
klauss | 121:ee02790d00b7 | 1107 | |
klauss | 121:ee02790d00b7 | 1108 | Call_Box * cb = find_CB ( v_cb, print_hex_this_sip ); |
klauss | 121:ee02790d00b7 | 1109 | if( cb != NULL ) |
klauss | 121:ee02790d00b7 | 1110 | { |
klauss | 121:ee02790d00b7 | 1111 | ptr = ( uint8_t * ) cb -> get_sip (); |
klauss | 121:ee02790d00b7 | 1112 | } |
klauss | 121:ee02790d00b7 | 1113 | |
klauss | 121:ee02790d00b7 | 1114 | if ( ptr != NULL ) |
klauss | 121:ee02790d00b7 | 1115 | { |
klauss | 121:ee02790d00b7 | 1116 | send_msg ("Values :: %p\r\n", ( void *) ptr ); |
klauss | 121:ee02790d00b7 | 1117 | for ( register int i = 0; i < sizeof( Sip ); i++ ) |
klauss | 121:ee02790d00b7 | 1118 | { |
klauss | 121:ee02790d00b7 | 1119 | if( debug_uart3 ) pc.printf("%x", *ptr++ ); |
klauss | 121:ee02790d00b7 | 1120 | |
klauss | 121:ee02790d00b7 | 1121 | if ( ( i % 32 ) == 0 ) |
klauss | 121:ee02790d00b7 | 1122 | { |
klauss | 121:ee02790d00b7 | 1123 | if( i != 0 ) |
klauss | 121:ee02790d00b7 | 1124 | { |
klauss | 121:ee02790d00b7 | 1125 | if( debug_uart3 ) pc.printf("\n\r> "); |
klauss | 121:ee02790d00b7 | 1126 | } |
klauss | 121:ee02790d00b7 | 1127 | else |
klauss | 121:ee02790d00b7 | 1128 | { |
klauss | 121:ee02790d00b7 | 1129 | if( debug_uart3 ) pc.printf(" "); |
klauss | 121:ee02790d00b7 | 1130 | } |
klauss | 121:ee02790d00b7 | 1131 | } |
klauss | 121:ee02790d00b7 | 1132 | else |
klauss | 121:ee02790d00b7 | 1133 | { |
klauss | 121:ee02790d00b7 | 1134 | if( debug_uart3 ) pc.printf(" "); |
klauss | 121:ee02790d00b7 | 1135 | } |
klauss | 121:ee02790d00b7 | 1136 | } |
klauss | 121:ee02790d00b7 | 1137 | if ( debug_uart3 ) pc.printf("\n\r> "); |
klauss | 121:ee02790d00b7 | 1138 | |
klauss | 121:ee02790d00b7 | 1139 | if ( tcp_session ) { |
klauss | 121:ee02790d00b7 | 1140 | char aux[ ( 32 * 3 ) + 5 ]; |
klauss | 121:ee02790d00b7 | 1141 | |
klauss | 121:ee02790d00b7 | 1142 | for ( register int i = 0; i < ( 32 * 3 ) + 5 ; i++ ) aux [ i ] = 0; |
klauss | 121:ee02790d00b7 | 1143 | |
klauss | 121:ee02790d00b7 | 1144 | ptr = NULL; |
klauss | 121:ee02790d00b7 | 1145 | |
klauss | 121:ee02790d00b7 | 1146 | print_hex_sip_var = false; |
klauss | 121:ee02790d00b7 | 1147 | Call_Box * cb = find_CB ( v_cb, print_hex_this_sip ); |
klauss | 121:ee02790d00b7 | 1148 | if( cb != NULL ) |
klauss | 121:ee02790d00b7 | 1149 | { |
klauss | 121:ee02790d00b7 | 1150 | ptr = ( uint8_t * ) cb -> get_sip (); |
klauss | 121:ee02790d00b7 | 1151 | } |
klauss | 121:ee02790d00b7 | 1152 | |
klauss | 121:ee02790d00b7 | 1153 | if ( ptr != NULL ) |
klauss | 121:ee02790d00b7 | 1154 | { |
klauss | 121:ee02790d00b7 | 1155 | bool finished = false; |
klauss | 121:ee02790d00b7 | 1156 | volatile int i = 0; |
klauss | 121:ee02790d00b7 | 1157 | int count = 0; |
klauss | 121:ee02790d00b7 | 1158 | Timer dont_overwrite_tcp_buffer; |
klauss | 121:ee02790d00b7 | 1159 | dont_overwrite_tcp_buffer.reset (); |
klauss | 121:ee02790d00b7 | 1160 | dont_overwrite_tcp_buffer.start (); |
klauss | 121:ee02790d00b7 | 1161 | |
klauss | 121:ee02790d00b7 | 1162 | while ( !finished ) |
klauss | 121:ee02790d00b7 | 1163 | { |
klauss | 121:ee02790d00b7 | 1164 | if( dont_overwrite_tcp_buffer.read_ms () >= 500 ) |
klauss | 121:ee02790d00b7 | 1165 | { |
klauss | 121:ee02790d00b7 | 1166 | dont_overwrite_tcp_buffer.reset(); |
klauss | 121:ee02790d00b7 | 1167 | for ( ; i < sizeof( Sip ); i++ ) |
klauss | 121:ee02790d00b7 | 1168 | { |
klauss | 121:ee02790d00b7 | 1169 | char tmp[ 16 ]; |
klauss | 121:ee02790d00b7 | 1170 | sprintf( tmp, "%x ", *ptr++ ); |
klauss | 121:ee02790d00b7 | 1171 | strcat( aux, tmp ); |
klauss | 121:ee02790d00b7 | 1172 | count++; |
klauss | 121:ee02790d00b7 | 1173 | |
klauss | 121:ee02790d00b7 | 1174 | if ( count >= 32 ) |
klauss | 121:ee02790d00b7 | 1175 | { |
klauss | 121:ee02790d00b7 | 1176 | count = 0; |
klauss | 121:ee02790d00b7 | 1177 | i++; |
klauss | 121:ee02790d00b7 | 1178 | break; |
klauss | 121:ee02790d00b7 | 1179 | } |
klauss | 121:ee02790d00b7 | 1180 | } |
klauss | 121:ee02790d00b7 | 1181 | strcat ( aux, "\n\r\0" ); |
klauss | 121:ee02790d00b7 | 1182 | tcp_client.send_all ( ( char *)aux, strlen( (char * )aux ) ); |
klauss | 121:ee02790d00b7 | 1183 | if ( i >= sizeof ( Sip ) ) finished = true; |
klauss | 121:ee02790d00b7 | 1184 | strcpy ( aux, "\0" ); |
klauss | 121:ee02790d00b7 | 1185 | } |
klauss | 121:ee02790d00b7 | 1186 | } |
klauss | 121:ee02790d00b7 | 1187 | dont_overwrite_tcp_buffer.reset(); |
klauss | 121:ee02790d00b7 | 1188 | dont_overwrite_tcp_buffer.stop(); |
klauss | 121:ee02790d00b7 | 1189 | tcp_client.send_all ( "\r\n> ", strlen( "\r\n> " ) ); |
klauss | 121:ee02790d00b7 | 1190 | } |
klauss | 121:ee02790d00b7 | 1191 | } |
klauss | 121:ee02790d00b7 | 1192 | } |
klauss | 121:ee02790d00b7 | 1193 | else |
klauss | 121:ee02790d00b7 | 1194 | { |
klauss | 121:ee02790d00b7 | 1195 | if ( print_values ) debug_msg ("Objeto CBx ( %d ) nao encontrado", print_this_cb ); |
klauss | 121:ee02790d00b7 | 1196 | } |
klauss | 121:ee02790d00b7 | 1197 | |
klauss | 121:ee02790d00b7 | 1198 | |
klauss | 121:ee02790d00b7 | 1199 | return ( 0 ); |
klauss | 121:ee02790d00b7 | 1200 | } |
klauss | 121:ee02790d00b7 | 1201 | |
klauss | 121:ee02790d00b7 | 1202 | int show_rtp_on_call ( void ) |
klauss | 121:ee02790d00b7 | 1203 | { |
klauss | 121:ee02790d00b7 | 1204 | send_msg(":: CAll RTP :: %u", v_call->size() ); |
klauss | 121:ee02790d00b7 | 1205 | |
klauss | 121:ee02790d00b7 | 1206 | for( register uint8_t i = 0; i < v_call->size(); i++ ) { |
klauss | 121:ee02790d00b7 | 1207 | VZ_call * call = ( VZ_call * )v_call->get_element( i ); |
klauss | 121:ee02790d00b7 | 1208 | if( call != NULL ) |
klauss | 121:ee02790d00b7 | 1209 | { |
klauss | 121:ee02790d00b7 | 1210 | send_msg("CBX ( %d, %d ) - Server ( %d, %d )", |
klauss | 121:ee02790d00b7 | 1211 | call->get_cb_ext(), |
klauss | 121:ee02790d00b7 | 1212 | call->get_cb_port(), |
klauss | 121:ee02790d00b7 | 1213 | call->get_rtp_server_ext(), |
klauss | 121:ee02790d00b7 | 1214 | call->get_rtp_server_port() |
klauss | 121:ee02790d00b7 | 1215 | ); |
klauss | 121:ee02790d00b7 | 1216 | } |
klauss | 121:ee02790d00b7 | 1217 | } |
klauss | 121:ee02790d00b7 | 1218 | |
klauss | 121:ee02790d00b7 | 1219 | return ( 0 ); |
klauss | 121:ee02790d00b7 | 1220 | } |
klauss | 121:ee02790d00b7 | 1221 | |
klauss | 121:ee02790d00b7 | 1222 | int show_call ( void ) |
klauss | 121:ee02790d00b7 | 1223 | { |
klauss | 121:ee02790d00b7 | 1224 | VZ_call * call = __find_Call__( v_call, print_this_call ); |
klauss | 121:ee02790d00b7 | 1225 | |
klauss | 121:ee02790d00b7 | 1226 | if ( call != NULL ) |
klauss | 121:ee02790d00b7 | 1227 | { |
klauss | 121:ee02790d00b7 | 1228 | send_msg ("Values :: %p\r\n", ( void *) call ); |
klauss | 121:ee02790d00b7 | 1229 | call -> print_yourself (); |
klauss | 121:ee02790d00b7 | 1230 | } |
klauss | 121:ee02790d00b7 | 1231 | else |
klauss | 121:ee02790d00b7 | 1232 | { |
klauss | 121:ee02790d00b7 | 1233 | if( print_values ) |
klauss | 121:ee02790d00b7 | 1234 | { |
klauss | 121:ee02790d00b7 | 1235 | debug_msg("Call %d not found", print_this_call ); |
klauss | 121:ee02790d00b7 | 1236 | } |
klauss | 121:ee02790d00b7 | 1237 | else |
klauss | 121:ee02790d00b7 | 1238 | { |
klauss | 121:ee02790d00b7 | 1239 | send_msg("Call %d not found", print_this_call ); |
klauss | 121:ee02790d00b7 | 1240 | } |
klauss | 121:ee02790d00b7 | 1241 | } |
klauss | 121:ee02790d00b7 | 1242 | |
klauss | 121:ee02790d00b7 | 1243 | return ( 0 ); |
klauss | 121:ee02790d00b7 | 1244 | } |
klauss | 121:ee02790d00b7 | 1245 | |
klauss | 121:ee02790d00b7 | 1246 | int show_hex_call ( void ) |
klauss | 121:ee02790d00b7 | 1247 | { |
klauss | 121:ee02790d00b7 | 1248 | VZ_call * call = __find_Call__( v_call, print_hex_this_call ); |
klauss | 121:ee02790d00b7 | 1249 | |
klauss | 121:ee02790d00b7 | 1250 | uint8_t * ptr = NULL; |
klauss | 121:ee02790d00b7 | 1251 | if( call != NULL ) |
klauss | 121:ee02790d00b7 | 1252 | { |
klauss | 121:ee02790d00b7 | 1253 | ptr = ( uint8_t * ) call; |
klauss | 121:ee02790d00b7 | 1254 | } |
klauss | 121:ee02790d00b7 | 1255 | |
klauss | 121:ee02790d00b7 | 1256 | if ( ptr != NULL ) |
klauss | 121:ee02790d00b7 | 1257 | { |
klauss | 121:ee02790d00b7 | 1258 | send_msg ("Values :: %p\r\n", ( void *) ptr ); |
klauss | 121:ee02790d00b7 | 1259 | for ( register int i = 0; i < sizeof( VZ_call ); i++ ) |
klauss | 121:ee02790d00b7 | 1260 | { |
klauss | 121:ee02790d00b7 | 1261 | if( debug_uart3 ) pc.printf("%x", *ptr++ ); |
klauss | 121:ee02790d00b7 | 1262 | |
klauss | 121:ee02790d00b7 | 1263 | if ( ( i % 32 ) == 0 ) |
klauss | 121:ee02790d00b7 | 1264 | { |
klauss | 121:ee02790d00b7 | 1265 | if( i != 0 ) |
klauss | 121:ee02790d00b7 | 1266 | { |
klauss | 121:ee02790d00b7 | 1267 | if( debug_uart3 ) pc.printf("\n\r> "); |
klauss | 121:ee02790d00b7 | 1268 | } |
klauss | 121:ee02790d00b7 | 1269 | else |
klauss | 121:ee02790d00b7 | 1270 | { |
klauss | 121:ee02790d00b7 | 1271 | if( debug_uart3 ) pc.printf(" "); |
klauss | 121:ee02790d00b7 | 1272 | } |
klauss | 121:ee02790d00b7 | 1273 | } |
klauss | 121:ee02790d00b7 | 1274 | else |
klauss | 121:ee02790d00b7 | 1275 | { |
klauss | 121:ee02790d00b7 | 1276 | if( debug_uart3 ) pc.printf(" "); |
klauss | 121:ee02790d00b7 | 1277 | } |
klauss | 121:ee02790d00b7 | 1278 | } |
klauss | 121:ee02790d00b7 | 1279 | if ( debug_uart3 ) pc.printf("\n\r> "); |
klauss | 121:ee02790d00b7 | 1280 | |
klauss | 121:ee02790d00b7 | 1281 | if ( tcp_session ) { |
klauss | 121:ee02790d00b7 | 1282 | char aux[ ( 32 * 3 ) + 5 ]; |
klauss | 121:ee02790d00b7 | 1283 | |
klauss | 121:ee02790d00b7 | 1284 | for ( register int i = 0; i < ( 32 * 3 ) + 5 ; i++ ) aux [ i ] = 0; |
klauss | 121:ee02790d00b7 | 1285 | |
klauss | 121:ee02790d00b7 | 1286 | ptr = NULL; |
klauss | 121:ee02790d00b7 | 1287 | |
klauss | 121:ee02790d00b7 | 1288 | VZ_call * call = __find_Call__( v_call, print_hex_this_call ); |
klauss | 121:ee02790d00b7 | 1289 | |
klauss | 121:ee02790d00b7 | 1290 | uint8_t * ptr = NULL; |
klauss | 121:ee02790d00b7 | 1291 | if( call != NULL ) |
klauss | 121:ee02790d00b7 | 1292 | { |
klauss | 121:ee02790d00b7 | 1293 | ptr = ( uint8_t * ) call; |
klauss | 121:ee02790d00b7 | 1294 | } |
klauss | 121:ee02790d00b7 | 1295 | |
klauss | 121:ee02790d00b7 | 1296 | if ( ptr != NULL ) |
klauss | 121:ee02790d00b7 | 1297 | { |
klauss | 121:ee02790d00b7 | 1298 | bool finished = false; |
klauss | 121:ee02790d00b7 | 1299 | volatile int i = 0; |
klauss | 121:ee02790d00b7 | 1300 | int count = 0; |
klauss | 121:ee02790d00b7 | 1301 | Timer dont_overwrite_tcp_buffer; |
klauss | 121:ee02790d00b7 | 1302 | dont_overwrite_tcp_buffer.reset (); |
klauss | 121:ee02790d00b7 | 1303 | dont_overwrite_tcp_buffer.start (); |
klauss | 121:ee02790d00b7 | 1304 | |
klauss | 121:ee02790d00b7 | 1305 | while ( !finished ) |
klauss | 121:ee02790d00b7 | 1306 | { |
klauss | 121:ee02790d00b7 | 1307 | if( dont_overwrite_tcp_buffer.read_ms () >= 20 ) |
klauss | 121:ee02790d00b7 | 1308 | { |
klauss | 121:ee02790d00b7 | 1309 | dont_overwrite_tcp_buffer.reset(); |
klauss | 121:ee02790d00b7 | 1310 | for ( ; i < sizeof( VZ_call ); i++ ) |
klauss | 121:ee02790d00b7 | 1311 | { |
klauss | 121:ee02790d00b7 | 1312 | char tmp[ 16 ]; |
klauss | 121:ee02790d00b7 | 1313 | sprintf( tmp, "%x ", *ptr++ ); |
klauss | 121:ee02790d00b7 | 1314 | strcat( aux, tmp ); |
klauss | 121:ee02790d00b7 | 1315 | count++; |
klauss | 121:ee02790d00b7 | 1316 | |
klauss | 121:ee02790d00b7 | 1317 | if ( count >= 32 ) |
klauss | 121:ee02790d00b7 | 1318 | { |
klauss | 121:ee02790d00b7 | 1319 | count = 0; |
klauss | 121:ee02790d00b7 | 1320 | i++; |
klauss | 121:ee02790d00b7 | 1321 | break; |
klauss | 121:ee02790d00b7 | 1322 | } |
klauss | 121:ee02790d00b7 | 1323 | } |
klauss | 121:ee02790d00b7 | 1324 | strcat ( aux, "\n\r\0" ); |
klauss | 121:ee02790d00b7 | 1325 | tcp_client.send_all ( ( char *)aux, strlen( (char * )aux ) ); |
klauss | 121:ee02790d00b7 | 1326 | if ( i >= sizeof ( VZ_call ) ) finished = true; |
klauss | 121:ee02790d00b7 | 1327 | strcpy ( aux, "\0" ); |
klauss | 121:ee02790d00b7 | 1328 | } |
klauss | 121:ee02790d00b7 | 1329 | } |
klauss | 121:ee02790d00b7 | 1330 | dont_overwrite_tcp_buffer.reset(); |
klauss | 121:ee02790d00b7 | 1331 | dont_overwrite_tcp_buffer.stop(); |
klauss | 121:ee02790d00b7 | 1332 | tcp_client.send_all ( "\r\n> ", strlen( "\r\n> " ) ); |
klauss | 121:ee02790d00b7 | 1333 | } |
klauss | 121:ee02790d00b7 | 1334 | } |
klauss | 121:ee02790d00b7 | 1335 | } |
klauss | 121:ee02790d00b7 | 1336 | else |
klauss | 121:ee02790d00b7 | 1337 | { |
klauss | 121:ee02790d00b7 | 1338 | if( print_values ) |
klauss | 121:ee02790d00b7 | 1339 | { |
klauss | 121:ee02790d00b7 | 1340 | debug_msg("Call %d not found", print_this_call ); |
klauss | 121:ee02790d00b7 | 1341 | } |
klauss | 121:ee02790d00b7 | 1342 | else |
klauss | 121:ee02790d00b7 | 1343 | { |
klauss | 121:ee02790d00b7 | 1344 | send_msg("Call %d not found", print_this_call ); |
klauss | 121:ee02790d00b7 | 1345 | } |
klauss | 121:ee02790d00b7 | 1346 | } |
klauss | 121:ee02790d00b7 | 1347 | |
klauss | 121:ee02790d00b7 | 1348 | return ( 0 ); |
klauss | 121:ee02790d00b7 | 1349 | } |
klauss | 121:ee02790d00b7 | 1350 | |
klauss | 121:ee02790d00b7 | 1351 | |
klauss | 121:ee02790d00b7 | 1352 | int show_cb_rtp ( void ) |
klauss | 121:ee02790d00b7 | 1353 | { |
klauss | 121:ee02790d00b7 | 1354 | VZ_call * call = __find_Call__( v_call, print_hex_this_rtp ); |
klauss | 121:ee02790d00b7 | 1355 | |
klauss | 121:ee02790d00b7 | 1356 | uint8_t * ptr = NULL; |
klauss | 121:ee02790d00b7 | 1357 | if( call != NULL ) |
klauss | 121:ee02790d00b7 | 1358 | { |
klauss | 121:ee02790d00b7 | 1359 | ptr = ( uint8_t * ) call -> check_rtp (); |
klauss | 121:ee02790d00b7 | 1360 | } |
klauss | 121:ee02790d00b7 | 1361 | |
klauss | 121:ee02790d00b7 | 1362 | if ( ptr != NULL ) |
klauss | 121:ee02790d00b7 | 1363 | { |
klauss | 121:ee02790d00b7 | 1364 | send_msg ("Values :: %p\r\n", ( void *) ptr ); |
klauss | 121:ee02790d00b7 | 1365 | for ( register int i = 0; i < sizeof( RTP ); i++ ) |
klauss | 121:ee02790d00b7 | 1366 | { |
klauss | 121:ee02790d00b7 | 1367 | if( debug_uart3 ) pc.printf("%x", *ptr++ ); |
klauss | 121:ee02790d00b7 | 1368 | |
klauss | 121:ee02790d00b7 | 1369 | if ( ( i % 32 ) == 0 ) |
klauss | 121:ee02790d00b7 | 1370 | { |
klauss | 121:ee02790d00b7 | 1371 | if( i != 0 ) |
klauss | 121:ee02790d00b7 | 1372 | { |
klauss | 121:ee02790d00b7 | 1373 | if( debug_uart3 ) pc.printf("\n\r> "); |
klauss | 121:ee02790d00b7 | 1374 | } |
klauss | 121:ee02790d00b7 | 1375 | else |
klauss | 121:ee02790d00b7 | 1376 | { |
klauss | 121:ee02790d00b7 | 1377 | if( debug_uart3 ) pc.printf(" "); |
klauss | 121:ee02790d00b7 | 1378 | } |
klauss | 121:ee02790d00b7 | 1379 | } |
klauss | 121:ee02790d00b7 | 1380 | else |
klauss | 121:ee02790d00b7 | 1381 | { |
klauss | 121:ee02790d00b7 | 1382 | if( debug_uart3 ) pc.printf(" "); |
klauss | 121:ee02790d00b7 | 1383 | } |
klauss | 121:ee02790d00b7 | 1384 | } |
klauss | 121:ee02790d00b7 | 1385 | if ( debug_uart3 ) pc.printf("\n\r> "); |
klauss | 121:ee02790d00b7 | 1386 | |
klauss | 121:ee02790d00b7 | 1387 | if ( tcp_session ) { |
klauss | 121:ee02790d00b7 | 1388 | char aux[ ( 32 * 3 ) + 5 ]; |
klauss | 121:ee02790d00b7 | 1389 | |
klauss | 121:ee02790d00b7 | 1390 | for ( register int i = 0; i < ( 32 * 3 ) + 5 ; i++ ) aux [ i ] = 0; |
klauss | 121:ee02790d00b7 | 1391 | |
klauss | 121:ee02790d00b7 | 1392 | ptr = NULL; |
klauss | 121:ee02790d00b7 | 1393 | |
klauss | 121:ee02790d00b7 | 1394 | VZ_call * call = __find_Call__( v_call, print_hex_this_rtp ); |
klauss | 121:ee02790d00b7 | 1395 | |
klauss | 121:ee02790d00b7 | 1396 | uint8_t * ptr = NULL; |
klauss | 121:ee02790d00b7 | 1397 | if( call != NULL ) |
klauss | 121:ee02790d00b7 | 1398 | { |
klauss | 121:ee02790d00b7 | 1399 | ptr = ( uint8_t * ) call -> check_rtp (); |
klauss | 121:ee02790d00b7 | 1400 | } |
klauss | 121:ee02790d00b7 | 1401 | |
klauss | 121:ee02790d00b7 | 1402 | if ( ptr != NULL ) |
klauss | 121:ee02790d00b7 | 1403 | { |
klauss | 121:ee02790d00b7 | 1404 | bool finished = false; |
klauss | 121:ee02790d00b7 | 1405 | volatile int i = 0; |
klauss | 121:ee02790d00b7 | 1406 | int count = 0; |
klauss | 121:ee02790d00b7 | 1407 | Timer dont_overwrite_tcp_buffer; |
klauss | 121:ee02790d00b7 | 1408 | dont_overwrite_tcp_buffer.reset (); |
klauss | 121:ee02790d00b7 | 1409 | dont_overwrite_tcp_buffer.start (); |
klauss | 121:ee02790d00b7 | 1410 | |
klauss | 121:ee02790d00b7 | 1411 | while ( !finished ) |
klauss | 121:ee02790d00b7 | 1412 | { |
klauss | 121:ee02790d00b7 | 1413 | if( dont_overwrite_tcp_buffer.read_ms () >= 20 ) |
klauss | 121:ee02790d00b7 | 1414 | { |
klauss | 121:ee02790d00b7 | 1415 | dont_overwrite_tcp_buffer.reset(); |
klauss | 121:ee02790d00b7 | 1416 | for ( ; i < sizeof( RTP ); i++ ) |
klauss | 121:ee02790d00b7 | 1417 | { |
klauss | 121:ee02790d00b7 | 1418 | char tmp[ 16 ]; |
klauss | 121:ee02790d00b7 | 1419 | sprintf( tmp, "%x ", *ptr++ ); |
klauss | 121:ee02790d00b7 | 1420 | strcat( aux, tmp ); |
klauss | 121:ee02790d00b7 | 1421 | count++; |
klauss | 121:ee02790d00b7 | 1422 | |
klauss | 121:ee02790d00b7 | 1423 | if ( count >= 32 ) |
klauss | 121:ee02790d00b7 | 1424 | { |
klauss | 121:ee02790d00b7 | 1425 | count = 0; |
klauss | 121:ee02790d00b7 | 1426 | i++; |
klauss | 121:ee02790d00b7 | 1427 | break; |
klauss | 121:ee02790d00b7 | 1428 | } |
klauss | 121:ee02790d00b7 | 1429 | } |
klauss | 121:ee02790d00b7 | 1430 | strcat ( aux, "\n\r\0" ); |
klauss | 121:ee02790d00b7 | 1431 | tcp_client.send_all ( ( char *)aux, strlen( (char * )aux ) ); |
klauss | 121:ee02790d00b7 | 1432 | if ( i >= sizeof ( RTP ) ) finished = true; |
klauss | 121:ee02790d00b7 | 1433 | strcpy ( aux, "\0" ); |
klauss | 121:ee02790d00b7 | 1434 | } |
klauss | 121:ee02790d00b7 | 1435 | } |
klauss | 121:ee02790d00b7 | 1436 | dont_overwrite_tcp_buffer.reset(); |
klauss | 121:ee02790d00b7 | 1437 | dont_overwrite_tcp_buffer.stop(); |
klauss | 121:ee02790d00b7 | 1438 | tcp_client.send_all ( "\r\n> ", strlen( "\r\n> " ) ); |
klauss | 121:ee02790d00b7 | 1439 | } |
klauss | 121:ee02790d00b7 | 1440 | } |
klauss | 121:ee02790d00b7 | 1441 | } |
klauss | 121:ee02790d00b7 | 1442 | else |
klauss | 121:ee02790d00b7 | 1443 | { |
klauss | 121:ee02790d00b7 | 1444 | if( print_values ) |
klauss | 121:ee02790d00b7 | 1445 | { |
klauss | 121:ee02790d00b7 | 1446 | debug_msg("Call %d not found", print_this_rtp ); |
klauss | 121:ee02790d00b7 | 1447 | } |
klauss | 121:ee02790d00b7 | 1448 | else |
klauss | 121:ee02790d00b7 | 1449 | { |
klauss | 121:ee02790d00b7 | 1450 | send_msg("Call %d not found", print_this_rtp ); |
klauss | 121:ee02790d00b7 | 1451 | } |
klauss | 121:ee02790d00b7 | 1452 | } |
klauss | 121:ee02790d00b7 | 1453 | |
klauss | 121:ee02790d00b7 | 1454 | return ( 0 ); |
klauss | 121:ee02790d00b7 | 1455 | } |
klauss | 121:ee02790d00b7 | 1456 | |
klauss | 121:ee02790d00b7 | 1457 | int show_cb_hex_rtp ( void ) |
klauss | 121:ee02790d00b7 | 1458 | { |
klauss | 121:ee02790d00b7 | 1459 | VZ_call * call = __find_Call__( v_call, print_this_rtp ); |
klauss | 121:ee02790d00b7 | 1460 | |
klauss | 121:ee02790d00b7 | 1461 | if ( call != NULL ) |
klauss | 121:ee02790d00b7 | 1462 | { |
klauss | 121:ee02790d00b7 | 1463 | if ( call -> check_rtp () != NULL ) |
klauss | 121:ee02790d00b7 | 1464 | { |
klauss | 121:ee02790d00b7 | 1465 | send_msg ("Values :: %p\r\n", ( void *) call -> check_rtp () ); |
klauss | 121:ee02790d00b7 | 1466 | call -> rtp_print_yourself (); |
klauss | 121:ee02790d00b7 | 1467 | } |
klauss | 121:ee02790d00b7 | 1468 | else |
klauss | 121:ee02790d00b7 | 1469 | { |
klauss | 121:ee02790d00b7 | 1470 | if( print_values ) |
klauss | 121:ee02790d00b7 | 1471 | { |
klauss | 121:ee02790d00b7 | 1472 | debug_msg("Call->RTP %d not found", print_this_rtp ); |
klauss | 121:ee02790d00b7 | 1473 | } |
klauss | 121:ee02790d00b7 | 1474 | else |
klauss | 121:ee02790d00b7 | 1475 | { |
klauss | 121:ee02790d00b7 | 1476 | send_msg("Call->RTP %d not found", print_this_rtp ); |
klauss | 121:ee02790d00b7 | 1477 | } |
klauss | 121:ee02790d00b7 | 1478 | } |
klauss | 121:ee02790d00b7 | 1479 | } |
klauss | 121:ee02790d00b7 | 1480 | else |
klauss | 121:ee02790d00b7 | 1481 | { |
klauss | 121:ee02790d00b7 | 1482 | if( print_values ) |
klauss | 121:ee02790d00b7 | 1483 | { |
klauss | 121:ee02790d00b7 | 1484 | debug_msg("Call->RTP %d not found", print_this_rtp ); |
klauss | 121:ee02790d00b7 | 1485 | } |
klauss | 121:ee02790d00b7 | 1486 | else |
klauss | 121:ee02790d00b7 | 1487 | { |
klauss | 121:ee02790d00b7 | 1488 | send_msg("Call->RTP %d not found", print_this_rtp ); |
klauss | 121:ee02790d00b7 | 1489 | } |
klauss | 121:ee02790d00b7 | 1490 | } |
klauss | 121:ee02790d00b7 | 1491 | |
klauss | 121:ee02790d00b7 | 1492 | return ( 0 ); |
klauss | 121:ee02790d00b7 | 1493 | } |
klauss | 121:ee02790d00b7 | 1494 | |
klauss | 121:ee02790d00b7 | 1495 | |
klauss | 121:ee02790d00b7 | 1496 | int reset_stats_cks ( void ) |
klauss | 121:ee02790d00b7 | 1497 | { |
klauss | 121:ee02790d00b7 | 1498 | pkg_cksok = 0; |
klauss | 121:ee02790d00b7 | 1499 | pkg_ckserr = 0; |
klauss | 121:ee02790d00b7 | 1500 | pkg_zero = 0; |
klauss | 121:ee02790d00b7 | 1501 | out_of_range = 0; |
klauss | 121:ee02790d00b7 | 1502 | missed_pkg = 0; |
klauss | 121:ee02790d00b7 | 1503 | delayed_pkg_to_cb = 0; |
klauss | 121:ee02790d00b7 | 1504 | cpld_pkg_tx_counter = 0; |
klauss | 121:ee02790d00b7 | 1505 | cpld_pkg_rx_counter = 0; |
klauss | 121:ee02790d00b7 | 1506 | |
klauss | 121:ee02790d00b7 | 1507 | return ( 0 ); |
klauss | 121:ee02790d00b7 | 1508 | } |
klauss | 121:ee02790d00b7 | 1509 | |
klauss | 121:ee02790d00b7 | 1510 | int show_cb_stats ( void ) |
klauss | 121:ee02790d00b7 | 1511 | { |
klauss | 121:ee02790d00b7 | 1512 | send_msg( |
klauss | 121:ee02790d00b7 | 1513 | "\r\n" |
klauss | 121:ee02790d00b7 | 1514 | " PKG_CKS OK: %d ( %003.2f )\r\n" |
klauss | 121:ee02790d00b7 | 1515 | " PKG_CKS ERR: %d ( %003.2f )\r\n" |
klauss | 121:ee02790d00b7 | 1516 | " PKG_0: %d ( %003.2f )\r\n" |
klauss | 121:ee02790d00b7 | 1517 | " Out_of_range: %d ( %003.2f )\r\n" |
klauss | 121:ee02790d00b7 | 1518 | " Miss_Pkg: %d\r\n" |
klauss | 121:ee02790d00b7 | 1519 | " TX_delayed: %d\n\r" |
klauss | 121:ee02790d00b7 | 1520 | " TX_Counter: %d\n\r" |
klauss | 121:ee02790d00b7 | 1521 | " RX_Counter: %d\r\n", |
klauss | 121:ee02790d00b7 | 1522 | pkg_cksok, ( cpld_pkg_rx_counter == 0 ) ? 0.00 : ( ( double ) pkg_cksok / cpld_pkg_rx_counter ) * 100, |
klauss | 121:ee02790d00b7 | 1523 | pkg_ckserr, ( cpld_pkg_rx_counter == 0 ) ? 0.00 : ( ( double ) pkg_ckserr / cpld_pkg_rx_counter ) * 100, |
klauss | 121:ee02790d00b7 | 1524 | pkg_zero, ( cpld_pkg_rx_counter == 0 ) ? 0.00 : ( ( double ) pkg_zero / cpld_pkg_rx_counter ) * 100, |
klauss | 121:ee02790d00b7 | 1525 | out_of_range, ( cpld_pkg_rx_counter == 0 ) ? 0.00 : ( ( double ) out_of_range / cpld_pkg_rx_counter ) * 100, |
klauss | 121:ee02790d00b7 | 1526 | missed_pkg, |
klauss | 121:ee02790d00b7 | 1527 | delayed_pkg_to_cb, |
klauss | 121:ee02790d00b7 | 1528 | cpld_pkg_tx_counter, |
klauss | 121:ee02790d00b7 | 1529 | cpld_pkg_rx_counter |
klauss | 121:ee02790d00b7 | 1530 | ); |
klauss | 121:ee02790d00b7 | 1531 | |
klauss | 121:ee02790d00b7 | 1532 | return ( 0 ); |
klauss | 121:ee02790d00b7 | 1533 | } |
klauss | 121:ee02790d00b7 | 1534 | |
klauss | 121:ee02790d00b7 | 1535 | |
klauss | 121:ee02790d00b7 | 1536 | int reset_missed_send_udp ( void ) |
klauss | 121:ee02790d00b7 | 1537 | { |
klauss | 121:ee02790d00b7 | 1538 | miss_fw_send_pkg = 0; |
klauss | 121:ee02790d00b7 | 1539 | miss_prompt_udp_send_pkg = 0; |
klauss | 121:ee02790d00b7 | 1540 | miss_sip_registry_send_pkg = 0; |
klauss | 121:ee02790d00b7 | 1541 | miss_sip_invite_send_pkg = 0; |
klauss | 121:ee02790d00b7 | 1542 | miss_sip_bye_send_pkg = 0; |
klauss | 121:ee02790d00b7 | 1543 | miss_sip_unregistry_send_pkg = 0; |
klauss | 121:ee02790d00b7 | 1544 | miss_sip_ok_send_pkg = 0; |
klauss | 121:ee02790d00b7 | 1545 | miss_sip_rcv_bye_send_pkg = 0; |
klauss | 121:ee02790d00b7 | 1546 | miss_wdt_send_pkg = 0; |
klauss | 121:ee02790d00b7 | 1547 | miss_prompt_udp_send_pkg = 0; |
klauss | 121:ee02790d00b7 | 1548 | miss_ftp_udp_send_pkg = 0; |
klauss | 121:ee02790d00b7 | 1549 | miss_prompt_udp_rcv_pkg = 0; |
klauss | 121:ee02790d00b7 | 1550 | |
klauss | 121:ee02790d00b7 | 1551 | return ( 0 ); |
klauss | 121:ee02790d00b7 | 1552 | } |
klauss | 121:ee02790d00b7 | 1553 | |
klauss | 121:ee02790d00b7 | 1554 | int show_missed_send_udp_pkg ( void ) |
klauss | 121:ee02790d00b7 | 1555 | { |
klauss | 121:ee02790d00b7 | 1556 | send_msg( "\r\nMissed pkgs ::\r\n " |
klauss | 121:ee02790d00b7 | 1557 | "FW: %d\r\n " |
klauss | 121:ee02790d00b7 | 1558 | "Prompt UDP %d\r\n " |
klauss | 121:ee02790d00b7 | 1559 | "Registry %d\r\n " |
klauss | 121:ee02790d00b7 | 1560 | "Invite %d\r\n " |
klauss | 121:ee02790d00b7 | 1561 | "Bye %d\r\n " |
klauss | 121:ee02790d00b7 | 1562 | "Unregistry %d\r\n " |
klauss | 121:ee02790d00b7 | 1563 | "UDP incoming ( invite ans ) %d\r\n " |
klauss | 121:ee02790d00b7 | 1564 | "UDP incoming ( bye from * ) %d\r\n " |
klauss | 121:ee02790d00b7 | 1565 | "Wdt [ alive | rst ] %d\r\n " |
klauss | 121:ee02790d00b7 | 1566 | "Rcv prompt %d\r\n " |
klauss | 121:ee02790d00b7 | 1567 | "[ debug | send ]_msg %d\r\n " |
klauss | 121:ee02790d00b7 | 1568 | "RTP %d\r\n", |
klauss | 121:ee02790d00b7 | 1569 | miss_fw_send_pkg, |
klauss | 121:ee02790d00b7 | 1570 | miss_prompt_udp_send_pkg, |
klauss | 121:ee02790d00b7 | 1571 | miss_sip_registry_send_pkg, |
klauss | 121:ee02790d00b7 | 1572 | miss_sip_invite_send_pkg, |
klauss | 121:ee02790d00b7 | 1573 | miss_sip_bye_send_pkg, |
klauss | 121:ee02790d00b7 | 1574 | miss_sip_unregistry_send_pkg, |
klauss | 121:ee02790d00b7 | 1575 | miss_sip_ok_send_pkg, |
klauss | 121:ee02790d00b7 | 1576 | miss_sip_rcv_bye_send_pkg, |
klauss | 121:ee02790d00b7 | 1577 | miss_wdt_send_pkg, |
klauss | 121:ee02790d00b7 | 1578 | miss_prompt_udp_send_pkg, |
klauss | 121:ee02790d00b7 | 1579 | miss_prompt_udp_rcv_pkg, |
klauss | 121:ee02790d00b7 | 1580 | miss_ftp_udp_send_pkg |
klauss | 121:ee02790d00b7 | 1581 | ); |
klauss | 121:ee02790d00b7 | 1582 | |
klauss | 121:ee02790d00b7 | 1583 | return ( 0 ); |
klauss | 121:ee02790d00b7 | 1584 | } |
klauss | 121:ee02790d00b7 | 1585 | |
klauss | 121:ee02790d00b7 | 1586 | int invite_ack_to_cb_handler ( Vector * v_cb, Vector * v_call ) |
klauss | 121:ee02790d00b7 | 1587 | { |
klauss | 121:ee02790d00b7 | 1588 | static int retry_invite_pkg = 0; |
klauss | 121:ee02790d00b7 | 1589 | bool need_retry = false; |
klauss | 121:ee02790d00b7 | 1590 | Call_Box * cb = NULL; |
klauss | 121:ee02790d00b7 | 1591 | |
klauss | 121:ee02790d00b7 | 1592 | for ( register int i = 0; i < v_cb->size(); i++ ) |
klauss | 121:ee02790d00b7 | 1593 | { |
klauss | 121:ee02790d00b7 | 1594 | retry_invite_pkg++; |
klauss | 121:ee02790d00b7 | 1595 | if ( retry_invite_pkg >= v_cb->size() ) retry_invite_pkg = 0; |
klauss | 121:ee02790d00b7 | 1596 | |
klauss | 121:ee02790d00b7 | 1597 | cb = (Call_Box * )v_cb->get_element( i ); |
klauss | 121:ee02790d00b7 | 1598 | if ( cb != NULL ) |
klauss | 121:ee02790d00b7 | 1599 | { |
klauss | 121:ee02790d00b7 | 1600 | if ( ( cb -> get_status () == cb_ringing ) || ( cb -> get_status () == cb_trying ) || ( cb -> get_status () == cb_on_call ) ) |
klauss | 121:ee02790d00b7 | 1601 | { |
klauss | 121:ee02790d00b7 | 1602 | need_retry = true; |
klauss | 121:ee02790d00b7 | 1603 | break; |
klauss | 121:ee02790d00b7 | 1604 | } |
klauss | 121:ee02790d00b7 | 1605 | } |
klauss | 121:ee02790d00b7 | 1606 | } |
klauss | 121:ee02790d00b7 | 1607 | |
klauss | 121:ee02790d00b7 | 1608 | if ( need_retry ) |
klauss | 121:ee02790d00b7 | 1609 | { |
klauss | 121:ee02790d00b7 | 1610 | if( cb->get_invite_response() == false ) |
klauss | 121:ee02790d00b7 | 1611 | { |
klauss | 121:ee02790d00b7 | 1612 | cb->set_msg_id( ( cb->get_msg_id() + 1 ) & ~BIT7 ); |
klauss | 121:ee02790d00b7 | 1613 | |
klauss | 121:ee02790d00b7 | 1614 | buffer[ TIMESLICE_PLACE ] = cb->get_timeslice(); |
klauss | 121:ee02790d00b7 | 1615 | |
klauss | 121:ee02790d00b7 | 1616 | send2callboxes( build_cb_package( cb->get_ext(), cb->get_port(), INVITE, ( char * )buffer, |
klauss | 121:ee02790d00b7 | 1617 | cb->get_msg_id(), CB_BUFFER_SIZE - VZ_HEADER_OFFSET, write_buffer ) ); |
klauss | 121:ee02790d00b7 | 1618 | |
klauss | 121:ee02790d00b7 | 1619 | if( debug_invite ) debug_msg("[%d] resend invite OK to Cbx : ( %d, %d )", cb->get_ext(), cb->get_ext(), cb->get_port() ); |
klauss | 121:ee02790d00b7 | 1620 | } |
klauss | 121:ee02790d00b7 | 1621 | |
klauss | 121:ee02790d00b7 | 1622 | if ( __find_Call__( v_call, cb->get_ext () ) == NULL ) |
klauss | 121:ee02790d00b7 | 1623 | { |
klauss | 121:ee02790d00b7 | 1624 | |
klauss | 121:ee02790d00b7 | 1625 | if ( ( ( cb -> get_status () == cb_ringing ) || ( cb -> get_status () == cb_trying ) ) ) |
klauss | 121:ee02790d00b7 | 1626 | { |
klauss | 121:ee02790d00b7 | 1627 | char rtp_src_tmp_write_buffer [ CB_BUFFER_SIZE ]; |
klauss | 121:ee02790d00b7 | 1628 | uint8_t rtp_dst_tmp_write_buffer [ CB_BUFFER_SIZE ]; |
klauss | 121:ee02790d00b7 | 1629 | |
klauss | 121:ee02790d00b7 | 1630 | for ( register int i = 0; i < RTP_MSG_SIZE; i++ ) rtp_src_tmp_write_buffer [ i ] = 'U'; // 0x55 |
klauss | 121:ee02790d00b7 | 1631 | |
klauss | 121:ee02790d00b7 | 1632 | send2callboxes( build_cb_package( cb->get_ext (), cb->get_port (), AUDIO, |
klauss | 121:ee02790d00b7 | 1633 | rtp_src_tmp_write_buffer, AUDIO, RTP_MSG_SIZE, rtp_dst_tmp_write_buffer ) ); |
klauss | 121:ee02790d00b7 | 1634 | } else { |
klauss | 121:ee02790d00b7 | 1635 | if ( cb->get_invite_retry_count() == 0 ) |
klauss | 121:ee02790d00b7 | 1636 | { |
klauss | 121:ee02790d00b7 | 1637 | cb->set_msg_id( ( cb->get_msg_id() + 1 ) & ~BIT7 ); |
klauss | 121:ee02790d00b7 | 1638 | |
klauss | 121:ee02790d00b7 | 1639 | for ( register uint8_t i = 0; i < v_call->size(); i++ ) |
klauss | 121:ee02790d00b7 | 1640 | { |
klauss | 121:ee02790d00b7 | 1641 | VZ_call * call = ( VZ_call * )v_call->get_element( i ); |
klauss | 121:ee02790d00b7 | 1642 | if( call->get_cb_ext() == cb->get_ext() ) |
klauss | 121:ee02790d00b7 | 1643 | { |
klauss | 121:ee02790d00b7 | 1644 | v_call->remove_element( i ); |
klauss | 121:ee02790d00b7 | 1645 | if( call != NULL ) delete( call ); |
klauss | 121:ee02790d00b7 | 1646 | break; |
klauss | 121:ee02790d00b7 | 1647 | } |
klauss | 121:ee02790d00b7 | 1648 | } |
klauss | 121:ee02790d00b7 | 1649 | |
klauss | 121:ee02790d00b7 | 1650 | ts->return_timeslice( cb->call_end () ); |
klauss | 121:ee02790d00b7 | 1651 | |
klauss | 121:ee02790d00b7 | 1652 | if( debug_invite ) debug_msg( "[%d]-- No audio pkgs --", cb->get_ext () ); |
klauss | 121:ee02790d00b7 | 1653 | } |
klauss | 121:ee02790d00b7 | 1654 | } |
klauss | 121:ee02790d00b7 | 1655 | } |
klauss | 121:ee02790d00b7 | 1656 | } |
klauss | 121:ee02790d00b7 | 1657 | |
klauss | 121:ee02790d00b7 | 1658 | return ( 0 ); |
klauss | 121:ee02790d00b7 | 1659 | } |
klauss | 121:ee02790d00b7 | 1660 | |
klauss | 121:ee02790d00b7 | 1661 | int check_audio_from_ast ( Vector * v_cb, Vector * v_call ) |
klauss | 121:ee02790d00b7 | 1662 | { |
klauss | 121:ee02790d00b7 | 1663 | for( register uint8_t i = 0; i < v_call->size(); i++ ) { |
klauss | 121:ee02790d00b7 | 1664 | VZ_call * call = ( VZ_call * )v_call->get_element( i ); |
klauss | 121:ee02790d00b7 | 1665 | if ( call != NULL ) |
klauss | 121:ee02790d00b7 | 1666 | { |
klauss | 121:ee02790d00b7 | 1667 | int length = 0; |
klauss | 121:ee02790d00b7 | 1668 | char * tmp = call->get_eth_message( &length ); |
klauss | 121:ee02790d00b7 | 1669 | if( tmp != NULL ) { |
klauss | 121:ee02790d00b7 | 1670 | int cb_port = 0xffff; |
klauss | 121:ee02790d00b7 | 1671 | Call_Box * cb = find_CB( v_cb, call->get_cb_ext() ); |
klauss | 121:ee02790d00b7 | 1672 | |
klauss | 121:ee02790d00b7 | 1673 | if( cb != NULL ) { |
klauss | 121:ee02790d00b7 | 1674 | cb_port = cb->get_port(); |
klauss | 121:ee02790d00b7 | 1675 | |
klauss | 121:ee02790d00b7 | 1676 | if ( drop_rtp_from_ast_pkg ) |
klauss | 121:ee02790d00b7 | 1677 | { |
klauss | 121:ee02790d00b7 | 1678 | led1 = !led1; |
klauss | 121:ee02790d00b7 | 1679 | } |
klauss | 121:ee02790d00b7 | 1680 | else |
klauss | 121:ee02790d00b7 | 1681 | { |
klauss | 121:ee02790d00b7 | 1682 | uint8_t * pkg2cb = build_cb_package( call->get_cb_ext(), cb_port, AUDIO, |
klauss | 121:ee02790d00b7 | 1683 | tmp, AUDIO, length, write_buffer ); |
klauss | 121:ee02790d00b7 | 1684 | |
klauss | 121:ee02790d00b7 | 1685 | send2callboxes( pkg2cb ); |
klauss | 121:ee02790d00b7 | 1686 | } |
klauss | 121:ee02790d00b7 | 1687 | |
klauss | 121:ee02790d00b7 | 1688 | } else if( debug_main ) debug_msg("[%d] received missed package -- Type :: %i", ext, type ); |
klauss | 121:ee02790d00b7 | 1689 | } |
klauss | 121:ee02790d00b7 | 1690 | } |
klauss | 121:ee02790d00b7 | 1691 | } |
klauss | 121:ee02790d00b7 | 1692 | |
klauss | 121:ee02790d00b7 | 1693 | return ( 0 ); |
klauss | 121:ee02790d00b7 | 1694 | } |
klauss | 121:ee02790d00b7 | 1695 | |
klauss | 121:ee02790d00b7 | 1696 | int wake_up_or_refresh_handler ( Vector * v_cb ) |
klauss | 121:ee02790d00b7 | 1697 | { |
klauss | 121:ee02790d00b7 | 1698 | if( timer_sync_refresh.read_ms() > 250 ) { |
klauss | 121:ee02790d00b7 | 1699 | timer_sync_refresh.reset(); |
klauss | 121:ee02790d00b7 | 1700 | |
klauss | 121:ee02790d00b7 | 1701 | static uint8_t time_to_mode = TIME_TO_REFRESH; |
klauss | 121:ee02790d00b7 | 1702 | |
klauss | 121:ee02790d00b7 | 1703 | if ( time_to_mode == TIME_TO_REFRESH ){ |
klauss | 121:ee02790d00b7 | 1704 | time_to_mode = TIME_TO_WAKE_UP; |
klauss | 121:ee02790d00b7 | 1705 | refresh ( v_cb ); |
klauss | 121:ee02790d00b7 | 1706 | } else { |
klauss | 121:ee02790d00b7 | 1707 | time_to_mode = TIME_TO_REFRESH; |
klauss | 121:ee02790d00b7 | 1708 | if ( wake_all ) if ( v_call->size() == 0 ) wake_all_up ( v_cb ); |
klauss | 121:ee02790d00b7 | 1709 | } |
klauss | 121:ee02790d00b7 | 1710 | } |
klauss | 121:ee02790d00b7 | 1711 | |
klauss | 121:ee02790d00b7 | 1712 | return ( 0 ); |
klauss | 121:ee02790d00b7 | 1713 | } |
klauss | 121:ee02790d00b7 | 1714 | |
klauss | 121:ee02790d00b7 | 1715 | int check_sip_messages_from_ast ( Vector * v_cb, Vector * v_call ) |
klauss | 121:ee02790d00b7 | 1716 | { |
klauss | 121:ee02790d00b7 | 1717 | // check sip messages only for cbx in call ? |
klauss | 121:ee02790d00b7 | 1718 | int ext_to__be_removed = sip_manager( v_cb ); |
klauss | 121:ee02790d00b7 | 1719 | if( ext_to__be_removed > 0 ) { |
klauss | 121:ee02790d00b7 | 1720 | Call_Box * cb = find_CB( v_cb, ext_to__be_removed ); |
klauss | 121:ee02790d00b7 | 1721 | if( cb != NULL ) { |
klauss | 121:ee02790d00b7 | 1722 | //if( cb->status == cb_on_call ) // poderia ser if( cb->status != cb_idle ) ??? |
klauss | 121:ee02790d00b7 | 1723 | if ( cb -> get_status () == cb_on_call ) |
klauss | 121:ee02790d00b7 | 1724 | { |
klauss | 121:ee02790d00b7 | 1725 | buffer[ TIMESLICE_PLACE ] = 0; |
klauss | 121:ee02790d00b7 | 1726 | |
klauss | 121:ee02790d00b7 | 1727 | for( register uint8_t i = 0; i < v_call->size(); i++ ) { |
klauss | 121:ee02790d00b7 | 1728 | VZ_call * call = ( VZ_call * )v_call->get_element( i ); |
klauss | 121:ee02790d00b7 | 1729 | if( call->get_cb_ext() == ext_to__be_removed ) { |
klauss | 121:ee02790d00b7 | 1730 | v_call->remove_element( i ); |
klauss | 121:ee02790d00b7 | 1731 | delete( call ); |
klauss | 121:ee02790d00b7 | 1732 | } |
klauss | 121:ee02790d00b7 | 1733 | } |
klauss | 121:ee02790d00b7 | 1734 | |
klauss | 121:ee02790d00b7 | 1735 | ts->return_timeslice( cb->call_end ( false ) ); |
klauss | 121:ee02790d00b7 | 1736 | |
klauss | 121:ee02790d00b7 | 1737 | send2callboxes( build_cb_package( cb->get_ext (), cb->get_port (), CB_BYE, |
klauss | 121:ee02790d00b7 | 1738 | ( char * )buffer, cb->get_msg_id(), CB_BUFFER_SIZE - VZ_HEADER_OFFSET, write_buffer ) ); |
klauss | 121:ee02790d00b7 | 1739 | |
klauss | 121:ee02790d00b7 | 1740 | if( debug_invite ) debug_msg("[%d] Received Bye from *", cb->get_ext () ); |
klauss | 121:ee02790d00b7 | 1741 | } |
klauss | 121:ee02790d00b7 | 1742 | } else if( debug_main ) debug_msg("[%d] Missed bye request", ext_to__be_removed ); |
klauss | 121:ee02790d00b7 | 1743 | } |
klauss | 121:ee02790d00b7 | 1744 | |
klauss | 121:ee02790d00b7 | 1745 | return ( 0 ); |
klauss | 121:ee02790d00b7 | 1746 | } |
klauss | 121:ee02790d00b7 | 1747 | |
klauss | 121:ee02790d00b7 | 1748 | int check_for_runaways_ts ( Vector * v_cb, Timeslice * ts ) |
klauss | 121:ee02790d00b7 | 1749 | { |
klauss | 121:ee02790d00b7 | 1750 | if( ( v_call->size() == 0 ) && ( ts->remain_timeslices() != MAX_TIMESLICES ) ) { |
klauss | 121:ee02790d00b7 | 1751 | bool ts_reset = true; |
klauss | 121:ee02790d00b7 | 1752 | for( register uint8_t i = 0; i < v_cb->size(); i++ ) { |
klauss | 121:ee02790d00b7 | 1753 | uint16_t cb_status = ((Call_Box *)v_cb->get_element( i ))->get_status(); |
klauss | 121:ee02790d00b7 | 1754 | uint16_t cb_sip_status = ((Call_Box *)v_cb->get_element( i ))->get_sip_status(); |
klauss | 121:ee02790d00b7 | 1755 | |
klauss | 121:ee02790d00b7 | 1756 | if ((cb_status != cb_idle) and (cb_sip_status != sip_idle)) { |
klauss | 121:ee02790d00b7 | 1757 | ts_reset = false; |
klauss | 121:ee02790d00b7 | 1758 | break; |
klauss | 121:ee02790d00b7 | 1759 | } |
klauss | 121:ee02790d00b7 | 1760 | |
klauss | 121:ee02790d00b7 | 1761 | } |
klauss | 121:ee02790d00b7 | 1762 | if( ts_reset && !bl_start_flag ) |
klauss | 121:ee02790d00b7 | 1763 | { |
klauss | 121:ee02790d00b7 | 1764 | if( debug_invite ) debug_msg("Resetando TS"); |
klauss | 121:ee02790d00b7 | 1765 | ts->reset(); |
klauss | 121:ee02790d00b7 | 1766 | } |
klauss | 121:ee02790d00b7 | 1767 | } |
klauss | 121:ee02790d00b7 | 1768 | |
klauss | 121:ee02790d00b7 | 1769 | return ( 0 ); |
klauss | 121:ee02790d00b7 | 1770 | } |
klauss | 121:ee02790d00b7 | 1771 | |
klauss | 121:ee02790d00b7 | 1772 | int show_wdt_status ( void ) |
klauss | 121:ee02790d00b7 | 1773 | { |
klauss | 121:ee02790d00b7 | 1774 | send_msg("lpc_low_level_input_counter :: %d", lpc_low_level_input_counter ); |
klauss | 121:ee02790d00b7 | 1775 | |
klauss | 121:ee02790d00b7 | 1776 | lpc_low_level_input_counter = 0; |
klauss | 121:ee02790d00b7 | 1777 | |
klauss | 121:ee02790d00b7 | 1778 | if( eth_status == 0 ) { |
klauss | 121:ee02790d00b7 | 1779 | send_msg( "Wdt last reset: %s - status_eth :: Connected - Extern Wdt idle for :: %3d sec ( %3d ) - Rx from CBx idle for :: %3d sec ( %3d )", |
klauss | 121:ee02790d00b7 | 1780 | ( wdt.WatchdogCausedReset() ) ? "true" : "false", |
klauss | 121:ee02790d00b7 | 1781 | EXTERN_WDT_IDLE - external_wdt, |
klauss | 121:ee02790d00b7 | 1782 | EXTERN_WDT_IDLE, |
klauss | 121:ee02790d00b7 | 1783 | RX_CB_IDLE - pkg_wdt, |
klauss | 121:ee02790d00b7 | 1784 | RX_CB_IDLE |
klauss | 121:ee02790d00b7 | 1785 | ); |
klauss | 121:ee02790d00b7 | 1786 | } else { |
klauss | 121:ee02790d00b7 | 1787 | send_msg( "Wdt last reset: %s - status_eth :: Disconnected :: since %3d sec - Extern Wdt idle for :: %3d sec ( %3d ) - Rx from CBx idle for :: %3d sec ( %3d )", |
klauss | 121:ee02790d00b7 | 1788 | ( wdt.WatchdogCausedReset() ) ? "true" : "false", |
klauss | 121:ee02790d00b7 | 1789 | ETH_CONNECT_TIMEOUT - eth_wdt, |
klauss | 121:ee02790d00b7 | 1790 | EXTERN_WDT_IDLE - external_wdt, |
klauss | 121:ee02790d00b7 | 1791 | EXTERN_WDT_IDLE, |
klauss | 121:ee02790d00b7 | 1792 | RX_CB_IDLE - pkg_wdt, |
klauss | 121:ee02790d00b7 | 1793 | RX_CB_IDLE |
klauss | 121:ee02790d00b7 | 1794 | ); |
klauss | 121:ee02790d00b7 | 1795 | } |
klauss | 121:ee02790d00b7 | 1796 | |
klauss | 121:ee02790d00b7 | 1797 | return ( 0 ); |
klauss | 121:ee02790d00b7 | 1798 | } |
klauss | 121:ee02790d00b7 | 1799 | |
klauss | 121:ee02790d00b7 | 1800 | |
klauss | 121:ee02790d00b7 | 1801 | int wdt_update ( void ) |
klauss | 121:ee02790d00b7 | 1802 | { |
klauss | 121:ee02790d00b7 | 1803 | uptime++; |
klauss | 121:ee02790d00b7 | 1804 | |
klauss | 121:ee02790d00b7 | 1805 | current_time++; |
klauss | 121:ee02790d00b7 | 1806 | |
klauss | 121:ee02790d00b7 | 1807 | if( wdt_show ) debug_wdt = true; |
klauss | 121:ee02790d00b7 | 1808 | |
klauss | 121:ee02790d00b7 | 1809 | if( external_wdt ) external_wdt--; |
klauss | 121:ee02790d00b7 | 1810 | if( pkg_wdt ) pkg_wdt--; |
klauss | 121:ee02790d00b7 | 1811 | if( eth_wdt ) eth_wdt--; |
klauss | 121:ee02790d00b7 | 1812 | |
klauss | 121:ee02790d00b7 | 1813 | if( eth_wdt && external_wdt && pkg_wdt ){ |
klauss | 121:ee02790d00b7 | 1814 | wdt.kick(); |
klauss | 121:ee02790d00b7 | 1815 | } |
klauss | 121:ee02790d00b7 | 1816 | |
klauss | 121:ee02790d00b7 | 1817 | return ( 0 ); |
klauss | 121:ee02790d00b7 | 1818 | } |
klauss | 121:ee02790d00b7 | 1819 | |
klauss | 121:ee02790d00b7 | 1820 | int check_for_unwanted_rtp_ports ( Vector * v_cb ) |
klauss | 121:ee02790d00b7 | 1821 | { |
klauss | 121:ee02790d00b7 | 1822 | for ( register uint8_t i = 0; i < v_cb->size(); i++ ) |
klauss | 121:ee02790d00b7 | 1823 | { |
klauss | 121:ee02790d00b7 | 1824 | Call_Box * cb = (Call_Box *) v_cb->get_element (i); |
klauss | 121:ee02790d00b7 | 1825 | if ( cb != NULL ) |
klauss | 121:ee02790d00b7 | 1826 | { |
klauss | 121:ee02790d00b7 | 1827 | if ( ( cb->get_status () == cb_idle ) && ( cb->get_sip_status () == sip_idle ) && ( cb -> is_rtp_timer_timeout () ) ) |
klauss | 121:ee02790d00b7 | 1828 | { |
klauss | 121:ee02790d00b7 | 1829 | if ( debug_reset_rtp ) debug_msg( "[%d] rtp reset", cb -> get_ext () ); |
klauss | 121:ee02790d00b7 | 1830 | cb -> cb_set_status( cb_idle ); |
klauss | 121:ee02790d00b7 | 1831 | cb -> set_sip_status ( sip_idle ); |
klauss | 121:ee02790d00b7 | 1832 | cb -> reset_rtp_timer (); |
klauss | 121:ee02790d00b7 | 1833 | cb -> set_rtp_port ( 0 ); |
klauss | 121:ee02790d00b7 | 1834 | } |
klauss | 121:ee02790d00b7 | 1835 | } |
klauss | 121:ee02790d00b7 | 1836 | } |
klauss | 121:ee02790d00b7 | 1837 | return ( 0 ); |
klauss | 121:ee02790d00b7 | 1838 | } |
klauss | 121:ee02790d00b7 | 1839 | |
klauss | 121:ee02790d00b7 | 1840 | |
klauss | 121:ee02790d00b7 | 1841 | int process_received_pkg_from_cbx ( void ) |
klauss | 121:ee02790d00b7 | 1842 | { |
klauss | 121:ee02790d00b7 | 1843 | pkg_wdt = RX_CB_IDLE; |
klauss | 121:ee02790d00b7 | 1844 | xmemcpy( cb_rx_buffer, buffer_from_cb_ptr, CB_BUFFER_SIZE ); |
klauss | 121:ee02790d00b7 | 1845 | status = WAITING; |
klauss | 121:ee02790d00b7 | 1846 | missed_pkg--; |
klauss | 121:ee02790d00b7 | 1847 | xmemcpy( buffer, cb_rx_buffer, CB_BUFFER_SIZE ); |
klauss | 121:ee02790d00b7 | 1848 | |
klauss | 121:ee02790d00b7 | 1849 | if( rx ) { |
klauss | 121:ee02790d00b7 | 1850 | char str[ 1024 ]; |
klauss | 121:ee02790d00b7 | 1851 | strcpy( str, "RX :: \n\r " ); |
klauss | 121:ee02790d00b7 | 1852 | for( register uint16_t i = 0; i < CB_BUFFER_SIZE; i++ ) { |
klauss | 121:ee02790d00b7 | 1853 | char tmp[ 16 ]; |
klauss | 121:ee02790d00b7 | 1854 | snprintf ( tmp, sizeof ( tmp ), "%x", cb_rx_buffer[ i ] ); |
klauss | 121:ee02790d00b7 | 1855 | strcat( str, tmp ); |
klauss | 121:ee02790d00b7 | 1856 | if( ( i != 0 ) && !( ( i + 1 ) % 50 ) ) strcat( str, "\n\r " ); |
klauss | 121:ee02790d00b7 | 1857 | |
klauss | 121:ee02790d00b7 | 1858 | else strcat( str, " " ); |
klauss | 121:ee02790d00b7 | 1859 | } |
klauss | 121:ee02790d00b7 | 1860 | send_msg ( "%s", str ); |
klauss | 121:ee02790d00b7 | 1861 | rx = false; |
klauss | 121:ee02790d00b7 | 1862 | } |
klauss | 121:ee02790d00b7 | 1863 | |
klauss | 121:ee02790d00b7 | 1864 | data = parse_vz_pkg ( &ext, &port, &type, buffer ); |
klauss | 121:ee02790d00b7 | 1865 | |
klauss | 121:ee02790d00b7 | 1866 | if( data != NULL ) |
klauss | 121:ee02790d00b7 | 1867 | { |
klauss | 121:ee02790d00b7 | 1868 | if( min_ext == 0 ) min_ext = ext; |
klauss | 121:ee02790d00b7 | 1869 | |
klauss | 121:ee02790d00b7 | 1870 | if( ext > max_ext ) max_ext = ext; |
klauss | 121:ee02790d00b7 | 1871 | |
klauss | 121:ee02790d00b7 | 1872 | if( ext < min_ext ) min_ext = ext; |
klauss | 121:ee02790d00b7 | 1873 | |
klauss | 121:ee02790d00b7 | 1874 | if( debug_fw ){ fw_cbx_pkg( ext, port, ( char *)buffer ); } |
klauss | 121:ee02790d00b7 | 1875 | |
klauss | 121:ee02790d00b7 | 1876 | if( type == TELEMETRY ) telemetry_counter++; |
klauss | 121:ee02790d00b7 | 1877 | |
klauss | 121:ee02790d00b7 | 1878 | if( type != AUDIO ) { |
klauss | 121:ee02790d00b7 | 1879 | if( |
klauss | 121:ee02790d00b7 | 1880 | type == TELEMETRY || |
klauss | 121:ee02790d00b7 | 1881 | type == CB_STATS || |
klauss | 121:ee02790d00b7 | 1882 | type == FW1 || |
klauss | 121:ee02790d00b7 | 1883 | type == FW2 || |
klauss | 121:ee02790d00b7 | 1884 | type == FW3 || |
klauss | 121:ee02790d00b7 | 1885 | type == FW4 || |
klauss | 121:ee02790d00b7 | 1886 | type == FW5 || |
klauss | 121:ee02790d00b7 | 1887 | type == FW6 |
klauss | 121:ee02790d00b7 | 1888 | ) type = FW; |
klauss | 121:ee02790d00b7 | 1889 | |
klauss | 121:ee02790d00b7 | 1890 | if( debug_cb_rx == true ){ |
klauss | 121:ee02790d00b7 | 1891 | send_msg("[%d %d] -- Type :: %d", ext, port, type ); |
klauss | 121:ee02790d00b7 | 1892 | } |
klauss | 121:ee02790d00b7 | 1893 | |
klauss | 121:ee02790d00b7 | 1894 | Call_Box * cb = find_CB( v_cb, ext ); |
klauss | 121:ee02790d00b7 | 1895 | if( cb != NULL ) { |
klauss | 121:ee02790d00b7 | 1896 | if( data[ 0 ] & BIT7 ) { |
klauss | 121:ee02790d00b7 | 1897 | if( type == BOOT ) { |
klauss | 121:ee02790d00b7 | 1898 | send2callboxes( build_cb_package( ext, port, REGISTRY, |
klauss | 121:ee02790d00b7 | 1899 | ( char * )data, cb->get_msg_id(), CB_BUFFER_SIZE - VZ_HEADER_OFFSET, write_buffer ) ); |
klauss | 121:ee02790d00b7 | 1900 | } else { |
klauss | 121:ee02790d00b7 | 1901 | if( debug_main ) debug_msg("[%d] Received ack pkg with seq_num %d", ext, data[ 0 ] ); |
klauss | 121:ee02790d00b7 | 1902 | |
klauss | 121:ee02790d00b7 | 1903 | switch( type ) { |
klauss | 121:ee02790d00b7 | 1904 | case INVITE : { |
klauss | 121:ee02790d00b7 | 1905 | if( debug_main || debug_invite ) debug_msg("[%d] Invite Ack - msg_id %d -- Cbx seqNum %d", ext, cb->get_msg_id(), data[ 0 ] ); |
klauss | 121:ee02790d00b7 | 1906 | break; |
klauss | 121:ee02790d00b7 | 1907 | } |
klauss | 121:ee02790d00b7 | 1908 | case CB_BYE : { |
klauss | 121:ee02790d00b7 | 1909 | if( debug_main || debug_invite ) debug_msg("[%d] BYE Ack - msg_id %d", ext, cb->get_msg_id() ); |
klauss | 121:ee02790d00b7 | 1910 | cb->set_bye_response_ok(); |
klauss | 121:ee02790d00b7 | 1911 | break; |
klauss | 121:ee02790d00b7 | 1912 | } |
klauss | 121:ee02790d00b7 | 1913 | case REGISTRY : { |
klauss | 121:ee02790d00b7 | 1914 | if( debug_main || debug_aging ) debug_msg("[%d] Registry ACK - msg_id %d", ext, cb->get_msg_id() ); |
klauss | 121:ee02790d00b7 | 1915 | break; |
klauss | 121:ee02790d00b7 | 1916 | } |
klauss | 121:ee02790d00b7 | 1917 | default : { |
klauss | 121:ee02790d00b7 | 1918 | if( debug_main || debug_aging ) debug_msg("[%d] ACK msg_id :: %d :: type %d", ext, cb->get_msg_id(), type ); |
klauss | 121:ee02790d00b7 | 1919 | } |
klauss | 121:ee02790d00b7 | 1920 | } |
klauss | 121:ee02790d00b7 | 1921 | if( type != REGISTRY && type != CB_BYE && type != INVITE ) type = DO_NOTHING; |
klauss | 121:ee02790d00b7 | 1922 | if( type == CB_BYE ){ |
klauss | 121:ee02790d00b7 | 1923 | VZ_call * call = __find_Call__( v_call, ext ); |
klauss | 121:ee02790d00b7 | 1924 | if( call != NULL ){ |
klauss | 121:ee02790d00b7 | 1925 | if( call->get_elapsed_time() < 120000 ){ |
klauss | 121:ee02790d00b7 | 1926 | if( debug_invite ) debug_msg("[%d] ack bye ignored", ext ); |
klauss | 121:ee02790d00b7 | 1927 | type = DO_NOTHING; |
klauss | 121:ee02790d00b7 | 1928 | } |
klauss | 121:ee02790d00b7 | 1929 | } |
klauss | 121:ee02790d00b7 | 1930 | } |
klauss | 121:ee02790d00b7 | 1931 | } |
klauss | 121:ee02790d00b7 | 1932 | } |
klauss | 121:ee02790d00b7 | 1933 | } |
klauss | 121:ee02790d00b7 | 1934 | } |
klauss | 121:ee02790d00b7 | 1935 | } else type = DO_NOTHING; |
klauss | 121:ee02790d00b7 | 1936 | |
klauss | 121:ee02790d00b7 | 1937 | return 0; |
klauss | 121:ee02790d00b7 | 1938 | } |