So I was able to a write code that gets my IP address from a file and changes it on initialization.
// Get and Update properties from those in the file on the SD sd.GetAddressesFromFile(); var interf = NetworkInterface.GetAllNetworkInterfaces()[0]; interf.EnableStaticIP(sd.IP, sd.SubnetMask, sd.DefaultGateway); //Debug print our IP address Debug.Print(Microsoft.SPOT.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()[0].IPAddress);
And that works great. However when I send a request from my browser to update the IP address, the only way I can get it to actually change is doing a PowerState.RebootDevice();
I was just wondering what dependencies are in the RebootDevice method that cause the IP address to reset. I tried playing around with the ReleaseDhcpLease() and RenewDhcpLease() but they didn't really do anything for me. Here is my code that changes the IP address after I get it from the browser:
private void UpdateAddressesRequest() { // If no values were actually updated, we don't need to run this method. if (sd.ChangeFlag == false) return; var interf = NetworkInterface.GetAllNetworkInterfaces()[0]; interf.EnableStaticIP(sd.IP, sd.SubnetMask, sd.DefaultGateway); interf.EnableStaticDns(new string[] { "172.16.1.1", "172.16.1.2" }); sd.ChangeFlag = false; PowerState.RebootDevice(soft: false); }