From e471636dd172a91cf05d9712a1e3e624d10f2500 Mon Sep 17 00:00:00 2001 From: James Rich <2199651+jamesarich@users.noreply.github.com> Date: Sat, 9 Aug 2025 11:55:42 -0500 Subject: [PATCH] fix(regression): replace lost ringtone and canned message handling (#2672) Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com> --- .../geeksville/mesh/service/MeshService.kt | 38 +++++++++++-------- app/src/main/res/values/strings.xml | 2 +- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/com/geeksville/mesh/service/MeshService.kt b/app/src/main/java/com/geeksville/mesh/service/MeshService.kt index 1ae64375e..fcb80b5f0 100644 --- a/app/src/main/java/com/geeksville/mesh/service/MeshService.kt +++ b/app/src/main/java/com/geeksville/mesh/service/MeshService.kt @@ -103,7 +103,6 @@ import kotlinx.coroutines.flow.catch import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.isActive -import kotlinx.coroutines.launch import kotlinx.coroutines.withTimeoutOrNull import java.util.Random import java.util.UUID @@ -233,7 +232,7 @@ class MeshService : private val notificationSummary: String get() = when (connectionRouter.connectionState.value) { - ConnectionState.CONNECTED -> getString(R.string.connected_count, numOnlineNodes) + ConnectionState.CONNECTED -> getString(R.string.connected_count, numOnlineNodes.toString()) ConnectionState.DISCONNECTED -> getString(R.string.disconnected) ConnectionState.DEVICE_SLEEP -> getString(R.string.device_sleeping) ConnectionState.CONNECTING -> getString(R.string.connecting_to_device) @@ -436,7 +435,7 @@ class MeshService : * switching to a new device connection to prevent state from a previous session from affecting the new one. It * ensures a clean slate for node information, configurations, pending operations, and cached data. */ - private fun resetState() = serviceScope.launch { + private fun resetState() = serviceScope.handledLaunch { debug("Discarding NodeDB and resetting all service state for new device connection") clearDatabases() // Core Node and Config data @@ -465,6 +464,10 @@ class MeshService : batteryPercentCooldowns.clear() + radioConfigRepository.clearChannelSet() + radioConfigRepository.clearLocalConfig() + radioConfigRepository.clearLocalModuleConfig() + info("MeshService state has been reset for a new device session.") } @@ -1550,11 +1553,6 @@ class MeshService : ), ) rawMyNodeInfo = myInfo - serviceScope.handledLaunch { - radioConfigRepository.clearChannelSet() - radioConfigRepository.clearLocalConfig() - radioConfigRepository.clearLocalModuleConfig() - } } private fun handleDeviceUiConfig(deviceuiConfig: DeviceUIProtos.DeviceUIConfig) { @@ -1967,20 +1965,28 @@ class MeshService : ) } - override fun setRingtone(destNum: Int, ringtone: String?) { - TODO("Not yet implemented") + override fun setRingtone(destNum: Int, ringtone: String) = toRemoteExceptions { + sendToRadio(newMeshPacketTo(destNum).buildAdminPacket { setRingtoneMessage = ringtone }) } - override fun getRingtone(requestId: Int, destNum: Int) { - TODO("Not yet implemented") + override fun getRingtone(id: Int, destNum: Int) = toRemoteExceptions { + sendToRadio( + newMeshPacketTo(destNum).buildAdminPacket(id = id, wantResponse = true) { + getRingtoneRequest = true + }, + ) } - override fun setCannedMessages(destNum: Int, messages: String?) { - TODO("Not yet implemented") + override fun setCannedMessages(destNum: Int, messages: String) = toRemoteExceptions { + sendToRadio(newMeshPacketTo(destNum).buildAdminPacket { setCannedMessageModuleMessages = messages }) } - override fun getCannedMessages(requestId: Int, destNum: Int) { - TODO("Not yet implemented") + override fun getCannedMessages(id: Int, destNum: Int) = toRemoteExceptions { + sendToRadio( + newMeshPacketTo(destNum).buildAdminPacket(id = id, wantResponse = true) { + getCannedMessageModuleMessagesRequest = true + }, + ) } override fun setChannel(payload: ByteArray) = toRemoteExceptions { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 465c47776..a2ab5c9e4 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -117,7 +117,7 @@ New Node Seen: %s Disconnected Device sleeping - Connected: %1$d online + Connected: %1$s online IP Address: Port: Connected to radio