add methods to communicate with the LTE modul (not tested)
authorStricted <info@stricted.net>
Thu, 12 Jan 2017 03:01:47 +0000 (04:01 +0100)
committerStricted <info@stricted.net>
Thu, 12 Jan 2017 03:02:52 +0000 (04:02 +0100)
SpeedportHybridControl.Implementations/util.cs

index a3c814e65564f317a801092fc0ee9d82df0a097d..5c8210de48390a1e739f98eea79689af314e3cd0 100644 (file)
@@ -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();
+                       }
+               }
     }
 }