commit
540050f484
2 changed files with 13 additions and 7 deletions
|
@ -43,7 +43,12 @@ class ServiceDiscoverer(
|
|||
}
|
||||
logger.debug(LTag.PUMPBTCOMM, "Services discovered")
|
||||
val service = gatt.getService(SERVICE_UUID.toUuid())
|
||||
?: throw ConnectException("Service not found: $SERVICE_UUID")
|
||||
?: run {
|
||||
for (service in gatt.services) {
|
||||
logger.debug(LTag.PUMPBTCOMM, "Found service: ${service.uuid}")
|
||||
}
|
||||
throw ConnectException("Service not found: $SERVICE_UUID")
|
||||
}
|
||||
val cmdChar = service.getCharacteristic(CharacteristicType.CMD.uuid)
|
||||
?: throw ConnectException("Characteristic not found: ${CharacteristicType.CMD.value}")
|
||||
val dataChar = service.getCharacteristic(CharacteristicType.DATA.uuid)
|
||||
|
|
|
@ -394,7 +394,7 @@ class OmnipodDashPodStateManagerImpl @Inject constructor(
|
|||
if (activeCommand == null) {
|
||||
Completable.complete()
|
||||
} else {
|
||||
logger.warn(LTag.PUMP, "Active command already existing: $activeCommand")
|
||||
logger.warn(LTag.PUMPCOMM, "Active command already existing: $activeCommand")
|
||||
Completable.error(
|
||||
java.lang.IllegalStateException(
|
||||
"Trying to send a command " +
|
||||
|
@ -432,7 +432,7 @@ class OmnipodDashPodStateManagerImpl @Inject constructor(
|
|||
override fun updateActiveCommand() = Maybe.create<CommandConfirmed> { source ->
|
||||
val activeCommand = podState.activeCommand
|
||||
if (activeCommand == null) {
|
||||
logger.error("No active command to update")
|
||||
logger.error(LTag.PUMPCOMM, "No active command to update")
|
||||
source.onComplete()
|
||||
return@create
|
||||
}
|
||||
|
@ -502,6 +502,7 @@ class OmnipodDashPodStateManagerImpl @Inject constructor(
|
|||
override fun getCommandConfirmationFromState(): CommandConfirmationFromState {
|
||||
return podState.activeCommand?.run {
|
||||
logger.debug(
|
||||
LTag.PUMPCOMM,
|
||||
"Getting command state with parameters: $activeCommand " +
|
||||
"lastResponse=$lastStatusResponseReceived " +
|
||||
"$sequenceNumberOfLastProgrammingCommand $historyId"
|
||||
|
@ -634,7 +635,7 @@ class OmnipodDashPodStateManagerImpl @Inject constructor(
|
|||
|
||||
override fun updateFromAlarmStatusResponse(response: AlarmStatusResponse) {
|
||||
logger.info(
|
||||
LTag.PUMP,
|
||||
LTag.PUMPCOMM,
|
||||
"Received AlarmStatusResponse: $response"
|
||||
)
|
||||
podState.deliveryStatus = response.deliveryStatus
|
||||
|
@ -678,12 +679,12 @@ class OmnipodDashPodStateManagerImpl @Inject constructor(
|
|||
private fun store() {
|
||||
try {
|
||||
val cleanPodState = podState.copy(ltk = byteArrayOf()) // do not log ltk
|
||||
logger.debug(LTag.PUMP, "Storing Pod state: ${Gson().toJson(cleanPodState)}")
|
||||
logger.debug(LTag.PUMPCOMM, "Storing Pod state: ${Gson().toJson(cleanPodState)}")
|
||||
|
||||
val serialized = Gson().toJson(podState)
|
||||
sharedPreferences.putString(R.string.key_omnipod_dash_pod_state, serialized)
|
||||
} catch (ex: Exception) {
|
||||
logger.error(LTag.PUMP, "Failed to store Pod state", ex)
|
||||
logger.error(LTag.PUMPCOMM, "Failed to store Pod state", ex)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -695,7 +696,7 @@ class OmnipodDashPodStateManagerImpl @Inject constructor(
|
|||
PodState::class.java
|
||||
)
|
||||
} catch (ex: Exception) {
|
||||
logger.error(LTag.PUMP, "Failed to deserialize Pod state", ex)
|
||||
logger.error(LTag.PUMPCOMM, "Failed to deserialize Pod state", ex)
|
||||
}
|
||||
}
|
||||
return PodState()
|
||||
|
|
Loading…
Reference in a new issue