diff --git a/Meshtastic/Helpers/Extensions.swift b/Meshtastic/Helpers/Extensions.swift index de4b4ddf..67dbb074 100644 --- a/Meshtastic/Helpers/Extensions.swift +++ b/Meshtastic/Helpers/Extensions.swift @@ -2,9 +2,6 @@ import Foundation import SwiftUI extension Data { - var hexDescription: String { - return reduce("") {$0 + String(format: "%02x", $1)} - } var macAddressString: String { let mac: String = reduce("") {$0 + String(format: "%02x:", $1)} return String(mac.dropLast()) @@ -35,31 +32,13 @@ extension Int { } extension String { - - /// Create `Data` from hexadecimal string representation - /// - /// This creates a `Data` object from hex string. Note, if the string has any spaces or non-hex characters (e.g. starts with '<' and with a '>'), those are ignored and only hex characters are processed. - /// - /// - returns: Data represented by this hexadecimal string. - - var hexadecimal: Data? { - var data = Data(capacity: count / 2) - let regex = try! NSRegularExpression(pattern: "[0-9a-f]{1,2}", options: .caseInsensitive) - regex.enumerateMatches(in: self, range: NSRange(startIndex..., in: self)) { match, _, _ in - let byteString = (self as NSString).substring(with: match!.range) - let num = UInt8(byteString, radix: 16)! - data.append(num) - } - guard data.count > 0 else { return nil } - return data - } func base64urlToBase64() -> String { var base64 = self .replacingOccurrences(of: "-", with: "+") .replacingOccurrences(of: "_", with: "/") if base64.count % 4 != 0 { - base64.append(String(repeating: "=", count: 4 - base64.count % 4)) + base64.append(String(repeating: "==", count: 4 - base64.count % 4)) } return base64 } diff --git a/Meshtastic/Views/Settings/ShareChannels.swift b/Meshtastic/Views/Settings/ShareChannels.swift index 6d93b643..e7a259ed 100644 --- a/Meshtastic/Views/Settings/ShareChannels.swift +++ b/Meshtastic/Views/Settings/ShareChannels.swift @@ -266,9 +266,7 @@ struct ShareChannels: View { } } func GenerateChannelSet() { - channelSet = ChannelSet() - var loRaConfig = Config.LoRaConfig() loRaConfig.region = RegionCodes(rawValue: Int(node!.loRaConfig!.regionCode))!.protoEnumValue() loRaConfig.modemPreset = ModemPresets(rawValue: Int(node!.loRaConfig!.modemPreset))!.protoEnumValue() @@ -280,9 +278,7 @@ struct ShareChannels: View { loRaConfig.txEnabled = node!.loRaConfig!.txEnabled loRaConfig.txPower = node!.loRaConfig!.txPower loRaConfig.channelNum = UInt32(node!.loRaConfig!.channelNum) - channelSet.loraConfig = loRaConfig - for ch in node!.myInfo!.channels!.array as! [ChannelEntity] { if ch.role > 0 { @@ -299,7 +295,6 @@ struct ShareChannels: View { } } } - let settingsString = try! channelSet.serializedData().base64EncodedString() channelsUrl = ("https://www.meshtastic.org/e/#" + settingsString.base64ToBase64url()) }