Fix mac crashes

This commit is contained in:
Garth Vander Houwen 2023-01-29 00:16:17 -08:00
parent dd6da2727e
commit 5fdf97f7c5
6 changed files with 39 additions and 34 deletions

View file

@ -1038,7 +1038,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 2.0.12;
MARKETING_VERSION = 2.0.11;
PRODUCT_BUNDLE_IDENTIFIER = gvh.MeshtasticClient;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTS_MACCATALYST = YES;
@ -1071,7 +1071,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 2.0.12;
MARKETING_VERSION = 2.0.11;
PRODUCT_BUNDLE_IDENTIFIER = gvh.MeshtasticClient;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTS_MACCATALYST = YES;

View file

@ -862,7 +862,7 @@ class BLEManager: NSObject, CBPeripheralDelegate, ObservableObject {
adminPacket.rebootSeconds = 5
var meshPacket: MeshPacket = MeshPacket()
meshPacket.to = UInt32(connectedPeripheral.num)
meshPacket.to = UInt32(toUser.num)
meshPacket.from = UInt32(fromUser.num)
meshPacket.id = UInt32.random(in: UInt32(UInt8.max)..<UInt32.max)
meshPacket.priority = MeshPacket.Priority.reliable

View file

@ -356,20 +356,6 @@ struct NodeDetail: View {
}
Divider()
}
VStack {
AsyncImage(url: attributionLogo) { image in
image
.resizable()
.scaledToFit()
} placeholder: {
ProgressView()
.controlSize(.mini)
}
.frame(height: 15)
Link("Other data sources", destination: attributionLink ?? URL(string: "https://weather-data.apple.com/legal-attribution.html")!)
}
.font(.footnote)
}
if self.bleManager.connectedPeripheral != nil && self.bleManager.connectedPeripheral.num == node.num && self.bleManager.connectedPeripheral.num == node.num {
@ -411,7 +397,7 @@ struct NodeDetail: View {
.controlSize(.large)
.padding()
.confirmationDialog("are.you.sure",
isPresented: $showingRebootConfirm
isPresented: $showingRebootConfirm
) {
Button("reboot.node", role: .destructive) {
if !bleManager.sendReboot(fromUser: node.user!, toUser: node.user!) {
@ -421,7 +407,23 @@ struct NodeDetail: View {
}
}
.padding(5)
Divider()
}
VStack {
AsyncImage(url: attributionLogo) { image in
image
.resizable()
.scaledToFit()
} placeholder: {
ProgressView()
.controlSize(.mini)
}
.frame(height: 15)
Link("Other data sources", destination: attributionLink ?? URL(string: "https://weather-data.apple.com/legal-attribution.html")!)
}
.font(.footnote)
}
}
.edgesIgnoringSafeArea([.leading, .trailing])

View file

@ -132,7 +132,11 @@ struct BluetoothConfig: View {
print("empty bluetooth config")
}
let adminMessageId = bleManager.requestBluetoothConfig(fromUser: connectedNode!.user!, toUser: node!.user!, adminIndex: connectedNode?.myInfo?.adminIndex ?? 0)
// Need to request a BluetoothConfig from the remote node before allowing changes
if connectedNode != nil && node?.bluetoothConfig == nil {
let adminMessageId = bleManager.requestBluetoothConfig(fromUser: connectedNode!.user!, toUser: node!.user!, adminIndex: connectedNode?.myInfo?.adminIndex ?? 0)
}
}
.onChange(of: enabled) { newEnabled in
if node != nil && node!.bluetoothConfig != nil {

View file

@ -116,7 +116,7 @@ struct LoRaConfig: View {
self.hasChanges = false
// Need to request a LoRaConfig from the remote node before allowing changes
if node?.loRaConfig == nil {
if connectedNode != nil && node?.loRaConfig == nil {
print("empty lora config")
let adminMessageId = bleManager.requestLoRaConfig(fromUser: connectedNode!.user!, toUser: node!.user!, adminIndex: connectedNode?.myInfo?.adminIndex ?? 0)
}

View file

@ -76,19 +76,19 @@ struct Settings: View {
.pickerStyle(.menu)
.labelsHidden()
.onChange(of: selectedNode) { newValue in
// if selectedNode > 0 {
// let node = nodes.first(where: { $0.num == newValue })
// let connectedNode = nodes.first(where: { $0.num == connectedNodeNum })
// connectedNodeNum = Int(bleManager.connectedPeripheral != nil ? bleManager.connectedPeripheral.num : 0)
//
// if node?.metadata == nil && node!.num != connectedNodeNum {
// let adminMessageId = bleManager.requestDeviceMetadata(fromUser: connectedNode!.user!, toUser: node!.user!, adminIndex: connectedNode!.myInfo!.adminIndex, context: context)
//
// if adminMessageId > 0 {
// print("Saved node metadata")
// }
// }
// }
if selectedNode > 0 {
let node = nodes.first(where: { $0.num == newValue })
let connectedNode = nodes.first(where: { $0.num == connectedNodeNum })
connectedNodeNum = Int(bleManager.connectedPeripheral != nil ? bleManager.connectedPeripheral.num : 0)
if node?.metadata == nil && node!.num != connectedNodeNum {
let adminMessageId = bleManager.requestDeviceMetadata(fromUser: connectedNode!.user!, toUser: node!.user!, adminIndex: connectedNode!.myInfo!.adminIndex, context: context)
if adminMessageId > 0 {
print("Saved node metadata")
}
}
}
}
}
}
@ -114,7 +114,6 @@ struct Settings: View {
Text("user")
}
.tag(SettingsSidebar.userConfig)
.disabled(selectedNode == 0)
NavigationLink() {
LoRaConfig(node: nodes.first(where: { $0.num == selectedNode }), connectedNode: nodes.first(where: { $0.num == connectedNodeNum }))