mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
QR Cleanup
This commit is contained in:
parent
b03881798a
commit
3e512de3b2
2 changed files with 19 additions and 10 deletions
|
|
@ -1091,7 +1091,11 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph
|
|||
i += 1
|
||||
chan.settings = cs
|
||||
chan.index = i
|
||||
|
||||
if i == 1 {
|
||||
chan.role = Channel.Role.primary
|
||||
} else {
|
||||
chan.role = Channel.Role.secondary
|
||||
}
|
||||
var adminPacket = AdminMessage()
|
||||
adminPacket.setChannel = chan
|
||||
var meshPacket: MeshPacket = MeshPacket()
|
||||
|
|
@ -1111,7 +1115,7 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph
|
|||
let binaryData: Data = try! toRadio.serializedData()
|
||||
if connectedPeripheral!.peripheral.state == CBPeripheralState.connected {
|
||||
self.connectedPeripheral.peripheral.writeValue(binaryData, for: self.TORADIO_characteristic, type: .withResponse)
|
||||
MeshLogger.log("💾 Saved a Channel for: \(String(self.connectedPeripheral.num))")
|
||||
MeshLogger.log("✈️ Sent a Channel for: \(String(self.connectedPeripheral.num)) Channel Index \(chan.index)")
|
||||
}
|
||||
}
|
||||
// Save the LoRa Config and the device will reboot
|
||||
|
|
@ -1124,7 +1128,7 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph
|
|||
meshPacket.id = UInt32.random(in: UInt32(UInt8.max)..<UInt32.max)
|
||||
|
||||
meshPacket.priority = MeshPacket.Priority.reliable
|
||||
meshPacket.wantAck = false
|
||||
meshPacket.wantAck = true
|
||||
meshPacket.hopLimit = 0
|
||||
|
||||
var dataMessage = DataMessage()
|
||||
|
|
@ -1138,7 +1142,7 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph
|
|||
let binaryData: Data = try! toRadio.serializedData()
|
||||
if connectedPeripheral!.peripheral.state == CBPeripheralState.connected {
|
||||
self.connectedPeripheral.peripheral.writeValue(binaryData, for: self.TORADIO_characteristic, type: .withResponse)
|
||||
MeshLogger.log("💾 Saved a LoRaConfig for: \(String(self.connectedPeripheral.num))")
|
||||
MeshLogger.log("✈️ Sent a LoRaConfig for: \(String(self.connectedPeripheral.num))")
|
||||
}
|
||||
|
||||
return true
|
||||
|
|
|
|||
|
|
@ -761,7 +761,7 @@ func channelPacket (channel: Channel, fromNum: Int64, context: NSManagedObjectCo
|
|||
|
||||
let fetchedMyInfo = try context.fetch(fetchedMyInfoRequest) as! [MyInfoEntity]
|
||||
|
||||
if fetchedMyInfo.count == 1 && channel.role.rawValue > 0 {
|
||||
if fetchedMyInfo.count == 1 {
|
||||
|
||||
let newChannel = ChannelEntity(context: context)
|
||||
newChannel.index = Int32(channel.index)
|
||||
|
|
@ -772,13 +772,18 @@ func channelPacket (channel: Channel, fromNum: Int64, context: NSManagedObjectCo
|
|||
newChannel.psk = channel.settings.psk
|
||||
|
||||
let mutableChannels = fetchedMyInfo[0].channels!.mutableCopy() as! NSMutableOrderedSet
|
||||
if channel.index == 1 {
|
||||
//mutableChannels.removeAllObjects()
|
||||
}
|
||||
|
||||
|
||||
mutableChannels.add(newChannel)
|
||||
fetchedMyInfo[0].channels = mutableChannels.copy() as? NSOrderedSet
|
||||
try context.save()
|
||||
fetchedMyInfo[0].objectWillChange.send()
|
||||
do {
|
||||
try context.save()
|
||||
} catch {
|
||||
|
||||
print("Failed to save channel")
|
||||
|
||||
}
|
||||
|
||||
MeshLogger.log("💾 Updated MyInfo channel \(channel.index) from Channel App Packet For: \(fetchedMyInfo[0].myNodeNum)")
|
||||
|
||||
} else if channel.role.rawValue > 0 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue