FirmwareRecoveryDataSource

Persists the PendingFirmwareRecovery record for a firmware update that may have left a device stranded in bootloader mode, plus the last BLE node as a candidate for one. Only the most recent of each is retained (updates are one-device-at-a-time in practice).

Constructors

Link copied to clipboard
constructor(dataStore: CorePreferencesDataStore)

Properties

Link copied to clipboard

The last node this app completed a BLE handshake with, kept so that node can be recovered when it turns up in its bootloader without the app having started the update that stranded it. Not shown by itself; a bootloader seen at its address promotes it to pending via promoteLastBleNode.

Link copied to clipboard

The pending recovery record, or null when no interrupted update is outstanding.

Functions

Link copied to clipboard
open suspend fun clear()

Clears the outstanding recovery record (update finished, or the device returned on its own).

Link copied to clipboard
open suspend fun dismiss()

Clears both records. Clearing only pending would let the next bootloader sighting promote lastBleNode straight back; it returns on the next successful handshake.

Link copied to clipboard
open suspend fun promoteLastBleNode(fullAddress: String)

Makes lastBleNode the pending recovery, unless one is already pending or the last node is no longer the one at fullAddress: a handshake with another node can replace it between the bootloader sighting and this call.

Link copied to clipboard
open suspend fun set(recovery: PendingFirmwareRecovery)

Records recovery as the outstanding interrupted update, replacing any previous record.

Link copied to clipboard
open suspend fun setLastBleNode(node: PendingFirmwareRecovery)

Records node as the last BLE node, replacing any previous one.