private INetwork SetupEthernet() { try { _characterDisplay.Clear(); _characterDisplay.SetCursorPosition(0, 0); _characterDisplay.Print("Getting IP address..."); //NetworkChange.NetworkAddressChanged += OnNetworkAddressChanged; //NetworkChange.NetworkAvailabilityChanged += OnNetworkAvailabilityChanged; // Try mIP? http://mip.codeplex.com/ _ethernet.Open(); _ethernet.EnableDhcp(); _ethernet.EnableDynamicDns(); while (_ethernet.IPAddress == "0.0.0.0") { Debug.Print("Waiting for DHCP"); Thread.Sleep(250); } return(new NetworkWrapper(_ethernet)); } catch (Exception ex) { Debug.Print("Could not set up Ethernet - " + ex); throw; } }
internal static void Initialize() { ethernet_Modul = new EthernetENC28J60(SPI.SPI_module.SPI2, G120.P1_10, G120.P2_11, G120.P1_9); ethernet_Modul.Open(); ethernet_Modul.EnableDhcp(); ethernet_Modul.EnableDynamicDns(); NetworkChange.NetworkAvailabilityChanged += NetworkChange_NetworkAvailabilityChanged; NetworkChange.NetworkAddressChanged += NetworkChange_NetworkAddressChanged; Debug.Print("Ethernet initialized."); }