Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Why do I have to reboot my device to change the IP address?

webserver ip netduino change address

  • Please log in to reply
2 replies to this topic

#1 cSharper

cSharper

    Member

  • Members
  • PipPip
  • 13 posts
  • LocationOrlando, FL

Posted 31 July 2015 - 06:44 PM

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);
        }


#2 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 06 August 2015 - 04:47 AM

Hey cSharper,

There are some limitations in NETMF and/or the lwIP integration regarding change of IP.

With Netduino.IP, we'll be able to get overcome some of those. We're currently working on a way to change IP settings on the fly. It's not ready to go today--but we should be able to include it in a firmware update later this year. Then you'll get the benefit of a managed code network stack and the ability to change IP settings on the fly :)

Chris

#3 cSharper

cSharper

    Member

  • Members
  • PipPip
  • 13 posts
  • LocationOrlando, FL

Posted 17 August 2015 - 12:41 PM

Chris,

 

Thank you for your reply, and I am looking forward to those updates in the near future!







Also tagged with one or more of these keywords: webserver, ip, netduino, change, address

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.