diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 00000000..788e7a2e --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,21 @@ +## What changed? + + +## Why did it change? + + +## How is this tested? + + +## Screenshots/Videos (when applicable) + + + +## Checklist + +- [ ] My code adheres to the project's coding and style guidelines. +- [ ] I have conducted a self-review of my code. +- [ ] I have commented my code, particularly in complex areas. +- [ ] I have made corresponding changes to the documentation. +- [ ] I have tested the change to ensure that it works as intended. + diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..94ade3d3 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,128 @@ +# Contributing to Meshtastic + +Thank you for considering contributing to Meshtastic! We appreciate your time and effort in helping to improve the project. This document outlines the guidelines for contributing to the project. + +## Table of Contents + +1. [Getting Started](#getting-started) +2. [Development Workflow](#development-workflow) + - [Targeting `main`](#targeting-main) + - [Small, Incremental Changes](#small-incremental-changes) + - [Rebase Commits](#rebase-commits) +3. [Creating a Branch](#creating-a-branch) +4. [Making Changes](#making-changes) +5. [Commit Messages](#commit-messages) +6. [Merging Changes](#merging-changes) +7. [Testing](#testing) +8. [Code Review](#code-review) +9. [Documentation](#documentation) +10. [Style Guides](#style-guides) + - [Git Commit Messages](#git-commit-messages) + - [Code Style](#code-style) +11. [Community](#community) + +## Getting Started + +1. Fork the repository on GitLab. +2. Clone your fork to your local machine: + ```sh + git clone https://gitlab.com//Meshtastic-Apple.git + ``` +3. Navigate to the project directory: + ```sh + cd Meshtastic-Apple + ``` +4. Open the Meshtastic.xcworkspace + ```sh + open Meshtastic.xcworkspace + ``` + +## Development Workflow + +### Targeting `main` + +In accordance with trunk-based development, all changes should target the `main` branch. + +### Small, Incremental Changes + +To facilitate easy code reviews and minimize merge conflicts, we encourage making small, incremental changes. Each change should be a self-contained, logically coherent unit of work that addresses a specific task or fixes a particular issue. + +### Rebase Commits + +To keep the project history clean, please use rebasing over merging when incorporating changes from the `main` branch into your feature branches. To rebase your branch on `main`, you can perform the following steps. + +```sh +git fetch +git rebase main +``` + +To enable pulls to rebase by default, you can use this git configuration option. + +```sh +git config pull.rebase true +``` + +## Creating a Branch + +1. Always create a new branch for your work. Use a descriptive name for your branch: + ```sh + git checkout -b your-branch-name + ``` + +## Making Changes + +1. Make your changes in the new branch. +2. Ensure your changes adhere to the project’s coding standards and conventions. +3. Keep your changes focused and avoid combining multiple unrelated tasks in a single branch. + +## Commit Messages + +1. Write clear and concise commit messages following the guidelines in [Git Commit Messages](#git-commit-messages). + +## Merging Changes + +1. Push your changes to your fork: + ```sh + git push origin your-branch-name + ``` +2. Create a pull request (PR) targeting the `main` branch. +3. Ensure your PR adheres to the project's guidelines and includes a clear description of the changes. +4. Request a code review from the project maintainers. + +## Testing + +1. Ensure all existing tests pass before submitting your PR. +2. Write new tests for any new features or bug fixes. +3. Run the tests locally + +## Code Review + +1. Address any feedback or changes requested by the reviewers. +2. Once approved, the PR will be merged into the `main` branch by a project maintainer. + +## Documentation + +1. Update the documentation to reflect any changes you have made. +2. Ensure the documentation is clear and concise. + +## Style Guides + +### Git Commit Messages + +- Use the imperative mood in the subject line (e.g., "Fix bug" instead of "Fixed bug"). +- Use the body to explain what and why, not how. + +### Code Style + +- This project requires swiftLint - see https://github.com/realm/SwiftLint +- Use SwiftUI +- Use SFSymbols for icons +- Use Core Data for persistence +- Ensure your code is clean and well-documented. + +## Community + +- Join our community on [Discord](https://discord.com/invite/ktMAKGBnBs). +- Participate in discussions and share your ideas. + +Thank you for contributing to Meshtastic! \ No newline at end of file diff --git a/MeshtasticProtobufs/Sources/meshtastic/apponly.pb.swift b/MeshtasticProtobufs/Sources/meshtastic/apponly.pb.swift index d1533d59..0457077c 100644 --- a/MeshtasticProtobufs/Sources/meshtastic/apponly.pb.swift +++ b/MeshtasticProtobufs/Sources/meshtastic/apponly.pb.swift @@ -33,27 +33,24 @@ public struct ChannelSet { /// /// Channel list with settings - public var settings: [ChannelSettings] { - get {return _storage._settings} - set {_uniqueStorage()._settings = newValue} - } + public var settings: [ChannelSettings] = [] /// /// LoRa config public var loraConfig: Config.LoRaConfig { - get {return _storage._loraConfig ?? Config.LoRaConfig()} - set {_uniqueStorage()._loraConfig = newValue} + get {return _loraConfig ?? Config.LoRaConfig()} + set {_loraConfig = newValue} } /// Returns true if `loraConfig` has been explicitly set. - public var hasLoraConfig: Bool {return _storage._loraConfig != nil} + public var hasLoraConfig: Bool {return self._loraConfig != nil} /// Clears the value of `loraConfig`. Subsequent reads from it will return its default value. - public mutating func clearLoraConfig() {_uniqueStorage()._loraConfig = nil} + public mutating func clearLoraConfig() {self._loraConfig = nil} public var unknownFields = SwiftProtobuf.UnknownStorage() public init() {} - fileprivate var _storage = _StorageClass.defaultInstance + fileprivate var _loraConfig: Config.LoRaConfig? = nil } #if swift(>=5.5) && canImport(_Concurrency) @@ -71,78 +68,36 @@ extension ChannelSet: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementatio 2: .standard(proto: "lora_config"), ] - fileprivate class _StorageClass { - var _settings: [ChannelSettings] = [] - var _loraConfig: Config.LoRaConfig? = nil - - #if swift(>=5.10) - // This property is used as the initial default value for new instances of the type. - // The type itself is protecting the reference to its storage via CoW semantics. - // This will force a copy to be made of this reference when the first mutation occurs; - // hence, it is safe to mark this as `nonisolated(unsafe)`. - static nonisolated(unsafe) let defaultInstance = _StorageClass() - #else - static let defaultInstance = _StorageClass() - #endif - - private init() {} - - init(copying source: _StorageClass) { - _settings = source._settings - _loraConfig = source._loraConfig - } - } - - fileprivate mutating func _uniqueStorage() -> _StorageClass { - if !isKnownUniquelyReferenced(&_storage) { - _storage = _StorageClass(copying: _storage) - } - return _storage - } - public mutating func decodeMessage(decoder: inout D) throws { - _ = _uniqueStorage() - try withExtendedLifetime(_storage) { (_storage: _StorageClass) in - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeRepeatedMessageField(value: &_storage._settings) }() - case 2: try { try decoder.decodeSingularMessageField(value: &_storage._loraConfig) }() - default: break - } + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeRepeatedMessageField(value: &self.settings) }() + case 2: try { try decoder.decodeSingularMessageField(value: &self._loraConfig) }() + default: break } } } public func traverse(visitor: inout V) throws { - try withExtendedLifetime(_storage) { (_storage: _StorageClass) in - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every if/case branch local when no optimizations - // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and - // https://github.com/apple/swift-protobuf/issues/1182 - if !_storage._settings.isEmpty { - try visitor.visitRepeatedMessageField(value: _storage._settings, fieldNumber: 1) - } - try { if let v = _storage._loraConfig { - try visitor.visitSingularMessageField(value: v, fieldNumber: 2) - } }() + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + if !self.settings.isEmpty { + try visitor.visitRepeatedMessageField(value: self.settings, fieldNumber: 1) } + try { if let v = self._loraConfig { + try visitor.visitSingularMessageField(value: v, fieldNumber: 2) + } }() try unknownFields.traverse(visitor: &visitor) } public static func ==(lhs: ChannelSet, rhs: ChannelSet) -> Bool { - if lhs._storage !== rhs._storage { - let storagesAreEqual: Bool = withExtendedLifetime((lhs._storage, rhs._storage)) { (_args: (_StorageClass, _StorageClass)) in - let _storage = _args.0 - let rhs_storage = _args.1 - if _storage._settings != rhs_storage._settings {return false} - if _storage._loraConfig != rhs_storage._loraConfig {return false} - return true - } - if !storagesAreEqual {return false} - } + if lhs.settings != rhs.settings {return false} + if lhs._loraConfig != rhs._loraConfig {return false} if lhs.unknownFields != rhs.unknownFields {return false} return true } diff --git a/MeshtasticProtobufs/Sources/meshtastic/config.pb.swift b/MeshtasticProtobufs/Sources/meshtastic/config.pb.swift index f6c42f70..f396367c 100644 --- a/MeshtasticProtobufs/Sources/meshtastic/config.pb.swift +++ b/MeshtasticProtobufs/Sources/meshtastic/config.pb.swift @@ -1087,7 +1087,10 @@ public struct Config { /// /// When enabled, the `modem_preset` fields will be adhered to, else the `bandwidth`/`spread_factor`/`coding_rate` /// will be taked from their respective manually defined fields - public var usePreset: Bool = false + public var usePreset: Bool { + get {return _storage._usePreset} + set {_uniqueStorage()._usePreset = newValue} + } /// /// Either modem_config or bandwidth/spreading/coding will be specified - NOT BOTH. @@ -1095,51 +1098,78 @@ public struct Config { /// Because protobufs take ZERO space when the value is zero this works out nicely. /// This value is replaced by bandwidth/spread_factor/coding_rate. /// If you'd like to experiment with other options add them to MeshRadio.cpp in the device code. - public var modemPreset: Config.LoRaConfig.ModemPreset = .longFast + public var modemPreset: Config.LoRaConfig.ModemPreset { + get {return _storage._modemPreset} + set {_uniqueStorage()._modemPreset = newValue} + } /// /// Bandwidth in MHz /// Certain bandwidth numbers are 'special' and will be converted to the /// appropriate floating point value: 31 -> 31.25MHz - public var bandwidth: UInt32 = 0 + public var bandwidth: UInt32 { + get {return _storage._bandwidth} + set {_uniqueStorage()._bandwidth = newValue} + } /// /// A number from 7 to 12. /// Indicates number of chirps per symbol as 1< 7 results in the default - public var hopLimit: UInt32 = 0 + public var hopLimit: UInt32 { + get {return _storage._hopLimit} + set {_uniqueStorage()._hopLimit = newValue} + } /// /// Disable TX from the LoRa radio. Useful for hot-swapping antennas and other tests. /// Defaults to false - public var txEnabled: Bool = false + public var txEnabled: Bool { + get {return _storage._txEnabled} + set {_uniqueStorage()._txEnabled = newValue} + } /// /// If zero, then use default max legal continuous power (ie. something that won't /// burn out the radio hardware) /// In most cases you should use zero here. /// Units are in dBm. - public var txPower: Int32 = 0 + public var txPower: Int32 { + get {return _storage._txPower} + set {_uniqueStorage()._txPower = newValue} + } /// /// This controls the actual hardware frequency the radio transmits on. @@ -1149,17 +1179,26 @@ public struct Config { /// algorithm to derive the channel number") /// If using the hash algorithm the channel number will be: hash(channel_name) % /// NUM_CHANNELS (Where num channels depends on the regulatory region). - public var channelNum: UInt32 = 0 + public var channelNum: UInt32 { + get {return _storage._channelNum} + set {_uniqueStorage()._channelNum = newValue} + } /// /// If true, duty cycle limits will be exceeded and thus you're possibly not following /// the local regulations if you're not a HAM. /// Has no effect if the duty cycle of the used region is 100%. - public var overrideDutyCycle: Bool = false + public var overrideDutyCycle: Bool { + get {return _storage._overrideDutyCycle} + set {_uniqueStorage()._overrideDutyCycle = newValue} + } /// /// If true, sets RX boosted gain mode on SX126X based radios - public var sx126XRxBoostedGain: Bool = false + public var sx126XRxBoostedGain: Bool { + get {return _storage._sx126XRxBoostedGain} + set {_uniqueStorage()._sx126XRxBoostedGain = newValue} + } /// /// This parameter is for advanced users and licensed HAM radio operators. @@ -1167,17 +1206,33 @@ public struct Config { /// will still be applied. This will allow you to use out-of-band frequencies. /// Please respect your local laws and regulations. If you are a HAM, make sure you /// enable HAM mode and turn off encryption. - public var overrideFrequency: Float = 0 + public var overrideFrequency: Float { + get {return _storage._overrideFrequency} + set {_uniqueStorage()._overrideFrequency = newValue} + } + + /// + /// If true, disable the build-in PA FAN using pin define in RF95_FAN_EN. + public var paFanDisabled: Bool { + get {return _storage._paFanDisabled} + set {_uniqueStorage()._paFanDisabled = newValue} + } /// /// For testing it is useful sometimes to force a node to never listen to /// particular other nodes (simulating radio out of range). All nodenums listed /// in ignore_incoming will have packets they send dropped on receive (by router.cpp) - public var ignoreIncoming: [UInt32] = [] + public var ignoreIncoming: [UInt32] { + get {return _storage._ignoreIncoming} + set {_uniqueStorage()._ignoreIncoming = newValue} + } /// /// If true, the device will not process any packets received via LoRa that passed via MQTT anywhere on the path towards it. - public var ignoreMqtt: Bool = false + public var ignoreMqtt: Bool { + get {return _storage._ignoreMqtt} + set {_uniqueStorage()._ignoreMqtt = newValue} + } public var unknownFields = SwiftProtobuf.UnknownStorage() @@ -1391,6 +1446,8 @@ public struct Config { } public init() {} + + fileprivate var _storage = _StorageClass.defaultInstance } public struct BluetoothConfig { @@ -2443,106 +2500,184 @@ extension Config.LoRaConfig: SwiftProtobuf.Message, SwiftProtobuf._MessageImplem 12: .standard(proto: "override_duty_cycle"), 13: .standard(proto: "sx126x_rx_boosted_gain"), 14: .standard(proto: "override_frequency"), + 15: .standard(proto: "pa_fan_disabled"), 103: .standard(proto: "ignore_incoming"), 104: .standard(proto: "ignore_mqtt"), ] + fileprivate class _StorageClass { + var _usePreset: Bool = false + var _modemPreset: Config.LoRaConfig.ModemPreset = .longFast + var _bandwidth: UInt32 = 0 + var _spreadFactor: UInt32 = 0 + var _codingRate: UInt32 = 0 + var _frequencyOffset: Float = 0 + var _region: Config.LoRaConfig.RegionCode = .unset + var _hopLimit: UInt32 = 0 + var _txEnabled: Bool = false + var _txPower: Int32 = 0 + var _channelNum: UInt32 = 0 + var _overrideDutyCycle: Bool = false + var _sx126XRxBoostedGain: Bool = false + var _overrideFrequency: Float = 0 + var _paFanDisabled: Bool = false + var _ignoreIncoming: [UInt32] = [] + var _ignoreMqtt: Bool = false + + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif + + private init() {} + + init(copying source: _StorageClass) { + _usePreset = source._usePreset + _modemPreset = source._modemPreset + _bandwidth = source._bandwidth + _spreadFactor = source._spreadFactor + _codingRate = source._codingRate + _frequencyOffset = source._frequencyOffset + _region = source._region + _hopLimit = source._hopLimit + _txEnabled = source._txEnabled + _txPower = source._txPower + _channelNum = source._channelNum + _overrideDutyCycle = source._overrideDutyCycle + _sx126XRxBoostedGain = source._sx126XRxBoostedGain + _overrideFrequency = source._overrideFrequency + _paFanDisabled = source._paFanDisabled + _ignoreIncoming = source._ignoreIncoming + _ignoreMqtt = source._ignoreMqtt + } + } + + fileprivate mutating func _uniqueStorage() -> _StorageClass { + if !isKnownUniquelyReferenced(&_storage) { + _storage = _StorageClass(copying: _storage) + } + return _storage + } + public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularBoolField(value: &self.usePreset) }() - case 2: try { try decoder.decodeSingularEnumField(value: &self.modemPreset) }() - case 3: try { try decoder.decodeSingularUInt32Field(value: &self.bandwidth) }() - case 4: try { try decoder.decodeSingularUInt32Field(value: &self.spreadFactor) }() - case 5: try { try decoder.decodeSingularUInt32Field(value: &self.codingRate) }() - case 6: try { try decoder.decodeSingularFloatField(value: &self.frequencyOffset) }() - case 7: try { try decoder.decodeSingularEnumField(value: &self.region) }() - case 8: try { try decoder.decodeSingularUInt32Field(value: &self.hopLimit) }() - case 9: try { try decoder.decodeSingularBoolField(value: &self.txEnabled) }() - case 10: try { try decoder.decodeSingularInt32Field(value: &self.txPower) }() - case 11: try { try decoder.decodeSingularUInt32Field(value: &self.channelNum) }() - case 12: try { try decoder.decodeSingularBoolField(value: &self.overrideDutyCycle) }() - case 13: try { try decoder.decodeSingularBoolField(value: &self.sx126XRxBoostedGain) }() - case 14: try { try decoder.decodeSingularFloatField(value: &self.overrideFrequency) }() - case 103: try { try decoder.decodeRepeatedUInt32Field(value: &self.ignoreIncoming) }() - case 104: try { try decoder.decodeSingularBoolField(value: &self.ignoreMqtt) }() - default: break + _ = _uniqueStorage() + try withExtendedLifetime(_storage) { (_storage: _StorageClass) in + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBoolField(value: &_storage._usePreset) }() + case 2: try { try decoder.decodeSingularEnumField(value: &_storage._modemPreset) }() + case 3: try { try decoder.decodeSingularUInt32Field(value: &_storage._bandwidth) }() + case 4: try { try decoder.decodeSingularUInt32Field(value: &_storage._spreadFactor) }() + case 5: try { try decoder.decodeSingularUInt32Field(value: &_storage._codingRate) }() + case 6: try { try decoder.decodeSingularFloatField(value: &_storage._frequencyOffset) }() + case 7: try { try decoder.decodeSingularEnumField(value: &_storage._region) }() + case 8: try { try decoder.decodeSingularUInt32Field(value: &_storage._hopLimit) }() + case 9: try { try decoder.decodeSingularBoolField(value: &_storage._txEnabled) }() + case 10: try { try decoder.decodeSingularInt32Field(value: &_storage._txPower) }() + case 11: try { try decoder.decodeSingularUInt32Field(value: &_storage._channelNum) }() + case 12: try { try decoder.decodeSingularBoolField(value: &_storage._overrideDutyCycle) }() + case 13: try { try decoder.decodeSingularBoolField(value: &_storage._sx126XRxBoostedGain) }() + case 14: try { try decoder.decodeSingularFloatField(value: &_storage._overrideFrequency) }() + case 15: try { try decoder.decodeSingularBoolField(value: &_storage._paFanDisabled) }() + case 103: try { try decoder.decodeRepeatedUInt32Field(value: &_storage._ignoreIncoming) }() + case 104: try { try decoder.decodeSingularBoolField(value: &_storage._ignoreMqtt) }() + default: break + } } } } public func traverse(visitor: inout V) throws { - if self.usePreset != false { - try visitor.visitSingularBoolField(value: self.usePreset, fieldNumber: 1) - } - if self.modemPreset != .longFast { - try visitor.visitSingularEnumField(value: self.modemPreset, fieldNumber: 2) - } - if self.bandwidth != 0 { - try visitor.visitSingularUInt32Field(value: self.bandwidth, fieldNumber: 3) - } - if self.spreadFactor != 0 { - try visitor.visitSingularUInt32Field(value: self.spreadFactor, fieldNumber: 4) - } - if self.codingRate != 0 { - try visitor.visitSingularUInt32Field(value: self.codingRate, fieldNumber: 5) - } - if self.frequencyOffset != 0 { - try visitor.visitSingularFloatField(value: self.frequencyOffset, fieldNumber: 6) - } - if self.region != .unset { - try visitor.visitSingularEnumField(value: self.region, fieldNumber: 7) - } - if self.hopLimit != 0 { - try visitor.visitSingularUInt32Field(value: self.hopLimit, fieldNumber: 8) - } - if self.txEnabled != false { - try visitor.visitSingularBoolField(value: self.txEnabled, fieldNumber: 9) - } - if self.txPower != 0 { - try visitor.visitSingularInt32Field(value: self.txPower, fieldNumber: 10) - } - if self.channelNum != 0 { - try visitor.visitSingularUInt32Field(value: self.channelNum, fieldNumber: 11) - } - if self.overrideDutyCycle != false { - try visitor.visitSingularBoolField(value: self.overrideDutyCycle, fieldNumber: 12) - } - if self.sx126XRxBoostedGain != false { - try visitor.visitSingularBoolField(value: self.sx126XRxBoostedGain, fieldNumber: 13) - } - if self.overrideFrequency != 0 { - try visitor.visitSingularFloatField(value: self.overrideFrequency, fieldNumber: 14) - } - if !self.ignoreIncoming.isEmpty { - try visitor.visitPackedUInt32Field(value: self.ignoreIncoming, fieldNumber: 103) - } - if self.ignoreMqtt != false { - try visitor.visitSingularBoolField(value: self.ignoreMqtt, fieldNumber: 104) + try withExtendedLifetime(_storage) { (_storage: _StorageClass) in + if _storage._usePreset != false { + try visitor.visitSingularBoolField(value: _storage._usePreset, fieldNumber: 1) + } + if _storage._modemPreset != .longFast { + try visitor.visitSingularEnumField(value: _storage._modemPreset, fieldNumber: 2) + } + if _storage._bandwidth != 0 { + try visitor.visitSingularUInt32Field(value: _storage._bandwidth, fieldNumber: 3) + } + if _storage._spreadFactor != 0 { + try visitor.visitSingularUInt32Field(value: _storage._spreadFactor, fieldNumber: 4) + } + if _storage._codingRate != 0 { + try visitor.visitSingularUInt32Field(value: _storage._codingRate, fieldNumber: 5) + } + if _storage._frequencyOffset != 0 { + try visitor.visitSingularFloatField(value: _storage._frequencyOffset, fieldNumber: 6) + } + if _storage._region != .unset { + try visitor.visitSingularEnumField(value: _storage._region, fieldNumber: 7) + } + if _storage._hopLimit != 0 { + try visitor.visitSingularUInt32Field(value: _storage._hopLimit, fieldNumber: 8) + } + if _storage._txEnabled != false { + try visitor.visitSingularBoolField(value: _storage._txEnabled, fieldNumber: 9) + } + if _storage._txPower != 0 { + try visitor.visitSingularInt32Field(value: _storage._txPower, fieldNumber: 10) + } + if _storage._channelNum != 0 { + try visitor.visitSingularUInt32Field(value: _storage._channelNum, fieldNumber: 11) + } + if _storage._overrideDutyCycle != false { + try visitor.visitSingularBoolField(value: _storage._overrideDutyCycle, fieldNumber: 12) + } + if _storage._sx126XRxBoostedGain != false { + try visitor.visitSingularBoolField(value: _storage._sx126XRxBoostedGain, fieldNumber: 13) + } + if _storage._overrideFrequency != 0 { + try visitor.visitSingularFloatField(value: _storage._overrideFrequency, fieldNumber: 14) + } + if _storage._paFanDisabled != false { + try visitor.visitSingularBoolField(value: _storage._paFanDisabled, fieldNumber: 15) + } + if !_storage._ignoreIncoming.isEmpty { + try visitor.visitPackedUInt32Field(value: _storage._ignoreIncoming, fieldNumber: 103) + } + if _storage._ignoreMqtt != false { + try visitor.visitSingularBoolField(value: _storage._ignoreMqtt, fieldNumber: 104) + } } try unknownFields.traverse(visitor: &visitor) } public static func ==(lhs: Config.LoRaConfig, rhs: Config.LoRaConfig) -> Bool { - if lhs.usePreset != rhs.usePreset {return false} - if lhs.modemPreset != rhs.modemPreset {return false} - if lhs.bandwidth != rhs.bandwidth {return false} - if lhs.spreadFactor != rhs.spreadFactor {return false} - if lhs.codingRate != rhs.codingRate {return false} - if lhs.frequencyOffset != rhs.frequencyOffset {return false} - if lhs.region != rhs.region {return false} - if lhs.hopLimit != rhs.hopLimit {return false} - if lhs.txEnabled != rhs.txEnabled {return false} - if lhs.txPower != rhs.txPower {return false} - if lhs.channelNum != rhs.channelNum {return false} - if lhs.overrideDutyCycle != rhs.overrideDutyCycle {return false} - if lhs.sx126XRxBoostedGain != rhs.sx126XRxBoostedGain {return false} - if lhs.overrideFrequency != rhs.overrideFrequency {return false} - if lhs.ignoreIncoming != rhs.ignoreIncoming {return false} - if lhs.ignoreMqtt != rhs.ignoreMqtt {return false} + if lhs._storage !== rhs._storage { + let storagesAreEqual: Bool = withExtendedLifetime((lhs._storage, rhs._storage)) { (_args: (_StorageClass, _StorageClass)) in + let _storage = _args.0 + let rhs_storage = _args.1 + if _storage._usePreset != rhs_storage._usePreset {return false} + if _storage._modemPreset != rhs_storage._modemPreset {return false} + if _storage._bandwidth != rhs_storage._bandwidth {return false} + if _storage._spreadFactor != rhs_storage._spreadFactor {return false} + if _storage._codingRate != rhs_storage._codingRate {return false} + if _storage._frequencyOffset != rhs_storage._frequencyOffset {return false} + if _storage._region != rhs_storage._region {return false} + if _storage._hopLimit != rhs_storage._hopLimit {return false} + if _storage._txEnabled != rhs_storage._txEnabled {return false} + if _storage._txPower != rhs_storage._txPower {return false} + if _storage._channelNum != rhs_storage._channelNum {return false} + if _storage._overrideDutyCycle != rhs_storage._overrideDutyCycle {return false} + if _storage._sx126XRxBoostedGain != rhs_storage._sx126XRxBoostedGain {return false} + if _storage._overrideFrequency != rhs_storage._overrideFrequency {return false} + if _storage._paFanDisabled != rhs_storage._paFanDisabled {return false} + if _storage._ignoreIncoming != rhs_storage._ignoreIncoming {return false} + if _storage._ignoreMqtt != rhs_storage._ignoreMqtt {return false} + return true + } + if !storagesAreEqual {return false} + } if lhs.unknownFields != rhs.unknownFields {return false} return true } diff --git a/MeshtasticProtobufs/Sources/meshtastic/mesh.pb.swift b/MeshtasticProtobufs/Sources/meshtastic/mesh.pb.swift index 2b9f69c6..57e8bde4 100644 --- a/MeshtasticProtobufs/Sources/meshtastic/mesh.pb.swift +++ b/MeshtasticProtobufs/Sources/meshtastic/mesh.pb.swift @@ -2165,26 +2165,20 @@ public struct FromRadio { /// /// The packet id, used to allow the phone to request missing read packets from the FIFO, /// see our bluetooth docs - public var id: UInt32 { - get {return _storage._id} - set {_uniqueStorage()._id = newValue} - } + public var id: UInt32 = 0 /// /// Log levels, chosen to match python logging conventions. - public var payloadVariant: OneOf_PayloadVariant? { - get {return _storage._payloadVariant} - set {_uniqueStorage()._payloadVariant = newValue} - } + public var payloadVariant: FromRadio.OneOf_PayloadVariant? = nil /// /// Log levels, chosen to match python logging conventions. public var packet: MeshPacket { get { - if case .packet(let v)? = _storage._payloadVariant {return v} + if case .packet(let v)? = payloadVariant {return v} return MeshPacket() } - set {_uniqueStorage()._payloadVariant = .packet(newValue)} + set {payloadVariant = .packet(newValue)} } /// @@ -2192,10 +2186,10 @@ public struct FromRadio { /// NOTE: This ID must not change - to keep (minimal) compatibility with <1.2 version of android apps. public var myInfo: MyNodeInfo { get { - if case .myInfo(let v)? = _storage._payloadVariant {return v} + if case .myInfo(let v)? = payloadVariant {return v} return MyNodeInfo() } - set {_uniqueStorage()._payloadVariant = .myInfo(newValue)} + set {payloadVariant = .myInfo(newValue)} } /// @@ -2203,30 +2197,30 @@ public struct FromRadio { /// starts over with the first node in our DB public var nodeInfo: NodeInfo { get { - if case .nodeInfo(let v)? = _storage._payloadVariant {return v} + if case .nodeInfo(let v)? = payloadVariant {return v} return NodeInfo() } - set {_uniqueStorage()._payloadVariant = .nodeInfo(newValue)} + set {payloadVariant = .nodeInfo(newValue)} } /// /// Include a part of the config (was: RadioConfig radio) public var config: Config { get { - if case .config(let v)? = _storage._payloadVariant {return v} + if case .config(let v)? = payloadVariant {return v} return Config() } - set {_uniqueStorage()._payloadVariant = .config(newValue)} + set {payloadVariant = .config(newValue)} } /// /// Set to send debug console output over our protobuf stream public var logRecord: LogRecord { get { - if case .logRecord(let v)? = _storage._payloadVariant {return v} + if case .logRecord(let v)? = payloadVariant {return v} return LogRecord() } - set {_uniqueStorage()._payloadVariant = .logRecord(newValue)} + set {payloadVariant = .logRecord(newValue)} } /// @@ -2236,10 +2230,10 @@ public struct FromRadio { /// NOTE: This ID must not change - to keep (minimal) compatibility with <1.2 version of android apps. public var configCompleteID: UInt32 { get { - if case .configCompleteID(let v)? = _storage._payloadVariant {return v} + if case .configCompleteID(let v)? = payloadVariant {return v} return 0 } - set {_uniqueStorage()._payloadVariant = .configCompleteID(newValue)} + set {payloadVariant = .configCompleteID(newValue)} } /// @@ -2249,80 +2243,80 @@ public struct FromRadio { /// NOTE: This ID must not change - to keep (minimal) compatibility with <1.2 version of android apps. public var rebooted: Bool { get { - if case .rebooted(let v)? = _storage._payloadVariant {return v} + if case .rebooted(let v)? = payloadVariant {return v} return false } - set {_uniqueStorage()._payloadVariant = .rebooted(newValue)} + set {payloadVariant = .rebooted(newValue)} } /// /// Include module config public var moduleConfig: ModuleConfig { get { - if case .moduleConfig(let v)? = _storage._payloadVariant {return v} + if case .moduleConfig(let v)? = payloadVariant {return v} return ModuleConfig() } - set {_uniqueStorage()._payloadVariant = .moduleConfig(newValue)} + set {payloadVariant = .moduleConfig(newValue)} } /// /// One packet is sent for each channel public var channel: Channel { get { - if case .channel(let v)? = _storage._payloadVariant {return v} + if case .channel(let v)? = payloadVariant {return v} return Channel() } - set {_uniqueStorage()._payloadVariant = .channel(newValue)} + set {payloadVariant = .channel(newValue)} } /// /// Queue status info public var queueStatus: QueueStatus { get { - if case .queueStatus(let v)? = _storage._payloadVariant {return v} + if case .queueStatus(let v)? = payloadVariant {return v} return QueueStatus() } - set {_uniqueStorage()._payloadVariant = .queueStatus(newValue)} + set {payloadVariant = .queueStatus(newValue)} } /// /// File Transfer Chunk public var xmodemPacket: XModem { get { - if case .xmodemPacket(let v)? = _storage._payloadVariant {return v} + if case .xmodemPacket(let v)? = payloadVariant {return v} return XModem() } - set {_uniqueStorage()._payloadVariant = .xmodemPacket(newValue)} + set {payloadVariant = .xmodemPacket(newValue)} } /// /// Device metadata message public var metadata: DeviceMetadata { get { - if case .metadata(let v)? = _storage._payloadVariant {return v} + if case .metadata(let v)? = payloadVariant {return v} return DeviceMetadata() } - set {_uniqueStorage()._payloadVariant = .metadata(newValue)} + set {payloadVariant = .metadata(newValue)} } /// /// MQTT Client Proxy Message (device sending to client / phone for publishing to MQTT) public var mqttClientProxyMessage: MqttClientProxyMessage { get { - if case .mqttClientProxyMessage(let v)? = _storage._payloadVariant {return v} + if case .mqttClientProxyMessage(let v)? = payloadVariant {return v} return MqttClientProxyMessage() } - set {_uniqueStorage()._payloadVariant = .mqttClientProxyMessage(newValue)} + set {payloadVariant = .mqttClientProxyMessage(newValue)} } /// /// File system manifest messages public var fileInfo: FileInfo { get { - if case .fileInfo(let v)? = _storage._payloadVariant {return v} + if case .fileInfo(let v)? = payloadVariant {return v} return FileInfo() } - set {_uniqueStorage()._payloadVariant = .fileInfo(newValue)} + set {payloadVariant = .fileInfo(newValue)} } public var unknownFields = SwiftProtobuf.UnknownStorage() @@ -2450,8 +2444,6 @@ public struct FromRadio { } public init() {} - - fileprivate var _storage = _StorageClass.defaultInstance } /// @@ -4303,305 +4295,263 @@ extension FromRadio: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementation 15: .same(proto: "fileInfo"), ] - fileprivate class _StorageClass { - var _id: UInt32 = 0 - var _payloadVariant: FromRadio.OneOf_PayloadVariant? - - #if swift(>=5.10) - // This property is used as the initial default value for new instances of the type. - // The type itself is protecting the reference to its storage via CoW semantics. - // This will force a copy to be made of this reference when the first mutation occurs; - // hence, it is safe to mark this as `nonisolated(unsafe)`. - static nonisolated(unsafe) let defaultInstance = _StorageClass() - #else - static let defaultInstance = _StorageClass() - #endif - - private init() {} - - init(copying source: _StorageClass) { - _id = source._id - _payloadVariant = source._payloadVariant - } - } - - fileprivate mutating func _uniqueStorage() -> _StorageClass { - if !isKnownUniquelyReferenced(&_storage) { - _storage = _StorageClass(copying: _storage) - } - return _storage - } - public mutating func decodeMessage(decoder: inout D) throws { - _ = _uniqueStorage() - try withExtendedLifetime(_storage) { (_storage: _StorageClass) in - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularUInt32Field(value: &_storage._id) }() - case 2: try { - var v: MeshPacket? - var hadOneofValue = false - if let current = _storage._payloadVariant { - hadOneofValue = true - if case .packet(let m) = current {v = m} - } - try decoder.decodeSingularMessageField(value: &v) - if let v = v { - if hadOneofValue {try decoder.handleConflictingOneOf()} - _storage._payloadVariant = .packet(v) - } - }() - case 3: try { - var v: MyNodeInfo? - var hadOneofValue = false - if let current = _storage._payloadVariant { - hadOneofValue = true - if case .myInfo(let m) = current {v = m} - } - try decoder.decodeSingularMessageField(value: &v) - if let v = v { - if hadOneofValue {try decoder.handleConflictingOneOf()} - _storage._payloadVariant = .myInfo(v) - } - }() - case 4: try { - var v: NodeInfo? - var hadOneofValue = false - if let current = _storage._payloadVariant { - hadOneofValue = true - if case .nodeInfo(let m) = current {v = m} - } - try decoder.decodeSingularMessageField(value: &v) - if let v = v { - if hadOneofValue {try decoder.handleConflictingOneOf()} - _storage._payloadVariant = .nodeInfo(v) - } - }() - case 5: try { - var v: Config? - 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 6: try { - var v: LogRecord? - var hadOneofValue = false - if let current = _storage._payloadVariant { - hadOneofValue = true - if case .logRecord(let m) = current {v = m} - } - try decoder.decodeSingularMessageField(value: &v) - if let v = v { - if hadOneofValue {try decoder.handleConflictingOneOf()} - _storage._payloadVariant = .logRecord(v) - } - }() - case 7: try { - var v: UInt32? - try decoder.decodeSingularUInt32Field(value: &v) - if let v = v { - if _storage._payloadVariant != nil {try decoder.handleConflictingOneOf()} - _storage._payloadVariant = .configCompleteID(v) - } - }() - case 8: try { - var v: Bool? - try decoder.decodeSingularBoolField(value: &v) - if let v = v { - if _storage._payloadVariant != nil {try decoder.handleConflictingOneOf()} - _storage._payloadVariant = .rebooted(v) - } - }() - case 9: try { - var v: ModuleConfig? - var hadOneofValue = false - if let current = _storage._payloadVariant { - hadOneofValue = true - if case .moduleConfig(let m) = current {v = m} - } - try decoder.decodeSingularMessageField(value: &v) - if let v = v { - if hadOneofValue {try decoder.handleConflictingOneOf()} - _storage._payloadVariant = .moduleConfig(v) - } - }() - case 10: try { - var v: Channel? - var hadOneofValue = false - if let current = _storage._payloadVariant { - hadOneofValue = true - if case .channel(let m) = current {v = m} - } - try decoder.decodeSingularMessageField(value: &v) - if let v = v { - if hadOneofValue {try decoder.handleConflictingOneOf()} - _storage._payloadVariant = .channel(v) - } - }() - case 11: try { - var v: QueueStatus? - var hadOneofValue = false - if let current = _storage._payloadVariant { - hadOneofValue = true - if case .queueStatus(let m) = current {v = m} - } - try decoder.decodeSingularMessageField(value: &v) - if let v = v { - if hadOneofValue {try decoder.handleConflictingOneOf()} - _storage._payloadVariant = .queueStatus(v) - } - }() - case 12: try { - var v: XModem? - var hadOneofValue = false - if let current = _storage._payloadVariant { - hadOneofValue = true - if case .xmodemPacket(let m) = current {v = m} - } - try decoder.decodeSingularMessageField(value: &v) - if let v = v { - if hadOneofValue {try decoder.handleConflictingOneOf()} - _storage._payloadVariant = .xmodemPacket(v) - } - }() - case 13: try { - var v: DeviceMetadata? - var hadOneofValue = false - if let current = _storage._payloadVariant { - hadOneofValue = true - if case .metadata(let m) = current {v = m} - } - try decoder.decodeSingularMessageField(value: &v) - if let v = v { - if hadOneofValue {try decoder.handleConflictingOneOf()} - _storage._payloadVariant = .metadata(v) - } - }() - case 14: try { - var v: MqttClientProxyMessage? - var hadOneofValue = false - if let current = _storage._payloadVariant { - hadOneofValue = true - if case .mqttClientProxyMessage(let m) = current {v = m} - } - try decoder.decodeSingularMessageField(value: &v) - if let v = v { - if hadOneofValue {try decoder.handleConflictingOneOf()} - _storage._payloadVariant = .mqttClientProxyMessage(v) - } - }() - case 15: try { - var v: FileInfo? - var hadOneofValue = false - if let current = _storage._payloadVariant { - hadOneofValue = true - if case .fileInfo(let m) = current {v = m} - } - try decoder.decodeSingularMessageField(value: &v) - if let v = v { - if hadOneofValue {try decoder.handleConflictingOneOf()} - _storage._payloadVariant = .fileInfo(v) - } - }() - default: break + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularUInt32Field(value: &self.id) }() + case 2: try { + var v: MeshPacket? + var hadOneofValue = false + if let current = self.payloadVariant { + hadOneofValue = true + if case .packet(let m) = current {v = m} } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.payloadVariant = .packet(v) + } + }() + case 3: try { + var v: MyNodeInfo? + var hadOneofValue = false + if let current = self.payloadVariant { + hadOneofValue = true + if case .myInfo(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.payloadVariant = .myInfo(v) + } + }() + case 4: try { + var v: NodeInfo? + var hadOneofValue = false + if let current = self.payloadVariant { + hadOneofValue = true + if case .nodeInfo(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.payloadVariant = .nodeInfo(v) + } + }() + case 5: try { + var v: Config? + var hadOneofValue = false + if let current = self.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()} + self.payloadVariant = .config(v) + } + }() + case 6: try { + var v: LogRecord? + var hadOneofValue = false + if let current = self.payloadVariant { + hadOneofValue = true + if case .logRecord(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.payloadVariant = .logRecord(v) + } + }() + case 7: try { + var v: UInt32? + try decoder.decodeSingularUInt32Field(value: &v) + if let v = v { + if self.payloadVariant != nil {try decoder.handleConflictingOneOf()} + self.payloadVariant = .configCompleteID(v) + } + }() + case 8: try { + var v: Bool? + try decoder.decodeSingularBoolField(value: &v) + if let v = v { + if self.payloadVariant != nil {try decoder.handleConflictingOneOf()} + self.payloadVariant = .rebooted(v) + } + }() + case 9: try { + var v: ModuleConfig? + var hadOneofValue = false + if let current = self.payloadVariant { + hadOneofValue = true + if case .moduleConfig(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.payloadVariant = .moduleConfig(v) + } + }() + case 10: try { + var v: Channel? + var hadOneofValue = false + if let current = self.payloadVariant { + hadOneofValue = true + if case .channel(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.payloadVariant = .channel(v) + } + }() + case 11: try { + var v: QueueStatus? + var hadOneofValue = false + if let current = self.payloadVariant { + hadOneofValue = true + if case .queueStatus(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.payloadVariant = .queueStatus(v) + } + }() + case 12: try { + var v: XModem? + var hadOneofValue = false + if let current = self.payloadVariant { + hadOneofValue = true + if case .xmodemPacket(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.payloadVariant = .xmodemPacket(v) + } + }() + case 13: try { + var v: DeviceMetadata? + var hadOneofValue = false + if let current = self.payloadVariant { + hadOneofValue = true + if case .metadata(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.payloadVariant = .metadata(v) + } + }() + case 14: try { + var v: MqttClientProxyMessage? + var hadOneofValue = false + if let current = self.payloadVariant { + hadOneofValue = true + if case .mqttClientProxyMessage(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.payloadVariant = .mqttClientProxyMessage(v) + } + }() + case 15: try { + var v: FileInfo? + var hadOneofValue = false + if let current = self.payloadVariant { + hadOneofValue = true + if case .fileInfo(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.payloadVariant = .fileInfo(v) + } + }() + default: break } } } public func traverse(visitor: inout V) throws { - try withExtendedLifetime(_storage) { (_storage: _StorageClass) in - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every if/case branch local when no optimizations - // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and - // https://github.com/apple/swift-protobuf/issues/1182 - if _storage._id != 0 { - try visitor.visitSingularUInt32Field(value: _storage._id, fieldNumber: 1) - } - switch _storage._payloadVariant { - case .packet?: try { - guard case .packet(let v)? = _storage._payloadVariant else { preconditionFailure() } - try visitor.visitSingularMessageField(value: v, fieldNumber: 2) - }() - case .myInfo?: try { - guard case .myInfo(let v)? = _storage._payloadVariant else { preconditionFailure() } - try visitor.visitSingularMessageField(value: v, fieldNumber: 3) - }() - case .nodeInfo?: try { - 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: 5) - }() - case .logRecord?: try { - guard case .logRecord(let v)? = _storage._payloadVariant else { preconditionFailure() } - try visitor.visitSingularMessageField(value: v, fieldNumber: 6) - }() - case .configCompleteID?: try { - guard case .configCompleteID(let v)? = _storage._payloadVariant else { preconditionFailure() } - try visitor.visitSingularUInt32Field(value: v, fieldNumber: 7) - }() - case .rebooted?: try { - guard case .rebooted(let v)? = _storage._payloadVariant else { preconditionFailure() } - try visitor.visitSingularBoolField(value: v, fieldNumber: 8) - }() - case .moduleConfig?: try { - guard case .moduleConfig(let v)? = _storage._payloadVariant else { preconditionFailure() } - try visitor.visitSingularMessageField(value: v, fieldNumber: 9) - }() - case .channel?: try { - guard case .channel(let v)? = _storage._payloadVariant else { preconditionFailure() } - try visitor.visitSingularMessageField(value: v, fieldNumber: 10) - }() - case .queueStatus?: try { - guard case .queueStatus(let v)? = _storage._payloadVariant else { preconditionFailure() } - try visitor.visitSingularMessageField(value: v, fieldNumber: 11) - }() - case .xmodemPacket?: try { - guard case .xmodemPacket(let v)? = _storage._payloadVariant else { preconditionFailure() } - try visitor.visitSingularMessageField(value: v, fieldNumber: 12) - }() - case .metadata?: try { - guard case .metadata(let v)? = _storage._payloadVariant else { preconditionFailure() } - try visitor.visitSingularMessageField(value: v, fieldNumber: 13) - }() - case .mqttClientProxyMessage?: try { - guard case .mqttClientProxyMessage(let v)? = _storage._payloadVariant else { preconditionFailure() } - try visitor.visitSingularMessageField(value: v, fieldNumber: 14) - }() - case .fileInfo?: try { - guard case .fileInfo(let v)? = _storage._payloadVariant else { preconditionFailure() } - try visitor.visitSingularMessageField(value: v, fieldNumber: 15) - }() - case nil: break - } + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + if self.id != 0 { + try visitor.visitSingularUInt32Field(value: self.id, fieldNumber: 1) + } + switch self.payloadVariant { + case .packet?: try { + guard case .packet(let v)? = self.payloadVariant else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 2) + }() + case .myInfo?: try { + guard case .myInfo(let v)? = self.payloadVariant else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 3) + }() + case .nodeInfo?: try { + guard case .nodeInfo(let v)? = self.payloadVariant else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 4) + }() + case .config?: try { + guard case .config(let v)? = self.payloadVariant else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 5) + }() + case .logRecord?: try { + guard case .logRecord(let v)? = self.payloadVariant else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 6) + }() + case .configCompleteID?: try { + guard case .configCompleteID(let v)? = self.payloadVariant else { preconditionFailure() } + try visitor.visitSingularUInt32Field(value: v, fieldNumber: 7) + }() + case .rebooted?: try { + guard case .rebooted(let v)? = self.payloadVariant else { preconditionFailure() } + try visitor.visitSingularBoolField(value: v, fieldNumber: 8) + }() + case .moduleConfig?: try { + guard case .moduleConfig(let v)? = self.payloadVariant else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 9) + }() + case .channel?: try { + guard case .channel(let v)? = self.payloadVariant else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 10) + }() + case .queueStatus?: try { + guard case .queueStatus(let v)? = self.payloadVariant else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 11) + }() + case .xmodemPacket?: try { + guard case .xmodemPacket(let v)? = self.payloadVariant else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 12) + }() + case .metadata?: try { + guard case .metadata(let v)? = self.payloadVariant else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 13) + }() + case .mqttClientProxyMessage?: try { + guard case .mqttClientProxyMessage(let v)? = self.payloadVariant else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 14) + }() + case .fileInfo?: try { + guard case .fileInfo(let v)? = self.payloadVariant else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 15) + }() + case nil: break } try unknownFields.traverse(visitor: &visitor) } public static func ==(lhs: FromRadio, rhs: FromRadio) -> Bool { - if lhs._storage !== rhs._storage { - let storagesAreEqual: Bool = withExtendedLifetime((lhs._storage, rhs._storage)) { (_args: (_StorageClass, _StorageClass)) in - let _storage = _args.0 - let rhs_storage = _args.1 - if _storage._id != rhs_storage._id {return false} - if _storage._payloadVariant != rhs_storage._payloadVariant {return false} - return true - } - if !storagesAreEqual {return false} - } + if lhs.id != rhs.id {return false} + if lhs.payloadVariant != rhs.payloadVariant {return false} if lhs.unknownFields != rhs.unknownFields {return false} return true } diff --git a/README.md b/README.md index 1b8bed5a..f14d938b 100644 --- a/README.md +++ b/README.md @@ -37,11 +37,16 @@ open Meshtastic.xcworkspace - Use Core Data for persistence ## Updating Protobufs: -- run: - ```bash - ./scripts/gen_protos.sh - ``` -- build, test, commit changes + +1. run +```bash +./scripts/gen_protos.sh +``` +2. Build, test, and commit the changes. + +## Release Process + +For more information on how a new release of Meshtastic is managed, please refer to [RELEASING.md](./RELEASING.md) ## License diff --git a/RELEASING.md b/RELEASING.md new file mode 100644 index 00000000..087c3a3d --- /dev/null +++ b/RELEASING.md @@ -0,0 +1,45 @@ +# Releasing Meshtastic + +This document outlines the process for preparing and making a release for Meshtastic. + +## Table of Contents + +1. [Branching Strategy](#branching-strategy) +2. [Preparing for a Release](#preparing-for-a-release) +3. [Creating a Release Branch](#creating-a-release-branch) +4. [Finalizing the Release](#finalizing-the-release) + +## Branching Strategy + +- **Main Branch (`main`)**: This is the main development branch where daily development occurs. +- **Release Branch (`X.YY.ZZ-release`)**: This branch is created from `main` for preparing a specific release version. + +## Preparing for a Release + +1. Ensure all desired features and fixes are merged into the `main` branch. +2. Update the version number in the relevant files. +3. Update the project documentation to reflect the upcoming release. + +## Creating a Release Branch + +1. Create a release branch from `main`. + ```sh + ./scripts/create-release-branch.sh + ``` + +## Finalizing the Release + +1. Perform final testing and quality checks on the `X.YY.ZZ-release` branch. + a. If any hotfix changes are required, merge those changes into `X.YY.ZZ-release`. + b. After merging these changes into the release branch, cherry-pick the changes onto `main`. +2. Once everything is ready, create a final tag for the release: + ```sh + git tag -a X.YY.ZZ -m "Release version X.Y.Z" + git push origin X.YY.ZZ + ``` + +Thank you for following the release process and helping to ensure the stability and quality of Meshtastic! + +--- + +Feel free to modify this template to better fit your project's specific needs. \ No newline at end of file diff --git a/protobufs b/protobufs index 0fd5023a..d191975e 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit 0fd5023a0aa67eefdf2292a624e8fbbda4489a6c +Subproject commit d191975ebc572527c6d9eec48d5b0a1e3331999f diff --git a/scripts/create-release-branch.sh b/scripts/create-release-branch.sh new file mode 100644 index 00000000..807ef077 --- /dev/null +++ b/scripts/create-release-branch.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +# Check if the release version number is provided +if [ -z "$1" ]; then + echo "Usage: $0 " + exit 1 +fi + +# Set the release version number +RELEASE_VERSION=$1 + +# Check if the release branch already exists on the remote repository +if git ls-remote --exit-code --heads origin $RELEASE_BRANCH; then + echo "The branch $RELEASE_BRANCH already exists on the remote repository." + exit 1 +fi + +# Prompt the user for confirmation +echo "You are about to create and push the release branch ${RELEASE_VERSION}-release." +read -p "Are you sure you want to proceed? (Y/n): " confirmation + +# Check the user's response +if [[ ! "$confirmation" =~ ^[Yy]$ ]]; then + echo "Operation cancelled." + exit 0 +fi + +# Check out the main branch and pull the latest changes +git checkout main +git pull origin main + +# Create a new branch for the release +RELEASE_BRANCH="${RELEASE_VERSION}-release" +git checkout -b $RELEASE_BRANCH + +# Push the new release branch to the remote repository +git push origin $RELEASE_BRANCH + +echo "Release branch $RELEASE_BRANCH created and pushed successfully."