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