![](/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
Diff: call_box.cpp
- Revision:
- 123:1d395b5a4cad
- Parent:
- 122:480c44b0e205
- Child:
- 126:1f90756250fb
diff -r 480c44b0e205 -r 1d395b5a4cad call_box.cpp --- a/call_box.cpp Mon May 11 15:16:36 2015 +0000 +++ b/call_box.cpp Mon May 11 19:21:39 2015 +0000 @@ -6,8 +6,6 @@ this->port = port; t.start (); - remaining_attempts = __MAX_ATTEMPTS__; - timeout = __TIMEOUT__; msg_id = 0x10; timeslice = 0x00; status = cb_idle; @@ -46,13 +44,13 @@ sip_socket_fd = sip->get_socket_fd (); } - next_aging_type = __CYCLES__; invite_response = true; bye_response = true; invite_retry_count = MAX_INVITE_RETRY; cb_new_counter++; invite_try_number = 0; overflow = false; + overflow_times = 0; } int Call_Box::get_status ( void ) { return this->status; } @@ -75,13 +73,15 @@ int Call_Box::get_ext ( void ) { return ( this->ext ); } -float Call_Box::get_elapsed_time ( void ) { return ( this -> t.read_ms () ); } +uint16_t Call_Box::get_elapsed_time ( void ) { return ( ( uint16_t ) this -> t.read_ms () ); } void Call_Box::reset_elapsed_time ( void ) { + this -> t.stop (); this -> t.reset (); - timeout = __TIMEOUT__; - next_aging_type = __CYCLES__; + this -> t.start (); + overflow = false; + overflow_times = 0; } void Call_Box::registry ( void ) @@ -97,9 +97,9 @@ if ( sip -> registry () > 0 ) { reset_elapsed_time (); - overflow = false; + } - if ( debug_aging ) send_msg ( "[%d] Registered - ( %f )", this->ext, __TIMEOUT__ - t.read() ); + if ( debug_aging ) send_msg ( "[%d] Registered", this->ext ); } else { debug_msg ("[%d] Eu definitivamente nao deveria estar aqui!!!", this->ext ); @@ -121,6 +121,7 @@ } if ( debug_cb ) send_msg ("[%d] Call returned value :: %p ", this->ext, ( void * ) call ); + if ( call == NULL ) t.start (); return ( call ); @@ -241,14 +242,18 @@ { int now = t.read (); - //if ( now >= 30 || now < 0 ) - if ( now >= 1500 || now < 0 ) - { - t.reset (); + if ( now >= 30 || now < 0 ) + //if ( now >= 1500 || now < 0 ) + { + this -> t.stop (); + this -> t.reset (); + this -> t.start (); overflow = true; + //if ( overflow_times != 0xff ) overflow_times++; + if ( overflow_times != 0x05 ) overflow_times++; } - return t.read (); + return ( now ); } int Call_Box::get_rtp_port ( void ) @@ -328,8 +333,7 @@ send_msg ("ext :: %i", ext ); send_msg ("port :: %i", port ); send_msg ("Timer t :: %d", ( int )t.read () ); - send_msg ("remaining_attempts :: %u", remaining_attempts ); - send_msg ("timeout :: %f", timeout ); + send_msg ("overflow_times :: %u", overflow_times ); send_msg ("msg_id :: %d", msg_id ); send_msg ("timeslice :: %u", timeslice ); send_msg ("next_aging_type :: %u", next_aging_type ); @@ -409,8 +413,8 @@ } uint8_t Call_Box::msg_id_update ( void ) -{ - this->msg_id = ( ( this->msg_id + 1 ) & ~BIT7 ) ? msg_id : 0x11; +{ + this->msg_id = ( ( ( this->msg_id + 1 ) & ~BIT7 ) > 0x10 ) ? ( ( this->msg_id + 1 ) & ~BIT7 ) : 0x11; return this->msg_id; } @@ -465,4 +469,9 @@ Sip * Call_Box::get_sip ( void ) { return this -> sip ; } -bool Call_Box::get_overflow_flag ( void ) { get_timer () ; return ( this -> overflow ); } \ No newline at end of file +bool Call_Box::get_overflow_flag ( void ) { get_timer () ; return ( this -> overflow ); } + +uint8_t Call_Box::get_overflow_times ( void ) { return ( this -> overflow_times ); } + + +void Call_Box::update_time ( void ){ get_timer (); } \ No newline at end of file