From a554ec14abb8eb79a04c20ba05bcd263654842db Mon Sep 17 00:00:00 2001 From: Stricted Date: Thu, 12 Jan 2017 04:01:47 +0100 Subject: [PATCH] add methods to communicate with the LTE modul (not tested) --- .../util.cs | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/SpeedportHybridControl.Implementations/util.cs b/SpeedportHybridControl.Implementations/util.cs index a3c814e..5c8210d 100644 --- a/SpeedportHybridControl.Implementations/util.cs +++ b/SpeedportHybridControl.Implementations/util.cs @@ -2,6 +2,9 @@ using Newtonsoft.Json.Linq; using System; using System.Linq; +using System.Net; +using System.Net.NetworkInformation; +using System.Net.Sockets; using System.Security.Cryptography; using System.Text; using System.Windows.Media; @@ -238,5 +241,31 @@ namespace SpeedportHybridControl.Implementations return false; } + + public static bool checkLteModul () + { + Ping ping = new Ping(); + PingReply reply = ping.Send("172.10.10.1"); + + if (reply.Status == IPStatus.Success) + { + return true; + } + + return false; + } + + public static void sendCommandToLteModul (string Command) + { + if (checkLteModul().Equals(true)) + { + Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); + IPAddress serverAddr = IPAddress.Parse("172.10.10.1"); + IPEndPoint endPoint = new IPEndPoint(serverAddr, 1280); + byte[] cmd = Encoding.ASCII.GetBytes(Command); + sock.SendTo(cmd, endPoint); + sock.Close(); + } + } } } -- 2.20.1