Djeizan - Viewing Profile: Likes - Netduino Forums
   
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.

Djeizan

Member Since 28 Feb 2013
Offline Last Active Feb 11 2016 03:47 AM
-----

#64869 DynDns Netduino

Posted by Djeizan on 09 February 2016 - 08:46 PM

I´m use this code and work:

 

Netduino plus 2

Firmware:v4.3.2.1

 

 

    public static class NoIPDNSUpdater
    {
        private static Thread threadDaemon;
        private const string _Domain = "mydomain.noip.me";
        private const string _IP = "";
        private const string _Username = "myuser";
        private const string _Password = "mypassword";
        private static int _HeartBeat = 300000;
 
        public static void StartDaemon()
        {
            if (threadDaemon == null || !threadDaemon.IsAlive)
            {
                threadDaemon = new Thread(Daemon);
                threadDaemon.Start();
            }
        }
        private static void Daemon()
        {
            while(true)
            {
                DynamicUpdate(_Domain, _IP, _Username, _Password);
                Thread.Sleep(_HeartBeat);
            }            
 
        }
        /// <summary>
        /// Update the DNS information in no-ip Service.</summary>
        /// <param name="pHostName"> The host name in no-ip service.</param>
        /// <param name="pMyip"> Optional: if empty the service no-ip get the wan address.</param>
        /// <param name="pUsername"> Username of service.</param>
        /// <param name="pPassword"> Password of service.</param>
        private static void DynamicUpdate(string pHostname, string pMyip, string pUsername, string pPassword)
        {
            try
            {
                HttpWebRequest req = (HttpWebRequest) HttpWebRequest.Create("http://dynupdate.no-...date?hostname="+ pHostname + "&myip=" + pMyip);
                req.Credentials = new NetworkCredential(pUsername, pPassword);
                using (var res = (HttpWebResponse)req.GetResponse())
                {
                    // Do something with the response accordingly to
                    // http://www.noip.com/integrate/response
                }
            }
            catch (Exception ex)
            {
                string a = ex.Message;
            }
        }

  • Evo likes this


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.