Modularizando o src
Dependencies: EALib EthernetInterface_vz mbed-rtos mbed
Fork of header_main_colinas_V0-20-09-14 by
main.cpp@120:770f00554b1e, 2015-05-04 (annotated)
- Committer:
- klauss
- Date:
- Mon May 04 17:25:29 2015 +0000
- Revision:
- 120:770f00554b1e
- Parent:
- 119:ee6a53069455
- Child:
- 121:ee02790d00b7
clock request to server XXX port 123
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
klauss | 120:770f00554b1e | 1 | //#include "main_app_var_configs.h" |
klauss | 120:770f00554b1e | 2 | //#include "main_app_functions.h" |
klauss | 120:770f00554b1e | 3 | #include "main_app_var_configs.h" |
klauss | 85:b6f2dc1d0f4f | 4 | |
klauss | 91:c2a86b1f8aaa | 5 | int main() |
klauss | 114:472502b31a12 | 6 | { |
klauss | 100:09a23fcd3bdf | 7 | debug_uart3 = true; |
klauss | 119:ee6a53069455 | 8 | |
klauss | 119:ee6a53069455 | 9 | int header_app_init_ret = header_app_init (); |
klauss | 117:e9facba9db27 | 10 | |
klauss | 119:ee6a53069455 | 11 | send_msg( "header_app_init %s" , ( header_app_init_ret == 0 ) ? "Ok" : "Failure" ); |
klauss | 99:e80850c51106 | 12 | |
klauss | 119:ee6a53069455 | 13 | if ( header_app_init_ret == 0 ) send_msg("Ready"); |
klauss | 105:a930035b6556 | 14 | |
klauss | 114:472502b31a12 | 15 | debug_uart3 = false; |
klauss | 105:a930035b6556 | 16 | |
klauss | 119:ee6a53069455 | 17 | /*------------------------------------------ main loop ---------------------------------------------------------------*/ |
klauss | 115:a1e1e2e60a2c | 18 | |
klauss | 119:ee6a53069455 | 19 | while( true ) |
klauss | 119:ee6a53069455 | 20 | { |
klauss | 78:1353744f01e1 | 21 | if( v_cb->size() > max_registered_cbx ) max_registered_cbx = v_cb->size(); |
klauss | 91:c2a86b1f8aaa | 22 | |
klauss | 120:770f00554b1e | 23 | if ( sync_timer.read() > 5 ) |
klauss | 119:ee6a53069455 | 24 | { |
klauss | 78:1353744f01e1 | 25 | sync_timer.reset(); |
klauss | 91:c2a86b1f8aaa | 26 | |
klauss | 119:ee6a53069455 | 27 | if( debug_cks == true ) { pcks_s = true; } |
klauss | 91:c2a86b1f8aaa | 28 | |
klauss | 119:ee6a53069455 | 29 | if( debug_alive == true ) { pshowcb = true; } |
klauss | 105:a930035b6556 | 30 | |
klauss | 114:472502b31a12 | 31 | if( !( ++count % 15 ) ) { |
klauss | 91:c2a86b1f8aaa | 32 | if( eth_status ) { |
klauss | 119:ee6a53069455 | 33 | try_reconnect_with_eth (); |
klauss | 78:1353744f01e1 | 34 | } |
klauss | 78:1353744f01e1 | 35 | } |
klauss | 100:09a23fcd3bdf | 36 | |
klauss | 114:472502b31a12 | 37 | //35 sec. |
klauss | 91:c2a86b1f8aaa | 38 | if( ( count > 7 ) && ( wake_all == false ) ) { |
klauss | 81:3656f00ab3db | 39 | wake_all = true; |
klauss | 78:1353744f01e1 | 40 | if( debug_wake == true ) send_msg( "Time to wake" ); |
klauss | 78:1353744f01e1 | 41 | } |
klauss | 119:ee6a53069455 | 42 | |
klauss | 119:ee6a53069455 | 43 | // enable na variavel que exibe lista com estatisticas de pacotes que falharam ao serem enviados via interface eth |
klauss | 119:ee6a53069455 | 44 | if ( debug_missed ) { missed_send_udp_pkg = true; } |
klauss | 119:ee6a53069455 | 45 | |
klauss | 114:472502b31a12 | 46 | } |
klauss | 91:c2a86b1f8aaa | 47 | |
klauss | 119:ee6a53069455 | 48 | prompt_process( NULL, 0 ); |
klauss | 119:ee6a53069455 | 49 | |
klauss | 119:ee6a53069455 | 50 | check_clock (); |
klauss | 114:472502b31a12 | 51 | |
klauss | 119:ee6a53069455 | 52 | if ( r_stats ) |
klauss | 119:ee6a53069455 | 53 | { |
klauss | 119:ee6a53069455 | 54 | reset_stats (); |
klauss | 120:770f00554b1e | 55 | stats = true; |
klauss | 63:0d95da692bb4 | 56 | r_stats = false; |
klauss | 63:0d95da692bb4 | 57 | } |
klauss | 91:c2a86b1f8aaa | 58 | |
klauss | 119:ee6a53069455 | 59 | if ( stats ) |
klauss | 119:ee6a53069455 | 60 | { |
klauss | 119:ee6a53069455 | 61 | show_stats (); |
klauss | 63:0d95da692bb4 | 62 | stats =false; |
klauss | 63:0d95da692bb4 | 63 | } |
klauss | 114:472502b31a12 | 64 | |
klauss | 119:ee6a53069455 | 65 | if ( list ) |
klauss | 119:ee6a53069455 | 66 | { |
klauss | 119:ee6a53069455 | 67 | show_cb_list ( v_cb ); |
klauss | 91:c2a86b1f8aaa | 68 | list = false; |
klauss | 114:472502b31a12 | 69 | } |
klauss | 114:472502b31a12 | 70 | |
klauss | 119:ee6a53069455 | 71 | if ( long_list ) |
klauss | 106:a34fcf9f0e02 | 72 | { |
klauss | 119:ee6a53069455 | 73 | show_cb_long_list ( v_cb ); |
klauss | 91:c2a86b1f8aaa | 74 | long_list = false; |
klauss | 52:12930cef17c4 | 75 | } |
klauss | 119:ee6a53069455 | 76 | |
klauss | 119:ee6a53069455 | 77 | if ( pshowcb ) |
klauss | 119:ee6a53069455 | 78 | { |
klauss | 119:ee6a53069455 | 79 | show_cb ( v_cb ); |
klauss | 78:1353744f01e1 | 80 | pshowcb = false; |
klauss | 48:195c97f12e8e | 81 | } |
klauss | 97:8985817e8847 | 82 | |
klauss | 119:ee6a53069455 | 83 | if ( show_current_time ) |
klauss | 119:ee6a53069455 | 84 | { |
klauss | 119:ee6a53069455 | 85 | show_clock (); |
klauss | 119:ee6a53069455 | 86 | show_current_time = false;; |
klauss | 119:ee6a53069455 | 87 | } |
klauss | 119:ee6a53069455 | 88 | |
klauss | 120:770f00554b1e | 89 | if( show_sip ){ |
klauss | 120:770f00554b1e | 90 | show_cb_sip ( v_cb ); |
klauss | 97:8985817e8847 | 91 | show_sip = false; |
klauss | 97:8985817e8847 | 92 | } |
klauss | 91:c2a86b1f8aaa | 93 | |
klauss | 81:3656f00ab3db | 94 | if( pflood == true ) flood(); |
klauss | 91:c2a86b1f8aaa | 95 | |
klauss | 91:c2a86b1f8aaa | 96 | if( debug_eth ) { |
klauss | 120:770f00554b1e | 97 | send_msg("Eth status %s", ( eth_status == 0 ) ? "Connected" : "Disconnected" ); |
klauss | 81:3656f00ab3db | 98 | debug_eth = false; |
klauss | 81:3656f00ab3db | 99 | } |
klauss | 91:c2a86b1f8aaa | 100 | |
klauss | 120:770f00554b1e | 101 | // chechando se existe um pacote vindo do cbx pendente |
klauss | 119:ee6a53069455 | 102 | if( status != WAITING ) { |
klauss | 81:3656f00ab3db | 103 | pkg_wdt = RX_CB_IDLE; |
klauss | 119:ee6a53069455 | 104 | xmemcpy( cb_rx_buffer, buffer_from_cb_ptr, CB_BUFFER_SIZE ); |
klauss | 119:ee6a53069455 | 105 | status = WAITING; |
klauss | 81:3656f00ab3db | 106 | missed_pkg--; |
klauss | 119:ee6a53069455 | 107 | xmemcpy( buffer, cb_rx_buffer, CB_BUFFER_SIZE ); |
klauss | 91:c2a86b1f8aaa | 108 | |
klauss | 91:c2a86b1f8aaa | 109 | if( rx ) { |
klauss | 81:3656f00ab3db | 110 | char str[ 1024 ]; |
klauss | 81:3656f00ab3db | 111 | strcpy( str, "RX :: \n\r " ); |
klauss | 119:ee6a53069455 | 112 | for( register uint16_t i = 0; i < CB_BUFFER_SIZE; i++ ) { |
klauss | 81:3656f00ab3db | 113 | char tmp[ 16 ]; |
klauss | 81:3656f00ab3db | 114 | strcat( str, itoa( cb_rx_buffer[ i ], tmp, 16 ) ); |
klauss | 81:3656f00ab3db | 115 | if( ( i != 0 ) && !( ( i + 1 ) % 50 ) ) strcat( str, "\n\r " ); |
klauss | 91:c2a86b1f8aaa | 116 | |
klauss | 81:3656f00ab3db | 117 | else strcat( str, " " ); |
klauss | 81:3656f00ab3db | 118 | } |
klauss | 81:3656f00ab3db | 119 | send_msg( "%s", str ); |
klauss | 91:c2a86b1f8aaa | 120 | rx = false; |
klauss | 81:3656f00ab3db | 121 | } |
klauss | 91:c2a86b1f8aaa | 122 | |
klauss | 119:ee6a53069455 | 123 | data = parse_vz_pkg ( &ext, &port, &type, buffer ); |
klauss | 114:472502b31a12 | 124 | |
klauss | 119:ee6a53069455 | 125 | if( data != NULL ) |
klauss | 119:ee6a53069455 | 126 | { |
klauss | 78:1353744f01e1 | 127 | if( min_ext == 0 ) min_ext = ext; |
klauss | 91:c2a86b1f8aaa | 128 | |
klauss | 78:1353744f01e1 | 129 | if( ext > max_ext ) max_ext = ext; |
klauss | 91:c2a86b1f8aaa | 130 | |
klauss | 78:1353744f01e1 | 131 | if( ext < min_ext ) min_ext = ext; |
klauss | 99:e80850c51106 | 132 | |
klauss | 119:ee6a53069455 | 133 | if( debug_fw ){ fw_cbx_pkg( ext, port, ( char *)buffer ); } |
klauss | 99:e80850c51106 | 134 | |
klauss | 119:ee6a53069455 | 135 | if( type == TELEMETRY ) telemetry_counter++; |
klauss | 114:472502b31a12 | 136 | |
klauss | 119:ee6a53069455 | 137 | if( type != AUDIO ) { |
klauss | 99:e80850c51106 | 138 | if( |
klauss | 119:ee6a53069455 | 139 | type == TELEMETRY || |
klauss | 119:ee6a53069455 | 140 | type == CB_STATS || |
klauss | 119:ee6a53069455 | 141 | type == FW1 || |
klauss | 119:ee6a53069455 | 142 | type == FW2 || |
klauss | 119:ee6a53069455 | 143 | type == FW3 || |
klauss | 119:ee6a53069455 | 144 | type == FW4 || |
klauss | 119:ee6a53069455 | 145 | type == FW5 || |
klauss | 119:ee6a53069455 | 146 | type == FW6 |
klauss | 119:ee6a53069455 | 147 | ) type = FW; |
klauss | 99:e80850c51106 | 148 | |
klauss | 99:e80850c51106 | 149 | if( debug_cb_rx == true ){ |
klauss | 119:ee6a53069455 | 150 | send_msg("[%d %d] -- Type :: %d", ext, port, type ); |
klauss | 99:e80850c51106 | 151 | } |
klauss | 99:e80850c51106 | 152 | |
klauss | 0:4d17cd9c8f9d | 153 | Call_Box * cb = __find_CB__( v_cb, ext ); |
klauss | 91:c2a86b1f8aaa | 154 | if( cb != NULL ) { |
klauss | 92:92df17f538a8 | 155 | if( data[ 0 ] & BIT7 ) { |
klauss | 119:ee6a53069455 | 156 | if( type == BOOT ) { |
klauss | 119:ee6a53069455 | 157 | send2callboxes( build_cb_package( ext, port, REGISTRY, |
klauss | 119:ee6a53069455 | 158 | ( char * )data, cb->get_msg_id(), CB_BUFFER_SIZE - VZ_HEADER_OFFSET, write_buffer ) ); |
klauss | 92:92df17f538a8 | 159 | } else { |
klauss | 119:ee6a53069455 | 160 | if( debug_main ) debug_msg("[%d] Received ack pkg with seq_num %d", ext, data[ 0 ] ); |
klauss | 91:c2a86b1f8aaa | 161 | |
klauss | 91:c2a86b1f8aaa | 162 | switch( type ) { |
klauss | 119:ee6a53069455 | 163 | case INVITE : { |
klauss | 119:ee6a53069455 | 164 | if( debug_main || debug_invite ) debug_msg("[%d] Invite Ack - msg_id %d -- Cbx seqNum %d", ext, cb->get_msg_id(), data[ 0 ] ); |
klauss | 91:c2a86b1f8aaa | 165 | break; |
klauss | 81:3656f00ab3db | 166 | } |
klauss | 119:ee6a53069455 | 167 | case CB_BYE : { |
klauss | 119:ee6a53069455 | 168 | if( debug_main || debug_invite ) debug_msg("[%d] BYE Ack - msg_id %d", ext, cb->get_msg_id() ); |
klauss | 81:3656f00ab3db | 169 | cb->set_bye_response_ok(); |
klauss | 91:c2a86b1f8aaa | 170 | break; |
klauss | 81:3656f00ab3db | 171 | } |
klauss | 119:ee6a53069455 | 172 | case REGISTRY : { |
klauss | 119:ee6a53069455 | 173 | if( debug_main || debug_aging ) debug_msg("[%d] Registry ACK - msg_id %d", ext, cb->get_msg_id() ); |
klauss | 81:3656f00ab3db | 174 | break; |
klauss | 81:3656f00ab3db | 175 | } |
klauss | 81:3656f00ab3db | 176 | default : { |
klauss | 119:ee6a53069455 | 177 | if( debug_main || debug_aging ) debug_msg("[%d] ACK msg_id :: %d :: type %d", ext, cb->get_msg_id(), type ); |
klauss | 91:c2a86b1f8aaa | 178 | } |
klauss | 81:3656f00ab3db | 179 | } |
klauss | 119:ee6a53069455 | 180 | if( type != REGISTRY && type != CB_BYE && type != INVITE ) type = DO_NOTHING; |
klauss | 119:ee6a53069455 | 181 | if( type == CB_BYE ){ |
klauss | 92:92df17f538a8 | 182 | VZ_call * call = __find_Call__( v_call, ext ); |
klauss | 92:92df17f538a8 | 183 | if( call != NULL ){ |
klauss | 92:92df17f538a8 | 184 | if( call->get_elapsed_time() < 120000 ){ |
klauss | 119:ee6a53069455 | 185 | if( debug_invite ) debug_msg("[%d] ack bye ignored", ext ); |
klauss | 119:ee6a53069455 | 186 | type = DO_NOTHING; |
klauss | 92:92df17f538a8 | 187 | } |
klauss | 92:92df17f538a8 | 188 | } |
klauss | 92:92df17f538a8 | 189 | } |
klauss | 0:4d17cd9c8f9d | 190 | } |
klauss | 0:4d17cd9c8f9d | 191 | } |
klauss | 0:4d17cd9c8f9d | 192 | } |
klauss | 0:4d17cd9c8f9d | 193 | } |
klauss | 119:ee6a53069455 | 194 | } else type = DO_NOTHING; |
klauss | 0:4d17cd9c8f9d | 195 | } |
klauss | 91:c2a86b1f8aaa | 196 | |
klauss | 119:ee6a53069455 | 197 | if( sizes == true ) |
klauss | 119:ee6a53069455 | 198 | { |
klauss | 120:770f00554b1e | 199 | show_sizes (); |
klauss | 119:ee6a53069455 | 200 | sizes = false; |
klauss | 109:a5b8264ffbbc | 201 | } |
klauss | 109:a5b8264ffbbc | 202 | |
klauss | 120:770f00554b1e | 203 | // usado pra testes |
klauss | 114:472502b31a12 | 204 | if ( registra ) |
klauss | 112:6ae726539ab9 | 205 | { |
klauss | 112:6ae726539ab9 | 206 | int internal_ext = 8000; |
klauss | 112:6ae726539ab9 | 207 | registra = false; |
klauss | 112:6ae726539ab9 | 208 | for( register uint8_t i = 0; i < 4; i++ ) { |
klauss | 112:6ae726539ab9 | 209 | v_cb -> add ( new Call_Box ( internal_ext, internal_ext++ ) ); |
klauss | 112:6ae726539ab9 | 210 | } |
klauss | 112:6ae726539ab9 | 211 | } |
klauss | 112:6ae726539ab9 | 212 | |
klauss | 120:770f00554b1e | 213 | check_udp_packages_pending ( v_cb ); |
klauss | 120:770f00554b1e | 214 | |
klauss | 120:770f00554b1e | 215 | if( dshow_rtp == true ) |
klauss | 109:a5b8264ffbbc | 216 | { |
klauss | 120:770f00554b1e | 217 | show_rtp (); |
klauss | 120:770f00554b1e | 218 | dshow_rtp = false; |
klauss | 120:770f00554b1e | 219 | } |
klauss | 117:e9facba9db27 | 220 | |
klauss | 120:770f00554b1e | 221 | // usado pra test |
klauss | 120:770f00554b1e | 222 | if ( frtp ) |
klauss | 120:770f00554b1e | 223 | { |
klauss | 120:770f00554b1e | 224 | fuck_rtp ( v_cb ); |
klauss | 120:770f00554b1e | 225 | frtp = false; |
klauss | 109:a5b8264ffbbc | 226 | } |
klauss | 109:a5b8264ffbbc | 227 | |
klauss | 120:770f00554b1e | 228 | // usado pra test |
klauss | 109:a5b8264ffbbc | 229 | if ( rescue_rtp ) |
klauss | 109:a5b8264ffbbc | 230 | { |
klauss | 109:a5b8264ffbbc | 231 | rescue_rtp = false; |
klauss | 109:a5b8264ffbbc | 232 | Call_Box * cb = __find_CB__( v_cb, rescue_rtp_target ); |
klauss | 109:a5b8264ffbbc | 233 | if ( cb != NULL ) |
klauss | 109:a5b8264ffbbc | 234 | { |
klauss | 109:a5b8264ffbbc | 235 | cb -> set_rtp_port ( rescue_rtp_value ); |
klauss | 109:a5b8264ffbbc | 236 | } |
klauss | 109:a5b8264ffbbc | 237 | else |
klauss | 109:a5b8264ffbbc | 238 | { |
klauss | 109:a5b8264ffbbc | 239 | debug_msg("rescue rtp fail"); |
klauss | 109:a5b8264ffbbc | 240 | } |
klauss | 109:a5b8264ffbbc | 241 | |
klauss | 109:a5b8264ffbbc | 242 | } |
klauss | 109:a5b8264ffbbc | 243 | |
klauss | 109:a5b8264ffbbc | 244 | if ( print_v_cb ) |
klauss | 109:a5b8264ffbbc | 245 | { |
klauss | 120:770f00554b1e | 246 | v_cb->print_yourself (); |
klauss | 109:a5b8264ffbbc | 247 | print_v_cb = false; |
klauss | 109:a5b8264ffbbc | 248 | } |
klauss | 109:a5b8264ffbbc | 249 | |
klauss | 109:a5b8264ffbbc | 250 | if ( print_v_call ) |
klauss | 109:a5b8264ffbbc | 251 | { |
klauss | 109:a5b8264ffbbc | 252 | v_call->print_yourself (); |
klauss | 120:770f00554b1e | 253 | print_v_call = false; |
klauss | 109:a5b8264ffbbc | 254 | } |
klauss | 109:a5b8264ffbbc | 255 | |
klauss | 109:a5b8264ffbbc | 256 | if ( print_cb_var ) |
klauss | 109:a5b8264ffbbc | 257 | { |
klauss | 120:770f00554b1e | 258 | show_cb_content (); |
klauss | 109:a5b8264ffbbc | 259 | print_cb_var = false; |
klauss | 109:a5b8264ffbbc | 260 | } |
klauss | 109:a5b8264ffbbc | 261 | |
klauss | 109:a5b8264ffbbc | 262 | if ( print_cb_all ) |
klauss | 109:a5b8264ffbbc | 263 | { |
klauss | 120:770f00554b1e | 264 | show_cb_content_all (); |
klauss | 109:a5b8264ffbbc | 265 | print_cb_all = false; |
klauss | 109:a5b8264ffbbc | 266 | } |
klauss | 109:a5b8264ffbbc | 267 | |
klauss | 109:a5b8264ffbbc | 268 | if ( print_hex_cb_var ) |
klauss | 109:a5b8264ffbbc | 269 | { |
klauss | 120:770f00554b1e | 270 | show_hex_cb_content (); |
klauss | 109:a5b8264ffbbc | 271 | print_hex_cb_var = false; |
klauss | 81:3656f00ab3db | 272 | } |
klauss | 106:a34fcf9f0e02 | 273 | |
klauss | 109:a5b8264ffbbc | 274 | if ( print_hex_cb_all ) |
klauss | 109:a5b8264ffbbc | 275 | { |
klauss | 120:770f00554b1e | 276 | show_hex_cb_content_all (); |
klauss | 109:a5b8264ffbbc | 277 | print_hex_cb_all = false; |
klauss | 109:a5b8264ffbbc | 278 | } |
klauss | 106:a34fcf9f0e02 | 279 | |
klauss | 120:770f00554b1e | 280 | if ( print_sip_var ) |
klauss | 109:a5b8264ffbbc | 281 | { |
klauss | 120:770f00554b1e | 282 | show_cB_sip (); |
klauss | 120:770f00554b1e | 283 | print_sip_var = false; |
klauss | 120:770f00554b1e | 284 | } |
klauss | 109:a5b8264ffbbc | 285 | |
klauss | 120:770f00554b1e | 286 | if ( print_sip_all ) |
klauss | 120:770f00554b1e | 287 | { |
klauss | 120:770f00554b1e | 288 | show_cB_sip_all (); |
klauss | 120:770f00554b1e | 289 | print_sip_all = false; |
klauss | 120:770f00554b1e | 290 | } |
klauss | 120:770f00554b1e | 291 | |
klauss | 120:770f00554b1e | 292 | if ( print_hex_sip_var ) |
klauss | 120:770f00554b1e | 293 | { |
klauss | 120:770f00554b1e | 294 | show_cB_hex_sip (); |
klauss | 120:770f00554b1e | 295 | print_hex_sip_var = false; |
klauss | 120:770f00554b1e | 296 | } |
klauss | 109:a5b8264ffbbc | 297 | |
klauss | 109:a5b8264ffbbc | 298 | if( dcallshow_rtp == true ){ |
klauss | 120:770f00554b1e | 299 | show_rtp_on_call (); |
klauss | 109:a5b8264ffbbc | 300 | dcallshow_rtp = false; |
klauss | 109:a5b8264ffbbc | 301 | } |
klauss | 109:a5b8264ffbbc | 302 | |
klauss | 109:a5b8264ffbbc | 303 | if ( print_call_var ) |
klauss | 109:a5b8264ffbbc | 304 | { |
klauss | 120:770f00554b1e | 305 | show_call (); |
klauss | 109:a5b8264ffbbc | 306 | print_call_var = false; |
klauss | 120:770f00554b1e | 307 | |
klauss | 109:a5b8264ffbbc | 308 | } |
klauss | 109:a5b8264ffbbc | 309 | |
klauss | 109:a5b8264ffbbc | 310 | if ( print_hex_call_var ) |
klauss | 109:a5b8264ffbbc | 311 | { |
klauss | 120:770f00554b1e | 312 | show_hex_call (); |
klauss | 109:a5b8264ffbbc | 313 | print_hex_call_var = false; |
klauss | 109:a5b8264ffbbc | 314 | } |
klauss | 109:a5b8264ffbbc | 315 | |
klauss | 109:a5b8264ffbbc | 316 | |
klauss | 109:a5b8264ffbbc | 317 | if ( print_hex_rtp_var ) |
klauss | 109:a5b8264ffbbc | 318 | { |
klauss | 120:770f00554b1e | 319 | show_cb_rtp (); |
klauss | 109:a5b8264ffbbc | 320 | print_hex_rtp_var = false; |
klauss | 109:a5b8264ffbbc | 321 | } |
klauss | 109:a5b8264ffbbc | 322 | |
klauss | 109:a5b8264ffbbc | 323 | if ( print_rtp_var ) |
klauss | 109:a5b8264ffbbc | 324 | { |
klauss | 120:770f00554b1e | 325 | show_cb_hex_rtp (); |
klauss | 109:a5b8264ffbbc | 326 | print_rtp_var = false; |
klauss | 81:3656f00ab3db | 327 | } |
klauss | 91:c2a86b1f8aaa | 328 | |
klauss | 120:770f00554b1e | 329 | if( reset_cks == true ) |
klauss | 120:770f00554b1e | 330 | { |
klauss | 120:770f00554b1e | 331 | reset_stats_cks (); |
klauss | 120:770f00554b1e | 332 | pcks_s = true; |
klauss | 120:770f00554b1e | 333 | reset_cks = false; |
klauss | 120:770f00554b1e | 334 | } |
klauss | 120:770f00554b1e | 335 | |
klauss | 91:c2a86b1f8aaa | 336 | if( pcks_s == true ) { |
klauss | 120:770f00554b1e | 337 | show_cb_stats (); |
klauss | 81:3656f00ab3db | 338 | pcks_s = false; |
klauss | 81:3656f00ab3db | 339 | } |
klauss | 119:ee6a53069455 | 340 | |
klauss | 120:770f00554b1e | 341 | |
klauss | 120:770f00554b1e | 342 | if( reset_missed_send_udp_pkg ) |
klauss | 120:770f00554b1e | 343 | { |
klauss | 120:770f00554b1e | 344 | reset_missed_send_udp (); |
klauss | 120:770f00554b1e | 345 | missed_send_udp_pkg = true; |
klauss | 119:ee6a53069455 | 346 | reset_missed_send_udp_pkg = false; |
klauss | 119:ee6a53069455 | 347 | } |
klauss | 119:ee6a53069455 | 348 | |
klauss | 120:770f00554b1e | 349 | |
klauss | 119:ee6a53069455 | 350 | if( missed_send_udp_pkg ) |
klauss | 119:ee6a53069455 | 351 | { |
klauss | 120:770f00554b1e | 352 | show_missed_send_udp_pkg (); |
klauss | 119:ee6a53069455 | 353 | missed_send_udp_pkg = false; |
klauss | 119:ee6a53069455 | 354 | } |
klauss | 114:472502b31a12 | 355 | |
klauss | 100:09a23fcd3bdf | 356 | if( flood_bug_pkg ){ |
klauss | 100:09a23fcd3bdf | 357 | static int id = 0x10; |
klauss | 100:09a23fcd3bdf | 358 | if( id < 10 ) id = 0x0b; |
klauss | 119:ee6a53069455 | 359 | send2callboxes( build_cb_package( 5828, 5123, REGISTRY, |
klauss | 119:ee6a53069455 | 360 | ( char * )buffer, id++, CB_BUFFER_SIZE - VZ_HEADER_OFFSET, write_buffer ) ); |
klauss | 100:09a23fcd3bdf | 361 | } |
klauss | 100:09a23fcd3bdf | 362 | |
klauss | 114:472502b31a12 | 363 | if( led_sync_timer.read() > 1 ) { |
klauss | 78:1353744f01e1 | 364 | led_sync_timer.reset(); |
klauss | 78:1353744f01e1 | 365 | led3 = !led3; |
klauss | 78:1353744f01e1 | 366 | CAB_LED = !CAB_LED; |
klauss | 78:1353744f01e1 | 367 | } |
klauss | 114:472502b31a12 | 368 | |
klauss | 91:c2a86b1f8aaa | 369 | switch( type ) { |
klauss | 119:ee6a53069455 | 370 | case DO_NOTHING : |
klauss | 91:c2a86b1f8aaa | 371 | {} |
klauss | 91:c2a86b1f8aaa | 372 | break; |
klauss | 91:c2a86b1f8aaa | 373 | |
klauss | 119:ee6a53069455 | 374 | case CB_BYE : { |
klauss | 63:0d95da692bb4 | 375 | cb_bye_counter++; |
klauss | 0:4d17cd9c8f9d | 376 | Call_Box * cb = __find_CB__( v_cb, ext ); |
klauss | 91:c2a86b1f8aaa | 377 | if( cb != NULL ) { |
klauss | 119:ee6a53069455 | 378 | if( debug_invite || debug_main ) debug_msg("[%d] Bye pkg - msg_id %d e pkg_id %d", ext, cb->get_msg_id(), data[ 0 ] ); |
klauss | 92:92df17f538a8 | 379 | |
klauss | 81:3656f00ab3db | 380 | bool already_removed = true; |
klauss | 119:ee6a53069455 | 381 | |
klauss | 119:ee6a53069455 | 382 | if( cb->get_status() != cb_idle ) { |
klauss | 119:ee6a53069455 | 383 | already_removed = false; |
klauss | 119:ee6a53069455 | 384 | |
klauss | 119:ee6a53069455 | 385 | data[ TIMESLICE_PLACE ] = 0; |
klauss | 119:ee6a53069455 | 386 | |
klauss | 119:ee6a53069455 | 387 | send2callboxes( build_cb_package( ext, port, CB_BYE, |
klauss | 119:ee6a53069455 | 388 | ( char * )data, data[ 0 ] |= BIT7, CB_BUFFER_SIZE - VZ_HEADER_OFFSET, write_buffer ) ); |
klauss | 119:ee6a53069455 | 389 | |
klauss | 119:ee6a53069455 | 390 | ts->return_timeslice( cb->call_end () ); |
klauss | 119:ee6a53069455 | 391 | } |
klauss | 119:ee6a53069455 | 392 | |
klauss | 119:ee6a53069455 | 393 | if( already_removed ) if( debug_main || debug_invite ) debug_msg( "[%d] Already removed from inviting queue", ext ); |
klauss | 119:ee6a53069455 | 394 | |
klauss | 119:ee6a53069455 | 395 | already_removed = true; |
klauss | 119:ee6a53069455 | 396 | |
klauss | 119:ee6a53069455 | 397 | for ( register uint8_t i = 0; i < v_call->size(); i++ ) |
klauss | 119:ee6a53069455 | 398 | { |
klauss | 0:4d17cd9c8f9d | 399 | VZ_call * call = (VZ_call *)v_call->get_element( i ); |
klauss | 119:ee6a53069455 | 400 | if( call->get_cb_ext() == ext ) |
klauss | 119:ee6a53069455 | 401 | { |
klauss | 81:3656f00ab3db | 402 | already_removed = false; |
klauss | 119:ee6a53069455 | 403 | |
klauss | 119:ee6a53069455 | 404 | data[ TIMESLICE_PLACE ] = 0; |
klauss | 91:c2a86b1f8aaa | 405 | |
klauss | 81:3656f00ab3db | 406 | v_call->remove_element( i ); |
klauss | 119:ee6a53069455 | 407 | |
klauss | 119:ee6a53069455 | 408 | send2callboxes( build_cb_package( ext, port, CB_BYE, |
klauss | 119:ee6a53069455 | 409 | ( char * )data, data[ 0 ] |= BIT7, CB_BUFFER_SIZE - VZ_HEADER_OFFSET, write_buffer ) ); |
klauss | 117:e9facba9db27 | 410 | |
klauss | 3:cd9148672e25 | 411 | delete( call ); |
klauss | 119:ee6a53069455 | 412 | |
klauss | 119:ee6a53069455 | 413 | ts->return_timeslice( cb->call_end () ); |
klauss | 0:4d17cd9c8f9d | 414 | } |
klauss | 0:4d17cd9c8f9d | 415 | } |
klauss | 119:ee6a53069455 | 416 | |
klauss | 119:ee6a53069455 | 417 | if( already_removed ) if( debug_main || debug_invite ) debug_msg( "[%d] Already removed from vector call", ext ); |
klauss | 82:f55d13babca0 | 418 | |
klauss | 119:ee6a53069455 | 419 | cb -> registry(); |
klauss | 119:ee6a53069455 | 420 | |
klauss | 119:ee6a53069455 | 421 | } else if( debug_invite || debug_main ) debug_msg("[%d] Bye from who ?", ext ); |
klauss | 91:c2a86b1f8aaa | 422 | } |
klauss | 91:c2a86b1f8aaa | 423 | break; |
klauss | 91:c2a86b1f8aaa | 424 | |
klauss | 119:ee6a53069455 | 425 | case INVITE : { |
klauss | 114:472502b31a12 | 426 | if( drop_invite_pkg ){ |
klauss | 119:ee6a53069455 | 427 | debug_msg("[%d] Dropando invite pck - msg id :: %d", ext, data[ 0 ] ); |
klauss | 114:472502b31a12 | 428 | break; |
klauss | 114:472502b31a12 | 429 | } |
klauss | 119:ee6a53069455 | 430 | |
klauss | 63:0d95da692bb4 | 431 | invite_counter++; |
klauss | 119:ee6a53069455 | 432 | |
klauss | 119:ee6a53069455 | 433 | if( debug_invite ) debug_msg("[%d] Invite request", ext); |
klauss | 119:ee6a53069455 | 434 | |
klauss | 0:4d17cd9c8f9d | 435 | Call_Box * cb = __find_CB__( v_cb, ext ); |
klauss | 119:ee6a53069455 | 436 | |
klauss | 91:c2a86b1f8aaa | 437 | if( cb == NULL ) { |
klauss | 119:ee6a53069455 | 438 | if( v_cb->size() < MAX_CB_IN_A_BRANCH ) { |
klauss | 119:ee6a53069455 | 439 | if( debug_main ) debug_msg( "[%d] Adding CBx", ext ); |
klauss | 91:c2a86b1f8aaa | 440 | cb = new Call_Box( ext, port ); |
klauss | 91:c2a86b1f8aaa | 441 | |
klauss | 91:c2a86b1f8aaa | 442 | if( cb == NULL ) { |
klauss | 91:c2a86b1f8aaa | 443 | memory_is_over = true; |
klauss | 119:ee6a53069455 | 444 | if( debug_memory ) debug_msg("[%d] Invite allocation cb fail", ext ); |
klauss | 91:c2a86b1f8aaa | 445 | } else { |
klauss | 91:c2a86b1f8aaa | 446 | v_cb->add( cb ); |
klauss | 91:c2a86b1f8aaa | 447 | } |
klauss | 89:0fe315117b00 | 448 | } |
klauss | 0:4d17cd9c8f9d | 449 | } |
klauss | 119:ee6a53069455 | 450 | |
klauss | 119:ee6a53069455 | 451 | if( cb != NULL ) |
klauss | 119:ee6a53069455 | 452 | { |
klauss | 119:ee6a53069455 | 453 | cb->invite_retry_count_reset(); |
klauss | 119:ee6a53069455 | 454 | |
klauss | 91:c2a86b1f8aaa | 455 | cb->set_msg_id( data[ 0 ] ); |
klauss | 119:ee6a53069455 | 456 | |
klauss | 119:ee6a53069455 | 457 | if( cb->status == cb_idle ){ |
klauss | 119:ee6a53069455 | 458 | cb -> call_config (); |
klauss | 119:ee6a53069455 | 459 | } else { |
klauss | 119:ee6a53069455 | 460 | data[ TIMESLICE_PLACE ] = cb->get_timeslice(); |
klauss | 119:ee6a53069455 | 461 | |
klauss | 119:ee6a53069455 | 462 | cb->set_invite_response_pending(); |
klauss | 119:ee6a53069455 | 463 | |
klauss | 119:ee6a53069455 | 464 | send2callboxes( build_cb_package( ext, port, INVITE, |
klauss | 119:ee6a53069455 | 465 | ( char * )data, cb->msg_id_update (), CB_BUFFER_SIZE - VZ_HEADER_OFFSET, write_buffer ) ); |
klauss | 92:92df17f538a8 | 466 | } |
klauss | 119:ee6a53069455 | 467 | |
klauss | 87:679ee0d594a9 | 468 | invite_handler( v_call, v_cb, ts, cb ); |
klauss | 87:679ee0d594a9 | 469 | } |
klauss | 91:c2a86b1f8aaa | 470 | } |
klauss | 91:c2a86b1f8aaa | 471 | break; |
klauss | 120:770f00554b1e | 472 | |
klauss | 119:ee6a53069455 | 473 | case REGISTRY : { |
klauss | 63:0d95da692bb4 | 474 | registry_counter++; |
klauss | 78:1353744f01e1 | 475 | Call_Box * cb = __find_CB__( v_cb, ext ); |
klauss | 119:ee6a53069455 | 476 | |
klauss | 119:ee6a53069455 | 477 | if( cb == NULL ) |
klauss | 119:ee6a53069455 | 478 | { |
klauss | 119:ee6a53069455 | 479 | if( v_cb->size() < MAX_CB_IN_A_BRANCH ) |
klauss | 119:ee6a53069455 | 480 | { |
klauss | 119:ee6a53069455 | 481 | if( debug_main ) debug_msg("[%d] Adding Cbx", ext ); |
klauss | 91:c2a86b1f8aaa | 482 | cb = new Call_Box( ext, port ); |
klauss | 91:c2a86b1f8aaa | 483 | |
klauss | 91:c2a86b1f8aaa | 484 | if( cb == NULL ) { |
klauss | 91:c2a86b1f8aaa | 485 | memory_is_over = true; |
klauss | 119:ee6a53069455 | 486 | if( debug_memory ) debug_msg("[%d] Registry cb allocation fail", ext ); |
klauss | 91:c2a86b1f8aaa | 487 | } else { |
klauss | 91:c2a86b1f8aaa | 488 | v_cb->add( cb ); |
klauss | 119:ee6a53069455 | 489 | if( debug_main ) debug_msg("[%d] Added CBx", ext ); |
klauss | 91:c2a86b1f8aaa | 490 | } |
klauss | 87:679ee0d594a9 | 491 | } |
klauss | 0:4d17cd9c8f9d | 492 | } |
klauss | 119:ee6a53069455 | 493 | |
klauss | 119:ee6a53069455 | 494 | if( debug_main ) debug_msg("[%d %d] Registered", ext, port ); |
klauss | 91:c2a86b1f8aaa | 495 | |
klauss | 87:679ee0d594a9 | 496 | if( cb != NULL ) cb->registry(); |
klauss | 91:c2a86b1f8aaa | 497 | } |
klauss | 91:c2a86b1f8aaa | 498 | break; |
klauss | 120:770f00554b1e | 499 | |
klauss | 119:ee6a53069455 | 500 | case BOOT : { |
klauss | 63:0d95da692bb4 | 501 | boot_counter++; |
klauss | 99:e80850c51106 | 502 | if( debug_boot == true ){ |
klauss | 119:ee6a53069455 | 503 | send_msg("[%d %d] Boot pkg -- pkg-id %d", ext, port, data[ 0 ] ); |
klauss | 99:e80850c51106 | 504 | } |
klauss | 119:ee6a53069455 | 505 | send2callboxes( build_cb_package( ext, port, REGISTRY, |
klauss | 119:ee6a53069455 | 506 | ( char * )data, data[ 0 ] | BIT7, CB_BUFFER_SIZE - VZ_HEADER_OFFSET, write_buffer ) ); |
klauss | 117:e9facba9db27 | 507 | } |
klauss | 117:e9facba9db27 | 508 | break; |
klauss | 117:e9facba9db27 | 509 | |
klauss | 119:ee6a53069455 | 510 | case FW : { |
klauss | 119:ee6a53069455 | 511 | if( debug_fw_print ) send_msg("[%d %d]::FW pkg::", ext, port ); |
klauss | 99:e80850c51106 | 512 | fw_cbx_pkg( ext, port, ( char *)buffer ); |
klauss | 99:e80850c51106 | 513 | } |
klauss | 99:e80850c51106 | 514 | break; |
klauss | 91:c2a86b1f8aaa | 515 | |
klauss | 119:ee6a53069455 | 516 | case BOOTLOADER_CBX : { |
klauss | 117:e9facba9db27 | 517 | uint16_t bl_cnt2 = 0; |
klauss | 117:e9facba9db27 | 518 | //char bl_send_buffer[ BL_SIZE + 2 ]; |
klauss | 117:e9facba9db27 | 519 | //int ret = bl_cbx_reply_to_eth( ext, ( char * )data ); |
klauss | 117:e9facba9db27 | 520 | //BLEUBA |
klauss | 117:e9facba9db27 | 521 | //pc.printf("\r\nCBX RESPONDEU BOOTLOADER!\r\n"); |
klauss | 117:e9facba9db27 | 522 | if (debug_bootloader) { |
klauss | 117:e9facba9db27 | 523 | pc.printf("\r\npacote CBX->HDR {"); |
klauss | 117:e9facba9db27 | 524 | for (bl_cnt2 = 0;bl_cnt2 < BL_SIZE + 1;bl_cnt2++) { |
klauss | 117:e9facba9db27 | 525 | if ((bl_cnt2 % 30) == 0) { |
klauss | 117:e9facba9db27 | 526 | pc.printf("\r\n "); |
klauss | 117:e9facba9db27 | 527 | pc.printf(hex16(bl_cnt2)); |
klauss | 117:e9facba9db27 | 528 | pc.printf(" : "); |
klauss | 117:e9facba9db27 | 529 | } |
klauss | 117:e9facba9db27 | 530 | pc.printf(hex8(data[bl_cnt2])); |
klauss | 117:e9facba9db27 | 531 | pc.printf(", "); |
klauss | 117:e9facba9db27 | 532 | } |
klauss | 117:e9facba9db27 | 533 | pc.printf("\r\n}"); |
klauss | 117:e9facba9db27 | 534 | } |
klauss | 67:cdedc64d9921 | 535 | bootloader_cbx_counter++; |
klauss | 117:e9facba9db27 | 536 | bl_send_buffer[0] = (char)(ext >> 8); |
klauss | 117:e9facba9db27 | 537 | bl_send_buffer[1] = (char)(ext & 0xff); |
klauss | 117:e9facba9db27 | 538 | for (bl_cnt2 = 0; bl_cnt2 < BL_SIZE; bl_cnt2++) { |
klauss | 117:e9facba9db27 | 539 | bl_send_buffer[bl_cnt2 + 2] = data[bl_cnt2 + 1]; |
klauss | 117:e9facba9db27 | 540 | } |
klauss | 117:e9facba9db27 | 541 | if (debug_bootloader) { |
klauss | 117:e9facba9db27 | 542 | pc.printf("\r\npacote HDR->SRV {"); |
klauss | 117:e9facba9db27 | 543 | for (bl_cnt2 = 0;bl_cnt2 < UDP_BL_SIZE;bl_cnt2++) { |
klauss | 117:e9facba9db27 | 544 | if ((bl_cnt2 % 30) == 0) { |
klauss | 117:e9facba9db27 | 545 | pc.printf("\r\n "); |
klauss | 117:e9facba9db27 | 546 | pc.printf(hex16(bl_cnt2)); |
klauss | 117:e9facba9db27 | 547 | pc.printf(" : "); |
klauss | 117:e9facba9db27 | 548 | } |
klauss | 117:e9facba9db27 | 549 | pc.printf(hex8(bl_send_buffer[bl_cnt2])); |
klauss | 117:e9facba9db27 | 550 | pc.printf(", "); |
klauss | 117:e9facba9db27 | 551 | } |
klauss | 117:e9facba9db27 | 552 | pc.printf("\r\n}"); |
klauss | 117:e9facba9db27 | 553 | } |
klauss | 117:e9facba9db27 | 554 | udp_bl_client.sendTo( udp_bl_server, bl_send_buffer, UDP_BL_SIZE ); |
klauss | 91:c2a86b1f8aaa | 555 | } |
klauss | 91:c2a86b1f8aaa | 556 | break; |
klauss | 91:c2a86b1f8aaa | 557 | |
klauss | 119:ee6a53069455 | 558 | case PROMPT : { |
klauss | 78:1353744f01e1 | 559 | Call_Box * cb = __find_CB__( v_cb, ext ); |
klauss | 91:c2a86b1f8aaa | 560 | |
klauss | 91:c2a86b1f8aaa | 561 | if( cb == NULL ) { |
klauss | 119:ee6a53069455 | 562 | if( v_cb->size() < MAX_CB_IN_A_BRANCH ) { |
klauss | 119:ee6a53069455 | 563 | if( debug_main ) debug_msg("[%d] Adding Cbx", ext ); |
klauss | 119:ee6a53069455 | 564 | cb = new Call_Box( ext, port ); |
klauss | 119:ee6a53069455 | 565 | if( cb == NULL ){ |
klauss | 119:ee6a53069455 | 566 | memory_is_over = true; |
klauss | 119:ee6a53069455 | 567 | }else{ |
klauss | 119:ee6a53069455 | 568 | v_cb->add( cb ); |
klauss | 119:ee6a53069455 | 569 | if( debug_main ) debug_msg("[%d] Added CBx", ext ); |
klauss | 119:ee6a53069455 | 570 | } |
klauss | 87:679ee0d594a9 | 571 | } |
klauss | 48:195c97f12e8e | 572 | } |
klauss | 91:c2a86b1f8aaa | 573 | |
klauss | 92:92df17f538a8 | 574 | if( cb!= NULL ) cb->registry(); |
klauss | 91:c2a86b1f8aaa | 575 | |
klauss | 91:c2a86b1f8aaa | 576 | if( xstrmatch( ( uint8_t * )data, ( uint8_t * )"ping" ) ) { |
klauss | 119:ee6a53069455 | 577 | if( debug_ping ) send_msg( "[%d %d] Prompt pkg :: Ping", ext, port ); |
klauss | 91:c2a86b1f8aaa | 578 | } else { |
klauss | 78:1353744f01e1 | 579 | prompt_counter++; |
klauss | 114:472502b31a12 | 580 | //fixme isso nao poderia ser resolvido com um sendmsg ? |
klauss | 119:ee6a53069455 | 581 | send_msg( "[%i, %i] Prompt pkg::", ext, port ); |
klauss | 91:c2a86b1f8aaa | 582 | for( register uint8_t i = 0; i < 32; i++ ) { |
klauss | 100:09a23fcd3bdf | 583 | if( debug_uart3 ) pc.printf("%c", data[ i ] ); |
klauss | 100:09a23fcd3bdf | 584 | if( i == 15 ) if( debug_uart3 ) pc.printf( "\r\n" ); |
klauss | 78:1353744f01e1 | 585 | } |
klauss | 100:09a23fcd3bdf | 586 | if( debug_uart3 ) pc.printf("\n\r> "); |
klauss | 91:c2a86b1f8aaa | 587 | |
klauss | 114:472502b31a12 | 588 | if( tcp_session ) { |
klauss | 119:ee6a53069455 | 589 | char aux[ CB_BUFFER_SIZE + 3 ]; |
klauss | 119:ee6a53069455 | 590 | strncpy( aux, (char * )data, CB_BUFFER_SIZE ); |
klauss | 78:1353744f01e1 | 591 | strcat( aux, "\n\r\0" ); |
klauss | 78:1353744f01e1 | 592 | tcp_client.send_all( ( char *)data, strlen( (char * )data ) ); |
klauss | 78:1353744f01e1 | 593 | tcp_client.send_all( "\r\n> ", strlen( "\r\n> " ) ); |
klauss | 78:1353744f01e1 | 594 | } |
klauss | 48:195c97f12e8e | 595 | } |
klauss | 91:c2a86b1f8aaa | 596 | } |
klauss | 91:c2a86b1f8aaa | 597 | break; |
klauss | 120:770f00554b1e | 598 | |
klauss | 119:ee6a53069455 | 599 | case AUDIO : { |
klauss | 63:0d95da692bb4 | 600 | audio_counter++; |
klauss | 119:ee6a53069455 | 601 | if ( received_audio_from_cb ) { |
klauss | 119:ee6a53069455 | 602 | debug_msg("[%d] audio pkg", ext ); |
klauss | 119:ee6a53069455 | 603 | } |
klauss | 119:ee6a53069455 | 604 | |
klauss | 78:1353744f01e1 | 605 | VZ_call * call = __find_Call__( v_call, ext ); |
klauss | 91:c2a86b1f8aaa | 606 | if( call != NULL ) { |
klauss | 119:ee6a53069455 | 607 | if ( drop_rtp_from_cbx_pkg ){ |
klauss | 114:472502b31a12 | 608 | led2 = !led2; |
klauss | 114:472502b31a12 | 609 | break; |
klauss | 119:ee6a53069455 | 610 | } else { |
klauss | 114:472502b31a12 | 611 | char * pkg = call->build_eth_package( data + 2 ); |
klauss | 114:472502b31a12 | 612 | call->send_message( pkg ); |
klauss | 114:472502b31a12 | 613 | call->cbx_pkg_idle_timer_reset(); |
klauss | 114:472502b31a12 | 614 | } |
klauss | 119:ee6a53069455 | 615 | } |
klauss | 119:ee6a53069455 | 616 | |
klauss | 119:ee6a53069455 | 617 | Call_Box * cb = __find_CB__( v_cb, ext ); |
klauss | 119:ee6a53069455 | 618 | if( cb != NULL ){ |
klauss | 119:ee6a53069455 | 619 | if ( cb->get_invite_response() == false ) { |
klauss | 119:ee6a53069455 | 620 | cb->set_invite_response_ok(); |
klauss | 119:ee6a53069455 | 621 | cb->invite_retry_count_reset(); |
klauss | 119:ee6a53069455 | 622 | } else { |
klauss | 119:ee6a53069455 | 623 | if( debug_main ) debug_msg("[%d] received missed package", ext ); |
klauss | 119:ee6a53069455 | 624 | } |
klauss | 0:4d17cd9c8f9d | 625 | } |
klauss | 91:c2a86b1f8aaa | 626 | } |
klauss | 91:c2a86b1f8aaa | 627 | break; |
klauss | 114:472502b31a12 | 628 | }// fim switch |
klauss | 105:a930035b6556 | 629 | |
klauss | 120:770f00554b1e | 630 | // rajada |
klauss | 120:770f00554b1e | 631 | if( invite_retry_timer.read_ms() >= 20 ) |
klauss | 120:770f00554b1e | 632 | { |
klauss | 120:770f00554b1e | 633 | invite_ack_to_cb_handler ( v_cb, v_call ); |
klauss | 112:6ae726539ab9 | 634 | |
klauss | 120:770f00554b1e | 635 | invite_retry_timer.reset(); |
klauss | 120:770f00554b1e | 636 | } |
klauss | 120:770f00554b1e | 637 | |
klauss | 120:770f00554b1e | 638 | check_audio_from_ast ( v_cb, v_call ); |
klauss | 99:e80850c51106 | 639 | |
klauss | 120:770f00554b1e | 640 | wake_up_or_refresh_handler ( v_cb ); |
klauss | 117:e9facba9db27 | 641 | |
klauss | 120:770f00554b1e | 642 | check_sip_messages_from_ast ( v_cb, v_call ); |
klauss | 119:ee6a53069455 | 643 | |
klauss | 81:3656f00ab3db | 644 | /* Verifica andamento de ligações para eventualmente encerra-las por timeout */ |
klauss | 119:ee6a53069455 | 645 | call_manager( v_call, v_cb, ts ); |
klauss | 91:c2a86b1f8aaa | 646 | |
klauss | 81:3656f00ab3db | 647 | invite_handler( v_call, v_cb, ts, NULL ); |
klauss | 114:472502b31a12 | 648 | |
klauss | 120:770f00554b1e | 649 | check_for_runaways_ts ( v_cb, ts ); |
klauss | 112:6ae726539ab9 | 650 | |
klauss | 120:770f00554b1e | 651 | check_for_unwanted_rtp_ports ( v_cb ); |
klauss | 120:770f00554b1e | 652 | |
klauss | 72:895ca792c647 | 653 | tx_buffer_ring_buffer_handler(); |
klauss | 91:c2a86b1f8aaa | 654 | |
klauss | 119:ee6a53069455 | 655 | type = DO_NOTHING; |
klauss | 114:472502b31a12 | 656 | |
klauss | 81:3656f00ab3db | 657 | if( eth_status == 0 ) eth_wdt = ETH_CONNECT_TIMEOUT; |
klauss | 114:472502b31a12 | 658 | |
klauss | 91:c2a86b1f8aaa | 659 | if( wdt_timer.read() >= 1 ) { |
klauss | 120:770f00554b1e | 660 | wdt_update (); |
klauss | 81:3656f00ab3db | 661 | wdt_timer.reset(); |
klauss | 114:472502b31a12 | 662 | } |
klauss | 114:472502b31a12 | 663 | |
klauss | 120:770f00554b1e | 664 | if( debug_wdt ) |
klauss | 120:770f00554b1e | 665 | { |
klauss | 120:770f00554b1e | 666 | show_wdt_status (); |
klauss | 81:3656f00ab3db | 667 | debug_wdt = false; |
klauss | 120:770f00554b1e | 668 | |
klauss | 114:472502b31a12 | 669 | } |
klauss | 120:770f00554b1e | 670 | }// fim while |
klauss | 120:770f00554b1e | 671 | }// fim main \o/ |