Merge pull request #89 from meshtastic/feature/new_config

Update photos, consume new local config on connect
This commit is contained in:
Garth Vander Houwen 2022-06-15 22:53:25 -07:00 committed by GitHub
commit 31093f52eb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 157 additions and 31 deletions

View file

@ -799,7 +799,7 @@
CODE_SIGN_ENTITLEMENTS = MeshtasticApple/MeshtasticApple.entitlements;
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"MeshtasticApple/Preview Content\"";
DEVELOPMENT_TEAM = GCH7VS5Y9R;
ENABLE_PREVIEWS = YES;
@ -809,7 +809,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.3.17;
MARKETING_VERSION = 1.3.18;
PRODUCT_BUNDLE_IDENTIFIER = gvh.MeshtasticClient;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTS_MACCATALYST = YES;
@ -830,7 +830,7 @@
CODE_SIGN_ENTITLEMENTS = MeshtasticApple/MeshtasticApple.entitlements;
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"MeshtasticApple/Preview Content\"";
DEVELOPMENT_TEAM = GCH7VS5Y9R;
ENABLE_PREVIEWS = YES;
@ -840,7 +840,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.3.17;
MARKETING_VERSION = 1.3.18;
PRODUCT_BUNDLE_IDENTIFIER = gvh.MeshtasticClient;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTS_MACCATALYST = YES;

View file

@ -197,9 +197,9 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph
}
}
// let today = Date()
// let visibleDuration = Calendar.current.date(byAdding: .second, value: -7, to: Date())!
// peripherals.removeAll(where: { $0.lastUpdate <= visibleDuration})
let today = Date()
let visibleDuration = Calendar.current.date(byAdding: .second, value: -2, to: today)!
peripherals.removeAll(where: { $0.lastUpdate <= visibleDuration})
}
// Called when a peripheral is connected
@ -395,7 +395,9 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph
switch decodedInfo.packet.decoded.portnum {
// Handle Any local only packets we get over BLE
case .unknownApp:
if decodedInfo.myInfo.myNodeNum != 0 {
let myInfo = myInfoPacket(myInfo: decodedInfo.myInfo, meshLogging: meshLoggingEnabled, context: context!)
@ -427,6 +429,10 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph
}
}
} else if decodedInfo.config.version == 13 {
localConfig(config: decodedInfo.config, meshlogging: meshLoggingEnabled, context: context!, nodeLongName: self.connectedPeripheral.longName)
} else {
if meshLoggingEnabled { MeshLogger.log(" MESH PACKET received for Unknown App UNHANDLED \(try! decodedInfo.packet.jsonString())") }

View file

@ -9,6 +9,48 @@ import Foundation
import CoreData
import SwiftUI
func localConfig (config: LocalConfig, meshlogging: Bool, context:NSManagedObjectContext, nodeLongName: String) {
// We don't care about any of the Power settings
// We don't want to manage wifi from the phone app and disconnect our device
if meshlogging { MeshLogger.log("⚙️ Local Config version \(config.version) received for \(nodeLongName)") }
if (try! config.device.jsonString()) == "{}" {
print("📟 Default Device config")
} else {
print("📟 Has Device config")
}
if (try! config.display.jsonString()) == "{}" {
print("🖥️ Default Display config")
} else {
print("🖥️ Has Display config")
}
if (try! config.lora.jsonString()) == "{}" {
print("📡 Default LoRa config")
} else {
print("📡 Has LoRa config")
}
if (try! config.position.jsonString()) == "{}" {
print("📍 Default Position config")
} else {
print("📍 Has Position config")
}
}
func myInfoPacket (myInfo: MyNodeInfo, meshLogging: Bool, context: NSManagedObjectContext) -> MyInfoEntity? {
@ -352,15 +394,10 @@ func adminAppPacket (packet: MeshPacket, meshLogging: Bool, context: NSManagedOb
}
if meshLogging { MeshLogger.log(" MESH PACKET received for Admin App UNHANDLED \(try! packet.jsonString())") }
//PowerConfig
//WiFiConfig
//if let loraConfig = try? MeshtasticApple.Config.LoRaConfig(serializedData: packet.serializedData) {
// print(loraConfig)

View file

@ -177,6 +177,12 @@ struct ChannelFile {
/// The channels our node knows about
var channels: [Channel] = []
///
/// A version integer used to invalidate old save files when we make
/// incompatible changes This integer is set at build time and is private to
/// NodeDB.cpp in the device code.
var version: UInt32 = 0
var unknownFields = SwiftProtobuf.UnknownStorage()
init() {}
@ -360,6 +366,7 @@ extension ChannelFile: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementati
static let protoMessageName: String = "ChannelFile"
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
1: .same(proto: "channels"),
2: .same(proto: "version"),
]
mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
@ -369,6 +376,7 @@ extension ChannelFile: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementati
// enabled. https://github.com/apple/swift-protobuf/issues/1034
switch fieldNumber {
case 1: try { try decoder.decodeRepeatedMessageField(value: &self.channels) }()
case 2: try { try decoder.decodeSingularUInt32Field(value: &self.version) }()
default: break
}
}
@ -378,11 +386,15 @@ extension ChannelFile: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementati
if !self.channels.isEmpty {
try visitor.visitRepeatedMessageField(value: self.channels, fieldNumber: 1)
}
if self.version != 0 {
try visitor.visitSingularUInt32Field(value: self.version, fieldNumber: 2)
}
try unknownFields.traverse(visitor: &visitor)
}
static func ==(lhs: ChannelFile, rhs: ChannelFile) -> Bool {
if lhs.channels != rhs.channels {return false}
if lhs.version != rhs.version {return false}
if lhs.unknownFields != rhs.unknownFields {return false}
return true
}

