Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: EthernetInterface NTPClient mbed-rtos_old mbed
Fork of header_main_public by
call_box.cpp
00001 #include "call_box.h" 00002 00003 Call_Box::Call_Box( int ext, int port ){ 00004 this->ext = ext; 00005 this->port = port; 00006 t.start(); 00007 remaining_attempts = __MAX_ATTEMPTS__; 00008 timeout = __TIMEOUT__; 00009 //sip.set_ext( this->ext ); 00010 //sip.set_port( this->port ); 00011 msg_id = 0x10; 00012 timeslice = 0x00; 00013 status = cb_idle; 00014 //Sip sip( ext, port ); 00015 //sip = NULL; 00016 sip = new Sip( ext, port ); 00017 } 00018 00019 Call_Box::~Call_Box( void ){ 00020 if( sip != NULL ) delete( sip ); 00021 } 00022 00023 int Call_Box::get_port( void ){ return( this->port ); } 00024 int Call_Box::get_ext( void ){ return( this->ext ); } 00025 00026 float Call_Box::get_elapsed_time( void ){ return( this->t.read_ms() ); } 00027 00028 void Call_Box::reset_elapsed_time( void ){ 00029 this->t.reset(); 00030 remaining_attempts = __MAX_ATTEMPTS__; 00031 // timeout = __TIMEOUT__; 00032 } 00033 00034 bool Call_Box::is_timeout( void ){ 00035 return( t.read() > timeout ) ? true : false; 00036 } 00037 00038 uint8_t Call_Box::reconfigure_timeout( void ){ 00039 //static int count = 1; 00040 //if( timeout != __MAX_TIMEOUT__ ) timeout = __STEP__ * count++; 00041 t.reset(); 00042 return( remaining_attempts-- ); 00043 } 00044 00045 void Call_Box::registry( void ){ 00046 if( this->sip == NULL ){ 00047 this->sip = new Sip( ext, port ); 00048 debug_msg(" Registrando %d", ext ); 00049 00050 sip->registry(); 00051 00052 delete( sip ); 00053 this->sip = NULL; 00054 debug_msg(" Registrado %d", ext ); 00055 }else{ 00056 debug_msg(" Registrando %d", ext ) 00057 sip->registry(); 00058 debug_msg(" Registrado %d", ext ); 00059 } 00060 } 00061 00062 void Call_Box::unregistry( void ){ 00063 if( this->sip == NULL ){ 00064 this->sip = new Sip( ext, port ); 00065 00066 sip->send_unregistry_pkg(); 00067 00068 delete( sip ); 00069 this->sip = NULL; 00070 }else{ 00071 sip->send_unregistry_pkg(); 00072 } 00073 } 00074 00075 VZ_call * Call_Box::invite( void ){ 00076 if( this->sip == NULL ){ 00077 debug_msg("entrei no invite"); 00078 this->sip = new Sip( ext, port ); 00079 00080 VZ_call * call = sip->invite(); 00081 00082 delete( sip ); 00083 this->sip = NULL; 00084 00085 debug_msg("Valor do retorno do invite :: %p ", call ); 00086 return( call ); 00087 }else{ 00088 debug_msg("entrei no invite persistente"); 00089 00090 VZ_call * call = sip->invite(); 00091 00092 debug_msg("Valor do retorno do invite persistente :: %p ", call ); 00093 return( call ); 00094 } 00095 } 00096 00097 /* Retorna 00098 = 0 :: ok 00099 < 0 :: tive problemas 00100 > 0 :: devo remover essa call do vetor de calls 00101 */ 00102 int Call_Box::listen_SIP_server( void ){ 00103 if( this->sip == NULL ){ 00104 if( status == cb_on_call || status == cb_idle ){ 00105 this->sip = new Sip( ext, port ); 00106 int out_read = sip->listen_SIP_server(); 00107 delete( sip ); 00108 this->sip = NULL; 00109 return( out_read ); 00110 }else return( 0 ); 00111 }else{ 00112 if( status == cb_on_call || status == cb_idle ){ 00113 return ( sip->listen_SIP_server() ); 00114 } else return( 0 ); 00115 } 00116 } 00117 00118 void Call_Box::set_msg_id( uint8_t msg_id ){ 00119 this->msg_id = msg_id; 00120 } 00121 uint8_t Call_Box::get_msg_id( void ){ return( this->msg_id ); } 00122 00123 void Call_Box::set_timeslice( uint8_t timeslice ){ 00124 this->timeslice = timeslice; 00125 } 00126 uint8_t Call_Box::get_timeslice( void ){ return( this->timeslice ); } 00127 00128 //void Call_Box::set_sip( Sip * sip ){ 00129 // this->sip = sip; 00130 //} 00131 00132 void Call_Box::send_bye( void ){ 00133 if( this->sip == NULL ){ 00134 this->sip = new Sip( ext, port ); 00135 00136 sip->send_bye(); 00137 00138 delete( sip ); 00139 sip = NULL; 00140 }else{ 00141 sip->send_bye(); 00142 } 00143 } 00144 00145 void Call_Box::reset_sip( void ){ 00146 if( this->sip != NULL ) delete( this->sip ); 00147 00148 this->sip = new Sip( ext, port ); 00149 } 00150 00151 void Call_Box::set_sip_status( int status ){ 00152 if( this->sip != NULL ){ 00153 this->sip->status = status; 00154 }else{ 00155 debug_msg("Sem objeto sip vinculado"); 00156 } 00157 }
Generated on Sat Jul 16 2022 08:57:54 by
1.7.2
