JvmScannerViewModel

class JvmScannerViewModel(serviceRepository: ServiceRepository, radioController: RadioController, radioInterfaceService: RadioInterfaceService, radioPrefs: RadioPrefs, recentAddressesDataSource: RecentAddressesDataSource, getDiscoveredDevicesUseCase: GetDiscoveredDevicesUseCase, networkRepository: NetworkRepository, dispatchers: CoroutineDispatchers, uiPrefs: UiPrefs, firmwareRecoveryDataSource: FirmwareRecoveryDataSource, bleScanner: BleScanner? = null) : ScannerViewModel(source)

Desktop/JVM ScannerViewModel registration.

On Desktop, the base ScannerViewModel is used directly. The default requestBonding connects without explicit bonding since the OS Bluetooth stack handles pairing during the GATT connection.

Constructors

Link copied to clipboard
constructor(serviceRepository: ServiceRepository, radioController: RadioController, radioInterfaceService: RadioInterfaceService, radioPrefs: RadioPrefs, recentAddressesDataSource: RecentAddressesDataSource, getDiscoveredDevicesUseCase: GetDiscoveredDevicesUseCase, networkRepository: NetworkRepository, dispatchers: CoroutineDispatchers, uiPrefs: UiPrefs, firmwareRecoveryDataSource: FirmwareRecoveryDataSource, bleScanner: BleScanner? = null)

Properties

Link copied to clipboard
val activeTransport: StateFlow<DeviceType>

The single transport pane currently rendered by the Connections screen.

Link copied to clipboard
val bleAutoScan: StateFlow<Boolean>

User preference that controls whether BLE scanning auto-starts when the Connections screen opens.

Link copied to clipboard

BLE devices for the UI — restricted to those currently visible via an active scan.

Link copied to clipboard

Transient, fine-grained status text emitted during connect/bonding (e.g. "Bonding…", "Requesting config…"). Nullable because serviceRepository.connectionProgress does not emit during steady-state.

Link copied to clipboard

Discovered (NSD) TCP devices for the Connections device list, gated by the network-scan flag.

Link copied to clipboard
val isBleScanning: StateFlow<Boolean>

Whether a BLE scan is currently active.

Link copied to clipboard
val isNetworkScanning: StateFlow<Boolean>

Whether an NSD network scan is currently active.

Link copied to clipboard
val networkAutoScan: StateFlow<Boolean>

User preference that controls whether NSD network scanning auto-starts when the Connections screen opens.

Link copied to clipboard

A firmware update that didn't finish, leaving a device stranded in bootloader mode. Non-null drives the recovery banner on the Connections screen, whose tap deep-links into the Firmware Update screen to re-flash the device.

Link copied to clipboard
val persistedDeviceName: StateFlow<String?>

The persisted device name from the last selection, for use as a UI fallback.

Link copied to clipboard

Recently-used TCP addresses for the Connections device list.

Link copied to clipboard
val selectedAddressFlow: StateFlow<String?>

The currently-selected device address, or null when nothing is selected.

Link copied to clipboard
val selectedNotNullFlow: StateFlow<String>

Non-null variant of selectedAddressFlow that substitutes NO_DEVICE_SELECTED for null.

Link copied to clipboard
val showMockTransport: StateFlow<Boolean>

Whether the mock/demo transport is currently selected.

Link copied to clipboard

Functions

Link copied to clipboard
open fun addCloseable(closeable: AutoCloseable)
fun addCloseable(key: String, closeable: AutoCloseable)
Link copied to clipboard
fun addRecentAddress(address: String, name: String)

Persists address in the recent-TCP list under name. No-op when address does not start with TCP_DEVICE_PREFIX.

Link copied to clipboard

Asynchronously tells the radio controller to connect to address.

Link copied to clipboard
fun connectToManualAddress(fullAddress: String)

Connects to a manually-entered TCP address. Wraps the manual-entry flow with the same scan-cancel invariant as onSelected: stops discovery before connection setup so the manual connect does not race an in-progress BLE/network scan for radio resources.

Link copied to clipboard

Clears the persisted device name and tells the radio controller to disconnect.

Link copied to clipboard

Manually retire the pending recovery record (user dismissed the banner). Needed for a device whose bootloader can't be re-flashed over BLE at all — e.g. a stock nRF Legacy-DFU bootloader that never answers its control point — where recovery persistently fails and would otherwise nag forever (it only auto-clears on a successful reconnect or re-flash). The record is re-created next time a DFU update is triggered.

Link copied to clipboard
Link copied to clipboard

Called by the UI when a device has been tapped. BLE and USB entries may still need bonding/permission — the concrete return value tells the caller whether the connection was initiated immediately.

Link copied to clipboard

Persists the user's intent to auto-scan the network on next screen entry without flipping the active scan flag. Used by the Connections screen when it must defer the actual scan start until after the system permission grant dialog resolves. When enabled is true, also clears bleAutoScan so persisted state mirrors the runtime mutual-exclusion invariant (at most one of bleAutoScan / networkAutoScan may be true).

Link copied to clipboard

Removes address from the recent-TCP list.

Link copied to clipboard

Selects one Connections transport pane and stops scans that cannot belong to that pane.

Link copied to clipboard

Starts BLE scanning for screen-entry auto-scan only when no device is already selected. Manual scan toggles call startBleScan directly so users can still discover/switch devices while connected.

Link copied to clipboard

Starts BLE scanning. Enforces mutual exclusion (cancels any active network scan first). No-op if already scanning or if bleScanner is null.

Link copied to clipboard

Starts NSD scanning for screen-entry auto-scan only when the Network pane is active.

Link copied to clipboard

Starts NSD network scanning. Enforces the same mutual-exclusion invariant as startBleScan; starting Network cancels any active BLE scan first.

Link copied to clipboard

Cancels the active BLE scan and resets the scanning flag. Idempotent.

Link copied to clipboard

Cancels the active network scan and resets the scanning flag. Idempotent.

Link copied to clipboard

Toggles BLE scanning. Persists the auto-scan preference only when the scan actually activates, and clears the opposite networkAutoScan preference to keep persisted state consistent with the runtime mutual-exclusion invariant.

Link copied to clipboard

Toggles network scanning. Persists the auto-scan preference only when the scan actually activates, and clears the opposite bleAutoScan preference to keep persisted state consistent with the runtime mutual-exclusion invariant.