- Edit - I should have used this post: https://www.ghielectronics.com/community/forum/topic?id=11732 as it is the same issue but currently involves multiple and different locations.
We have a problem with a fez spider 1.0 with SDK 4.2.10.1 it hangs when network is being initialized. Based on the debug info it seems to have a problem to agree on the network speed. It fails to obtain a ip address from dhcp or even with a static address it is a problem.
We are migrating from 4.1.8.x sdk to 4.2.10.1 and on several different locations the problem occurs. Mostly common network config is a router → switch (-> switch) → fez spider.
Because the switches are unmanaged we can’t set it to fixed speed (10 or 100mbps).
Does this sound familiar?
Network initialization code:
void InitNic()
{
try
{
ethernet_J11D.Interface.CableConnectivityChanged += new EthernetBuiltIn.CableConnectivityChangedEventHandler(ethernet_CableConnectivityChanged);
ethernet_J11D.Interface.NetworkAddressChanged += new NetworkInterfaceExtension.NetworkAddressChangedEventHandler(ethernet_NetworkAddressChanged);
//ethernet_J11D.Interface.NetworkInterface.PhysicalAddress = Utils.MacAddressStringToBytes(MacAddress);
byte[] macaddr = Utils.MacAddressStringToBytes(MacAddress);
Util.SetMACAddress(NetworkInterface.Built_In_Ethernet , macaddr);
ethernet_J11D.Interface.Open();
if (NetworkInterfaceExtension.AssignedNetworkInterface == null)
{
NetworkInterfaceExtension.AssignNetworkingStackTo(ethernet_J11D.Interface);
}
else
{
if (NetworkInterfaceExtension.AssignedNetworkInterface.NetworkInterface.NetworkInterfaceType != Microsoft.SPOT.Net.NetworkInformation.NetworkInterfaceType.Ethernet)
NetworkInterfaceExtension.AssignNetworkingStackTo(ethernet_J11D.Interface);
}
if (ethernet_J11D.Interface.IsActivated && ethernet_J11D.Interface.IsOpen && ethernet_J11D.Interface.IsCableConnected)
{
if (UseDHCP)
{
if (ethernet_J11D.Interface.NetworkInterface.IsDhcpEnabled)
{
DebugPrint("Renewing DHCP Lease");
ethernet_J11D.Interface.NetworkInterface.RenewDhcpLease();
ethernet_J11D.Interface.NetworkInterface.EnableDynamicDns();
}
else
{
DebugPrint("Enabling DHCP");
ethernet_J11D.Interface.NetworkInterface.EnableDhcp();
ethernet_J11D.Interface.NetworkInterface.EnableDynamicDns();
}
int waitSecs = 10;
IPAddress ip = IPAddress.GetDefaultLocalAddress();
while (ip == IPAddress.Any && waitSecs > 0)
{
Thread.Sleep(1000);
waitSecs--;
ip = IPAddress.GetDefaultLocalAddress();
}
}
else
{
DebugPrint("Assigning static IPAddress");
if (AddGoogleDNS)
{
ethernet_J11D.Interface.NetworkInterface.EnableStaticDns(new String[] { dns, "8.8.8.8", "8.8.4.4" });
}
else
{
ethernet_J11D.Interface.NetworkInterface.EnableStaticDns(new String[] { dns });
}
ethernet_J11D.Interface.NetworkInterface.EnableStaticIP(IP_Address, Subnetmask, Gateway);
}
}
}
catch (Exception e)
{
DebugPrint(e.Message);
}
}
Modified: added code snippet