add comments

This commit is contained in:
Andrei Vereha 2021-05-01 17:59:22 +02:00
parent 8d112a12ca
commit 19ff47e53d

View file

@ -80,7 +80,22 @@ class OmnipodDashPumpPlugin @Inject constructor(
}
override fun isConnected(): Boolean {
// TODO
// NOTE: Using connected state for unconfirmed commands
// We are faking connection lost on unconfirmed commands.
// During normal execution, the activeCommand is set to null after a command was executed with success or we
// were not able to send that command.
// If we are not sure if the POD received the command or not, then we answer with "success" but keep this
// activeCommand set until we can confirm/deny it.
// In order to prevent AAPS from sending us other programming commands while the current command was not
// confirmed, we are simulating "connection lost".
// We need to prevent AAPS from sending other commands because they would overwrite the ID of the last
// programming command reported by the POD. And we using that ID to confirm/deny the activeCommand.
// The effect of answering with 'false' here is that AAPS will call connect() and will not sent any new
// commands. On connect(), we are calling getPodStatus where we are always trying to confirm/deny the
// activeCommand.
return podStateManager.activeCommand == null
}
@ -99,6 +114,8 @@ class OmnipodDashPumpPlugin @Inject constructor(
}
override fun connect(reason: String) {
// See:
// NOTE: Using connected state for unconfirmed commands
if (podStateManager.activeCommand == null) {
return
}