diff --git a/app/src/main/java/com/geeksville/mesh/model/Channel.kt b/app/src/main/java/com/geeksville/mesh/model/Channel.kt index abf759bd..fe66997c 100644 --- a/app/src/main/java/com/geeksville/mesh/model/Channel.kt +++ b/app/src/main/java/com/geeksville/mesh/model/Channel.kt @@ -7,9 +7,7 @@ import com.google.protobuf.ByteString fun byteArrayOfInts(vararg ints: Int) = ByteArray(ints.size) { pos -> ints[pos].toByte() } -data class Channel( - val settings: ChannelProtos.ChannelSettings = ChannelProtos.ChannelSettings.getDefaultInstance() -) { +data class Channel(val settings: ChannelProtos.ChannelSettings) { companion object { // These bytes must match the well known and not secret bytes used the default channel AES128 key device code val channelDefaultKey = byteArrayOfInts( @@ -22,7 +20,7 @@ data class Channel( byteArrayOfInts(1) // a shortstring code to indicate we need our default PSK // TH=he unsecured channel that devices ship with - val defaultChannel = Channel( + val default = Channel( ChannelProtos.ChannelSettings.newBuilder() .setModemConfig(ChannelProtos.ChannelSettings.ModemConfig.Bw125Cr48Sf4096) .setPsk(ByteString.copyFrom(defaultPSK)) diff --git a/app/src/main/java/com/geeksville/mesh/ui/ChannelFragment.kt b/app/src/main/java/com/geeksville/mesh/ui/ChannelFragment.kt index 95f6de77..b5f63000 100644 --- a/app/src/main/java/com/geeksville/mesh/ui/ChannelFragment.kt +++ b/app/src/main/java/com/geeksville/mesh/ui/ChannelFragment.kt @@ -86,7 +86,7 @@ class ChannelFragment : ScreenFragment("Channel"), Logging { // Only let buttons work if we are connected to the radio binding.shareButton.isEnabled = connected - binding.resetButton.isEnabled = connected && Channel.defaultChannel != channel + binding.resetButton.isEnabled = connected && Channel.default != channel binding.editableCheckbox.isChecked = false // start locked if (channel != null) { @@ -197,7 +197,7 @@ class ChannelFragment : ScreenFragment("Channel"), Logging { } .setPositiveButton(R.string.apply) { _, _ -> debug("Switching back to default channel") - installSettings(Channel.defaultChannel.settings) + installSettings(Channel.default.settings) } .show() } @@ -226,7 +226,7 @@ class ChannelFragment : ScreenFragment("Channel"), Logging { // Generate a new AES256 key unleess the user is trying to go back to stock if (!newSettings.name.equals( - Channel.defaultChannel.name, + Channel.default.name, ignoreCase = true ) ) { @@ -246,7 +246,7 @@ class ChannelFragment : ScreenFragment("Channel"), Logging { newSettings.modemConfig = modemConfig } else { debug("Switching back to default channel") - newSettings = Channel.defaultChannel.settings.toBuilder() + newSettings = Channel.default.settings.toBuilder() } installSettings(newSettings.build())