![](/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:
- 106:a34fcf9f0e02
- Parent:
- 100:09a23fcd3bdf
- Child:
- 108:18a3702650f3
--- a/call_box.cpp Tue Mar 10 18:10:57 2015 +0000 +++ b/call_box.cpp Fri Mar 13 19:40:56 2015 +0000 @@ -9,9 +9,34 @@ msg_id = 0x10; timeslice = 0x00; status = cb_idle; - sip = new Sip( ext, port ); + + { + FILE * fp = NULL; + char inner_tmp[ 20 ]; + + fp = fopen( "/qspi/shift_port.txt", "r" ); + if( fp == NULL ) + { + if( debug_cb ) debug_msg("Failed to open /qspi/shift_port.txt" ); + shift_port = SHIFT_PORT; + }else{ + if( fread( (void *)inner_tmp, 1, 20, fp ) > 0 ){ + shift_port = atoi( inner_tmp ); + if( debug_cb ) debug_msg("Shift port %d", shift_port ); + }else{ + if( debug_cb ) debug_msg("Failed to read /qspi/shift_port.txt" ); + shift_port = SHIFT_PORT; + } + } + + fclose( fp ); + } + + shift_port = SHIFT_PORT; + sip = new Sip( ext, ext + shift_port ); sip_socket_fd = sip->get_socket_fd(); if( sip == NULL ) + { memory_is_over = true; if( debug_memory ) debug_msg("Sip allocation fail"); @@ -20,7 +45,6 @@ next_aging_type = __CYCLES__; seconds.start(); invite_response = true; - //invite_first_response = true; bye_response = true; invite_retry_count = MAX_INVITE_RETRY; cb_new_counter++; @@ -73,7 +97,8 @@ void Call_Box::registry( void ){ if( this->sip == NULL ){ - this->sip = new Sip( ext, port ); + this->sip = new Sip( ext, ext + shift_port ); + deleted_sip++; if( sip == NULL ){ memory_is_over = true; if( debug_memory ) debug_msg("Call_Box cb allocation fail"); @@ -93,7 +118,8 @@ void Call_Box::unregistry( void ){ if( this->sip == NULL ){ - this->sip = new Sip( ext, port ); + this->sip = new Sip( ext, ext + shift_port ); + deleted_sip++; if( sip == NULL ){ memory_is_over = true; if( debug_memory ) debug_msg("Call_Box cb allocation fail"); @@ -113,7 +139,8 @@ VZ_call * call = NULL; if( this->sip == NULL ){ - this->sip = new Sip( ext, port ); + this->sip = new Sip( ext, ext + shift_port ); + deleted_sip++; if( sip != NULL ){ memory_is_over = true; @@ -142,7 +169,8 @@ int Call_Box::listen_SIP_server( void ){ if( this->sip == NULL ){ if( status == cb_on_call || status == cb_idle ){ - this->sip = new Sip( ext, port ); + this->sip = new Sip( ext, ext + shift_port ); + deleted_sip++; if( sip == NULL ){ memory_is_over = true; @@ -179,7 +207,8 @@ void Call_Box::send_bye( void ){ if( this->sip == NULL ){ - this->sip = new Sip( ext, port ); + this->sip = new Sip( ext, ext + shift_port ); + deleted_sip++; if( sip == NULL ){ memory_is_over = true; @@ -200,7 +229,8 @@ void Call_Box::reset_sip( void ){ if( this->sip != NULL ) delete( this->sip ); - this->sip = new Sip( ext, port ); + this->sip = new Sip( ext, ext + shift_port ); + deleted_sip++; if( sip == NULL ) memory_is_over = true; }