using System.Net.Sockets;
using System.Security.Cryptography;
using System.Text;
+using System.Threading;
+using System.Windows;
using System.Windows.Media;
using System.Xml;
public static bool checkLteModul ()
{
Ping ping = new Ping();
- PingReply reply = ping.Send("172.10.10.1");
-
- if (reply.Status == IPStatus.Success)
+ try
{
- return true;
+ PingReply reply = ping.Send("172.10.10.2", 2);
+
+ if (reply.Status == IPStatus.Success)
+ {
+ return true;
+ }
}
+ catch (PingException) { }
return false;
}
{
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();
+ try
+ {
+ 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();
+ }
+ catch (Exception)
+ {
+ new Thread(() => { MessageBox.Show("couldn't send Command to LTE Modul", MessageBoxButton.OK, MessageBoxImage.Error); }).Start();
+ LogManager.WriteToLog("couldn't send Command to LTE Modul");
+ }
}
}
}
-using System.Windows;
+using SpeedportHybridControl.Implementations;
+using System.Threading;
+using System.Windows;
namespace SpeedportHybridControl
{
public MainWindow()
{
InitializeComponent();
- }
+ /*
+ if (util.checkLteModul())
+ {
+ MessageBox.Show("ABC", "Confirmation", MessageBoxButton.OK, MessageBoxImage.Error);
+ }
+ else
+ {
+ MessageBox.Show("DEF", "Confirmation", MessageBoxButton.OK, MessageBoxImage.Error);
+ }
+ */
+ }
}
}