diff --git a/client/src-tauri/src/main.rs b/client/src-tauri/src/main.rs index 53ef00d..1dc64a5 100644 --- a/client/src-tauri/src/main.rs +++ b/client/src-tauri/src/main.rs @@ -1,6 +1,8 @@ // Prevents additional console window on Windows in release, DO NOT REMOVE!! #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] +use std::net::Ipv4Addr; + use tauri::Manager; mod telemetry; use tracing_subscriber::FmtSubscriber; @@ -12,7 +14,7 @@ struct Payload { message: String, } -const NTABLE_IP: (u8, u8, u8, u8) = (10, 12, 80, 2); +const NTABLE_IP: Ipv4Addr = Ipv4Addr::new(10, 12, 80, 2); const NTABLE_PORT: u16 = 5810; fn main() { diff --git a/client/src-tauri/src/telemetry/create_client.rs b/client/src-tauri/src/telemetry/create_client.rs index 4fc5691..40e09b5 100644 --- a/client/src-tauri/src/telemetry/create_client.rs +++ b/client/src-tauri/src/telemetry/create_client.rs @@ -13,15 +13,12 @@ use tokio::time::{sleep, Duration}; /// `telemetry_status` event with the payload `"disconnected"` instead. pub async fn create_client( app_handle: &AppHandle, - ntable_ip: &(u8, u8, u8, u8), + ntable_ip: &Ipv4Addr, ntable_port: &u16, ) -> Client { loop { let client_attempt = Client::try_new_w_config( - SocketAddrV4::new( - Ipv4Addr::new(ntable_ip.0, ntable_ip.1, ntable_ip.2, ntable_ip.3), - *ntable_port, - ), + SocketAddrV4::new(*ntable_ip, *ntable_port), Config { ..Default::default() }, diff --git a/client/src-tauri/src/telemetry/mod.rs b/client/src-tauri/src/telemetry/mod.rs index 206143e..5ab01d0 100644 --- a/client/src-tauri/src/telemetry/mod.rs +++ b/client/src-tauri/src/telemetry/mod.rs @@ -1,3 +1,5 @@ +use std::net::Ipv4Addr; + use network_tables::v4::{MessageData, Subscription}; use serde_json::to_string; use tauri::{AppHandle, Manager}; @@ -16,11 +18,7 @@ use create_subscription::create_subscription; /// to all connected frontends using the "telemetry_data" event. /// /// The function loops forever, retrying connection every 3 seconds, reconnecting if the client disconnects. -pub async fn subscribe_topics( - app_handle: AppHandle, - ntable_ip: (u8, u8, u8, u8), - ntable_port: u16, -) { +pub async fn subscribe_topics(app_handle: AppHandle, ntable_ip: Ipv4Addr, ntable_port: u16) { let mut previous_gpws: bool = false; loop {