![](/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
eth.cpp
- Committer:
- klauss
- Date:
- 2015-05-11
- Revision:
- 122:480c44b0e205
- Parent:
- 121:ee02790d00b7
- Child:
- 124:c1b6c893e1c3
File content as of revision 122:480c44b0e205:
#include "eth.h" EthernetInterface eth; int __init_eth__ ( void ) { static bool initialized = false; char buff_ip [ 16 ] = ""; char buff_msk [ 16 ] = ""; char buff_gtw [ 16 ] = ""; if( debug_uart3 ) pc.printf("\n\r"); int ip_return_value = get_ip ( buff_ip, sizeof ( buff_ip ) - 1 ); if ( ip_return_value < 0 ) { set_ip( MY_IP ); strncpy ( buff_ip, MY_IP, sizeof ( buff_ip ) - 1 ); if ( debug_file ) debug_msg ("Load default header_ip -- %s", buff_ip ); } buff_ip [ sizeof ( buff_ip ) - 1 ] = 0; int mask_return_value = get_ip ( buff_msk, sizeof ( buff_msk ) - 1 ); if ( mask_return_value < 0 ) { set_mask( MY_MSK ); strncpy ( buff_msk, MY_MSK, sizeof ( buff_msk ) - 1 ); if ( debug_file ) debug_msg ("Load default eth_mask -- %s", buff_msk ); } buff_msk [ sizeof ( buff_msk ) - 1 ] = 0; int gw_return_value = get_gateway ( buff_gtw, sizeof ( buff_gtw ) - 1 ); if ( gw_return_value < 0 ) { set_gateway( MY_GTW ); strncpy ( buff_gtw, MY_MSK, sizeof ( buff_gtw ) - 1 ); if ( debug_file ) debug_msg ("Load default eth_gateway -- %s", buff_gtw ); } buff_gtw [ sizeof ( buff_gtw ) - 1 ] = 0; if( !initialized ) { eth.init( buff_ip, buff_msk, buff_gtw ); initialized = true; return eth.connect(); } if( !eth.disconnect() ){ return eth.connect(); } else{ return eth.connect(); } }