Merge pull request #174 from meshtastic/channel_updates

Channel updates, require 1.3.41 version
This commit is contained in:
Garth Vander Houwen 2022-09-20 19:32:57 -07:00 committed by GitHub
commit 7c7129cd10
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 44 additions and 54 deletions

View file

@ -269,13 +269,6 @@
path = Custom;
sourceTree = "<group>";
};
DD2160AC28C5019400C17253 /* Messages */ = {
isa = PBXGroup;
children = (
);
path = Messages;
sourceTree = "<group>";
};
DD47E3CA26F0E50300029299 /* Nodes */ = {
isa = PBXGroup;
children = (
@ -507,7 +500,6 @@
DDC2E18D26CE25CB0042C5E4 /* Helpers */ = {
isa = PBXGroup;
children = (
DD2160AC28C5019400C17253 /* Messages */,
DD47E3D526F17ED900029299 /* CircleText.swift */,
DD47E3D826F3093800029299 /* MessageBubble.swift */,
DD90860B26F684AF00DC5189 /* BatteryIcon.swift */,

View file

@ -107,20 +107,23 @@ enum SerialBaudRates: Int, CaseIterable, Identifiable {
enum SerialModeTypes: Int, CaseIterable, Identifiable {
case modeDefault = 0
case modeSimple = 1
case modeProto = 2
case `default` = 0
case simple = 1
case proto = 2
case txtmsg = 3
var id: Int { self.rawValue }
var description: String {
get {
switch self {
case .modeDefault:
case .default:
return "Default"
case .modeSimple:
case .simple:
return "Simple"
case .modeProto:
case .proto:
return "Protobufs"
case .txtmsg:
return "Text Message"
}
}
}
@ -128,12 +131,14 @@ enum SerialModeTypes: Int, CaseIterable, Identifiable {
switch self {
case .modeDefault:
case .default:
return ModuleConfig.SerialConfig.Serial_Mode.default
case .modeSimple:
case .simple:
return ModuleConfig.SerialConfig.Serial_Mode.simple
case .modeProto:
case .proto:
return ModuleConfig.SerialConfig.Serial_Mode.proto
case .txtmsg:
return ModuleConfig.SerialConfig.Serial_Mode.textmsg
}
}
}
@ -141,6 +146,7 @@ enum SerialModeTypes: Int, CaseIterable, Identifiable {
enum SerialTimeoutIntervals: Int, CaseIterable, Identifiable {
case unset = 0
case oneSecond = 1
case fiveSeconds = 5
case tenSeconds = 10
case fifteenSeconds = 15
@ -154,6 +160,8 @@ enum SerialTimeoutIntervals: Int, CaseIterable, Identifiable {
switch self {
case .unset:
return "Unset"
case .oneSecond:
return "One Second"
case .fiveSeconds:
return "Five Seconds"
case .tenSeconds:

View file

@ -204,7 +204,7 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph
peripheralName = name
}
let newPeripheral = Peripheral(id: peripheral.identifier.uuidString, num: 0, name: peripheralName, shortName: last4Code, longName: peripheralName, lastFourCode: last4Code, firmwareVersion: "Unknown", rssi: RSSI.intValue, bitrate: nil, channelUtilization: nil, airTime: nil, lastUpdate: Date(), subscribed: false, peripheral: peripheral)
let newPeripheral = Peripheral(id: peripheral.identifier.uuidString, num: 0, name: peripheralName, shortName: last4Code, longName: peripheralName, lastFourCode: last4Code, firmwareVersion: "Unknown", rssi: RSSI.intValue, bitrate: nil, channelUtilization: nil, airTime: nil, maxChannels: 0, lastUpdate: Date(), subscribed: false, peripheral: peripheral)
let peripheralIndex = peripherals.firstIndex(where: { $0.id == newPeripheral.id })
if peripheralIndex != nil && newPeripheral.peripheral.state != CBPeripheralState.connected {
@ -514,6 +514,7 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph
self.connectedPeripheral.firmwareVersion = myInfo!.firmwareVersion ?? "Unknown"
self.connectedPeripheral.name = myInfo!.bleName ?? "Unknown"
self.connectedPeripheral.longName = myInfo!.bleName ?? "Unknown"
self.connectedPeripheral.maxChannels = myInfo!.maxChannels
}
}
@ -640,6 +641,20 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph
self.connectedPeripheral.subscribed = true
peripherals.removeAll(where: { $0.peripheral.state == CBPeripheralState.disconnected })
// Config conplete returns so we don't read the characteristic again
// Get all the channels
var i: UInt32 = 1;
Timer.scheduledTimer(withTimeInterval: 0.4,
repeats: true) { timer in
if i == (self.connectedPeripheral.maxChannels + 1) {
timer.invalidate() // invalidate the timer
} else {
_ = self.getChannel(channelIndex: i, wantResponse: true)
i+=1;
}
}
return
}

View file

@ -1065,37 +1065,10 @@ func nodeInfoAppPacket (packet: MeshPacket, meshLogging: Bool, context: NSManage
func adminAppPacket (packet: MeshPacket, meshLogging: Bool, context: NSManagedObjectContext) {
if let deviceConfig = try? Config.DeviceConfig(serializedData: packet.decoded.payload) {
print(try! deviceConfig.jsonString())
} else if let displayConfig = try? Config.DisplayConfig(serializedData: packet.decoded.payload) {
print(try! displayConfig.jsonUTF8Data())
print(displayConfig.gpsFormat)
} else if let loraConfig = try? Config.LoRaConfig(serializedData: packet.decoded.payload) {
print(try! loraConfig.jsonUTF8Data())
print(loraConfig.region)
} else if let positionConfig = try? Config.PositionConfig(serializedData: packet.decoded.payload) {
print(try! positionConfig.jsonUTF8Data())
print(positionConfig.positionBroadcastSecs)
} else if let powerConfig = try? Config.PowerConfig(serializedData: packet.decoded.payload) {
print(try! powerConfig.jsonUTF8Data())
} else if let channel = try? Channel(serializedData: packet.decoded.payload) {
print(try! channel.jsonUTF8Data())
print("channel settings:", channel.settings)
if let channelMessage = try? Channel(serializedData: packet.decoded.payload) {
if meshLogging { MeshLogger.log(" Channel Message received for Admin App \(try! channelMessage.jsonString())") }
}
if meshLogging { MeshLogger.log(" MESH PACKET received for Admin App UNHANDLED \(try! packet.jsonString())") }
}
func positionPacket (packet: MeshPacket, meshLogging: Bool, context: NSManagedObjectContext) {

View file

@ -13,11 +13,12 @@ struct Peripheral: Identifiable {
var bitrate: Float?
var channelUtilization: Float?
var airTime: Float?
var maxChannels: Int32
var lastUpdate: Date
var subscribed: Bool
var peripheral: CBPeripheral
init(id: String, num: Int64, name: String, shortName: String, longName: String, lastFourCode: String, firmwareVersion: String, rssi: Int, bitrate: Float?, channelUtilization: Float?, airTime: Float?, lastUpdate: Date, subscribed: Bool, peripheral: CBPeripheral) {
init(id: String, num: Int64, name: String, shortName: String, longName: String, lastFourCode: String, firmwareVersion: String, rssi: Int, bitrate: Float?, channelUtilization: Float?, airTime: Float?, maxChannels: Int32, lastUpdate: Date, subscribed: Bool, peripheral: CBPeripheral) {
self.id = id
self.num = num
self.name = name
@ -29,6 +30,7 @@ struct Peripheral: Identifiable {
self.bitrate = bitrate
self.channelUtilization = channelUtilization
self.airTime = airTime
self.maxChannels = maxChannels
self.lastUpdate = lastUpdate
self.subscribed = subscribed
self.peripheral = peripheral

View file

@ -309,11 +309,11 @@ struct CannedMessagesConfig: View {
if newPreset == 1 {
// RAK Rotary Encoder
updown1Enabled = true
updown1Enabled = false
rotary1Enabled = false
inputbrokerPinA = 4
inputbrokerPinB = 10
inputbrokerPinPress = 3
inputbrokerPinA = 32
inputbrokerPinB = 38
inputbrokerPinPress = 37
inputbrokerEventCw = InputEventChars.keyUp.rawValue
inputbrokerEventCcw = InputEventChars.keyDown.rawValue
inputbrokerEventPress = InputEventChars.keySelect.rawValue