RadioConfigViewModel

open class RadioConfigViewModel(destNum: Int?, radioConfigRepository: RadioConfigRepository, packetRepository: PacketRepository, serviceRepository: ServiceRepository, nodeRepository: NodeRepository, locationRepository: LocationRepository, mapConsentPrefs: MapConsentPrefs, analyticsPrefs: AnalyticsPrefs, homoglyphEncodingPrefs: HomoglyphPrefs, importProfileUseCase: ImportProfileUseCase, exportProfileUseCase: ExportProfileUseCase, importSecurityConfigUseCase: ImportSecurityConfigUseCase, installProfileUseCase: InstallProfileUseCase, radioConfigUseCase: RadioConfigUseCase, adminActionsUseCase: AdminActionsUseCase, processRadioResponseUseCase: ProcessRadioResponseUseCase, locationService: LocationService, fileService: FileService, mqttManager: MqttManager, lockdownCoordinator: LockdownCoordinator, securityKeyBackupStore: SecurityKeyBackupStore, snackbarManager: SnackbarManager) : ViewModel(source)

Constructors

Link copied to clipboard
constructor(destNum: Int?, radioConfigRepository: RadioConfigRepository, packetRepository: PacketRepository, serviceRepository: ServiceRepository, nodeRepository: NodeRepository, locationRepository: LocationRepository, mapConsentPrefs: MapConsentPrefs, analyticsPrefs: AnalyticsPrefs, homoglyphEncodingPrefs: HomoglyphPrefs, importProfileUseCase: ImportProfileUseCase, exportProfileUseCase: ExportProfileUseCase, importSecurityConfigUseCase: ImportSecurityConfigUseCase, installProfileUseCase: InstallProfileUseCase, radioConfigUseCase: RadioConfigUseCase, adminActionsUseCase: AdminActionsUseCase, processRadioResponseUseCase: ProcessRadioResponseUseCase, locationService: LocationService, fileService: FileService, mqttManager: MqttManager, lockdownCoordinator: LockdownCoordinator, securityKeyBackupStore: SecurityKeyBackupStore, snackbarManager: SnackbarManager)

Properties

Link copied to clipboard
Link copied to clipboard
val currentDeviceProfile: DeviceProfile
Link copied to clipboard
val destNode: StateFlow<Node?>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

MQTT proxy connection state for the settings UI.

Link copied to clipboard

Latest result from a probeMqttConnection call, or null if no probe has been run.

Link copied to clipboard
val mqttProxyActive: StateFlow<Boolean>

Whether this phone is currently running the MQTT proxy (relaying broker traffic to the connected device).

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val sessionAuthorized: StateFlow<Boolean>

Functions

Link copied to clipboard
expect open fun addCloseable(closeable: AutoCloseable)
expect fun addCloseable(key: String, closeable: AutoCloseable)
Link copied to clipboard
fun backupSecurityKeys(securityConfig: Config.SecurityConfig, onComplete: () -> Unit = {})

Saves the node's current public/private keys to OS-backed encrypted storage, keyed by node number.

Link copied to clipboard

Clear the latest probe result (e.g. when the user edits the address).

Link copied to clipboard
Link copied to clipboard
fun deleteSecurityKeyBackup(onComplete: () -> Unit = {})

Deletes the encrypted key backup for this node, if any.

Link copied to clipboard

Sets the initial loading state for remote config sub-screens. Must be called before the first collectAsStateWithLifecycle read so the LoadingOverlay is visible from the very first composition frame.

Link copied to clipboard
fun exportProfile(uri: CommonUri, profile: DeviceProfile)
Link copied to clipboard
expect fun <T : AutoCloseable> getCloseable(key: String): T?
Link copied to clipboard
open suspend fun getCurrentLocation(): Location?
Link copied to clipboard
fun importProfile(uri: CommonUri, onResult: (DeviceProfile) -> Unit)
Link copied to clipboard
fun installProfile(protobuf: DeviceProfile)
Link copied to clipboard
fun probeMqttConnection(address: String, tlsEnabled: Boolean, username: String?, password: String?)

Run a one-shot reachability/credentials probe against an MQTT broker. Cancels any in-flight probe before starting a new one. Result is exposed via mqttProbeStatus.

Link copied to clipboard
Link copied to clipboard

Restores the previously backed-up keys for this node and pushes them to the device via admin config.

Link copied to clipboard
fun saveUserConfig(user: User)

Routes the User config save: ham onboarding (set_ham_mode) when the licensed toggle transitions OFF→ON on the locally connected node, setOwner otherwise. Routing on the transition — not the toggle state — keeps subsequent saves of an already-licensed node on the set_owner path, so edits to other owner fields still reach the device and the node doesn't reboot on every save (firmware reboots on set_ham_mode). The local-node guard is the backstop for the UI gate — set_ham_mode must never be sent to a remote node.

Link copied to clipboard

Whether an encrypted key backup exists for the node currently being configured.

Link copied to clipboard
Link copied to clipboard
fun setCannedMessages(messages: String)
Link copied to clipboard
fun setConfig(config: Config)
Link copied to clipboard
fun setFixedPosition(position: Position)
Link copied to clipboard
fun setModuleConfig(config: ModuleConfig)
Link copied to clipboard

Phone-local control over the MQTT proxy that does not touch the device's persisted MQTT config. Turning it off calls MqttManager.stop immediately, cutting the proxy firehose that can saturate the BLE link and MCU on nRF devices — no slow device read-modify-write-readback round-trip. Turning it back on resumes proxying using the device's current MQTT config (a no-op unless the device has MQTT and proxy-to-client enabled).

Link copied to clipboard
fun setOwner(user: User)

Sends a plain set_owner with user. Prefer saveUserConfig for User config screen saves — it routes ham onboarding to set_ham_mode when the licensed toggle is first enabled; calling this directly bypasses that.

Link copied to clipboard
fun setPreserveFavorites(preserveFavorites: Boolean)
Link copied to clipboard
Link copied to clipboard
fun setRingtone(ringtone: String)
Link copied to clipboard
fun setShouldReportLocation(nodeNum: Int?, shouldReportLocation: Boolean)
Link copied to clipboard
fun shouldReportLocation(nodeNum: Int?): StateFlow<Boolean>
Link copied to clipboard
fun submitLockdownPassphrase(passphrase: String, boots: Int = LockdownPassphraseStore.DEFAULT_BOOTS, hours: Int = 0, maxSessionSeconds: Int = 0, disable: Boolean = false)

Submits a lockdown passphrase: enables lockdown (from DISABLED), authenticates (disable=false from LOCKED), or turns lockdown off (disable=true from UNLOCKED).

Link copied to clipboard
Link copied to clipboard
fun updateChannels(new: List<ChannelSettings>, old: List<ChannelSettings>)