Fix remote bolus distance
This commit is contained in:
parent
404bf7e633
commit
128547d1a5
1 changed files with 7 additions and 1 deletions
|
@ -191,6 +191,12 @@ object SmsCommunicatorPlugin : PluginBase(PluginDescription()
|
|||
log.debug(receivedSms.toString())
|
||||
val splitted = receivedSms.text.split(Regex("\\s+")).toTypedArray()
|
||||
val remoteCommandsAllowed = SP.getBoolean(R.string.key_smscommunicator_remotecommandsallowed, false)
|
||||
|
||||
val minDistance =
|
||||
if (areMoreNumbers(SP.getString(R.string.key_smscommunicator_allowednumbers, "")))
|
||||
T.mins(SP.getLong(R.string.key_smscommunicator_remotebolusmindistance, T.msecs(Constants.remoteBolusMinDistance).mins())).msecs()
|
||||
else Constants.remoteBolusMinDistance
|
||||
|
||||
if (splitted.isNotEmpty() && isCommand(splitted[0].toUpperCase(Locale.getDefault()), receivedSms.phoneNumber)) {
|
||||
when (splitted[0].toUpperCase(Locale.getDefault())) {
|
||||
"BG" ->
|
||||
|
@ -223,7 +229,7 @@ object SmsCommunicatorPlugin : PluginBase(PluginDescription()
|
|||
else sendSMS(Sms(receivedSms.phoneNumber, R.string.wrongformat))
|
||||
"BOLUS" ->
|
||||
if (!remoteCommandsAllowed) sendSMS(Sms(receivedSms.phoneNumber, R.string.smscommunicator_remotecommandnotallowed))
|
||||
else if (splitted.size == 2 && DateUtil.now() - lastRemoteBolusTime < Constants.remoteBolusMinDistance) sendSMS(Sms(receivedSms.phoneNumber, R.string.smscommunicator_remotebolusnotallowed))
|
||||
else if (splitted.size == 2 && DateUtil.now() - lastRemoteBolusTime < minDistance) sendSMS(Sms(receivedSms.phoneNumber, R.string.smscommunicator_remotebolusnotallowed))
|
||||
else if (splitted.size == 2 && pump.isSuspended) sendSMS(Sms(receivedSms.phoneNumber, R.string.pumpsuspended))
|
||||
else if (splitted.size == 2 || splitted.size == 3) processBOLUS(splitted, receivedSms)
|
||||
else sendSMS(Sms(receivedSms.phoneNumber, R.string.wrongformat))
|
||||
|
|
Loading…
Reference in a new issue