Cerbuino Bee Network IP Address DHCP

I am getting started learning networking and am attempting to run the sample found here.

When I attempt to renew the DHCP address, it returns 0.0.0.0.

The following is the code I am testing.


 if (Microsoft.SPOT.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces().Length < 1)
            {
                Debug.Print("No Active network interfaces.");
                Thread.CurrentThread.Abort();
            }

            Microsoft.SPOT.Net.NetworkInformation.NetworkInterface NI = Microsoft.SPOT.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()[0];

           if (NI.IsDhcpEnabled == false)
            {
                Debug.Print("Enabling DHCP.");
                NI.EnableDhcp();
                Debug.Print("DCHP - IP Address = " + NI.IPAddress + " ... Net Mask = " + NI.SubnetMask + " ... Gateway = " + NI.GatewayAddress);
            }
            else
            {
                Debug.Print("Renewing DHCP lease.");
                NI.RenewDhcpLease();
                Debug.Print("Renewed DCHP - IP Address = " + NI.IPAddress + " ... Net Mask = " + NI.SubnetMask + " ... Gateway = " + NI.GatewayAddress);
            }


Results in the following:


DMX : Initializing network...
Renewing DHCP lease.
Renewed DCHP - IP Address = 0.0.0.0 ... Net Mask = 0.0.0.0 ... Gateway = 0.0.0.0

Any ideas? Thank you.

search (edit: search the forum) for 0.0.0.0 and you will find some others who have also found the same. From memory it seems the DHCP address might take some time to be processed but it doesn’t block you, so polling the value and waiting for it to be non-zero will help.

There is a problem with DHCP in the current version of the port. See this reply from Cuno.

http://www.tinyclr.com/forum/topic?id=8967

Thanks. Switching to static IP address worked. Bret, thanks for the suggestion on timing. Good to know.