Clean up node details view, use timer to get back channels

This commit is contained in:
Garth Vander Houwen 2022-09-16 05:35:42 -07:00
parent c586a5cbd2
commit dceb20b42f
3 changed files with 22 additions and 33 deletions

View file

@ -643,20 +643,20 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph
// Config conplete returns so we don't read the characteristic again
// Get all the channels
var i: UInt32 = 0;
while i < 8 {
// this should actually loop over MyNodeInfo.maxChannels to get all channels
//let timer = Timer.scheduledTimer(withTimeInterval: 2.0, repeats: false) { (timer) in
print("requesting channel",i)
var i: UInt32 = 1;
let timer = Timer.scheduledTimer(withTimeInterval: 2.0,
repeats: true) { timer in
if i == 9 {
timer.invalidate() // invalidate the timer
} else {
print("requesting channel", i)
let resp = self.getChannel(channelIndex: i, wantResponse: true)
i+=1;
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + .seconds(3)) {}
//}
}
}
return
}
@ -1345,22 +1345,11 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph
if connectedPeripheral!.peripheral.state == CBPeripheralState.connected {
do {
try context!.save()
if meshLoggingEnabled { MeshLogger.log("💾 Saved a Get Channel Request Admin Message for node: \(String(connectedPeripheral.num))") }
if meshLoggingEnabled { MeshLogger.log("🛎️ Send Get Channel Request Admin Message for node: \(String(connectedPeripheral.num))") }
connectedPeripheral.peripheral.writeValue(binaryData, for: TORADIO_characteristic, type: .withResponse)
return true
} catch {
context!.rollback()
let nsError = error as NSError
print("💥 Error Inserting New Core Data MessageEntity: \(nsError)")
}
}
return false

View file

@ -1075,13 +1075,18 @@ func adminAppPacket (packet: MeshPacket, meshLogging: Bool, context: NSManagedOb
print(try! powerConfig.jsonUTF8Data())
} else if let channel = try? Channel(serializedData: packet.decoded.payload) {
print(try! channel.jsonUTF8Data())
print("channel settings:", channel.settings)
} else if let channel = try? ChannelSettings(serializedData: packet.decoded.payload) {
print(try! channel.jsonUTF8Data())
print("channel settings:", channel)
}
print(try! packet.decoded.jsonUTF8Data())
if meshLogging { MeshLogger.log(" MESH PACKET received for Admin App UNHANDLED \(try! packet.jsonString())") }
}

View file

@ -71,14 +71,9 @@ struct NodeDetail: View {
} else {
HStack {
Image(node.user?.hwModel ?? "UNSET")
.resizable()
.aspectRatio(contentMode: .fit)
.cornerRadius(10)
.frame(width: bounds.size.width, height: bounds.size.height / 2.3)
.padding([.top], 40)
}
.offset( y:-40)
.padding([.top], 40)
}
ScrollView {
@ -159,7 +154,7 @@ struct NodeDetail: View {
Text("AKA").font(.largeTitle)
.foregroundColor(.gray).fixedSize()
.offset(y:20)
.offset(y:15)
CircleText(text: node.user?.shortName ?? "???", color: .accentColor, circleSize: 75, fontSize: 26)
}
.padding()
@ -172,8 +167,8 @@ struct NodeDetail: View {
Image(hwModelString)
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 90, height: 90)
.aspectRatio(contentMode: .fill)
.frame(width: 200, height: 200)
.cornerRadius(5)
Text(String(hwModelString))