Modularizando o src
Dependencies: EALib EthernetInterface_vz mbed-rtos mbed
Fork of header_main_colinas_V0-20-09-14 by
Diff: main.cpp
- Revision:
- 121:ee02790d00b7
- Parent:
- 120:770f00554b1e
- Child:
- 122:480c44b0e205
diff -r 770f00554b1e -r ee02790d00b7 main.cpp --- a/main.cpp Mon May 04 17:25:29 2015 +0000 +++ b/main.cpp Fri May 08 04:15:23 2015 +0000 @@ -1,6 +1,6 @@ -//#include "main_app_var_configs.h" -//#include "main_app_functions.h" +#include "main_app_functions.h" #include "main_app_var_configs.h" +#include "header_app_includes.h" int main() { @@ -99,99 +99,9 @@ } // chechando se existe um pacote vindo do cbx pendente - if( status != WAITING ) { - pkg_wdt = RX_CB_IDLE; - xmemcpy( cb_rx_buffer, buffer_from_cb_ptr, CB_BUFFER_SIZE ); - status = WAITING; - missed_pkg--; - xmemcpy( buffer, cb_rx_buffer, CB_BUFFER_SIZE ); - - if( rx ) { - char str[ 1024 ]; - strcpy( str, "RX :: \n\r " ); - for( register uint16_t i = 0; i < CB_BUFFER_SIZE; i++ ) { - char tmp[ 16 ]; - strcat( str, itoa( cb_rx_buffer[ i ], tmp, 16 ) ); - if( ( i != 0 ) && !( ( i + 1 ) % 50 ) ) strcat( str, "\n\r " ); - - else strcat( str, " " ); - } - send_msg( "%s", str ); - rx = false; - } - - data = parse_vz_pkg ( &ext, &port, &type, buffer ); - - if( data != NULL ) - { - if( min_ext == 0 ) min_ext = ext; - - if( ext > max_ext ) max_ext = ext; - - if( ext < min_ext ) min_ext = ext; - - if( debug_fw ){ fw_cbx_pkg( ext, port, ( char *)buffer ); } - - if( type == TELEMETRY ) telemetry_counter++; - - if( type != AUDIO ) { - if( - type == TELEMETRY || - type == CB_STATS || - type == FW1 || - type == FW2 || - type == FW3 || - type == FW4 || - type == FW5 || - type == FW6 - ) type = FW; - - if( debug_cb_rx == true ){ - send_msg("[%d %d] -- Type :: %d", ext, port, type ); - } - - Call_Box * cb = __find_CB__( v_cb, ext ); - if( cb != NULL ) { - if( data[ 0 ] & BIT7 ) { - if( type == BOOT ) { - send2callboxes( build_cb_package( ext, port, REGISTRY, - ( char * )data, cb->get_msg_id(), CB_BUFFER_SIZE - VZ_HEADER_OFFSET, write_buffer ) ); - } else { - if( debug_main ) debug_msg("[%d] Received ack pkg with seq_num %d", ext, data[ 0 ] ); - - switch( type ) { - case INVITE : { - if( debug_main || debug_invite ) debug_msg("[%d] Invite Ack - msg_id %d -- Cbx seqNum %d", ext, cb->get_msg_id(), data[ 0 ] ); - break; - } - case CB_BYE : { - if( debug_main || debug_invite ) debug_msg("[%d] BYE Ack - msg_id %d", ext, cb->get_msg_id() ); - cb->set_bye_response_ok(); - break; - } - case REGISTRY : { - if( debug_main || debug_aging ) debug_msg("[%d] Registry ACK - msg_id %d", ext, cb->get_msg_id() ); - break; - } - default : { - if( debug_main || debug_aging ) debug_msg("[%d] ACK msg_id :: %d :: type %d", ext, cb->get_msg_id(), type ); - } - } - if( type != REGISTRY && type != CB_BYE && type != INVITE ) type = DO_NOTHING; - if( type == CB_BYE ){ - VZ_call * call = __find_Call__( v_call, ext ); - if( call != NULL ){ - if( call->get_elapsed_time() < 120000 ){ - if( debug_invite ) debug_msg("[%d] ack bye ignored", ext ); - type = DO_NOTHING; - } - } - } - } - } - } - } - } else type = DO_NOTHING; + if( status != WAITING ) + { + process_received_pkg_from_cbx (); } if( sizes == true ) @@ -229,7 +139,7 @@ if ( rescue_rtp ) { rescue_rtp = false; - Call_Box * cb = __find_CB__( v_cb, rescue_rtp_target ); + Call_Box * cb = find_CB( v_cb, rescue_rtp_target ); if ( cb != NULL ) { cb -> set_rtp_port ( rescue_rtp_value ); @@ -238,7 +148,6 @@ { debug_msg("rescue rtp fail"); } - } if ( print_v_cb ) @@ -338,7 +247,6 @@ pcks_s = false; } - if( reset_missed_send_udp_pkg ) { reset_missed_send_udp (); @@ -353,6 +261,7 @@ missed_send_udp_pkg = false; } + // usado pra test if( flood_bug_pkg ){ static int id = 0x10; if( id < 10 ) id = 0x0b; @@ -373,7 +282,7 @@ case CB_BYE : { cb_bye_counter++; - Call_Box * cb = __find_CB__( v_cb, ext ); + Call_Box * cb = find_CB( v_cb, ext ); if( cb != NULL ) { if( debug_invite || debug_main ) debug_msg("[%d] Bye pkg - msg_id %d e pkg_id %d", ext, cb->get_msg_id(), data[ 0 ] ); @@ -432,7 +341,7 @@ if( debug_invite ) debug_msg("[%d] Invite request", ext); - Call_Box * cb = __find_CB__( v_cb, ext ); + Call_Box * cb = find_CB( v_cb, ext ); if( cb == NULL ) { if( v_cb->size() < MAX_CB_IN_A_BRANCH ) { @@ -454,7 +363,7 @@ cb->set_msg_id( data[ 0 ] ); - if( cb->status == cb_idle ){ + if ( cb -> get_status () == cb_idle ){ cb -> call_config (); } else { data[ TIMESLICE_PLACE ] = cb->get_timeslice(); @@ -465,16 +374,16 @@ ( char * )data, cb->msg_id_update (), CB_BUFFER_SIZE - VZ_HEADER_OFFSET, write_buffer ) ); } - invite_handler( v_call, v_cb, ts, cb ); + invite_handler ( v_call, v_cb, ts, cb ); } } break; case REGISTRY : { registry_counter++; - Call_Box * cb = __find_CB__( v_cb, ext ); + Call_Box * cb = find_CB ( v_cb, ext ); - if( cb == NULL ) + if ( cb == NULL ) { if( v_cb->size() < MAX_CB_IN_A_BRANCH ) { @@ -491,9 +400,9 @@ } } - if( debug_main ) debug_msg("[%d %d] Registered", ext, port ); + if ( debug_main ) debug_msg("[%d %d] Registered", ext, port ); - if( cb != NULL ) cb->registry(); + if ( cb != NULL ) cb->registry(); } break; @@ -556,7 +465,7 @@ break; case PROMPT : { - Call_Box * cb = __find_CB__( v_cb, ext ); + Call_Box * cb = find_CB( v_cb, ext ); if( cb == NULL ) { if( v_cb->size() < MAX_CB_IN_A_BRANCH ) { @@ -614,7 +523,7 @@ } } - Call_Box * cb = __find_CB__( v_cb, ext ); + Call_Box * cb = find_CB( v_cb, ext ); if( cb != NULL ){ if ( cb->get_invite_response() == false ) { cb->set_invite_response_ok();