From 65a40c3e545f8e9b35d9b36c32dc201d85729d31 Mon Sep 17 00:00:00 2001 From: Idaax Inc <131035994+Idaax@users.noreply.github.com> Date: Wed, 19 Apr 2023 13:17:31 -0700 Subject: [PATCH] Added Program.cs --- .../Program.cs | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 Idaax.nanoFramework.CoAPSharp.Samples/Program.cs diff --git a/Idaax.nanoFramework.CoAPSharp.Samples/Program.cs b/Idaax.nanoFramework.CoAPSharp.Samples/Program.cs new file mode 100644 index 0000000..da0808f --- /dev/null +++ b/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; + } + } +}