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
}
}
catch (Exception ex)
{
string a = ex.Message;
}
}
- Evo likes this