summaryrefslogtreecommitdiff
path: root/LearnMapKit
diff options
context:
space:
mode:
authorArturs Artamonovs <arturs.artamonovs@protonmail.com>2024-07-25 12:13:51 +0100
committerArturs Artamonovs <arturs.artamonovs@protonmail.com>2024-07-25 12:13:51 +0100
commit901397ffe83cbf1aed01e6a77e00db57e9440dac (patch)
tree03742808a3f1d414615940446868ad30d25aa4d3 /LearnMapKit
parent6ab97d2dfe563c2c43c2519b2e6f22494572045c (diff)
downloadADSBDecoder-901397ffe83cbf1aed01e6a77e00db57e9440dac.tar.gz
ADSBDecoder-901397ffe83cbf1aed01e6a77e00db57e9440dac.zip
Receiving ADSB stream from dump1090 works in LearnMapKit
Diffstat (limited to 'LearnMapKit')
-rw-r--r--LearnMapKit/ContentView.swift1
-rw-r--r--LearnMapKit/LearnMapKit.entitlements2
-rw-r--r--LearnMapKit/LearnMapKitApp.swift27
-rw-r--r--LearnMapKit/NetConfigView.swift11
-rw-r--r--LearnMapKit/NetworkConfigure.swift13
5 files changed, 44 insertions, 10 deletions
diff --git a/LearnMapKit/ContentView.swift b/LearnMapKit/ContentView.swift
index 9f7fd29..e85c3b2 100644
--- a/LearnMapKit/ContentView.swift
+++ b/LearnMapKit/ContentView.swift
@@ -42,6 +42,7 @@ struct ContentView: View {
@State private var isImporting = false
@Binding var pos_queue: Deque<ADSBLocation>
+ @Binding var net_config: NetworkConfigure
@EnvironmentObject var evilClass: FlightState
@Environment(\.openWindow) private var openWindow
diff --git a/LearnMapKit/LearnMapKit.entitlements b/LearnMapKit/LearnMapKit.entitlements
index 61b4b47..ca15375 100644
--- a/LearnMapKit/LearnMapKit.entitlements
+++ b/LearnMapKit/LearnMapKit.entitlements
@@ -8,5 +8,7 @@
<true/>
<key>com.apple.security.files.user-selected.read-only</key>
<true/>
+ <key>com.apple.security.network.client</key>
+ <true/>
</dict>
</plist>
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<ADSBLocation> = []
+ @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)
}
}
diff --git a/LearnMapKit/NetConfigView.swift b/LearnMapKit/NetConfigView.swift
index 06fc5c2..0216f8a 100644
--- a/LearnMapKit/NetConfigView.swift
+++ b/LearnMapKit/NetConfigView.swift
@@ -12,6 +12,8 @@ struct NetConfigView: View {
@State private var server_port: String = ""
@Environment(\.dismissWindow) private var dismissWindow
+ @Binding var net_config: NetworkConfigure
+
var body: some View {
VStack {
HStack {
@@ -31,6 +33,9 @@ struct NetConfigView: View {
}
Button(action: {
print("Save config")
+ net_config.servername = server_name
+ // is there better way?
+ net_config.serverport = Int(server_port)!
dismissWindow(id:"net-config")
}) {
Text("Save")
@@ -40,6 +45,6 @@ struct NetConfigView: View {
}
}
-#Preview {
- NetConfigView()
-}
+//#Preview {
+ //NetConfigView(net_config: net_config)
+//}
diff --git a/LearnMapKit/NetworkConfigure.swift b/LearnMapKit/NetworkConfigure.swift
new file mode 100644
index 0000000..a566f8b
--- /dev/null
+++ b/LearnMapKit/NetworkConfigure.swift
@@ -0,0 +1,13 @@
+//
+// File.swift
+// LearnMapKit
+//
+// Created by Jacky Jack on 19/07/2024.
+//
+
+import Foundation
+
+class NetworkConfigure {
+ var servername: String = "192.168.4.201"
+ var serverport: Int = 30002
+}