diff --git a/GatewayWatchdog/MainWindow.xaml b/GatewayWatchdog/MainWindow.xaml
index 1ae3820..f8aa195 100644
--- a/GatewayWatchdog/MainWindow.xaml
+++ b/GatewayWatchdog/MainWindow.xaml
@@ -22,6 +22,7 @@
+
@@ -31,10 +32,10 @@
Current Result:
Time
- Gateway URL:
-
-
+ Gateway IP:
+
+
@@ -83,7 +84,7 @@
34ms
-
+
@@ -102,6 +103,7 @@
+
diff --git a/GatewayWatchdog/MainWindow.xaml.cs b/GatewayWatchdog/MainWindow.xaml.cs
index 898bd08..7b58b8f 100644
--- a/GatewayWatchdog/MainWindow.xaml.cs
+++ b/GatewayWatchdog/MainWindow.xaml.cs
@@ -14,6 +14,7 @@
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
+using System.Windows.Input;
using System.Windows.Threading;
using TMobileAPI;
@@ -72,7 +73,7 @@ public MainWindow()
queryWorker = new GatewayQueryWorker();
queryWorker.WorkerUpdate += QueryWorker_WorkerUpdate;
- queryWorker.GatewayUrl = UrlText.Text;
+ queryWorker.GatewayUrl = "http://" + UrlText.Text;
pingWorker = new PingWorker();
pingWorker.PingCompleted += PingWorker_PingCompleted;
@@ -374,7 +375,7 @@ private void TabItem_GotFocus(object sender, RoutedEventArgs e)
private void SetUrlBtn_Click(object sender, RoutedEventArgs e)
{
- queryWorker.GatewayUrl = UrlText.Text;
+ queryWorker.GatewayUrl = "http://" + UrlText.Text;
SetUrlBtn.IsEnabled = false;
}
@@ -383,6 +384,41 @@ private void UrlText_TextChanged(object sender, TextChangedEventArgs e)
if (SetUrlBtn != null)
SetUrlBtn.IsEnabled = true;
}
+
+ private void UrlText_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e)
+ {
+ if (!((e.Key >= Key.D0 && e.Key <= Key.D9) ||
+ (e.Key >= Key.NumPad0 && e.Key <= Key.NumPad9) ||
+ e.Key == Key.Decimal || e.Key == Key.OemPeriod || e.Key == Key.Back))
+ {
+ e.Handled = true;
+ }
+
+ if (UrlText.Text.Count(c => c == '.') >= 3 && (e.Key == Key.OemPeriod || e.Key == Key.Decimal))
+ {
+ e.Handled = true;
+ }
+ }
+
+ private async void ShowNetworkConfigBtn_Click(object sender, RoutedEventArgs e)
+ {
+ try
+ {
+ if (Session == null)
+ Authenticate();
+
+ if (Session != null)
+ {
+ var telemetryData = await _gatewayEngine.GetAccessPointData(_sessionInformation);
+ RawDataViewer rawDataViewer = new RawDataViewer(telemetryData);
+ rawDataViewer.ShowDialog();
+ }
+ }
+ catch (Exception exc)
+ {
+ MessageBox.Show("Error occurred: " + exc.Message);
+ }
+ }
}
}
\ No newline at end of file
diff --git a/TMobileAPI/GatewayEngine.cs b/TMobileAPI/GatewayEngine.cs
index 35ad0e7..e171b73 100644
--- a/TMobileAPI/GatewayEngine.cs
+++ b/TMobileAPI/GatewayEngine.cs
@@ -39,13 +39,20 @@ public async Task GetGatewayInformation(string gatewayUrl)
{
throw new Exception("Error occurred while retrieving data: " + result.StatusCode + ": " + result.Content.ReadAsStringAsync().Result);
}
- return JsonConvert.DeserializeObject(await result.Content.ReadAsStringAsync());
+
+ var json = await result.Content.ReadAsStringAsync();
+ if (!json.Contains("\"manufacturer\": \"Arcadyan\""))
+ {
+ throw new Exception("Invalid source retrieved, check gateway IP address.");
+ }
+
+ return JsonConvert.DeserializeObject(await result.Content.ReadAsStringAsync());
}
private async Task GetTelemetryData(SessionInformation session)
{
-
+
var telemetryRequest = new HttpRequestMessage(HttpMethod.Get, $"{session.GatewayUrl}/TMI/v1/network/telemetry?get=all");
telemetryRequest.Headers.Add("Authorization", $"Bearer {session.Token}");
@@ -56,8 +63,24 @@ private async Task GetTelemetryData(SessionInformation session)
var telemetryResponse = await client.SendAsync(telemetryRequest);
var telemetryJson = await telemetryResponse.Content.ReadAsStringAsync();
- return JsonConvert.DeserializeObject(telemetryJson);
-
+ return JsonConvert.DeserializeObject(telemetryJson);
+
+ }
+ public async Task GetAccessPointData(SessionInformation session)
+ {
+
+ var telemetryRequest = new HttpRequestMessage(HttpMethod.Get, $"{session.GatewayUrl}/TMI/v1/network/configuration?get=ap");
+ telemetryRequest.Headers.Add("Authorization", $"Bearer {session.Token}");
+
+ HttpClient client = new()
+ {
+ Timeout = TimeSpan.FromSeconds(5)
+ };
+
+ var telemetryResponse = await client.SendAsync(telemetryRequest);
+ var telemetryJson = await telemetryResponse.Content.ReadAsStringAsync();
+ return telemetryJson;
+
}