6 years, 7 months ago.

Ethernet DHCP errors

I am using DHCP with MBED 5.06 on a FRDM K64 platform. I instantiate the network interface as: EthernetInterface net;

When it first connects everything works properly. I get a connection with the valid IP address, netmask and gateway address. My network has between the Internet gateway and my board, the internet gateway is the DHCP server for the network. My gateway address as returned by net.get_gateway() is 192.168.1.1 which is correct; If I disconnect the switch from the internet gateway and reconnect it I get a server socket failure as expected.

My code does the following things next: net.disconnect(); net.set_network(NULL,NULL,NULL); (I have tried it both with and without this line) net.set_dhcp(true); net.connect(); Socket socket(); int iResult=socket.connect(MY_SERVER,SERVER_PORT);

The connection works but when I look at the gateway address it comes back as 192.168.1.254 which is incorrect as it should be 192.168.1.1. Even if I remove the internet connection locally from them board, reconnect it and go through the same code it will still fail in the same way. I can even reset the board and start the code from scratch and it will still fail in the same way. the error code is iResult=-3009 When I detect a connect error I execute the following code: socket.close(); net.disconnect();

All of this worked in mbed 5.3 but now it no longer works.

Be the first to answer this question.