feat: settings rework part 2, domain and usecase abstraction, tests (#4680)

Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit is contained in:
James Rich 2026-03-02 12:15:33 -06:00 committed by GitHub
parent 5f31df96d8
commit 8c6bd8ab7a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
121 changed files with 5245 additions and 1332 deletions

View file

@ -0,0 +1,39 @@
/*
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.meshtastic.core.model
sealed class ConnectionState {
/** We are disconnected from the device, and we should be trying to reconnect. */
data object Disconnected : ConnectionState()
/** We are currently attempting to connect to the device. */
data object Connecting : ConnectionState()
/** We are connected to the device and communicating normally. */
data object Connected : ConnectionState()
/** The device is in a light sleep state, and we are waiting for it to wake up and reconnect to us. */
data object DeviceSleep : ConnectionState()
fun isConnected() = this == Connected
fun isConnecting() = this == Connecting
fun isDisconnected() = this == Disconnected
fun isDeviceSleep() = this == DeviceSleep
}

View file

@ -0,0 +1,90 @@
/*
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.meshtastic.core.model
import kotlinx.coroutines.flow.StateFlow
import org.meshtastic.proto.ClientNotification
@Suppress("TooManyFunctions")
interface RadioController {
val connectionState: StateFlow<ConnectionState>
val clientNotification: StateFlow<ClientNotification?>
suspend fun sendMessage(packet: DataPacket)
fun clearClientNotification()
// Abstracted ServiceActions
suspend fun favoriteNode(nodeNum: Int)
suspend fun sendSharedContact(nodeNum: Int)
// Radio configuration
suspend fun setOwner(destNum: Int, user: org.meshtastic.proto.User, packetId: Int)
suspend fun setConfig(destNum: Int, config: org.meshtastic.proto.Config, packetId: Int)
suspend fun setModuleConfig(destNum: Int, config: org.meshtastic.proto.ModuleConfig, packetId: Int)
suspend fun setRemoteChannel(destNum: Int, channel: org.meshtastic.proto.Channel, packetId: Int)
suspend fun setFixedPosition(destNum: Int, position: Position)
suspend fun setRingtone(destNum: Int, ringtone: String)
suspend fun setCannedMessages(destNum: Int, messages: String)
// Admin get operations
suspend fun getOwner(destNum: Int, packetId: Int)
suspend fun getConfig(destNum: Int, configType: Int, packetId: Int)
suspend fun getModuleConfig(destNum: Int, moduleConfigType: Int, packetId: Int)
suspend fun getChannel(destNum: Int, index: Int, packetId: Int)
suspend fun getRingtone(destNum: Int, packetId: Int)
suspend fun getCannedMessages(destNum: Int, packetId: Int)
suspend fun getDeviceConnectionStatus(destNum: Int, packetId: Int)
// Admin operations
suspend fun reboot(destNum: Int, packetId: Int)
suspend fun shutdown(destNum: Int, packetId: Int)
suspend fun factoryReset(destNum: Int, packetId: Int)
suspend fun nodedbReset(destNum: Int, packetId: Int, preserveFavorites: Boolean)
suspend fun removeByNodenum(packetId: Int, nodeNum: Int)
// Batch editing
suspend fun beginEditSettings(destNum: Int)
suspend fun commitEditSettings(destNum: Int)
// Helpers
fun getPacketId(): Int
/** Starts providing the phone's location to the mesh. */
fun startProvideLocation()
/** Stops providing the phone's location to the mesh. */
fun stopProvideLocation()
}