mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
show channel suffix per https://github.com/meshtastic/Meshtastic-device/issues/269
This commit is contained in:
parent
dbe1d8065a
commit
93d4cd99fd
2 changed files with 20 additions and 3 deletions
|
|
@ -8,6 +8,7 @@ import com.google.zxing.BarcodeFormat
|
|||
import com.google.zxing.MultiFormatWriter
|
||||
import com.journeyapps.barcodescanner.BarcodeEncoder
|
||||
import java.net.MalformedURLException
|
||||
import kotlin.experimental.xor
|
||||
|
||||
/** Utility function to make it easy to declare byte arrays - FIXME move someplace better */
|
||||
fun byteArrayOfInts(vararg ints: Int) = ByteArray(ints.size) { pos -> ints[pos].toByte() }
|
||||
|
|
@ -52,6 +53,17 @@ data class Channel(
|
|||
val name: String get() = settings.name
|
||||
val modemConfig: MeshProtos.ChannelSettings.ModemConfig get() = settings.modemConfig
|
||||
|
||||
/**
|
||||
* Return a name that is formatted as #channename-suffix
|
||||
*
|
||||
* Where suffix indicates the hash of the PSK
|
||||
*/
|
||||
val humanName: String
|
||||
get() {
|
||||
val code = settings.psk.fold(0.toByte(), { acc, x -> acc xor x })
|
||||
return "#${settings.name}-${'A' + (code % 26)}"
|
||||
}
|
||||
|
||||
/// Can this channel be changed right now?
|
||||
var editable = false
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue