Modularizando o src

Dependencies:   EALib EthernetInterface_vz mbed-rtos mbed

Fork of header_main_colinas_V0-20-09-14 by VZTECH

Revision:
48:195c97f12e8e
Parent:
46:a670f187a704
Child:
50:d9b6577a70f5
--- a/sip.cpp	Tue Oct 07 18:43:44 2014 +0000
+++ b/sip.cpp	Mon Oct 20 16:13:10 2014 +0000
@@ -9,10 +9,15 @@
     sock.init();
 }
 
-void Sip::__end_sock__(){
+void Sip::__end_sock__( void ){
     sock.close(); 
 }
 
+void Sip::__reconnect__( void ){
+    sock.close(); 
+    sock.init();
+}
+
 Sip::Sip( char * server_ip, int server_port, char * my_ip, int my_port, int my_ext, int peer_ext, int id ){
     this->id = id;
     strncpy( this->server_ip, server_ip, 20 );
@@ -126,11 +131,12 @@
     }
     fclose( fp );
     
+    /*
     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 );
-    
+    */
     strcpy( this->fill_random_aux, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789pP" );
     strcpy( this->last_invite_tag, "" );
     strcpy( this->last_invite_callid, "");
@@ -149,7 +155,17 @@
     if( debug_sip ) debug_msg("Registry %d", this->my_ext );
     build_registry_package( buffer );
     int sent = sock.sendTo( sip_server, buffer, 512 ); // > 400
-    sock.receiveFrom( sip_server, buffer, sizeof( buffer ) );
+    int rcv = sock.receiveFrom( sip_server, buffer, sizeof( buffer ) );
+    /*
+    if( sent == -1 || rcv == -1 ){
+        debug_msg("");
+        __init_eth__();
+        debug_msg("");
+    }
+    */
+    if( sent == -1 || rcv == -1 ){
+        __reconnect__();
+    }
     if( debug_sip ) debug_msg("Received %i bytes to ext %d", sent, my_ext );
     if( decode_gettag( (unsigned char *)buffer, "cseq: ", out ) ){
         if(strlen( out ) > 7){