Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove 192bit channel keys, fix channel delete bug #747

Merged
merged 2 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,6 @@
},
"128 bit" : {

},
"192 bit" : {

},
"256 bit" : {

Expand Down Expand Up @@ -22405,4 +22402,4 @@
}
},
"version" : "1.0"
}
}
15 changes: 4 additions & 11 deletions Meshtastic/Views/Settings/Channels.swift
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,12 @@ struct Channels: View {
var channel = Channel()
channel.index = channelIndex
channel.role = ChannelRoles(rawValue: channelRole)?.protoEnumValue() ?? .secondary
if channel.role != Channel.Role.disabled {
channel.index = channelIndex
channel.settings.name = channelName
channel.settings.psk = Data(base64Encoded: channelKey) ?? Data()
channel.settings.uplinkEnabled = uplink
channel.settings.downlinkEnabled = downlink
channel.settings.moduleSettings.positionPrecision = UInt32(positionPrecision)

selectedChannel!.role = Int32(channelRole)
selectedChannel!.index = channelIndex
selectedChannel!.name = channelName
Expand All @@ -180,6 +178,7 @@ struct Channels: View {
}
node?.myInfo?.channels = mutableChannels.copy() as? NSOrderedSet
context.refresh(selectedChannel!, mergeChanges: true)
if channel.role != Channel.Role.disabled {
do {
try context.save()
Logger.data.info("💾 Saved Channel: \(channel.settings.name)")
Expand All @@ -189,19 +188,14 @@ struct Channels: View {
Logger.data.error("Unresolved Core Data error in the channel editor. Error: \(nsError)")
}
} else {
guard let channelEntities = node?.myInfo?.channels as? [ChannelEntity],
let channelEntity = channelEntities.first(where: { $0.index == channelIndex }) else {
return
}

let objects = channelEntity.allPrivateMessages
let objects = selectedChannel?.allPrivateMessages ?? []
for object in objects {
context.delete(object)
}
for node in nodes where node.channel == channelEntity.index {
for node in nodes where node.channel == channel.index {
context.delete(node)
}
context.delete(channelEntity)
context.delete(selectedChannel!)
do {
try context.save()
Logger.data.info("💾 Deleted Channel: \(channel.settings.name)")
Expand All @@ -211,7 +205,6 @@ struct Channels: View {
Logger.data.error("Unresolved Core Data error in the channel editor. Error: \(nsError)")
}
}

let adminMessageId = bleManager.saveChannel(channel: channel, fromUser: node!.user!, toUser: node!.user!)

if adminMessageId > 0 {
Expand Down
1 change: 0 additions & 1 deletion Meshtastic/Views/Settings/Channels/ChannelForm.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ struct ChannelForm: View {
Text("Default").tag(-1)
Text("1 byte").tag(1)
Text("128 bit").tag(16)
Text("192 bit").tag(24)
Text("256 bit").tag(32)
}
.pickerStyle(DefaultPickerStyle())
Expand Down