EthernetNetIf Compatibility.
Dependents: XBeeWiFi_SPI_example
Fork of NetServicesSource by
Diff: if/eth/EthernetNetIf.cpp
- Revision:
- 2:a4f97773c90f
- Parent:
- 0:632c9925f013
- Child:
- 4:fd826cad83c0
--- a/if/eth/EthernetNetIf.cpp Mon Jun 14 10:33:54 2010 +0000 +++ b/if/eth/EthernetNetIf.cpp Fri Jun 18 09:22:54 2010 +0000 @@ -34,7 +34,7 @@ #include "netCfg.h" #if NET_ETH -EthernetNetIf::EthernetNetIf() : LwipNetIf(), m_ethArpTicker(), m_dhcpCoarseTicker(), m_dhcpFineTicker(), m_pNetIf(NULL), +EthernetNetIf::EthernetNetIf() : LwipNetIf(), m_ethArpTimer(), m_dhcpCoarseTimer(), m_dhcpFineTimer(), m_pNetIf(NULL), m_netmask(255,255,255,255), m_gateway(), m_hostname(NULL) { m_hostname = NULL; @@ -42,7 +42,7 @@ m_useDhcp = true; } -EthernetNetIf::EthernetNetIf(IpAddr ip, IpAddr netmask, IpAddr gateway, IpAddr dns) : LwipNetIf(), m_ethArpTicker(), m_dhcpCoarseTicker(), m_dhcpFineTicker(), m_pNetIf(NULL), m_hostname(NULL) //W/o DHCP +EthernetNetIf::EthernetNetIf(IpAddr ip, IpAddr netmask, IpAddr gateway, IpAddr dns) : LwipNetIf(), m_ethArpTimer(), m_dhcpCoarseTimer(), m_dhcpFineTimer(), m_pNetIf(NULL), m_hostname(NULL) //W/o DHCP { m_hostname = NULL; m_netmask = netmask; @@ -67,11 +67,14 @@ EthernetErr EthernetNetIf::setup(int timeout_ms /*= 15000*/) { LwipNetIf::init(); - m_ethArpTicker.attach_us(ðarp_tmr, ARP_TMR_INTERVAL * 1000); // = 5s in etharp.h + //m_ethArpTicker.attach_us(ðarp_tmr, ARP_TMR_INTERVAL * 1000); // = 5s in etharp.h + m_ethArpTimer.start(); if(m_useDhcp) { - m_dhcpCoarseTicker.attach(&dhcp_coarse_tmr, DHCP_COARSE_TIMER_SECS); // = 60s in dhcp.h - m_dhcpFineTicker.attach_us(&dhcp_fine_tmr, DHCP_FINE_TIMER_MSECS * 1000); // = 500ms in dhcp.h + //m_dhcpCoarseTicker.attach(&dhcp_coarse_tmr, DHCP_COARSE_TIMER_SECS); // = 60s in dhcp.h + //m_dhcpFineTicker.attach_us(&dhcp_fine_tmr, DHCP_FINE_TIMER_MSECS * 1000); // = 500ms in dhcp.h + m_dhcpCoarseTimer.start(); + m_dhcpFineTimer.start(); } m_pNetIf->hwaddr_len = ETHARP_HWADDR_LEN; //6 eth_address((char *)m_pNetIf->hwaddr); @@ -79,8 +82,7 @@ DBG("\r\nHW Addr is : %02x:%02x:%02x:%02x:%02x:%02x.\r\n", m_pNetIf->hwaddr[0], m_pNetIf->hwaddr[1], m_pNetIf->hwaddr[2], m_pNetIf->hwaddr[3], m_pNetIf->hwaddr[4], m_pNetIf->hwaddr[5]); - DBG("\r\nIn Setup.\r\n"); - + m_pNetIf = netif_add(m_pNetIf, &(m_ip.getStruct()), &(m_netmask.getStruct()), &(m_gateway.getStruct()), NULL, eth_init, ip_input);//ethernet_input);// ip_input); //m_pNetIf->hostname = "mbedDG";//(char *)m_hostname; //Not used for now netif_set_default(m_pNetIf); @@ -101,6 +103,19 @@ timeout.start(); while( !netif_is_up(m_pNetIf) ) //Wait until device is up { + if(m_useDhcp) + { + if(m_dhcpFineTimer.read_ms()>=DHCP_FINE_TIMER_MSECS) + { + m_dhcpFineTimer.reset(); + dhcp_fine_tmr(); + } + if(m_dhcpCoarseTimer.read()>=DHCP_COARSE_TIMER_SECS) + { + m_dhcpCoarseTimer.reset(); + dhcp_coarse_tmr(); + } + } poll(); if( timeout.read_ms() > timeout_ms ) { @@ -123,6 +138,11 @@ void EthernetNetIf::poll() { + if(m_ethArpTimer.read_ms()>=ARP_TMR_INTERVAL) + { + m_ethArpTimer.reset(); + etharp_tmr(); + } LwipNetIf::poll(); eth_poll(); }