Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
I seem to have problems with the MBED hanging, when I instantiate a EthernetNetIF.
The behavior I need is that I request a new IP if a link is detected. If that times out I set a static IP.
if(hasLink) { printf("Got link!\r\n"); link.set_link(Ethernet::FullDuplex100); wait(0.1f); if(eth) { delete eth; wait(0.1f); } printf("Request DHCP address\r\n"); eth = new EthernetNetIf(); wait(0.1f); if(eth->setup() != ETH_OK) //USE static IP if timeout { delete eth; wait(0.1f); printf("DHCP timeout set static IP\r\n"); eth = new EthernetNetIf( IpAddr(192,168,MAC[4],MAC[5]), //IP Address IpAddr(255,255,0,0), //Network Mask IpAddr(192,168,1,1), //Gateway IpAddr(192,168,1,1) //DNS ); wait(0.1f); eth->setup(); } IpAddr ip = eth->getIp(); printf("IP Address is %d.%d.%d.%d\r\n", ip[0], ip[1], ip[2], ip[3]); stateGoto(STATE_ONLINE); }It seems to me that the EthernetNetIF crashes on second or third allocation, making me suspect a memory leak. What am I doing wrong?