From a8c810bae29c7a1495c2e88aabbdf2e03b196999 Mon Sep 17 00:00:00 2001 From: andrekir Date: Wed, 6 Nov 2024 10:21:32 -0300 Subject: [PATCH] feat: add `DeviceConfig` RebroadcastMode descriptions --- .../mesh/ui/components/DropDownPreference.kt | 21 ++++++++++++ .../components/config/DeviceConfigItemList.kt | 32 ++++++++++++------- app/src/main/res/values/strings.xml | 7 ++++ 3 files changed, 49 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/com/geeksville/mesh/ui/components/DropDownPreference.kt b/app/src/main/java/com/geeksville/mesh/ui/components/DropDownPreference.kt index fceec24f4..2224b23f9 100644 --- a/app/src/main/java/com/geeksville/mesh/ui/components/DropDownPreference.kt +++ b/app/src/main/java/com/geeksville/mesh/ui/components/DropDownPreference.kt @@ -22,6 +22,27 @@ import androidx.compose.ui.tooling.preview.Preview import com.geeksville.mesh.R import com.google.protobuf.ProtocolMessageEnum +@Composable +fun > DropDownPreference( + title: String, + enabled: Boolean, + selectedItem: T, + onItemSelected: (T) -> Unit, + modifier: Modifier = Modifier, + summary: String? = null, +) { + DropDownPreference( + title = title, + enabled = enabled, + items = selectedItem.declaringJavaClass.enumConstants + ?.filter { it.name != "UNRECOGNIZED" }?.map { it to it.name } ?: emptyList(), + selectedItem = selectedItem, + onItemSelected = onItemSelected, + modifier = modifier, + summary = summary, + ) +} + @Composable fun DropDownPreference( title: String, diff --git a/app/src/main/java/com/geeksville/mesh/ui/components/config/DeviceConfigItemList.kt b/app/src/main/java/com/geeksville/mesh/ui/components/config/DeviceConfigItemList.kt index c25d725d5..94c36bc52 100644 --- a/app/src/main/java/com/geeksville/mesh/ui/components/config/DeviceConfigItemList.kt +++ b/app/src/main/java/com/geeksville/mesh/ui/components/config/DeviceConfigItemList.kt @@ -45,6 +45,17 @@ private val DeviceConfig.Role.stringRes: Int else -> R.string.unrecognized } +private val DeviceConfig.RebroadcastMode.stringRes: Int + get() = when (this) { + DeviceConfig.RebroadcastMode.ALL -> R.string.rebroadcast_mode_all + DeviceConfig.RebroadcastMode.ALL_SKIP_DECODING -> R.string.rebroadcast_mode_all_skip_decoding + DeviceConfig.RebroadcastMode.LOCAL_ONLY -> R.string.rebroadcast_mode_local_only + DeviceConfig.RebroadcastMode.KNOWN_ONLY -> R.string.rebroadcast_mode_known_only + DeviceConfig.RebroadcastMode.NONE -> R.string.rebroadcast_mode_none + DeviceConfig.RebroadcastMode.CORE_PORTNUMS_ONLY -> R.string.rebroadcast_mode_core_portnums_only + else -> R.string.unrecognized + } + @Composable fun DeviceConfigScreen( viewModel: RadioConfigViewModel = hiltViewModel(), @@ -83,14 +94,13 @@ fun DeviceConfigItemList( item { PreferenceCategory(text = "Device Config") } item { - DropDownPreference(title = "Role", - summary = stringResource(id = deviceInput.role.stringRes), + DropDownPreference( + title = "Role", enabled = enabled, - items = DeviceConfig.Role.entries - .filter { it != DeviceConfig.Role.UNRECOGNIZED } - .map { it to it.name }, selectedItem = deviceInput.role, - onItemSelected = { deviceInput = deviceInput.copy { role = it } }) + onItemSelected = { deviceInput = deviceInput.copy { role = it } }, + summary = stringResource(id = deviceInput.role.stringRes), + ) } item { Divider() } @@ -115,13 +125,13 @@ fun DeviceConfigItemList( } item { - DropDownPreference(title = "Rebroadcast mode", + DropDownPreference( + title = "Rebroadcast mode", enabled = enabled, - items = DeviceConfig.RebroadcastMode.entries - .filter { it != DeviceConfig.RebroadcastMode.UNRECOGNIZED } - .map { it to it.name }, selectedItem = deviceInput.rebroadcastMode, - onItemSelected = { deviceInput = deviceInput.copy { rebroadcastMode = it } }) + onItemSelected = { deviceInput = deviceInput.copy { rebroadcastMode = it } }, + summary = stringResource(id = deviceInput.rebroadcastMode.stringRes), + ) } item { Divider() } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 1d73636bd..e1a1a9c8a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -57,6 +57,13 @@ Broadcasts location as message to default channel regularly for to assist with device recovery. Enables automatic TAK PLI broadcasts and reduces routine broadcasts. + Rebroadcast any observed message, if it was on our private channel or from another mesh with the same lora parameters. + Same as behavior as ALL but skips packet decoding and simply rebroadcasts them. Only available in Repeater role. Setting this on any other roles will result in ALL behavior. + Ignores observed messages from foreign meshes that are open or those which it cannot decrypt. Only rebroadcasts message on the nodes local primary / secondary channels. + Ignores observed messages from foreign meshes like LOCAL ONLY, but takes it step further by also ignoring messages from nodes not already in the node\'s known list. + Only permitted for SENSOR, TRACKER and TAK_TRACKER roles, this will inhibit all rebroadcasts, not unlike CLIENT_MUTE role. + Ignores packets from non-standard portnums such as: TAK, RangeTest, PaxCounter, etc. Only rebroadcasts packets with standard portnums: NodeInfo, Text, Position, Telemetry, and Routing. + MSL ChUtil %.1f%% AirUtilTX %.1f%%