Build for associated domains

This commit is contained in:
Garth Vander Houwen 2022-06-28 20:20:02 -07:00
parent 6b10e9aabe
commit d36c4e94ea
9 changed files with 189 additions and 18 deletions

View file

@ -70,6 +70,8 @@
DDC3B274283F411B00AC321C /* LastHeardText.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDC3B273283F411B00AC321C /* LastHeardText.swift */; };
DDC4D568275499A500A4208E /* Persistence.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDC4D567275499A500A4208E /* Persistence.swift */; };
DDCE4E2C2869F92900BE9F8F /* UserConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDCE4E2B2869F92900BE9F8F /* UserConfig.swift */; };
DDCE4E2E286B7BC400BE9F8F /* StoreForwaredConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDCE4E2D286B7BC400BE9F8F /* StoreForwaredConfig.swift */; };
DDCE4E30286B7BD800BE9F8F /* InputBrokerConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDCE4E2F286B7BD800BE9F8F /* InputBrokerConfig.swift */; };
DDCFF601285453A7005FA625 /* localonly.pb.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDCFF600285453A7005FA625 /* localonly.pb.swift */; };
DDD94A502845C8F5004A87A0 /* DateTimeText.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDD94A4F2845C8F5004A87A0 /* DateTimeText.swift */; };
DDD9E4E4284B208E003777C5 /* UserEntityExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDD9E4E3284B208E003777C5 /* UserEntityExtension.swift */; };
@ -165,6 +167,8 @@
DDC3B273283F411B00AC321C /* LastHeardText.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LastHeardText.swift; sourceTree = "<group>"; };
DDC4D567275499A500A4208E /* Persistence.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Persistence.swift; sourceTree = "<group>"; };
DDCE4E2B2869F92900BE9F8F /* UserConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserConfig.swift; sourceTree = "<group>"; };
DDCE4E2D286B7BC400BE9F8F /* StoreForwaredConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StoreForwaredConfig.swift; sourceTree = "<group>"; };
DDCE4E2F286B7BD800BE9F8F /* InputBrokerConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InputBrokerConfig.swift; sourceTree = "<group>"; };
DDCFF600285453A7005FA625 /* localonly.pb.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = localonly.pb.swift; sourceTree = "<group>"; };
DDD94A4F2845C8F5004A87A0 /* DateTimeText.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DateTimeText.swift; sourceTree = "<group>"; };
DDD9E4E3284B208E003777C5 /* UserEntityExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserEntityExtension.swift; sourceTree = "<group>"; };
@ -269,6 +273,8 @@
DD41582928585C32009B0E59 /* RangeTestConfig.swift */,
DD6193782863875F00E59241 /* SerialConfig.swift */,
DD415827285859C4009B0E59 /* TelemetryConfig.swift */,
DDCE4E2D286B7BC400BE9F8F /* StoreForwaredConfig.swift */,
DDCE4E2F286B7BD800BE9F8F /* InputBrokerConfig.swift */,
);
path = Module;
sourceTree = "<group>";
@ -636,6 +642,7 @@
C9A7BC1027759A9600760B50 /* PositionAnnotationView.swift in Sources */,
DD882F5D2772E4640005BF05 /* Contacts.swift in Sources */,
DD47E3CE26F103C600029299 /* NodeList.swift in Sources */,
DDCE4E30286B7BD800BE9F8F /* InputBrokerConfig.swift in Sources */,
DD8EBF43285058FA00426DCA /* DisplayConfig.swift in Sources */,
DD47E3D626F17ED900029299 /* CircleText.swift in Sources */,
DDC2E18F26CE25FE0042C5E4 /* ContentView.swift in Sources */,
@ -665,6 +672,7 @@
DDAF8C6726ED0C8C0058C060 /* remote_hardware.pb.swift in Sources */,
DDAF8C6526ED0A490058C060 /* channel.pb.swift in Sources */,
DDC2E15826CE248E0042C5E4 /* MeshtasticApp.swift in Sources */,
DDCE4E2E286B7BC400BE9F8F /* StoreForwaredConfig.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

View file

@ -1038,6 +1038,41 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph
return false
}
public func getModuleConfig (configType: AdminMessage.ModuleConfigType, destNum: Int64, wantResponse: Bool) -> Bool {
var adminPacket = AdminMessage()
adminPacket.getModuleConfigRequest = configType
var meshPacket: MeshPacket = MeshPacket()
meshPacket.to = UInt32(connectedPeripheral.num)
meshPacket.from = 0 //UInt32(connectedPeripheral.num)
meshPacket.id = UInt32.random(in: UInt32(UInt8.max)..<UInt32.max)
meshPacket.priority = MeshPacket.Priority.reliable
meshPacket.wantAck = wantResponse
meshPacket.hopLimit = 0
var dataMessage = DataMessage()
dataMessage.payload = try! adminPacket.serializedData()
dataMessage.portnum = PortNum.adminApp
meshPacket.decoded = dataMessage
var toRadio: ToRadio!
toRadio = ToRadio()
toRadio.packet = meshPacket
let binaryData: Data = try! toRadio.serializedData()
if connectedPeripheral!.peripheral.state == CBPeripheralState.connected {
connectedPeripheral.peripheral.writeValue(binaryData, for: TORADIO_characteristic, type: .withResponse)
return true
}
return false
}
public func saveRangeTestModuleConfig(config: ModuleConfig.RangeTestConfig, destNum: Int64, wantResponse: Bool) -> Bool {
var adminPacket = AdminMessage()
@ -1072,4 +1107,39 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph
return false
}
public func saveSerialModuleConfig(config: ModuleConfig.SerialConfig, destNum: Int64, wantResponse: Bool) -> Bool {
var adminPacket = AdminMessage()
adminPacket.setModuleConfig.serial = config
var meshPacket: MeshPacket = MeshPacket()
meshPacket.to = UInt32(connectedPeripheral.num)
meshPacket.from = 0 //UInt32(connectedPeripheral.num)
meshPacket.id = UInt32.random(in: UInt32(UInt8.max)..<UInt32.max)
meshPacket.priority = MeshPacket.Priority.reliable
meshPacket.wantAck = wantResponse
meshPacket.hopLimit = 0
var dataMessage = DataMessage()
dataMessage.payload = try! adminPacket.serializedData()
dataMessage.portnum = PortNum.adminApp
meshPacket.decoded = dataMessage
var toRadio: ToRadio!
toRadio = ToRadio()
toRadio.packet = meshPacket
let binaryData: Data = try! toRadio.serializedData()
if connectedPeripheral!.peripheral.state == CBPeripheralState.connected {
connectedPeripheral.peripheral.writeValue(binaryData, for: TORADIO_characteristic, type: .withResponse)
return true
}
return false
}
}

View file

@ -4,7 +4,7 @@
<dict>
<key>com.apple.developer.associated-domains</key>
<array>
<string>applinks:meshtastic.org/e/</string>
<string>applinks:meshtastic.org/*</string>
</array>
<key>com.apple.security.app-sandbox</key>
<true/>

View file

@ -19,8 +19,22 @@ struct MeshtasticAppleApp: App {
.environment(\.managedObjectContext, persistenceController.container.viewContext)
.environmentObject(bleManager)
.environmentObject(userSettings)
.onContinueUserActivity(NSUserActivityTypeBrowsingWeb) { userActivity in
print("Continue activity \(userActivity)")
guard let url = userActivity.webpageURL else {
return
}
print("User wants to open URL: \(url)")
// TODO same handling as done in onOpenURL()
}
.onOpenURL(perform: { (url) in
print("URL OPENED")
print(url)
//we are expecting a .mbtiles map file that contains raster data
//save it to the documents directory, and name it offline_map.mbtiles
let fileManager = FileManager.default

View file

@ -0,0 +1,8 @@
//
// InputBrokerConfig.swift
// Meshtastic
//
// Created by Garth Vander Houwen on 6/28/22.
//
import Foundation

View file

@ -104,34 +104,34 @@ struct RangeTestConfig: View {
if self.initialLoad{
self.bleManager.context = context
self.enabled = node.rangeTestConfig?.enabled ?? false
self.save = node.rangeTestConfig?.save ?? false
if node.rangeTestConfig?.sender != nil {
self.sender = node.rangeTestConfig!.sender == 1 ? true : false
} else {
self.sender = false
}
self.sender = node.rangeTestConfig?.sender != nil
// self.enabled = node.rangeTestConfig?.enabled ?? false
// self.save = node.rangeTestConfig?.save ?? false
//
// if node.rangeTestConfig?.sender != nil {
//
// self.sender = node.rangeTestConfig!.sender == 1 ? true : false
//
// } else {
// self.sender = false
// }
// self.sender = node.rangeTestConfig?.sender != nil
self.hasChanges = false
self.initialLoad = false
}
}
.onChange(of: enabled) { newEnabled in
if newEnabled != node.rangeTestConfig!.enabled {
//if newEnabled != node.rangeTestConfig!.enabled {
hasChanges = true
}
//}
}
.onChange(of: save) { newSave in
if newSave != node.rangeTestConfig!.save {
//if newSave != node.rangeTestConfig!.save {
hasChanges = true
}
//}
}
.onChange(of: sender) { newSender in

View file

@ -127,6 +127,10 @@ struct SerialConfig: View {
@Environment(\.managedObjectContext) var context
@EnvironmentObject var bleManager: BLEManager
@State private var isPresentingSaveConfirm: Bool = false
@State var initialLoad: Bool = true
@State var hasChanges = false
@State var enabled = false
@State var echo = false
@State var rxd = 0
@ -154,6 +158,8 @@ struct SerialConfig: View {
Label("Echo", systemImage: "repeat")
}
.toggleStyle(SwitchToggleStyle(tint: .accentColor))
Text("If set, any packets you send will be echoed back to your device.")
.font(.caption)
Picker("Baud Rate", selection: $baudRate ) {
ForEach(SerialBaudRates.allCases) { sbr in
@ -168,6 +174,8 @@ struct SerialConfig: View {
}
}
.pickerStyle(DefaultPickerStyle())
Text("The amount of time to wait before we consider your packet as done.")
.font(.caption)
Picker("Mode", selection: $mode ) {
ForEach(SerialModeTypes.allCases) { smt in
@ -207,8 +215,48 @@ struct SerialConfig: View {
}
}
.pickerStyle(DefaultPickerStyle())
Text("Set the GPIO pins for RXD and TXD.")
.font(.caption)
}
}
Button {
isPresentingSaveConfirm = true
} label: {
Label("Save", systemImage: "square.and.arrow.down")
}
.disabled(bleManager.connectedPeripheral == nil || !hasChanges)
.buttonStyle(.bordered)
.buttonBorderShape(.capsule)
.controlSize(.large)
.padding()
.confirmationDialog(
"Are you sure?",
isPresented: $isPresentingSaveConfirm
) {
Button("Save Range Test Module Config to \(bleManager.connectedPeripheral != nil ? bleManager.connectedPeripheral.longName : "Unknown")?") {
var sc = ModuleConfig.SerialConfig()
sc.enabled = enabled
//sc.save = save
//sc.sender = sender ? 1 : 0
if bleManager.saveSerialModuleConfig(config: sc, destNum: bleManager.connectedPeripheral.num, wantResponse: false) {
// Should show a saved successfully alert once I know that to be true
// for now just disable the button after a successful save
hasChanges = false
} else {
}
}
}
.navigationTitle("Serial Config")
.navigationBarItems(trailing:

View file

@ -0,0 +1,8 @@
//
// StoreForwaredConfig.swift
// Meshtastic
//
// Created by Garth Vander Houwen on 6/28/22.
//
import Foundation

View file

@ -17,7 +17,7 @@ struct Settings: View {
sortDescriptors: [NSSortDescriptor(key: "lastHeard", ascending: false)],
animation: .default)
private var nodes: FetchedResults<NodeInfoEntity>
private var nodes: FetchedResults<NodeInfoEntity>
var body: some View {
NavigationView {
@ -123,6 +123,7 @@ struct Settings: View {
Text("Canned Messages")
}
.disabled(bleManager.connectedPeripheral == nil)
NavigationLink {
ExternalNotificationConfig(node: nodes.first(where: { $0.num == connectedNodeNum }) ?? NodeInfoEntity())
@ -143,7 +144,9 @@ struct Settings: View {
Text("Range Test (ESP32 Only)")
}
.disabled(!(nodes.first(where: { $0.num == connectedNodeNum })?.myInfo?.hasWifi ?? true) || bleManager.connectedPeripheral == nil)
.disabled(!(bleManager.connectedPeripheral == nil))
//nodes.first(where: { $0.num == connectedNodeNum })?.myInfo?.hasWifi ?? true) ||
// nodes.first(where: { $0.num == connectedNodeNum })!.rangeTestConfig != nil)
NavigationLink {
SerialConfig()
@ -174,6 +177,18 @@ struct Settings: View {
}
.listStyle(GroupedListStyle())
.navigationTitle("Settings")
.onAppear {
//
// let connectedNode =
// if nodes.first(where: { $0.num == (bleManager.connectedPeripheral != nil ? bleManager.connectedPeripheral.num : 0) })!.rangeTestConfig == nil {
//
// // We have no Range Test Config, go get it
// self.bleManager.getModuleConfig(configType: AdminMessage.ModuleConfigType.rangetestConfig, destNum: bleManager.connectedPeripheral.num, wantResponse: tr)
// }
}
}
}
}