FEZ Spider NetMF 4.2 Networking revisited

I was determined to get the J11D Ethernet module working in the graphical Designer so after a lot of reading + trial and error….

http://www.tinyclr.com/forum/topic?id=9438
http://www.tinyclr.com/forum/topic?id=9661
http://www.tinyclr.com/forum/topic?id=9816
http://www.tinyclr.com/forum/topic?id=9845
http://www.tinyclr.com/forum/topic?id=10120

Making the J11D work after both reflashing the firmware & reboot was critical

void ProgramStarted()
{
Debug.Print("Program Started");

ethernet_J11D.Interface.Open();

if (!ethernet_J11D.Interface.IsActivated)
{
NetworkInterfaceExtension.AssignNetworkingStackTo(ethernet_J11D.Interface);
}
ethernet_J11D.Interface.NetworkAddressChanged += new NetworkInterfaceExtension.NetworkAddressChangedEventHandler(NetworkAddressChanged);

// The code below (Dynamic configuration or static configuration) could be removed once the MFDeploy fixed.
// This is a known issue see (http://wiki.tinyclr.com/index.php?title=NETMF4.2_developer)

// For networks with dynamic configuration
ethernet_J11D.Interface.NetworkInterface.EnableDhcp();
ethernet_J11D.Interface.NetworkInterface.EnableDynamicDns();

// For networks with static IP
//Ethernet.NetworkInterface.EnableStaticIP("x.x.x.x", "y.y.y.y", "z.z.z.z");
//Ethernet.NetworkInterface.EnableStaticDns(new[] { "x.x.x.x", "y.y.y.y" });

ipAddressReady.WaitOne();

// Display network config for debugging
Debug.Print("Network configuration");
Debug.Print(" Network interface type: " + ethernet_J11D.Interface.NetworkInterface.NetworkInterfaceType.ToString());
Debug.Print(" MAC Address: " + BytesToHexString(ethernet_J11D.Interface.NetworkInterface.PhysicalAddress));
Debug.Print(" DHCP enabled: " + ethernet_J11D.Interface.NetworkInterface.IsDhcpEnabled.ToString());
Debug.Print(" Dynamic DNS enabled: " + ethernet_J11D.Interface.NetworkInterface.IsDynamicDnsEnabled.ToString());
Debug.Print(" IP Address: " + ethernet_J11D.Interface.NetworkInterface.IPAddress.ToString());
Debug.Print(" Subnet Mask: " + ethernet_J11D.Interface.NetworkInterface.SubnetMask.ToString());
Debug.Print(" Gateway: " + ethernet_J11D.Interface.NetworkInterface.GatewayAddress.ToString());
foreach (string dnsAddress in ethernet_J11D.Interface.NetworkInterface.DnsAddresses)
{
Debug.Print(" DNS Server: " + dnsAddress.ToString());
}
}

void NetworkAddressChanged(object sender, EventArgs e)
{
Debug.Print("NetworkAddressChanged");
Debug.Print(" IP Address: " + ethernet_J11D.Interface.NetworkInterface.IPAddress.ToString());

if (ethernet_J11D.Interface.NetworkInterface.IPAddress != IPAddress.Any.ToString())
{
ipAddressReady.Set();
}
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s