Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,29 @@ class ConnectivityStatus(characteristicValue: ByteArray) {
val pairingErrorCode: PairingErrorCode

init {
val flags = characteristicValue[0]
connected = flags and 0b1 > 0
paired = flags and 0b10 > 0
encrypted = flags and 0b100 > 0
hasBondedGateway = flags and 0b1000 > 0
supportsPinningWithoutSlaveSecurity = flags and 0b10000 > 0
hasRemoteAttemptedToUseStalePairing = flags and 0b100000 > 0
pairingErrorCode = PairingErrorCode.getByValue(characteristicValue[3])
// Handle empty array (can happen with recovery firmware)
if (characteristicValue.isEmpty()) {
connected = false
paired = false
encrypted = false
hasBondedGateway = false
supportsPinningWithoutSlaveSecurity = false
hasRemoteAttemptedToUseStalePairing = false
pairingErrorCode = PairingErrorCode.NO_ERROR
} else {
val flags = characteristicValue[0]
connected = flags and 0b1 > 0
paired = flags and 0b10 > 0
encrypted = flags and 0b100 > 0
hasBondedGateway = flags and 0b1000 > 0
supportsPinningWithoutSlaveSecurity = flags and 0b10000 > 0
hasRemoteAttemptedToUseStalePairing = flags and 0b100000 > 0
pairingErrorCode = if (characteristicValue.size > 3) {
PairingErrorCode.getByValue(characteristicValue[3])
} else {
PairingErrorCode.NO_ERROR
}
}
}

override fun toString(): String =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,15 @@ private sealed class UiFirmwareUpdateStatus {
"Couldn't start: ${status.error.message()}"
)

is FirmwareUpdater.FirmwareUpdateStatus.NotInProgress.Idle -> Idle
is FirmwareUpdater.FirmwareUpdateStatus.NotInProgress.Idle -> {
// Check if there was a failure
val failure = status.lastFailure
if (failure != null) {
Error(failure, failure.message ?: "Unknown error")
} else {
Idle
}
}
}
}
}
Expand Down