Modularizando o src
Dependencies: EALib EthernetInterface_vz mbed-rtos mbed
Fork of header_main_colinas_V0-20-09-14 by
Diff: sip.cpp
- Revision:
- 46:a670f187a704
- Parent:
- 43:455522f98de5
- Child:
- 48:195c97f12e8e
diff -r c80574f24dc3 -r a670f187a704 sip.cpp --- a/sip.cpp Tue Oct 07 12:10:36 2014 +0000 +++ b/sip.cpp Tue Oct 07 18:38:30 2014 +0000 @@ -48,8 +48,14 @@ if( debug_sip ) debug_msg("Failed to open /qspi/serverip.txt" ); strncpy( this->server_ip, __SERVER_IP__, 20 ); }else{ - char tmp[ 20 ]; - if( fread( tmp, 1, 20, fp ) > 0 ){ + char tmp[ 16 ]; + int read = fread( tmp, 1, 15, fp ); + if( read > 0 ){ + for( int i = 0; i < read; i++ ) + if( tmp[ i ] == '\n' || tmp[ i ] == '\r' ){ + tmp[ i ] = '\0'; + break; + } strcpy( this->server_ip, tmp ); if( debug_sip ) debug_msg("Objeto SIP fixado no server ip %s", this->server_ip ); }else{ @@ -58,7 +64,8 @@ } } fclose( fp ); - this->server_ip[19] = 0; + this->server_ip[ 15 ] = 0; + fp = fopen( "/qspi/serverport.txt", "r"); if( fp == NULL ){ @@ -81,7 +88,13 @@ strncpy( this->my_ip, __MY_IP__, 20 ); }else{ char tmp[ 20 ]; - if( fread( tmp, 1, 20, fp ) > 0 ){ + int read = fread( tmp, 1, 15, fp ); + if( read > 0 ){ + for( int i = 0; i < read; i++ ) + if( tmp[ i ] == '\n' || tmp[ i ] == '\r' ){ + tmp[ i ] = '\0'; + break; + } strcpy( this->my_ip, tmp ); if( debug_sip ) debug_msg("Objeto SIP fixado no ip %s", this->my_ip ); }else{ @@ -90,13 +103,14 @@ } } fclose( fp ); - this->my_ip[ 19 ] = 0; + + this->my_ip[ 15 ] = 0; this->my_port = my_port; this->my_rtp_port = fill_random_rtp_port(); this->my_ext = id; itoa( this->my_ext, this->my_display, 10 ); - + fp = fopen( "/qspi/peerext.txt", "r"); if( fp == NULL ) { if( debug_sip ) debug_msg("Failed to open /qspi/peerext.txt" );