View file

@ -26,7 +26,7 @@ struct LocalConfig {
// methods supported on all messages.
///
/// TODO: REPLACE
/// The part of the config that is specific to the Device
var device: Config.DeviceConfig {
get {return _storage._device ?? Config.DeviceConfig()}
set {_uniqueStorage()._device = newValue}
@ -37,7 +37,7 @@ struct LocalConfig {
mutating func clearDevice() {_uniqueStorage()._device = nil}
///
/// TODO: REPLACE
/// The part of the config that is specific to the GPS Position
var position: Config.PositionConfig {
get {return _storage._position ?? Config.PositionConfig()}
set {_uniqueStorage()._position = newValue}
@ -48,7 +48,7 @@ struct LocalConfig {
mutating func clearPosition() {_uniqueStorage()._position = nil}
///
/// TODO: REPLACE
/// The part of the config that is specific to the Power settings
var power: Config.PowerConfig {
get {return _storage._power ?? Config.PowerConfig()}
set {_uniqueStorage()._power = newValue}
@ -59,7 +59,7 @@ struct LocalConfig {
mutating func clearPower() {_uniqueStorage()._power = nil}
///
/// TODO: REPLACE
/// The part of the config that is specific to the Wifi Settings
var wifi: Config.WiFiConfig {
get {return _storage._wifi ?? Config.WiFiConfig()}
set {_uniqueStorage()._wifi = newValue}
@ -70,7 +70,7 @@ struct LocalConfig {
mutating func clearWifi() {_uniqueStorage()._wifi = nil}
///
/// TODO: REPLACE
/// The part of the config that is specific to the Display
var display: Config.DisplayConfig {
get {return _storage._display ?? Config.DisplayConfig()}
set {_uniqueStorage()._display = newValue}
@ -81,7 +81,7 @@ struct LocalConfig {
mutating func clearDisplay() {_uniqueStorage()._display = nil}
///
/// TODO: REPLACE
/// The part of the config that is specific to the Lora Radio
var lora: Config.LoRaConfig {
get {return _storage._lora ?? Config.LoRaConfig()}
set {_uniqueStorage()._lora = newValue}
@ -91,6 +91,15 @@ struct LocalConfig {
/// Clears the value of `lora`. Subsequent reads from it will return its default value.
mutating func clearLora() {_uniqueStorage()._lora = nil}
///
/// A version integer used to invalidate old save files when we make
/// incompatible changes This integer is set at build time and is private to
/// NodeDB.cpp in the device code.
var version: UInt32 {
get {return _storage._version}
set {_uniqueStorage()._version = newValue}
}
var unknownFields = SwiftProtobuf.UnknownStorage()
init() {}
@ -104,7 +113,7 @@ struct LocalModuleConfig {
// methods supported on all messages.
///
/// TODO: REPLACE
/// The part of the config that is specific to the MQTT module
var mqtt: ModuleConfig.MQTTConfig {
get {return _storage._mqtt ?? ModuleConfig.MQTTConfig()}
set {_uniqueStorage()._mqtt = newValue}
@ -115,7 +124,7 @@ struct LocalModuleConfig {
mutating func clearMqtt() {_uniqueStorage()._mqtt = nil}
///
/// TODO: REPLACE
/// The part of the config that is specific to the Serial module
var serial: ModuleConfig.SerialConfig {
get {return _storage._serial ?? ModuleConfig.SerialConfig()}
set {_uniqueStorage()._serial = newValue}
@ -126,7 +135,7 @@ struct LocalModuleConfig {
mutating func clearSerial() {_uniqueStorage()._serial = nil}
///
/// TODO: REPLACE
/// The part of the config that is specific to the ExternalNotification module
var externalNotification: ModuleConfig.ExternalNotificationConfig {
get {return _storage._externalNotification ?? ModuleConfig.ExternalNotificationConfig()}
set {_uniqueStorage()._externalNotification = newValue}
@ -137,7 +146,7 @@ struct LocalModuleConfig {
mutating func clearExternalNotification() {_uniqueStorage()._externalNotification = nil}
///
/// TODO: REPLACE
/// The part of the config that is specific to the Store & Forward module
var storeForward: ModuleConfig.StoreForwardConfig {
get {return _storage._storeForward ?? ModuleConfig.StoreForwardConfig()}
set {_uniqueStorage()._storeForward = newValue}
@ -148,7 +157,7 @@ struct LocalModuleConfig {
mutating func clearStoreForward() {_uniqueStorage()._storeForward = nil}
///
/// TODO: REPLACE
/// The part of the config that is specific to the RangeTest module
var rangeTest: ModuleConfig.RangeTestConfig {
get {return _storage._rangeTest ?? ModuleConfig.RangeTestConfig()}
set {_uniqueStorage()._rangeTest = newValue}
@ -159,7 +168,7 @@ struct LocalModuleConfig {
mutating func clearRangeTest() {_uniqueStorage()._rangeTest = nil}
///
/// TODO: REPLACE
/// The part of the config that is specific to the Telemetry module
var telemetry: ModuleConfig.TelemetryConfig {
get {return _storage._telemetry ?? ModuleConfig.TelemetryConfig()}
set {_uniqueStorage()._telemetry = newValue}
@ -170,7 +179,7 @@ struct LocalModuleConfig {
mutating func clearTelemetry() {_uniqueStorage()._telemetry = nil}
///
/// TODO: REPLACE
/// The part of the config that is specific to the Canned Message module
var cannedMessage: ModuleConfig.CannedMessageConfig {
get {return _storage._cannedMessage ?? ModuleConfig.CannedMessageConfig()}
set {_uniqueStorage()._cannedMessage = newValue}
@ -180,6 +189,15 @@ struct LocalModuleConfig {
/// Clears the value of `cannedMessage`. Subsequent reads from it will return its default value.
mutating func clearCannedMessage() {_uniqueStorage()._cannedMessage = nil}
///
/// A version integer used to invalidate old save files when we make
/// incompatible changes This integer is set at build time and is private to
/// NodeDB.cpp in the device code.
var version: UInt32 {
get {return _storage._version}
set {_uniqueStorage()._version = newValue}
}
var unknownFields = SwiftProtobuf.UnknownStorage()
init() {}
@ -203,6 +221,7 @@ extension LocalConfig: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementati
4: .same(proto: "wifi"),
5: .same(proto: "display"),
6: .same(proto: "lora"),
7: .same(proto: "version"),
]
fileprivate class _StorageClass {
@ -212,6 +231,7 @@ extension LocalConfig: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementati
var _wifi: Config.WiFiConfig? = nil
var _display: Config.DisplayConfig? = nil
var _lora: Config.LoRaConfig? = nil
var _version: UInt32 = 0
static let defaultInstance = _StorageClass()
@ -224,6 +244,7 @@ extension LocalConfig: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementati
_wifi = source._wifi
_display = source._display
_lora = source._lora
_version = source._version
}
}
@ -248,6 +269,7 @@ extension LocalConfig: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementati
case 4: try { try decoder.decodeSingularMessageField(value: &_storage._wifi) }()
case 5: try { try decoder.decodeSingularMessageField(value: &_storage._display) }()
case 6: try { try decoder.decodeSingularMessageField(value: &_storage._lora) }()
case 7: try { try decoder.decodeSingularUInt32Field(value: &_storage._version) }()
default: break
}
}
@ -278,6 +300,9 @@ extension LocalConfig: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementati
try { if let v = _storage._lora {
try visitor.visitSingularMessageField(value: v, fieldNumber: 6)
} }()
if _storage._version != 0 {
try visitor.visitSingularUInt32Field(value: _storage._version, fieldNumber: 7)
}
}
try unknownFields.traverse(visitor: &visitor)
}
@ -293,6 +318,7 @@ extension LocalConfig: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementati
if _storage._wifi != rhs_storage._wifi {return false}
if _storage._display != rhs_storage._display {return false}
if _storage._lora != rhs_storage._lora {return false}
if _storage._version != rhs_storage._version {return false}
return true
}
if !storagesAreEqual {return false}
@ -312,6 +338,7 @@ extension LocalModuleConfig: SwiftProtobuf.Message, SwiftProtobuf._MessageImplem
5: .standard(proto: "range_test"),
6: .same(proto: "telemetry"),
7: .standard(proto: "canned_message"),
8: .same(proto: "version"),
]
fileprivate class _StorageClass {
@ -322,6 +349,7 @@ extension LocalModuleConfig: SwiftProtobuf.Message, SwiftProtobuf._MessageImplem
var _rangeTest: ModuleConfig.RangeTestConfig? = nil
var _telemetry: ModuleConfig.TelemetryConfig? = nil
var _cannedMessage: ModuleConfig.CannedMessageConfig? = nil
var _version: UInt32 = 0
static let defaultInstance = _StorageClass()
@ -335,6 +363,7 @@ extension LocalModuleConfig: SwiftProtobuf.Message, SwiftProtobuf._MessageImplem
_rangeTest = source._rangeTest
_telemetry = source._telemetry
_cannedMessage = source._cannedMessage
_version = source._version
}
}
@ -360,6 +389,7 @@ extension LocalModuleConfig: SwiftProtobuf.Message, SwiftProtobuf._MessageImplem
case 5: try { try decoder.decodeSingularMessageField(value: &_storage._rangeTest) }()
case 6: try { try decoder.decodeSingularMessageField(value: &_storage._telemetry) }()
case 7: try { try decoder.decodeSingularMessageField(value: &_storage._cannedMessage) }()
case 8: try { try decoder.decodeSingularUInt32Field(value: &_storage._version) }()
default: break
}
}
@ -393,6 +423,9 @@ extension LocalModuleConfig: SwiftProtobuf.Message, SwiftProtobuf._MessageImplem
try { if let v = _storage._cannedMessage {
try visitor.visitSingularMessageField(value: v, fieldNumber: 7)
} }()
if _storage._version != 0 {
try visitor.visitSingularUInt32Field(value: _storage._version, fieldNumber: 8)
}
}
try unknownFields.traverse(visitor: &visitor)
}
@ -409,6 +442,7 @@ extension LocalModuleConfig: SwiftProtobuf.Message, SwiftProtobuf._MessageImplem
if _storage._rangeTest != rhs_storage._rangeTest {return false}
if _storage._telemetry != rhs_storage._telemetry {return false}
if _storage._cannedMessage != rhs_storage._cannedMessage {return false}
if _storage._version != rhs_storage._version {return false}
return true
}
if !storagesAreEqual {return false}

View file

@ -1809,6 +1809,16 @@ struct FromRadio {
set {_uniqueStorage()._payloadVariant = .nodeInfo(newValue)}
}
///
/// Include the entire config (was: RadioConfig radio)
var config: LocalConfig {
get {
if case .config(let v)? = _storage._payloadVariant {return v}
return LocalConfig()
}
set {_uniqueStorage()._payloadVariant = .config(newValue)}
}
///
/// Set to send debug console output over our protobuf stream
var logRecord: LogRecord {
@ -1862,6 +1872,9 @@ struct FromRadio {
/// starts over with the first node in our DB
case nodeInfo(NodeInfo)
///
/// Include the entire config (was: RadioConfig radio)
case config(LocalConfig)
///
/// Set to send debug console output over our protobuf stream
case logRecord(LogRecord)
///
@ -1895,6 +1908,10 @@ struct FromRadio {
guard case .nodeInfo(let l) = lhs, case .nodeInfo(let r) = rhs else { preconditionFailure() }
return l == r
}()
case (.config, .config): return {
guard case .config(let l) = lhs, case .config(let r) = rhs else { preconditionFailure() }
return l == r
}()
case (.logRecord, .logRecord): return {
guard case .logRecord(let l) = lhs, case .logRecord(let r) = rhs else { preconditionFailure() }
return l == r
@ -3276,6 +3293,7 @@ extension FromRadio: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementation
11: .same(proto: "packet"),
3: .standard(proto: "my_info"),
4: .standard(proto: "node_info"),
6: .same(proto: "config"),
7: .standard(proto: "log_record"),
8: .standard(proto: "config_complete_id"),
9: .same(proto: "rebooted"),
@ -3337,6 +3355,19 @@ extension FromRadio: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementation
_storage._payloadVariant = .nodeInfo(v)
}
}()
case 6: try {
var v: LocalConfig?
var hadOneofValue = false
if let current = _storage._payloadVariant {
hadOneofValue = true
if case .config(let m) = current {v = m}
}
try decoder.decodeSingularMessageField(value: &v)
if let v = v {
if hadOneofValue {try decoder.handleConflictingOneOf()}
_storage._payloadVariant = .config(v)
}
}()
case 7: try {
var v: LogRecord?
var hadOneofValue = false
@ -3403,6 +3434,10 @@ extension FromRadio: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementation
guard case .nodeInfo(let v)? = _storage._payloadVariant else { preconditionFailure() }
try visitor.visitSingularMessageField(value: v, fieldNumber: 4)
}()
case .config?: try {
guard case .config(let v)? = _storage._payloadVariant else { preconditionFailure() }
try visitor.visitSingularMessageField(value: v, fieldNumber: 6)
}()
case .logRecord?: try {
guard case .logRecord(let v)? = _storage._payloadVariant else { preconditionFailure() }
try visitor.visitSingularMessageField(value: v, fieldNumber: 7)

View file

@ -27,7 +27,7 @@ struct CircleText: View {
struct CircleText_Previews: PreviewProvider {
static var previews: some View {
CircleText(text: "RDN", color: Color.accentColor)
CircleText(text: "RDDN", color: Color.accentColor)
.previewLayout(.fixed(width: 300, height: 100))
}
}

View file

@ -69,18 +69,23 @@ struct UserMessageList: View {
}
}
HStack (alignment: .top) {
if currentUser { Spacer(minLength:50) }
if !currentUser {
CircleText(text: message.fromUser?.shortName ?? "????", color: currentUser ? .accentColor : Color(.darkGray), circleSize: 46, fontSize: 16).padding(.all, 5)
CircleText(text: message.fromUser?.shortName ?? "????", color: currentUser ? .accentColor : Color(.darkGray), circleSize: 44, fontSize: 14)
.padding(.all, 5)
.offset(y: -5)
}
VStack(alignment: currentUser ? .trailing : .leading) {
Text(message.messagePayload ?? "EMPTY MESSAGE")
.padding(10)
.foregroundColor(.white)
.background(currentUser ? Color.blue : Color(.darkGray))
.cornerRadius(15)
@ -283,8 +288,8 @@ struct UserMessageList: View {
}
.padding(.bottom)
.id(user.messageList.firstIndex(of: message))
if !currentUser {
Spacer(minLength:50)
}
}
@ -379,7 +384,6 @@ struct UserMessageList: View {
} else {
typingMessage = "📍 " + userLongName + " has shared their position with the mesh."
}
} else {
@ -436,7 +440,6 @@ struct UserMessageList: View {
}
.padding(.all, 15)
}
.navigationViewStyle(.stack)
.navigationBarTitleDisplayMode(.inline)
.toolbar {

View file

@ -26,7 +26,6 @@ struct QrCodeImage {
qrImage = UIImage(cgImage: image)
}
}
let qrCode = filter.outputImage!.transformed(by: transform)
return qrImage
}