diff --git a/app/src/main/kotlin/app/aaps/activities/MyPreferenceFragment.kt b/app/src/main/kotlin/app/aaps/activities/MyPreferenceFragment.kt
index 46883de3df5..dc68b1777b9 100644
--- a/app/src/main/kotlin/app/aaps/activities/MyPreferenceFragment.kt
+++ b/app/src/main/kotlin/app/aaps/activities/MyPreferenceFragment.kt
@@ -407,8 +407,6 @@ class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChang
summary = app.aaps.plugins.main.R.string.theme_switcher_summary
)
)
- addPreference(AdaptiveSwitchPreference(ctx = context, booleanKey = BooleanKey.SmsAllowRemoteCommands, summary = R.string.client_allow_sms_warning, title = R.string.client_allow_sms))
- addPreference(AdaptiveStringPreference(ctx = context, stringKey = StringKey.SmsReceiverNumber, dialogMessage = R.string.sms_receiver_number_dialog, title = app.aaps.core.ui.R.string.sms_receiver_number))
}
}
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 9f9e49e0b30..3e1988b7f9b 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -25,11 +25,6 @@
Authorization failed
Cannula
Identification not set in dev mode
- dialog
-
- If number is provided, insulin and calculator buttons will be able to send SMS command to inject bolus. Note that you still need to confirm it and reply with security token/code. Note that you need to enabled SMS control of AAPS phone to use this function.
- Allow AAPSClient to send SMS with bolus command
- "Use this functionality with caution. Before enabling make sure that IOB and BG is synchronized between AAPS and AAPSClient. Some users reported issue with that. Use it at your own risk, every time you shall check IOB and BG before issuing a bolus. You can do that by sending 'BG' command."
Remove selected items
%1$d selected
diff --git a/core/objects/src/main/kotlin/app/aaps/core/objects/wizard/BolusWizard.kt b/core/objects/src/main/kotlin/app/aaps/core/objects/wizard/BolusWizard.kt
index 98a2be3cdd3..db8b30656ca 100644
--- a/core/objects/src/main/kotlin/app/aaps/core/objects/wizard/BolusWizard.kt
+++ b/core/objects/src/main/kotlin/app/aaps/core/objects/wizard/BolusWizard.kt
@@ -552,14 +552,16 @@ class BolusWizard @Inject constructor(
if (preferences.get(BooleanKey.SmsAllowRemoteCommands) && !phoneNumber.isNullOrBlank()) {
rh.gs(app.aaps.core.ui.R.string.sms_bolus_notification).formatColor(context, rh, app.aaps.core.ui.R.attr.warningColor)
smsCommunicator.sendSMS(Sms(phoneNumber, rh.gs(app.aaps.core.ui.R.string.bolus) + " " + insulin))
- } else if (!config.APS)
- commandQueue.bolus(this, object : Callback() {
- override fun run() {
- if (!result.success) {
- uiInteraction.runAlarm(result.comment, rh.gs(app.aaps.core.ui.R.string.treatmentdeliveryerror), app.aaps.core.ui.R.raw.boluserror)
- }
+ insulin = 0.0 // commandQueue will process carbs
+ }
+
+ commandQueue.bolus(this, object : Callback() {
+ override fun run() {
+ if (!result.success) {
+ uiInteraction.runAlarm(result.comment, rh.gs(app.aaps.core.ui.R.string.treatmentdeliveryerror), app.aaps.core.ui.R.raw.boluserror)
}
- })
+ }
+ })
}
bolusCalculatorResult?.let { persistenceLayer.insertOrUpdateBolusCalculatorResult(it).blockingGet() }
}
diff --git a/plugins/main/src/main/kotlin/app/aaps/plugins/main/general/overview/OverviewPlugin.kt b/plugins/main/src/main/kotlin/app/aaps/plugins/main/general/overview/OverviewPlugin.kt
index 427d3dd4672..3f1f60b916e 100644
--- a/plugins/main/src/main/kotlin/app/aaps/plugins/main/general/overview/OverviewPlugin.kt
+++ b/plugins/main/src/main/kotlin/app/aaps/plugins/main/general/overview/OverviewPlugin.kt
@@ -41,10 +41,13 @@ import app.aaps.core.objects.extensions.putString
import app.aaps.core.objects.extensions.store
import app.aaps.core.objects.extensions.storeBoolean
import app.aaps.core.objects.extensions.storeString
+import app.aaps.core.validators.DefaultEditTextValidator
+import app.aaps.core.validators.EditTextValidator
import app.aaps.core.validators.preferences.AdaptiveClickPreference
import app.aaps.core.validators.preferences.AdaptiveDoublePreference
import app.aaps.core.validators.preferences.AdaptiveIntPreference
import app.aaps.core.validators.preferences.AdaptiveIntentPreference
+import app.aaps.core.validators.preferences.AdaptiveStringPreference
import app.aaps.core.validators.preferences.AdaptiveSwitchPreference
import app.aaps.core.validators.preferences.AdaptiveUnitPreference
import app.aaps.plugins.main.R
@@ -219,6 +222,13 @@ class OverviewPlugin @Inject constructor(
addPreference(AdaptiveSwitchPreference(ctx = context, booleanKey = BooleanKey.OverviewShowTreatmentButton, title = R.string.treatments))
addPreference(AdaptiveSwitchPreference(ctx = context, booleanKey = BooleanKey.OverviewShowWizardButton, title = R.string.calculator_label))
addPreference(AdaptiveSwitchPreference(ctx = context, booleanKey = BooleanKey.OverviewShowInsulinButton, title = app.aaps.core.ui.R.string.configbuilder_insulin))
+ addPreference(AdaptiveSwitchPreference(ctx = context, booleanKey = BooleanKey.SmsAllowRemoteCommands, summary = R.string.client_allow_sms_warning, title = R.string.client_allow_sms))
+ addPreference(
+ AdaptiveStringPreference(
+ ctx = context, stringKey = StringKey.SmsReceiverNumber, dialogMessage = R.string.sms_receiver_number_dialog, title = app.aaps.core.ui.R.string.sms_receiver_number,
+ validatorParams = DefaultEditTextValidator.Parameters(testType = EditTextValidator.TEST_PHONE)
+ )
+ )
addPreference(AdaptiveDoublePreference(ctx = context, doubleKey = DoubleKey.OverviewInsulinButtonIncrement1, dialogMessage = R.string.insulin_increment_button_message, title = R.string.firstinsulinincrement))
addPreference(AdaptiveDoublePreference(ctx = context, doubleKey = DoubleKey.OverviewInsulinButtonIncrement2, dialogMessage = R.string.insulin_increment_button_message, title = R.string.secondinsulinincrement))
addPreference(AdaptiveDoublePreference(ctx = context, doubleKey = DoubleKey.OverviewInsulinButtonIncrement3, dialogMessage = R.string.insulin_increment_button_message, title = R.string.thirdinsulinincrement))
@@ -279,11 +289,13 @@ class OverviewPlugin @Inject constructor(
addPreference(AdaptiveIntPreference(ctx = context, intKey = IntKey.OverviewResCritical, title = R.string.statuslights_res_critical))
addPreference(AdaptiveIntPreference(ctx = context, intKey = IntKey.OverviewBattWarning, title = R.string.statuslights_bat_warning))
addPreference(AdaptiveIntPreference(ctx = context, intKey = IntKey.OverviewBattCritical, title = R.string.statuslights_bat_critical))
- addPreference(AdaptiveClickPreference(ctx = context, stringKey = StringKey.OverviewCopySettingsFromNs, title = R.string.statuslights_copy_ns,
- onPreferenceClickListener = {
- nsSettingStatus.copyStatusLightsNsSettings(context)
- true
- }))
+ addPreference(
+ AdaptiveClickPreference(ctx = context, stringKey = StringKey.OverviewCopySettingsFromNs, title = R.string.statuslights_copy_ns,
+ onPreferenceClickListener = {
+ nsSettingStatus.copyStatusLightsNsSettings(context)
+ true
+ })
+ )
})
addPreference(AdaptiveIntPreference(ctx = context, intKey = IntKey.OverviewBolusPercentage, dialogMessage = R.string.deliverpartofboluswizard, title = app.aaps.core.ui.R.string.partialboluswizard))
diff --git a/plugins/main/src/main/kotlin/app/aaps/plugins/main/general/smsCommunicator/SmsCommunicatorPlugin.kt b/plugins/main/src/main/kotlin/app/aaps/plugins/main/general/smsCommunicator/SmsCommunicatorPlugin.kt
index 7e36ee88d28..6ce0c81854e 100644
--- a/plugins/main/src/main/kotlin/app/aaps/plugins/main/general/smsCommunicator/SmsCommunicatorPlugin.kt
+++ b/plugins/main/src/main/kotlin/app/aaps/plugins/main/general/smsCommunicator/SmsCommunicatorPlugin.kt
@@ -933,11 +933,12 @@ class SmsCommunicatorPlugin @Inject constructor(
if (divided.size == 3 && !isMeal) {
sendSMS(Sms(receivedSms.phoneNumber, rh.gs(R.string.wrong_format)))
} else if (bolus > 0.0) {
+ val iob = (iobCobCalculator.calculateIobFromBolus() + iobCobCalculator.calculateIobFromTempBasalsIncludingConvertedExtended()).round()
val passCode = generatePassCode()
val reply = if (isMeal)
- rh.gs(R.string.smscommunicator_meal_bolus_reply_with_code, bolus, passCode)
+ rh.gs(R.string.smscommunicator_meal_bolus_reply_with_code, bolus, passCode, iob)
else
- rh.gs(R.string.smscommunicator_bolus_reply_with_code, bolus, passCode)
+ rh.gs(R.string.smscommunicator_bolus_reply_with_code, bolus, passCode, iob)
receivedSms.processed = true
messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction(pumpCommand = true, bolus) {
override fun run() {
diff --git a/plugins/main/src/main/res/values/strings.xml b/plugins/main/src/main/res/values/strings.xml
index 475c4368737..615c6037ffd 100644
--- a/plugins/main/src/main/res/values/strings.xml
+++ b/plugins/main/src/main/res/values/strings.xml
@@ -33,8 +33,8 @@
Timeout while waiting for finish of previous pump communication
Allowed phone numbers
+XXXXXXXXXX;+YYYYYYYYYY
- To deliver bolus %1$.2fU reply with code %2$s
- To deliver meal bolus %1$.2fU reply with code %2$s
+ To deliver bolus %1$.2fU reply with code %2$s. Current IOB is %3$.2fU
+ To deliver meal bolus %1$.2fU reply with code %2$s. Current IOB is %3$.2fU
To set the Temp Target %1$s reply with code %2$s
To cancel Temp Target reply with code %1$s
To disable the SMS Remote Service reply with code %1$s.\n\nKeep in mind that you\'ll able to reactivate it directly from the AAPS master smartphone only.
@@ -275,8 +275,12 @@
Enable bolus reminder
Use reminder to bolus later with wizard ("post-bolus")
Run %s?
+
+ If number is provided, insulin and calculator buttons will be able to send SMS command to inject bolus. Note that you still need to confirm it and reply with security token/code. Note that you need to enabled SMS control of AAPS phone to use this function.
+ Allow AAPSClient to send SMS with bolus command
+ "Use this functionality with caution. Before enabling make sure that IOB and BG is synchronized between AAPS and AAPSClient. Some users reported issue with that. Use it at your own risk, every time you shall check IOB and BG before issuing a bolus. You can do that by sending 'BG' command."
-
+
graphconfig
Predictions
Treatments
diff --git a/ui/src/main/kotlin/app/aaps/ui/dialogs/InsulinDialog.kt b/ui/src/main/kotlin/app/aaps/ui/dialogs/InsulinDialog.kt
index d3fd6a811ae..c3b047befc7 100644
--- a/ui/src/main/kotlin/app/aaps/ui/dialogs/InsulinDialog.kt
+++ b/ui/src/main/kotlin/app/aaps/ui/dialogs/InsulinDialog.kt
@@ -132,8 +132,13 @@ class InsulinDialog : DialogFragmentWithDate() {
if (config.NSCLIENT) {
// If SmsAllowRemoteCommands is True, then user might use either SMS command or record only, otherwise hardcode record_only option
val allowSms = preferences.get(BooleanKey.SmsAllowRemoteCommands)
- binding.recordOnly.isEnabled = allowSms
- binding.recordOnly.isChecked = preferences.get(StringKey.SmsReceiverNumber).isNullOrBlank()
+ if(allowSms) {
+ binding.recordOnly.isEnabled = !preferences.get(StringKey.SmsReceiverNumber).isNullOrBlank()
+ binding.recordOnly.isChecked = preferences.get(StringKey.SmsReceiverNumber).isNullOrBlank()
+ } else {
+ binding.recordOnly.isEnabled = false
+ binding.recordOnly.isChecked = true
+ }
}
val maxInsulin = constraintChecker.getMaxBolusAllowed().value()
@@ -207,6 +212,7 @@ class InsulinDialog : DialogFragmentWithDate() {
val phoneNumber = preferences.get(StringKey.SmsReceiverNumber)
val recordOnlyChecked = binding.recordOnly.isChecked
val eatingSoonChecked = binding.startEatingSoonTt.isChecked
+ val sendSMS = preferences.get(BooleanKey.SmsAllowRemoteCommands) && !phoneNumber.isNullOrBlank()
if (insulinAfterConstraints > 0) {
actions.add(
@@ -215,7 +221,7 @@ class InsulinDialog : DialogFragmentWithDate() {
)
if (recordOnlyChecked)
actions.add(rh.gs(app.aaps.core.ui.R.string.bolus_recorded_only).formatColor(context, rh, app.aaps.core.ui.R.attr.warningColor))
- else if (preferences.get(BooleanKey.SmsAllowRemoteCommands) && !phoneNumber.isNullOrBlank())
+ else if (sendSMS)
actions.add(rh.gs(app.aaps.core.ui.R.string.sms_bolus_notification).formatColor(context, rh, app.aaps.core.ui.R.attr.warningColor))
if (abs(insulinAfterConstraints - insulin) > pumpDescription.pumpType.determineCorrectBolusStepSize(insulinAfterConstraints))
@@ -280,7 +286,7 @@ class InsulinDialog : DialogFragmentWithDate() {
).subscribe()
if (timeOffset == 0)
automation.removeAutomationEventBolusReminder()
- } else if (preferences.get(BooleanKey.SmsAllowRemoteCommands) && !phoneNumber.isNullOrBlank()) {
+ } else if (sendSMS) {
smsCommunicator.sendSMS(Sms(phoneNumber, rh.gs(app.aaps.core.ui.R.string.bolus) + " " + detailedBolusInfo.insulin))
} else {
uel.log(
diff --git a/ui/src/main/kotlin/app/aaps/ui/dialogs/TreatmentDialog.kt b/ui/src/main/kotlin/app/aaps/ui/dialogs/TreatmentDialog.kt
index 430dd95ca59..85bc8ab2480 100644
--- a/ui/src/main/kotlin/app/aaps/ui/dialogs/TreatmentDialog.kt
+++ b/ui/src/main/kotlin/app/aaps/ui/dialogs/TreatmentDialog.kt
@@ -110,7 +110,11 @@ class TreatmentDialog : DialogFragmentWithDate() {
super.onViewCreated(view, savedInstanceState)
if (config.NSCLIENT) {
- binding.recordOnly.isChecked = preferences.get(StringKey.SmsReceiverNumber).isNullOrBlank()
+ if(preferences.get(BooleanKey.SmsAllowRemoteCommands)) {
+ binding.recordOnly.isChecked = preferences.get(StringKey.SmsReceiverNumber).isNullOrBlank()
+ } else {
+ binding.recordOnly.isChecked = true
+ }
}
val maxCarbs = constraintChecker.getMaxCarbsAllowed().value().toDouble()
val maxInsulin = constraintChecker.getMaxBolusAllowed().value()
@@ -150,6 +154,7 @@ class TreatmentDialog : DialogFragmentWithDate() {
val actions: LinkedList = LinkedList()
val insulinAfterConstraints = constraintChecker.applyBolusConstraints(ConstraintObject(insulin, aapsLogger)).value()
val carbsAfterConstraints = constraintChecker.applyCarbsConstraints(ConstraintObject(carbs, aapsLogger)).value()
+ val sendSMS = preferences.get(BooleanKey.SmsAllowRemoteCommands) && !phoneNumber.isNullOrBlank()
if (insulinAfterConstraints > 0) {
actions.add(
@@ -161,7 +166,7 @@ class TreatmentDialog : DialogFragmentWithDate() {
)
if (recordOnlyChecked)
actions.add(rh.gs(app.aaps.core.ui.R.string.bolus_recorded_only).formatColor(context, rh, app.aaps.core.ui.R.attr.warningColor))
- else if (preferences.get(BooleanKey.SmsAllowRemoteCommands) && !phoneNumber.isNullOrBlank())
+ else if (sendSMS)
actions.add(
rh.gs(
app.aaps.core.ui.R.string.sms_bolus_notification
@@ -196,9 +201,9 @@ class TreatmentDialog : DialogFragmentWithDate() {
detailedBolusInfo.insulin = insulinAfterConstraints
detailedBolusInfo.carbs = carbsAfterConstraints.toDouble()
detailedBolusInfo.context = context
- if (recordOnlyChecked) {
+ if (recordOnlyChecked || sendSMS) {
if (detailedBolusInfo.insulin > 0)
- if (preferences.get(BooleanKey.SmsAllowRemoteCommands) && !phoneNumber.isNullOrBlank())
+ if (sendSMS)
smsCommunicator.sendSMS(Sms(phoneNumber, rh.gs(app.aaps.core.ui.R.string.bolus) + " " + detailedBolusInfo.insulin))
else
disposable += persistenceLayer.insertOrUpdateBolus(