Modularizando o src

Dependencies:   EALib EthernetInterface_vz mbed-rtos mbed

Fork of header_main_colinas_V0-20-09-14 by VZTECH

Revision:
27:98f824719d1c
Parent:
20:2d6ab23956e5
Child:
28:94aec56c6329
diff -r 725cbbedadd5 -r 98f824719d1c utils.cpp
--- a/utils.cpp	Mon Sep 22 16:56:00 2014 +0000
+++ b/utils.cpp	Mon Sep 22 21:15:07 2014 +0000
@@ -42,24 +42,58 @@
 }
 
 int __init_eth__( EthernetInterface * eth ){
-    eth->init( __MY_IP__, "255.255.255.0", "192.168.120.1" );     //Default
-    //eth->init( "192.168.2.200", "255.255.255.0", "192.168.2.254" );     //Colinas 1
+    char buff_ip[ 16 ];
+    char buff_msk[ 16 ];
+    char buff_gtw[ 16 ];
+    FILE *fp = fopen( "/qspi/myip.txt", "r");
+    if( fp == NULL ){
+        pc.printf("Failed to open /qspi/myip.txt\n\r" );
+        strncpy( buff_ip, __MY_IP__, 20 );    
+    }else{
+        if( fread( buff_ip, 1, 512, fp ) > 0 ){
+            debug_msg("Eth ip %s", buff_ip );
+        }else{
+            pc.printf("Failed to read /qspi/myip.txt\n\r" );
+            strncpy( buff_ip, __MY_IP__, 20 );
+        }
+    }
+    fclose( fp );
+    buff_ip[ 15 ] = 0;
+    
     
-/*
-#ifdef debug_colinas
-#define __MY_IP__ "192.168.2.200"
-#define __MY_GT__ "192.168.2.254"
-#endif
-#ifndef debug_colinas
-#define __MY_IP__ "192.168.120.169"
-#define __MY_GT__ "192.168.120.1"
-#endif
-
-#define __MY_MK__ "255.255.255.0"
-*/
+    fp = fopen( "/qspi/mymask.txt", "r");
+    if( fp == NULL ){
+        pc.printf("Failed to open /qspi/mymask.txt \n\r" );
+        strncpy( buff_msk, __MY_IP__, 20 );    
+    }else{
+        if( fread( buff_msk, 1, 512, fp ) > 0 ){
+            debug_msg("mascara de rede Eth %s", buff_msk );
+        }else{
+            pc.printf("Failed to read /qspi/mymask.txt\n\r" );
+            strncpy( buff_msk, __MY_IP__, 20 );
+        }
+    }
+    fclose( fp );
+    buff_msk[ 15 ] = 0;
+    
+    
+    fp = fopen( "/qspi/mygate.txt", "r");
+    if( fp == NULL ){
+        pc.printf("Failed to open /qspi/mygate.txt \n\r" );
+        strncpy( buff_gtw, __MY_IP__, 20 );    
+    }else{
+        if( fread( buff_gtw, 1, 512, fp ) > 0 ){
+            debug_msg("Ip Gateway Eth %s", buff_gtw );
+        }else{
+            pc.printf("Failed to read /qspi/mygate.txt\n\r" );
+            strncpy( buff_gtw, __MY_IP__, 20 );
+        }
+    }
+    fclose( fp );
+    buff_gtw[ 15 ] = 0;
+    
+    eth->init( buff_ip, buff_msk, buff_gtw );
     return eth->connect();
-    // pensar em o que acontece e como sinalizar que nao consegui conectar na web
-    // aparente so da time out, so que algo vai travar quando eu tentar usar a conexao
 }
 
 Call_Box * __find_CB__( Vector * v_cb, int ext ){