Skip to content

Commit

Permalink
Added Program.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
Idaax committed Apr 19, 2023
1 parent e18ab16 commit 65a40c3
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions Idaax.nanoFramework.CoAPSharp.Samples/Program.cs
@@ -0,0 +1,35 @@
using Idaax.nanoFramework.CoAPSharp.Samples.Server;
using nanoFramework.Networking;
using System;
using System.Diagnostics;
using System.Net.NetworkInformation;
using System.Threading;

namespace Idaax.nanoFramework.CoAPSharp.Samples
{
public class Program
{
public static void Main()
{
try
{
WiFiHelper.Connect("SSID", "PWD", 60_000);
Debug.WriteLine("Connection to WiFi successful : " + GetMyIP());
ICoAPSample coapSample = null;
//Basic CoAP NON Server example
coapSample = new BasicCoAPNONServer();
coapSample.Run();
WiFiHelper.Disconnect();
}
catch (Exception ex)
{
Debug.WriteLine($"{ex.ToString()}");
}
}

private static string GetMyIP()
{
return NetworkInterface.GetAllNetworkInterfaces()[0].IPv4Address;
}
}
}

0 comments on commit 65a40c3

Please sign in to comment.