From: Stricted Date: Thu, 12 Jan 2017 03:01:47 +0000 (+0100) Subject: add methods to communicate with the LTE modul (not tested) X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=a554ec14abb8eb79a04c20ba05bcd263654842db;p=GitHub%2FStricted%2FSpeedportHybridControl.git add methods to communicate with the LTE modul (not tested) --- 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(); + } + } } }