From 901397ffe83cbf1aed01e6a77e00db57e9440dac Mon Sep 17 00:00:00 2001 From: Arturs Artamonovs Date: Thu, 25 Jul 2024 12:13:51 +0100 Subject: Receiving ADSB stream from dump1090 works in LearnMapKit --- LearnMapKit/LearnMapKitApp.swift | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'LearnMapKit/LearnMapKitApp.swift') diff --git a/LearnMapKit/LearnMapKitApp.swift b/LearnMapKit/LearnMapKitApp.swift index 6c46f3b..62a902f 100644 --- a/LearnMapKit/LearnMapKitApp.swift +++ b/LearnMapKit/LearnMapKitApp.swift @@ -15,26 +15,39 @@ import ArgumentParser @main struct LearnMapKitApp: App { - - - + @State var queue: Deque = [] + @State var netconfig: NetworkConfigure = NetworkConfigure() @StateObject private var flightState = FlightState() init() { + print("Init app") + let ADSBClient = NetADSBDecoder(host: "192.168.4.201", port: 30002) + /*do { + try ADSBClient.start() + } catch let error { + print("Error: \(error.localizedDescription)") + ADSBClient.stop() + }*/ + DispatchQueue.global(qos: .background).async { + do { + try ADSBClient.start() + } catch let error { + print("Error: \(error.localizedDescription)") + ADSBClient.stop() + } + } } - - var body: some Scene { WindowGroup { - ContentView(pos_queue: $queue) + ContentView(pos_queue: $queue, net_config: $netconfig) }.environmentObject(flightState) WindowGroup("Network", id: "net-config") { - NetConfigView() + NetConfigView(net_config: $netconfig) } } -- cgit v1.2.3