diff --git a/plugins/main/src/main/java/info/nightscout/plugins/sync/nsShared/events/EventNSClientNewLog.kt b/app-wear-shared/shared/src/main/java/info/nightscout/rx/events/EventNSClientNewLog.kt similarity index 76% rename from plugins/main/src/main/java/info/nightscout/plugins/sync/nsShared/events/EventNSClientNewLog.kt rename to app-wear-shared/shared/src/main/java/info/nightscout/rx/events/EventNSClientNewLog.kt index bdc98f1463..379d2750ff 100644 --- a/plugins/main/src/main/java/info/nightscout/plugins/sync/nsShared/events/EventNSClientNewLog.kt +++ b/app-wear-shared/shared/src/main/java/info/nightscout/rx/events/EventNSClientNewLog.kt @@ -1,11 +1,9 @@ -package info.nightscout.plugins.sync.nsShared.events +package info.nightscout.rx.events -import info.nightscout.interfaces.sync.NsClient -import info.nightscout.rx.events.Event import java.text.SimpleDateFormat import java.util.Locale -class EventNSClientNewLog(val action: String, val logText: String, val version: NsClient.Version) : Event() { +class EventNSClientNewLog(val action: String, val logText: String) : Event() { var date = System.currentTimeMillis() private var timeFormat = SimpleDateFormat("HH:mm:ss", Locale.getDefault()) diff --git a/app/src/main/java/info/nightscout/androidaps/di/AppComponent.kt b/app/src/main/java/info/nightscout/androidaps/di/AppComponent.kt index 05fce0f281..ea32c41a5b 100644 --- a/app/src/main/java/info/nightscout/androidaps/di/AppComponent.kt +++ b/app/src/main/java/info/nightscout/androidaps/di/AppComponent.kt @@ -54,6 +54,7 @@ import javax.inject.Singleton AutomationModule::class, ApsModule::class, ConfigurationModule::class, + ConfigurationModule.Bindings::class, CoreModule::class, DatabaseModule::class, ImplementationModule::class, diff --git a/app/src/main/java/info/nightscout/androidaps/di/AppModule.kt b/app/src/main/java/info/nightscout/androidaps/di/AppModule.kt index 543e22a221..a2876990ad 100644 --- a/app/src/main/java/info/nightscout/androidaps/di/AppModule.kt +++ b/app/src/main/java/info/nightscout/androidaps/di/AppModule.kt @@ -9,7 +9,7 @@ import dagger.android.HasAndroidInjector import info.nightscout.androidaps.MainApp import info.nightscout.androidaps.implementations.ActivityNamesImpl import info.nightscout.androidaps.implementations.ConfigImpl -import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin +import info.nightscout.configuration.configBuilder.ConfigBuilderPlugin import info.nightscout.implementation.profile.ProfileFunctionImpl import info.nightscout.androidaps.plugins.general.maintenance.ImportExportPrefsImpl import info.nightscout.androidaps.workflow.CalculationWorkflowImpl diff --git a/app/src/main/java/info/nightscout/androidaps/di/FragmentsModule.kt b/app/src/main/java/info/nightscout/androidaps/di/FragmentsModule.kt index 0399e2aad5..47ecaf177b 100644 --- a/app/src/main/java/info/nightscout/androidaps/di/FragmentsModule.kt +++ b/app/src/main/java/info/nightscout/androidaps/di/FragmentsModule.kt @@ -3,7 +3,7 @@ package info.nightscout.androidaps.di import dagger.Module import dagger.android.ContributesAndroidInjector import info.nightscout.androidaps.activities.MyPreferenceFragment -import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderFragment +import info.nightscout.configuration.configBuilder.ConfigBuilderFragment import info.nightscout.androidaps.plugins.general.maintenance.MaintenanceFragment import info.nightscout.androidaps.plugins.general.overview.OverviewFragment import info.nightscout.androidaps.plugins.general.overview.dialogs.EditQuickWizardDialog diff --git a/app/src/main/java/info/nightscout/androidaps/di/PluginsListModule.kt b/app/src/main/java/info/nightscout/androidaps/di/PluginsListModule.kt index a315e1b9f4..a7230024b8 100644 --- a/app/src/main/java/info/nightscout/androidaps/di/PluginsListModule.kt +++ b/app/src/main/java/info/nightscout/androidaps/di/PluginsListModule.kt @@ -8,7 +8,7 @@ import info.nightscout.androidaps.danaRKorean.DanaRKoreanPlugin import info.nightscout.androidaps.danaRv2.DanaRv2Plugin import info.nightscout.androidaps.danar.DanaRPlugin import info.nightscout.androidaps.plugin.general.openhumans.OpenHumansUploaderPlugin -import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin +import info.nightscout.configuration.configBuilder.ConfigBuilderPlugin import info.nightscout.androidaps.plugins.general.maintenance.MaintenancePlugin import info.nightscout.androidaps.plugins.general.overview.OverviewPlugin import info.nightscout.androidaps.plugins.general.persistentNotification.PersistentNotificationPlugin diff --git a/app/src/main/java/info/nightscout/androidaps/receivers/KeepAliveWorker.kt b/app/src/main/java/info/nightscout/androidaps/receivers/KeepAliveWorker.kt index 0fd6767276..34c0bbb41b 100644 --- a/app/src/main/java/info/nightscout/androidaps/receivers/KeepAliveWorker.kt +++ b/app/src/main/java/info/nightscout/androidaps/receivers/KeepAliveWorker.kt @@ -28,7 +28,7 @@ import info.nightscout.interfaces.plugin.PluginBase import info.nightscout.interfaces.profile.ProfileFunction import info.nightscout.interfaces.queue.Command import info.nightscout.interfaces.queue.CommandQueue -import info.nightscout.plugins.configBuilder.RunningConfiguration +import info.nightscout.interfaces.configBuilder.RunningConfiguration import info.nightscout.plugins.sync.nsclient.extensions.buildDeviceStatus import info.nightscout.rx.bus.RxBus import info.nightscout.rx.events.EventProfileSwitchChanged diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6e1a66dac0..c1b3da6cbf 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -37,11 +37,9 @@ Reset Databases Do you really want to reset the databases? Exit - Used for configuring the active plugins Displays the current state of your loop and buttons for most common actions Shows an ongoing notification with a short overview of what your loop is doing Delta - Config Builder Overview Treatments Constraints violation @@ -82,7 +80,6 @@ Wear Ongoing Notification OLD DATA - CONF HOME TREAT Shorten tab titles @@ -173,7 +170,6 @@ keep_screen_on Remove items Sort items - Attention: If you activate and connect to a hardware pump, AAPS will copy the basal settings from the profile to the pump, overwriting the existing basal rate stored on the pump. Make sure you have the correct basal setting in AAPS. If you are not sure or don\'t want to overwrite the basal settings on your pump, press cancel and repeat switching to the pump at a later time. Treatment data incomplete Maintenance Settings Email recipient @@ -229,7 +225,6 @@ %1$d selected Sort Graph scale - open settings All Phone Watch diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/aps/loop/LoopPluginTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/aps/loop/LoopPluginTest.kt index 774bfcb7b9..9ae6a34163 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/aps/loop/LoopPluginTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/aps/loop/LoopPluginTest.kt @@ -21,7 +21,7 @@ import info.nightscout.interfaces.queue.CommandQueue import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.plugins.aps.loop.LoopFragment import info.nightscout.plugins.aps.loop.LoopPlugin -import info.nightscout.plugins.configBuilder.RunningConfiguration +import info.nightscout.interfaces.configBuilder.RunningConfiguration import info.nightscout.plugins.pump.virtual.VirtualPumpPlugin import info.nightscout.rx.bus.RxBus import info.nightscout.shared.interfaces.ResourceHelper diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/configBuilder/ConfigBuilderPluginTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/configBuilder/ConfigBuilderPluginTest.kt index 1786668af9..6814acceb0 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/configBuilder/ConfigBuilderPluginTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/configBuilder/ConfigBuilderPluginTest.kt @@ -6,6 +6,7 @@ import info.nightscout.androidaps.TestBase import info.nightscout.interfaces.logging.UserEntryLogger import info.nightscout.interfaces.plugin.ActivePlugin import info.nightscout.interfaces.pump.PumpSync +import info.nightscout.configuration.configBuilder.ConfigBuilderPlugin import info.nightscout.rx.bus.RxBus import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.sharedPreferences.SP diff --git a/core/interfaces/build.gradle b/core/interfaces/build.gradle index b47e31a5e6..a5b27fe3f6 100644 --- a/core/interfaces/build.gradle +++ b/core/interfaces/build.gradle @@ -23,6 +23,7 @@ dependencies { // (ResourceHelper, AAPSLogger interface) implementation project(':app-wear-shared:shared') implementation project(':database:entities') + implementation project(':core:ns-sdk') api "androidx.appcompat:appcompat:$appcompat_version" diff --git a/core/interfaces/src/main/java/info/nightscout/interfaces/configBuilder/RunningConfiguration.kt b/core/interfaces/src/main/java/info/nightscout/interfaces/configBuilder/RunningConfiguration.kt new file mode 100644 index 0000000000..b7fd861e60 --- /dev/null +++ b/core/interfaces/src/main/java/info/nightscout/interfaces/configBuilder/RunningConfiguration.kt @@ -0,0 +1,13 @@ +package info.nightscout.interfaces.configBuilder + +import info.nightscout.sdk.remotemodel.RemoteDeviceStatus +import org.json.JSONObject + +interface RunningConfiguration { + + // called in AAPS mode only + fun configuration(): JSONObject + + // called in NSClient mode only + fun apply(configuration: RemoteDeviceStatus.Configuration) +} \ No newline at end of file diff --git a/core/interfaces/src/main/java/info/nightscout/interfaces/plugin/ActivePlugin.kt b/core/interfaces/src/main/java/info/nightscout/interfaces/plugin/ActivePlugin.kt index fd22e37b43..bcf3e2b360 100644 --- a/core/interfaces/src/main/java/info/nightscout/interfaces/plugin/ActivePlugin.kt +++ b/core/interfaces/src/main/java/info/nightscout/interfaces/plugin/ActivePlugin.kt @@ -110,4 +110,6 @@ interface ActivePlugin { * List of all plugins of type */ fun getSpecificPluginsList(type: PluginType): ArrayList + + fun loadDefaults() } \ No newline at end of file diff --git a/ui/src/main/res/drawable/ic_visibility.xml b/core/ui/src/main/res/drawable/ic_visibility.xml similarity index 100% rename from ui/src/main/res/drawable/ic_visibility.xml rename to core/ui/src/main/res/drawable/ic_visibility.xml diff --git a/ui/src/main/res/drawable/ic_visibility_off.xml b/core/ui/src/main/res/drawable/ic_visibility_off.xml similarity index 100% rename from ui/src/main/res/drawable/ic_visibility_off.xml rename to core/ui/src/main/res/drawable/ic_visibility_off.xml diff --git a/core/ui/src/main/res/values/strings.xml b/core/ui/src/main/res/values/strings.xml index a2083b818c..663eb22044 100644 --- a/core/ui/src/main/res/values/strings.xml +++ b/core/ui/src/main/res/values/strings.xml @@ -24,6 +24,8 @@ mmol/l Save Snooze + Virtual Pump + Constraints Battery diff --git a/implementation/src/main/java/info/nightscout/implementation/plugin/PluginStore.kt b/implementation/src/main/java/info/nightscout/implementation/plugin/PluginStore.kt index 21eaeac57d..6778b0b51d 100644 --- a/implementation/src/main/java/info/nightscout/implementation/plugin/PluginStore.kt +++ b/implementation/src/main/java/info/nightscout/implementation/plugin/PluginStore.kt @@ -37,7 +37,7 @@ class PluginStore @Inject constructor( private var activeInsulinStore: Insulin? = null private var activeSensitivityStore: Sensitivity? = null - fun loadDefaults() { + override fun loadDefaults() { verifySelectionInCategories() } diff --git a/plugins/configuration/build.gradle b/plugins/configuration/build.gradle index 90a51b94a5..5032f4a7d4 100644 --- a/plugins/configuration/build.gradle +++ b/plugins/configuration/build.gradle @@ -21,6 +21,7 @@ dependencies { implementation project(':database:entities') implementation project(':core:core-main') implementation project(':core:interfaces') + implementation project(':core:ns-sdk') implementation project(':core:utils') implementation project(':core:ui') } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ConfigBuilderFragment.kt b/plugins/configuration/src/main/java/info/nightscout/configuration/configBuilder/ConfigBuilderFragment.kt similarity index 95% rename from app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ConfigBuilderFragment.kt rename to plugins/configuration/src/main/java/info/nightscout/configuration/configBuilder/ConfigBuilderFragment.kt index 53feb82b9c..738d37b389 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ConfigBuilderFragment.kt +++ b/plugins/configuration/src/main/java/info/nightscout/configuration/configBuilder/ConfigBuilderFragment.kt @@ -1,4 +1,4 @@ -package info.nightscout.androidaps.plugins.configBuilder +package info.nightscout.configuration.configBuilder import android.content.Context import android.content.Intent @@ -15,10 +15,9 @@ import android.widget.TextView import androidx.annotation.StringRes import androidx.core.content.ContextCompat import dagger.android.support.DaggerFragment -import info.nightscout.androidaps.R -import info.nightscout.androidaps.activities.PreferencesActivity -import info.nightscout.androidaps.databinding.ConfigbuilderFragmentBinding -import info.nightscout.androidaps.plugins.configBuilder.events.EventConfigBuilderUpdateGui +import info.nightscout.configuration.R +import info.nightscout.configuration.configBuilder.events.EventConfigBuilderUpdateGui +import info.nightscout.configuration.databinding.ConfigbuilderFragmentBinding import info.nightscout.core.utils.fabric.FabricPrivacy import info.nightscout.interfaces.Config import info.nightscout.interfaces.plugin.ActivePlugin @@ -26,12 +25,12 @@ import info.nightscout.interfaces.plugin.PluginBase import info.nightscout.interfaces.plugin.PluginType import info.nightscout.interfaces.protection.ProtectionCheck import info.nightscout.interfaces.protection.ProtectionCheck.Protection.PREFERENCES +import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.rx.AapsSchedulers import info.nightscout.rx.bus.RxBus import info.nightscout.rx.events.EventRebuildTabs import info.nightscout.shared.extensions.toVisibility import info.nightscout.shared.interfaces.ResourceHelper -import info.nightscout.ui.activities.SingleFragmentActivity import io.reactivex.rxjava3.disposables.CompositeDisposable import io.reactivex.rxjava3.kotlin.plusAssign import javax.inject.Inject @@ -47,6 +46,7 @@ class ConfigBuilderFragment : DaggerFragment() { @Inject lateinit var protectionCheck: ProtectionCheck @Inject lateinit var config: Config @Inject lateinit var ctx: Context + @Inject lateinit var activityNames: ActivityNames private var disposable: CompositeDisposable = CompositeDisposable() private val pluginViewHolders = ArrayList() @@ -65,7 +65,7 @@ class ConfigBuilderFragment : DaggerFragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) val parentClass = this.activity?.let { it::class.java } - inMenu = parentClass == SingleFragmentActivity::class.java + inMenu = parentClass == activityNames.singleFragmentActivity updateProtectedUi() binding.unlock.setOnClickListener { queryProtection() } } @@ -166,7 +166,7 @@ class ConfigBuilderFragment : DaggerFragment() { pluginPreferences.setOnClickListener { fragment.activity?.let { activity -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.PREFERENCES, { - val i = Intent(ctx, PreferencesActivity::class.java) + val i = Intent(ctx, activityNames.preferencesActivity) i.putExtra("id", plugin.preferencesId) fragment.startActivity(i) }, null) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ConfigBuilderPlugin.kt b/plugins/configuration/src/main/java/info/nightscout/configuration/configBuilder/ConfigBuilderPlugin.kt similarity index 96% rename from app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ConfigBuilderPlugin.kt rename to plugins/configuration/src/main/java/info/nightscout/configuration/configBuilder/ConfigBuilderPlugin.kt index 7a22b12675..7eb13f963f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ConfigBuilderPlugin.kt +++ b/plugins/configuration/src/main/java/info/nightscout/configuration/configBuilder/ConfigBuilderPlugin.kt @@ -1,14 +1,13 @@ -package info.nightscout.androidaps.plugins.configBuilder +package info.nightscout.configuration.configBuilder import androidx.fragment.app.FragmentActivity import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.R -import info.nightscout.androidaps.plugins.configBuilder.events.EventConfigBuilderUpdateGui +import info.nightscout.configuration.R +import info.nightscout.configuration.configBuilder.events.EventConfigBuilderUpdateGui import info.nightscout.core.ui.dialogs.OKDialog import info.nightscout.database.entities.UserEntry.Action import info.nightscout.database.entities.UserEntry.Sources import info.nightscout.database.entities.ValueWithUnit -import info.nightscout.implementation.plugin.PluginStore import info.nightscout.interfaces.ConfigBuilder import info.nightscout.interfaces.aps.APS import info.nightscout.interfaces.aps.Sensitivity @@ -52,14 +51,14 @@ class ConfigBuilderPlugin @Inject constructor( .alwaysEnabled(true) .alwaysVisible(false) .pluginIcon(R.drawable.ic_cogs) - .pluginName(R.string.configbuilder) - .shortName(R.string.configbuilder_shortname) + .pluginName(R.string.config_builder) + .shortName(R.string.config_builder_shortname) .description(R.string.description_config_builder), aapsLogger, rh, injector ), ConfigBuilder { override fun initialize() { - (activePlugin as PluginStore).loadDefaults() + activePlugin.loadDefaults() loadSettings() setAlwaysEnabledPluginsEnabled() rxBus.send(EventAppInitialized()) diff --git a/plugins/main/src/main/java/info/nightscout/plugins/configBuilder/RunningConfiguration.kt b/plugins/configuration/src/main/java/info/nightscout/configuration/configBuilder/RunningConfigurationImpl.kt similarity index 92% rename from plugins/main/src/main/java/info/nightscout/plugins/configBuilder/RunningConfiguration.kt rename to plugins/configuration/src/main/java/info/nightscout/configuration/configBuilder/RunningConfigurationImpl.kt index 73f2ccda71..32a54ca971 100644 --- a/plugins/main/src/main/java/info/nightscout/plugins/configBuilder/RunningConfiguration.kt +++ b/plugins/configuration/src/main/java/info/nightscout/configuration/configBuilder/RunningConfigurationImpl.kt @@ -1,19 +1,19 @@ -package info.nightscout.plugins.configBuilder +package info.nightscout.configuration.configBuilder import info.nightscout.core.events.EventNewNotification import info.nightscout.core.main.R import info.nightscout.interfaces.Config import info.nightscout.interfaces.ConfigBuilder import info.nightscout.interfaces.aps.Sensitivity +import info.nightscout.interfaces.configBuilder.RunningConfiguration import info.nightscout.interfaces.insulin.Insulin import info.nightscout.interfaces.notifications.Notification import info.nightscout.interfaces.plugin.ActivePlugin import info.nightscout.interfaces.plugin.PluginType import info.nightscout.interfaces.pump.PumpSync import info.nightscout.interfaces.pump.defs.PumpType -import info.nightscout.interfaces.sync.NsClient -import info.nightscout.plugins.sync.nsShared.events.EventNSClientNewLog import info.nightscout.rx.bus.RxBus +import info.nightscout.rx.events.EventNSClientNewLog import info.nightscout.rx.logging.AAPSLogger import info.nightscout.rx.logging.LTag import info.nightscout.sdk.remotemodel.RemoteDeviceStatus @@ -25,7 +25,7 @@ import javax.inject.Inject import javax.inject.Singleton @Singleton -class RunningConfiguration @Inject constructor( +class RunningConfigurationImpl @Inject constructor( private val activePlugin: ActivePlugin, private val configBuilder: ConfigBuilder, private val sp: SP, @@ -34,13 +34,13 @@ class RunningConfiguration @Inject constructor( private val rh: ResourceHelper, private val rxBus: RxBus, private val pumpSync: PumpSync -) { +) : RunningConfiguration { private var counter = 0 private val every = 12 // Send only every 12 device status to save traffic // called in AAPS mode only - fun configuration(): JSONObject { + override fun configuration(): JSONObject { val json = JSONObject() val pumpInterface = activePlugin.activePump @@ -67,11 +67,11 @@ class RunningConfiguration @Inject constructor( } // called in NSClient mode only - fun apply(configuration: RemoteDeviceStatus.Configuration, version: NsClient.Version) { + override fun apply(configuration: RemoteDeviceStatus.Configuration) { assert(config.NSCLIENT) configuration.version?.let { - rxBus.send(EventNSClientNewLog("VERSION", "Received AndroidAPS version $it", version)) + rxBus.send(EventNSClientNewLog("VERSION", "Received AndroidAPS version $it")) if (config.VERSION_NAME.startsWith(it).not()) rxBus.send(EventNewNotification(Notification(Notification.NSCLIENT_VERSION_DOES_NOT_MATCH, rh.gs(R.string.nsclient_version_does_not_match), Notification.NORMAL))) } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/events/EventConfigBuilderUpdateGui.kt b/plugins/configuration/src/main/java/info/nightscout/configuration/configBuilder/events/EventConfigBuilderUpdateGui.kt similarity index 61% rename from app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/events/EventConfigBuilderUpdateGui.kt rename to plugins/configuration/src/main/java/info/nightscout/configuration/configBuilder/events/EventConfigBuilderUpdateGui.kt index f28fe962a1..9dc8fc2ad4 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/events/EventConfigBuilderUpdateGui.kt +++ b/plugins/configuration/src/main/java/info/nightscout/configuration/configBuilder/events/EventConfigBuilderUpdateGui.kt @@ -1,4 +1,4 @@ -package info.nightscout.androidaps.plugins.configBuilder.events +package info.nightscout.configuration.configBuilder.events import info.nightscout.rx.events.EventUpdateGui diff --git a/plugins/configuration/src/main/java/info/nightscout/configuration/di/ConfigurationModule.kt b/plugins/configuration/src/main/java/info/nightscout/configuration/di/ConfigurationModule.kt index 9671a0f704..f31d80903c 100644 --- a/plugins/configuration/src/main/java/info/nightscout/configuration/di/ConfigurationModule.kt +++ b/plugins/configuration/src/main/java/info/nightscout/configuration/di/ConfigurationModule.kt @@ -1,10 +1,20 @@ package info.nightscout.configuration.di +import dagger.Binds import dagger.Module +import info.nightscout.configuration.configBuilder.RunningConfigurationImpl +import info.nightscout.interfaces.configBuilder.RunningConfiguration @Module( includes = [ SetupWizardModule::class ] ) -open class ConfigurationModule \ No newline at end of file +open class ConfigurationModule { + + @Module + interface Bindings { + + @Binds fun bindRunningConfiguration(runningConfigurationImpl: RunningConfigurationImpl): RunningConfiguration + } +} \ No newline at end of file diff --git a/app/src/main/res/layout/configbuilder_fragment.xml b/plugins/configuration/src/main/res/layout/configbuilder_fragment.xml similarity index 100% rename from app/src/main/res/layout/configbuilder_fragment.xml rename to plugins/configuration/src/main/res/layout/configbuilder_fragment.xml diff --git a/app/src/main/res/layout/configbuilder_single_category.xml b/plugins/configuration/src/main/res/layout/configbuilder_single_category.xml similarity index 100% rename from app/src/main/res/layout/configbuilder_single_category.xml rename to plugins/configuration/src/main/res/layout/configbuilder_single_category.xml diff --git a/app/src/main/res/layout/configbuilder_single_plugin.xml b/plugins/configuration/src/main/res/layout/configbuilder_single_plugin.xml similarity index 100% rename from app/src/main/res/layout/configbuilder_single_plugin.xml rename to plugins/configuration/src/main/res/layout/configbuilder_single_plugin.xml diff --git a/plugins/configuration/src/main/res/values/strings.xml b/plugins/configuration/src/main/res/values/strings.xml index d3cffca1b2..d05a5498e1 100644 --- a/plugins/configuration/src/main/res/values/strings.xml +++ b/plugins/configuration/src/main/res/values/strings.xml @@ -55,6 +55,11 @@ This identification will attached to crash reports so we can contact you in urgent cases. It\'s optional. Identification (email, FB or Discord nick etc) + APS Mode + Preferred APS mode + + + Config Builder Pump Which pump would you like to use with AAPS? Profile @@ -71,9 +76,12 @@ Which type of insulin are you using? BG Source Where should AAPS gain it\'s data from? - APS Mode - Preferred APS mode Sensitivity detection Which sensitivity algorithm should be used? + CONF + Used for configuring the active plugins + Attention: If you activate and connect to a hardware pump, AAPS will copy the basal settings from the profile to the pump, overwriting the existing basal rate stored on the pump. Make sure you have the correct basal setting in AAPS. If you are not sure or don\'t want to overwrite the basal settings on your pump, press cancel and repeat switching to the pump at a later time. + open settings + \ No newline at end of file diff --git a/plugins/main/src/main/java/info/nightscout/plugins/aps/loop/LoopPlugin.kt b/plugins/main/src/main/java/info/nightscout/plugins/aps/loop/LoopPlugin.kt index 5725f186b6..d038f6d1e8 100644 --- a/plugins/main/src/main/java/info/nightscout/plugins/aps/loop/LoopPlugin.kt +++ b/plugins/main/src/main/java/info/nightscout/plugins/aps/loop/LoopPlugin.kt @@ -55,7 +55,7 @@ import info.nightscout.plugins.R import info.nightscout.plugins.aps.loop.events.EventLoopSetLastRunGui import info.nightscout.plugins.aps.loop.events.EventLoopUpdateGui import info.nightscout.plugins.aps.loop.events.EventNewOpenLoopNotification -import info.nightscout.plugins.configBuilder.RunningConfiguration +import info.nightscout.interfaces.configBuilder.RunningConfiguration import info.nightscout.plugins.pump.virtual.VirtualPumpPlugin import info.nightscout.plugins.sync.nsclient.extensions.buildDeviceStatus import info.nightscout.rx.AapsSchedulers diff --git a/plugins/main/src/main/java/info/nightscout/plugins/sync/nsShared/StoreDataForDb.kt b/plugins/main/src/main/java/info/nightscout/plugins/sync/nsShared/StoreDataForDb.kt index bcf70e2841..196da55760 100644 --- a/plugins/main/src/main/java/info/nightscout/plugins/sync/nsShared/StoreDataForDb.kt +++ b/plugins/main/src/main/java/info/nightscout/plugins/sync/nsShared/StoreDataForDb.kt @@ -36,13 +36,11 @@ import info.nightscout.interfaces.Constants import info.nightscout.interfaces.XDripBroadcast import info.nightscout.interfaces.logging.UserEntryLogger import info.nightscout.interfaces.notifications.Notification -import info.nightscout.interfaces.plugin.ActivePlugin -import info.nightscout.interfaces.sync.NsClient import info.nightscout.plugins.R import info.nightscout.plugins.pump.virtual.VirtualPumpPlugin import info.nightscout.plugins.source.NSClientSourcePlugin -import info.nightscout.plugins.sync.nsShared.events.EventNSClientNewLog import info.nightscout.rx.bus.RxBus +import info.nightscout.rx.events.EventNSClientNewLog import info.nightscout.rx.logging.AAPSLogger import info.nightscout.rx.logging.LTag import info.nightscout.sdk.localmodel.treatment.NSBolus @@ -69,7 +67,6 @@ class StoreDataForDb @Inject constructor( private val sp: SP, private val uel: UserEntryLogger, private val dateUtil: DateUtil, - private val activePlugin: ActivePlugin, private val config: Config, private val nsClientSourcePlugin: NSClientSourcePlugin, private val xDripBroadcast: XDripBroadcast, @@ -122,7 +119,7 @@ class StoreDataForDb @Inject constructor( else put(key, 1) private fun storeGlucoseValuesToDb() { - rxBus.send(EventNSClientNewLog("PROCESSING BG", "", activePlugin.activeNsClient?.version ?: NsClient.Version.V3)) + rxBus.send(EventNSClientNewLog("PROCESSING BG", "")) if (glucoseValues.isNotEmpty()) repository.runTransactionForResult(CgmSourceTransaction(glucoseValues, emptyList(), null)) @@ -154,11 +151,11 @@ class StoreDataForDb @Inject constructor( sendLog("GlucoseValue", GlucoseValue::class.java.simpleName) SystemClock.sleep(pause) - rxBus.send(EventNSClientNewLog("DONE BG", "", activePlugin.activeNsClient?.version ?: NsClient.Version.V3)) + rxBus.send(EventNSClientNewLog("DONE BG", "")) } fun storeTreatmentsToDb() { - rxBus.send(EventNSClientNewLog("PROCESSING TR", "", activePlugin.activeNsClient?.version ?: NsClient.Version.V3)) + rxBus.send(EventNSClientNewLog("PROCESSING TR", "")) if (boluses.isNotEmpty()) repository.runTransactionForResult(SyncNsBolusTransaction(boluses)) @@ -734,32 +731,32 @@ class StoreDataForDb @Inject constructor( SystemClock.sleep(pause) uel.log(userEntries) - rxBus.send(EventNSClientNewLog("DONE TR", "", activePlugin.activeNsClient?.version ?: NsClient.Version.V3)) + rxBus.send(EventNSClientNewLog("DONE TR", "")) } private fun sendLog(item: String, clazz: String) { inserted[clazz]?.let { - rxBus.send(EventNSClientNewLog("INSERT", "$item $it", activePlugin.activeNsClient?.version ?: NsClient.Version.V3)) + rxBus.send(EventNSClientNewLog("INSERT", "$item $it")) } inserted.remove(clazz) updated[clazz]?.let { - rxBus.send(EventNSClientNewLog("UPDATE", "$item $it", activePlugin.activeNsClient?.version ?: NsClient.Version.V3)) + rxBus.send(EventNSClientNewLog("UPDATE", "$item $it")) } updated.remove(clazz) invalidated[clazz]?.let { - rxBus.send(EventNSClientNewLog("INVALIDATE", "$item $it", activePlugin.activeNsClient?.version ?: NsClient.Version.V3)) + rxBus.send(EventNSClientNewLog("INVALIDATE", "$item $it")) } invalidated.remove(clazz) nsIdUpdated[clazz]?.let { - rxBus.send(EventNSClientNewLog("NS_ID", "$item $it", activePlugin.activeNsClient?.version ?: NsClient.Version.V3)) + rxBus.send(EventNSClientNewLog("NS_ID", "$item $it")) } nsIdUpdated.remove(clazz) durationUpdated[clazz]?.let { - rxBus.send(EventNSClientNewLog("DURATION", "$item $it", activePlugin.activeNsClient?.version ?: NsClient.Version.V3)) + rxBus.send(EventNSClientNewLog("DURATION", "$item $it")) } durationUpdated.remove(clazz) ended[clazz]?.let { - rxBus.send(EventNSClientNewLog("CUT", "$item $it", activePlugin.activeNsClient?.version ?: NsClient.Version.V3)) + rxBus.send(EventNSClientNewLog("CUT", "$item $it")) } ended.remove(clazz) } diff --git a/plugins/main/src/main/java/info/nightscout/plugins/sync/nsShared/events/EventNSClientStatus.kt b/plugins/main/src/main/java/info/nightscout/plugins/sync/nsShared/events/EventNSClientStatus.kt index 3f567e9f97..88c7c1d571 100644 --- a/plugins/main/src/main/java/info/nightscout/plugins/sync/nsShared/events/EventNSClientStatus.kt +++ b/plugins/main/src/main/java/info/nightscout/plugins/sync/nsShared/events/EventNSClientStatus.kt @@ -4,6 +4,6 @@ import android.content.Context import info.nightscout.interfaces.sync.NsClient import info.nightscout.rx.events.EventStatus -class EventNSClientStatus(var text: String, val version: NsClient.Version) : EventStatus() { +class EventNSClientStatus(var text: String) : EventStatus() { override fun getStatus(context: Context): String = text } \ No newline at end of file diff --git a/plugins/main/src/main/java/info/nightscout/plugins/sync/nsclient/NSClientPlugin.kt b/plugins/main/src/main/java/info/nightscout/plugins/sync/nsclient/NSClientPlugin.kt index 60fe9cba87..59e9f70eff 100644 --- a/plugins/main/src/main/java/info/nightscout/plugins/sync/nsclient/NSClientPlugin.kt +++ b/plugins/main/src/main/java/info/nightscout/plugins/sync/nsclient/NSClientPlugin.kt @@ -26,7 +26,6 @@ import info.nightscout.interfaces.sync.Sync import info.nightscout.interfaces.utils.HtmlHelper.fromHtml import info.nightscout.plugins.R import info.nightscout.plugins.sync.nsShared.NSClientFragment -import info.nightscout.plugins.sync.nsShared.events.EventNSClientNewLog import info.nightscout.plugins.sync.nsShared.events.EventNSClientResend import info.nightscout.plugins.sync.nsShared.events.EventNSClientStatus import info.nightscout.plugins.sync.nsShared.events.EventNSClientUpdateGUI @@ -37,6 +36,7 @@ import info.nightscout.rx.AapsSchedulers import info.nightscout.rx.bus.RxBus import info.nightscout.rx.events.EventAppExit import info.nightscout.rx.events.EventChargingState +import info.nightscout.rx.events.EventNSClientNewLog import info.nightscout.rx.events.EventNetworkChange import info.nightscout.rx.events.EventPreferenceChange import info.nightscout.rx.events.EventSWSyncStatus @@ -92,12 +92,10 @@ class NSClientPlugin @Inject constructor( .toObservable(EventNSClientStatus::class.java) .observeOn(aapsSchedulers.io) .subscribe({ event -> - if (event.version == NsClient.Version.V1) { status = event.getStatus(context) rxBus.send(EventNSClientUpdateGUI()) // Pass to setup wizard rxBus.send(EventSWSyncStatus(event.getStatus(context))) - } }, fabricPrivacy::logException) disposable += rxBus .toObservable(EventNetworkChange::class.java) @@ -115,7 +113,6 @@ class NSClientPlugin @Inject constructor( .toObservable(EventNSClientNewLog::class.java) .observeOn(aapsSchedulers.io) .subscribe({ event: EventNSClientNewLog -> - if (event.version != NsClient.Version.V1) return@subscribe addToLog(event) aapsLogger.debug(LTag.NSCLIENT, event.action + " " + event.logText) }, fabricPrivacy::logException) diff --git a/plugins/main/src/main/java/info/nightscout/plugins/sync/nsclient/data/NSDeviceStatusHandler.kt b/plugins/main/src/main/java/info/nightscout/plugins/sync/nsclient/data/NSDeviceStatusHandler.kt index 84338e0ffd..90a4e9d096 100644 --- a/plugins/main/src/main/java/info/nightscout/plugins/sync/nsclient/data/NSDeviceStatusHandler.kt +++ b/plugins/main/src/main/java/info/nightscout/plugins/sync/nsclient/data/NSDeviceStatusHandler.kt @@ -1,12 +1,11 @@ package info.nightscout.plugins.sync.nsclient.data import info.nightscout.interfaces.Config +import info.nightscout.interfaces.configBuilder.RunningConfiguration import info.nightscout.interfaces.nsclient.ProcessedDeviceStatusData -import info.nightscout.interfaces.sync.NsClient import info.nightscout.interfaces.utils.HtmlHelper import info.nightscout.interfaces.utils.JsonHelper import info.nightscout.plugins.R -import info.nightscout.plugins.configBuilder.RunningConfiguration import info.nightscout.sdk.remotemodel.RemoteDeviceStatus import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.utils.DateUtil @@ -75,7 +74,7 @@ class NSDeviceStatusHandler @Inject constructor( private val processedDeviceStatusData: ProcessedDeviceStatusData ) { - fun handleNewData(deviceStatuses: Array, version: NsClient.Version) { + fun handleNewData(deviceStatuses: Array) { var configurationDetected = false for (i in deviceStatuses.size - 1 downTo 0) { val nsDeviceStatus = deviceStatuses[i] @@ -87,7 +86,7 @@ class NSDeviceStatusHandler @Inject constructor( if (config.NSCLIENT && !configurationDetected) nsDeviceStatus.configuration?.let { // copy configuration of Insulin and Sensitivity from main AAPS - runningConfiguration.apply(it, version) + runningConfiguration.apply(it) configurationDetected = true // pick only newest } } diff --git a/plugins/main/src/main/java/info/nightscout/plugins/sync/nsclient/extensions/DeviceStatusExtension.kt b/plugins/main/src/main/java/info/nightscout/plugins/sync/nsclient/extensions/DeviceStatusExtension.kt index caeecb48db..8e2ef28855 100644 --- a/plugins/main/src/main/java/info/nightscout/plugins/sync/nsclient/extensions/DeviceStatusExtension.kt +++ b/plugins/main/src/main/java/info/nightscout/plugins/sync/nsclient/extensions/DeviceStatusExtension.kt @@ -8,7 +8,7 @@ import info.nightscout.interfaces.aps.Loop import info.nightscout.interfaces.iob.IobCobCalculator import info.nightscout.interfaces.profile.ProfileFunction import info.nightscout.interfaces.pump.Pump -import info.nightscout.plugins.configBuilder.RunningConfiguration +import info.nightscout.interfaces.configBuilder.RunningConfiguration import info.nightscout.plugins.sync.nsShared.extensions.json import info.nightscout.shared.utils.DateUtil import org.json.JSONObject diff --git a/plugins/main/src/main/java/info/nightscout/plugins/sync/nsclient/services/NSClientService.kt b/plugins/main/src/main/java/info/nightscout/plugins/sync/nsclient/services/NSClientService.kt index c912ca0cd3..556546cc7a 100644 --- a/plugins/main/src/main/java/info/nightscout/plugins/sync/nsclient/services/NSClientService.kt +++ b/plugins/main/src/main/java/info/nightscout/plugins/sync/nsclient/services/NSClientService.kt @@ -32,7 +32,7 @@ import info.nightscout.plugins.general.overview.notifications.NotificationWithAc import info.nightscout.plugins.profile.ProfilePlugin import info.nightscout.plugins.source.NSClientSourcePlugin import info.nightscout.plugins.sync.nsShared.StoreDataForDb -import info.nightscout.plugins.sync.nsShared.events.EventNSClientNewLog +import info.nightscout.rx.events.EventNSClientNewLog import info.nightscout.plugins.sync.nsShared.events.EventNSClientStatus import info.nightscout.plugins.sync.nsShared.events.EventNSClientUpdateGUI import info.nightscout.plugins.sync.nsclient.NSClientPlugin @@ -210,13 +210,13 @@ class NSClientService : DaggerService(), NsClient.NSClientService { connectionStatus += ')' isConnected = true hasWriteAuth = ack.write && ack.writeTreatment - rxBus.send(EventNSClientStatus(connectionStatus, NsClient.Version.V1)) - rxBus.send(EventNSClientNewLog("AUTH", connectionStatus, NsClient.Version.V1)) + rxBus.send(EventNSClientStatus(connectionStatus)) + rxBus.send(EventNSClientNewLog("AUTH", connectionStatus)) if (!ack.write) { - rxBus.send(EventNSClientNewLog("ERROR", "Write permission not granted ", NsClient.Version.V1)) + rxBus.send(EventNSClientNewLog("ERROR", "Write permission not granted ")) } if (!ack.writeTreatment) { - rxBus.send(EventNSClientNewLog("ERROR", "Write treatment permission not granted ", NsClient.Version.V1)) + rxBus.send(EventNSClientNewLog("ERROR", "Write treatment permission not granted ")) } if (!hasWriteAuth) { val noWritePerm = Notification(Notification.NSCLIENT_NO_WRITE_PERMISSION, rh.gs(R.string.no_write_permission), Notification.URGENT) @@ -241,19 +241,19 @@ class NSClientService : DaggerService(), NsClient.NSClientService { readPreferences() @Suppress("DEPRECATION") if (nsAPISecret != "") nsApiHashCode = Hashing.sha1().hashString(nsAPISecret, Charsets.UTF_8).toString() - rxBus.send(EventNSClientStatus("Initializing", NsClient.Version.V1)) + rxBus.send(EventNSClientStatus("Initializing")) if (!nsClientPlugin.isAllowed) { - rxBus.send(EventNSClientNewLog("NSCLIENT", nsClientPlugin.blockingReason, NsClient.Version.V1)) - rxBus.send(EventNSClientStatus(nsClientPlugin.blockingReason, NsClient.Version.V1)) + rxBus.send(EventNSClientNewLog("NSCLIENT", nsClientPlugin.blockingReason)) + rxBus.send(EventNSClientStatus(nsClientPlugin.blockingReason)) } else if (sp.getBoolean(R.string.key_ns_client_paused, false)) { - rxBus.send(EventNSClientNewLog("NSCLIENT", "paused", NsClient.Version.V1)) - rxBus.send(EventNSClientStatus("Paused", NsClient.Version.V1)) + rxBus.send(EventNSClientNewLog("NSCLIENT", "paused")) + rxBus.send(EventNSClientStatus("Paused")) } else if (!nsEnabled) { - rxBus.send(EventNSClientNewLog("NSCLIENT", "disabled", NsClient.Version.V1)) - rxBus.send(EventNSClientStatus("Disabled", NsClient.Version.V1)) + rxBus.send(EventNSClientNewLog("NSCLIENT", "disabled")) + rxBus.send(EventNSClientStatus("Disabled")) } else if (nsURL != "" && (config.isEngineeringMode() || nsURL.lowercase(Locale.getDefault()).startsWith("https://"))) { try { - rxBus.send(EventNSClientStatus("Connecting ...", NsClient.Version.V1)) + rxBus.send(EventNSClientStatus("Connecting ...")) val opt = IO.Options() opt.forceNew = true opt.reconnection = true @@ -264,7 +264,7 @@ class NSClientService : DaggerService(), NsClient.NSClientService { socket.on(Socket.EVENT_CONNECT_ERROR, onError) socket.on(Socket.EVENT_CONNECT_TIMEOUT, onError) socket.on(Socket.EVENT_PING, onPing) - rxBus.send(EventNSClientNewLog("NSCLIENT", "do connect", NsClient.Version.V1)) + rxBus.send(EventNSClientNewLog("NSCLIENT", "do connect")) socket.connect() socket.on("dataUpdate", onDataUpdate) socket.on("announcement", onAnnouncement) @@ -273,25 +273,25 @@ class NSClientService : DaggerService(), NsClient.NSClientService { socket.on("clear_alarm", onClearAlarm) } } catch (e: URISyntaxException) { - rxBus.send(EventNSClientNewLog("NSCLIENT", "Wrong URL syntax", NsClient.Version.V1)) - rxBus.send(EventNSClientStatus("Wrong URL syntax", NsClient.Version.V1)) + rxBus.send(EventNSClientNewLog("NSCLIENT", "Wrong URL syntax")) + rxBus.send(EventNSClientStatus("Wrong URL syntax")) } catch (e: RuntimeException) { - rxBus.send(EventNSClientNewLog("NSCLIENT", "Wrong URL syntax", NsClient.Version.V1)) - rxBus.send(EventNSClientStatus("Wrong URL syntax", NsClient.Version.V1)) + rxBus.send(EventNSClientNewLog("NSCLIENT", "Wrong URL syntax")) + rxBus.send(EventNSClientStatus("Wrong URL syntax")) } } else if (nsURL.lowercase(Locale.getDefault()).startsWith("http://")) { - rxBus.send(EventNSClientNewLog("NSCLIENT", "NS URL not encrypted", NsClient.Version.V1)) - rxBus.send(EventNSClientStatus("Not encrypted", NsClient.Version.V1)) + rxBus.send(EventNSClientNewLog("NSCLIENT", "NS URL not encrypted")) + rxBus.send(EventNSClientStatus("Not encrypted")) } else { - rxBus.send(EventNSClientNewLog("NSCLIENT", "No NS URL specified", NsClient.Version.V1)) - rxBus.send(EventNSClientStatus("Not configured", NsClient.Version.V1)) + rxBus.send(EventNSClientNewLog("NSCLIENT", "No NS URL specified")) + rxBus.send(EventNSClientStatus("Not configured")) } } private val onConnect = Emitter.Listener { connectCounter++ val socketId = socket?.id() ?: "NULL" - rxBus.send(EventNSClientNewLog("NSCLIENT", "connect #$connectCounter event. ID: $socketId", NsClient.Version.V1)) + rxBus.send(EventNSClientNewLog("NSCLIENT", "connect #$connectCounter event. ID: $socketId")) if (socket != null) sendAuthMessage(NSAuthAck(rxBus)) watchdog() } @@ -305,16 +305,16 @@ class NSClientService : DaggerService(), NsClient.NSClientService { reconnections.remove(r) } } - rxBus.send(EventNSClientNewLog("WATCHDOG", "connections in last " + WATCHDOG_INTERVAL_MINUTES + " minutes: " + reconnections.size + "/" + WATCHDOG_MAX_CONNECTIONS, NsClient.Version.V1)) + rxBus.send(EventNSClientNewLog("WATCHDOG", "connections in last " + WATCHDOG_INTERVAL_MINUTES + " minutes: " + reconnections.size + "/" + WATCHDOG_MAX_CONNECTIONS)) if (reconnections.size >= WATCHDOG_MAX_CONNECTIONS) { val n = Notification(Notification.NS_MALFUNCTION, rh.gs(R.string.ns_malfunction), Notification.URGENT) rxBus.send(EventNewNotification(n)) - rxBus.send(EventNSClientNewLog("WATCHDOG", "pausing for $WATCHDOG_RECONNECT_IN minutes", NsClient.Version.V1)) + rxBus.send(EventNSClientNewLog("WATCHDOG", "pausing for $WATCHDOG_RECONNECT_IN minutes")) nsClientPlugin.pause(true) rxBus.send(EventNSClientUpdateGUI()) Thread { SystemClock.sleep(mins(WATCHDOG_RECONNECT_IN.toLong()).msecs()) - rxBus.send(EventNSClientNewLog("WATCHDOG", "re-enabling NSClient", NsClient.Version.V1)) + rxBus.send(EventNSClientNewLog("WATCHDOG", "re-enabling NSClient")) nsClientPlugin.pause(false) }.start() } @@ -323,7 +323,7 @@ class NSClientService : DaggerService(), NsClient.NSClientService { private val onDisconnect = Emitter.Listener { args -> aapsLogger.debug(LTag.NSCLIENT, "disconnect reason: {}", *args) - rxBus.send(EventNSClientNewLog("NSCLIENT", "disconnect event", NsClient.Version.V1)) + rxBus.send(EventNSClientNewLog("NSCLIENT", "disconnect event")) } @Synchronized fun destroy() { @@ -335,7 +335,7 @@ class NSClientService : DaggerService(), NsClient.NSClientService { socket?.off("alarm") socket?.off("urgent_alarm") socket?.off("clear_alarm") - rxBus.send(EventNSClientNewLog("NSCLIENT", "destroy", NsClient.Version.V1)) + rxBus.send(EventNSClientNewLog("NSCLIENT", "destroy")) isConnected = false hasWriteAuth = false socket?.disconnect() @@ -354,7 +354,7 @@ class NSClientService : DaggerService(), NsClient.NSClientService { aapsLogger.error("Unhandled exception", e) return } - rxBus.send(EventNSClientNewLog("AUTH", "requesting auth", NsClient.Version.V1)) + rxBus.send(EventNSClientNewLog("AUTH", "requesting auth")) socket?.emit("authorize", authMessage, ack) } @@ -370,10 +370,10 @@ class NSClientService : DaggerService(), NsClient.NSClientService { if (args.isNotEmpty() && args[0] != null) { msg = args[0].toString() } - rxBus.send(EventNSClientNewLog("ERROR", msg, NsClient.Version.V1)) + rxBus.send(EventNSClientNewLog("ERROR", msg)) } private val onPing = Emitter.Listener { - rxBus.send(EventNSClientNewLog("PING", "received", NsClient.Version.V1)) + rxBus.send(EventNSClientNewLog("PING", "received")) // send data if there is something waiting resend("Ping received") } @@ -443,7 +443,7 @@ class NSClientService : DaggerService(), NsClient.NSClientService { val data: JSONObject try { data = args[0] as JSONObject - rxBus.send(EventNSClientNewLog("CLEARALARM", "received", NsClient.Version.V1)) + rxBus.send(EventNSClientNewLog("CLEARALARM", "received")) rxBus.send(EventDismissNotification(Notification.NS_ALARM)) rxBus.send(EventDismissNotification(Notification.NS_URGENT_ALARM)) aapsLogger.debug(LTag.NSCLIENT, data.toString()) @@ -462,19 +462,19 @@ class NSClientService : DaggerService(), NsClient.NSClientService { try { // delta means only increment/changes are coming val isDelta = data.has("delta") - rxBus.send(EventNSClientNewLog("DATA", "Data packet #" + dataCounter++ + if (isDelta) " delta" else " full", NsClient.Version.V1)) + rxBus.send(EventNSClientNewLog("DATA", "Data packet #" + dataCounter++ + if (isDelta) " delta" else " full")) if (data.has("status")) { val status = data.getJSONObject("status") nsSettingsStatus.handleNewData(status) } else if (!isDelta) { - rxBus.send(EventNSClientNewLog("ERROR", "Unsupported Nightscout version ", NsClient.Version.V1)) + rxBus.send(EventNSClientNewLog("ERROR", "Unsupported Nightscout version ")) } if (data.has("profiles")) { val profiles = data.getJSONArray("profiles") if (profiles.length() > 0) { // take the newest val profileStoreJson = profiles[profiles.length() - 1] as JSONObject - rxBus.send(EventNSClientNewLog("PROFILE", "profile received", NsClient.Version.V1)) + rxBus.send(EventNSClientNewLog("PROFILE", "profile received")) dataWorkerStorage.enqueue( OneTimeWorkRequest.Builder(ProfilePlugin.NSProfileWorker::class.java) .setInputData(dataWorkerStorage.storeInputData(profileStoreJson)) @@ -485,7 +485,7 @@ class NSClientService : DaggerService(), NsClient.NSClientService { if (data.has("treatments")) { val treatments = data.getJSONArray("treatments") val addedOrUpdatedTreatments = JSONArray() - if (treatments.length() > 0) rxBus.send(EventNSClientNewLog("DATA", "received " + treatments.length() + " treatments", NsClient.Version.V1)) + if (treatments.length() > 0) rxBus.send(EventNSClientNewLog("DATA", "received " + treatments.length() + " treatments")) for (index in 0 until treatments.length()) { val jsonTreatment = treatments.getJSONObject(index) val action = safeGetStringAllowNull(jsonTreatment, "action", null) @@ -510,13 +510,13 @@ class NSClientService : DaggerService(), NsClient.NSClientService { }.create() val devicestatuses = gson.fromJson(data.getString("devicestatus"), Array::class.java) if (devicestatuses.isNotEmpty()) { - rxBus.send(EventNSClientNewLog("DATA", "received " + devicestatuses.size + " device statuses", NsClient.Version.V1)) - nsDeviceStatusHandler.handleNewData(devicestatuses, NsClient.Version.V1) + rxBus.send(EventNSClientNewLog("DATA", "received " + devicestatuses.size + " device statuses")) + nsDeviceStatusHandler.handleNewData(devicestatuses) } } if (data.has("food")) { val foods = data.getJSONArray("food") - if (foods.length() > 0) rxBus.send(EventNSClientNewLog("DATA", "received " + foods.length() + " foods", NsClient.Version.V1)) + if (foods.length() > 0) rxBus.send(EventNSClientNewLog("DATA", "received " + foods.length() + " foods")) dataWorkerStorage.enqueue( OneTimeWorkRequest.Builder(FoodPlugin.FoodWorker::class.java) .setInputData(dataWorkerStorage.storeInputData(foods)) @@ -525,7 +525,7 @@ class NSClientService : DaggerService(), NsClient.NSClientService { } if (data.has("mbgs")) { val mbgArray = data.getJSONArray("mbgs") - if (mbgArray.length() > 0) rxBus.send(EventNSClientNewLog("DATA", "received " + mbgArray.length() + " mbgs", NsClient.Version.V1)) + if (mbgArray.length() > 0) rxBus.send(EventNSClientNewLog("DATA", "received " + mbgArray.length() + " mbgs")) dataWorkerStorage.enqueue( OneTimeWorkRequest.Builder(NSClientMbgWorker::class.java) .setInputData(dataWorkerStorage.storeInputData(mbgArray)) @@ -534,13 +534,13 @@ class NSClientService : DaggerService(), NsClient.NSClientService { } if (data.has("cals")) { val cals = data.getJSONArray("cals") - if (cals.length() > 0) rxBus.send(EventNSClientNewLog("DATA", "received " + cals.length() + " cals", NsClient.Version.V1)) + if (cals.length() > 0) rxBus.send(EventNSClientNewLog("DATA", "received " + cals.length() + " cals")) // Calibrations ignored } if (data.has("sgvs")) { val sgvs = data.getJSONArray("sgvs") if (sgvs.length() > 0) { - rxBus.send(EventNSClientNewLog("DATA", "received " + sgvs.length() + " sgvs", NsClient.Version.V1)) + rxBus.send(EventNSClientNewLog("DATA", "received " + sgvs.length() + " sgvs")) // Objective0 sp.putBoolean(R.string.key_objectives_bg_is_available_in_ns, true) dataWorkerStorage @@ -553,7 +553,7 @@ class NSClientService : DaggerService(), NsClient.NSClientService { .enqueue() } } - rxBus.send(EventNSClientNewLog("LAST", dateUtil.dateAndTimeString(latestDateInReceivedData), NsClient.Version.V1)) + rxBus.send(EventNSClientNewLog("LAST", dateUtil.dateAndTimeString(latestDateInReceivedData))) } catch (e: JSONException) { aapsLogger.error("Unhandled exception", e) } @@ -576,7 +576,7 @@ class NSClientService : DaggerService(), NsClient.NSClientService { rxBus.send( EventNSClientNewLog( "DBUPDATE $collection", "Sent " + originalObject.javaClass.simpleName + " " + - "" + _id + " " + data + progress, NsClient.Version.V1 + "" + _id + " " + data + progress ) ) } catch (e: JSONException) { @@ -591,7 +591,7 @@ class NSClientService : DaggerService(), NsClient.NSClientService { message.put("collection", collection) message.put("data", data) socket?.emit("dbAdd", message, NSAddAck(aapsLogger, rxBus, originalObject)) - rxBus.send(EventNSClientNewLog("DBADD $collection", "Sent " + originalObject.javaClass.simpleName + " " + data + " " + progress, NsClient.Version.V1)) + rxBus.send(EventNSClientNewLog("DBADD $collection", "Sent " + originalObject.javaClass.simpleName + " " + data + " " + progress)) } catch (e: JSONException) { aapsLogger.error("Unhandled exception", e) } @@ -600,7 +600,7 @@ class NSClientService : DaggerService(), NsClient.NSClientService { fun sendAlarmAck(alarmAck: AlarmAck) { if (!isConnected || !hasWriteAuth) return socket?.emit("ack", alarmAck.level, alarmAck.group, alarmAck.silenceTime) - rxBus.send(EventNSClientNewLog("ALARMACK ", alarmAck.level.toString() + " " + alarmAck.group + " " + alarmAck.silenceTime, NsClient.Version.V1)) + rxBus.send(EventNSClientNewLog("ALARMACK ", alarmAck.level.toString() + " " + alarmAck.group + " " + alarmAck.silenceTime)) } fun resend(reason: String) { @@ -616,9 +616,9 @@ class NSClientService : DaggerService(), NsClient.NSClientService { // "AndroidAPS:NSClientService_onDataUpdate") // wakeLock.acquire(mins(10).msecs()) try { - rxBus.send(EventNSClientNewLog("QUEUE", "Resend started: $reason", NsClient.Version.V1)) + rxBus.send(EventNSClientNewLog("QUEUE", "Resend started: $reason")) dataSyncSelector.doUpload() - rxBus.send(EventNSClientNewLog("QUEUE", "Resend ended: $reason", NsClient.Version.V1)) + rxBus.send(EventNSClientNewLog("QUEUE", "Resend ended: $reason")) } finally { // if (wakeLock.isHeld) wakeLock.release() } @@ -636,7 +636,7 @@ class NSClientService : DaggerService(), NsClient.NSClientService { val nsAlarm = NSAlarm(announcement) val notification: Notification = NotificationWithAction(injector, nsAlarm) rxBus.send(EventNewNotification(notification)) - rxBus.send(EventNSClientNewLog("ANNOUNCEMENT", safeGetString(announcement, "message", "received"), NsClient.Version.V1)) + rxBus.send(EventNSClientNewLog("ANNOUNCEMENT", safeGetString(announcement, "message", "received"))) aapsLogger.debug(LTag.NSCLIENT, announcement.toString()) } } @@ -650,7 +650,7 @@ class NSClientService : DaggerService(), NsClient.NSClientService { val notification: Notification = NotificationWithAction(injector, nsAlarm) rxBus.send(EventNewNotification(notification)) } - rxBus.send(EventNSClientNewLog("ALARM", safeGetString(alarm, "message", "received"), NsClient.Version.V1)) + rxBus.send(EventNSClientNewLog("ALARM", safeGetString(alarm, "message", "received"))) aapsLogger.debug(LTag.NSCLIENT, alarm.toString()) } } @@ -664,7 +664,7 @@ class NSClientService : DaggerService(), NsClient.NSClientService { val notification: Notification = NotificationWithAction(injector, nsAlarm) rxBus.send(EventNewNotification(notification)) } - rxBus.send(EventNSClientNewLog("URGENTALARM", safeGetString(alarm, "message", "received"), NsClient.Version.V1)) + rxBus.send(EventNSClientNewLog("URGENTALARM", safeGetString(alarm, "message", "received"))) aapsLogger.debug(LTag.NSCLIENT, alarm.toString()) } } diff --git a/plugins/main/src/main/java/info/nightscout/plugins/sync/nsclient/workers/NSClientAddAckWorker.kt b/plugins/main/src/main/java/info/nightscout/plugins/sync/nsclient/workers/NSClientAddAckWorker.kt index e6b1f9c58e..9045e93e88 100644 --- a/plugins/main/src/main/java/info/nightscout/plugins/sync/nsclient/workers/NSClientAddAckWorker.kt +++ b/plugins/main/src/main/java/info/nightscout/plugins/sync/nsclient/workers/NSClientAddAckWorker.kt @@ -36,12 +36,11 @@ import info.nightscout.interfaces.sync.DataSyncSelector.PairProfileSwitch import info.nightscout.interfaces.sync.DataSyncSelector.PairTemporaryBasal import info.nightscout.interfaces.sync.DataSyncSelector.PairTemporaryTarget import info.nightscout.interfaces.sync.DataSyncSelector.PairTherapyEvent -import info.nightscout.interfaces.sync.NsClient import info.nightscout.plugins.R -import info.nightscout.plugins.sync.nsShared.events.EventNSClientNewLog import info.nightscout.plugins.sync.nsclient.acks.NSAddAck import info.nightscout.rx.AapsSchedulers import info.nightscout.rx.bus.RxBus +import info.nightscout.rx.events.EventNSClientNewLog import info.nightscout.rx.logging.AAPSLogger import info.nightscout.rx.logging.LTag import info.nightscout.shared.sharedPreferences.SP @@ -83,7 +82,7 @@ class NSClientAddAckWorker( dataSyncSelector.confirmLastTempTargetsIdIfGreater(pair.updateRecordId) } .blockingGet() - rxBus.send(EventNSClientNewLog("DBADD", "Acked TemporaryTarget " + pair.value.interfaceIDs.nightscoutId, NsClient.Version.V1)) + rxBus.send(EventNSClientNewLog("DBADD", "Acked TemporaryTarget " + pair.value.interfaceIDs.nightscoutId)) // Send new if waiting dataSyncSelector.processChangedTempTargetsCompat() } @@ -102,7 +101,7 @@ class NSClientAddAckWorker( dataSyncSelector.confirmLastGlucoseValueIdIfGreater(pair.updateRecordId) } .blockingGet() - rxBus.send(EventNSClientNewLog("DBADD", "Acked GlucoseValue " + pair.value.interfaceIDs.nightscoutId, NsClient.Version.V1)) + rxBus.send(EventNSClientNewLog("DBADD", "Acked GlucoseValue " + pair.value.interfaceIDs.nightscoutId)) // Send new if waiting dataSyncSelector.processChangedGlucoseValuesCompat() } @@ -121,7 +120,7 @@ class NSClientAddAckWorker( dataSyncSelector.confirmLastFoodIdIfGreater(pair.updateRecordId) } .blockingGet() - rxBus.send(EventNSClientNewLog("DBADD", "Acked Food " + pair.value.interfaceIDs.nightscoutId, NsClient.Version.V1)) + rxBus.send(EventNSClientNewLog("DBADD", "Acked Food " + pair.value.interfaceIDs.nightscoutId)) // Send new if waiting dataSyncSelector.processChangedFoodsCompat() } @@ -140,7 +139,7 @@ class NSClientAddAckWorker( dataSyncSelector.confirmLastTherapyEventIdIfGreater(pair.updateRecordId) } .blockingGet() - rxBus.send(EventNSClientNewLog("DBADD", "Acked TherapyEvent " + pair.value.interfaceIDs.nightscoutId, NsClient.Version.V1)) + rxBus.send(EventNSClientNewLog("DBADD", "Acked TherapyEvent " + pair.value.interfaceIDs.nightscoutId)) // Send new if waiting dataSyncSelector.processChangedTherapyEventsCompat() } @@ -159,7 +158,7 @@ class NSClientAddAckWorker( dataSyncSelector.confirmLastBolusIdIfGreater(pair.updateRecordId) } .blockingGet() - rxBus.send(EventNSClientNewLog("DBADD", "Acked Bolus " + pair.value.interfaceIDs.nightscoutId, NsClient.Version.V1)) + rxBus.send(EventNSClientNewLog("DBADD", "Acked Bolus " + pair.value.interfaceIDs.nightscoutId)) // Send new if waiting dataSyncSelector.processChangedBolusesCompat() } @@ -178,7 +177,7 @@ class NSClientAddAckWorker( dataSyncSelector.confirmLastCarbsIdIfGreater(pair.updateRecordId) } .blockingGet() - rxBus.send(EventNSClientNewLog("DBADD", "Acked Carbs " + pair.value.interfaceIDs.nightscoutId, NsClient.Version.V1)) + rxBus.send(EventNSClientNewLog("DBADD", "Acked Carbs " + pair.value.interfaceIDs.nightscoutId)) // Send new if waiting dataSyncSelector.processChangedCarbsCompat() } @@ -197,7 +196,7 @@ class NSClientAddAckWorker( dataSyncSelector.confirmLastBolusCalculatorResultsIdIfGreater(pair.updateRecordId) } .blockingGet() - rxBus.send(EventNSClientNewLog("DBADD", "Acked BolusCalculatorResult " + pair.value.interfaceIDs.nightscoutId, NsClient.Version.V1)) + rxBus.send(EventNSClientNewLog("DBADD", "Acked BolusCalculatorResult " + pair.value.interfaceIDs.nightscoutId)) // Send new if waiting dataSyncSelector.processChangedBolusCalculatorResultsCompat() } @@ -216,7 +215,7 @@ class NSClientAddAckWorker( dataSyncSelector.confirmLastTemporaryBasalIdIfGreater(pair.updateRecordId) } .blockingGet() - rxBus.send(EventNSClientNewLog("DBADD", "Acked TemporaryBasal " + pair.value.interfaceIDs.nightscoutId, NsClient.Version.V1)) + rxBus.send(EventNSClientNewLog("DBADD", "Acked TemporaryBasal " + pair.value.interfaceIDs.nightscoutId)) // Send new if waiting dataSyncSelector.processChangedTemporaryBasalsCompat() } @@ -235,7 +234,7 @@ class NSClientAddAckWorker( dataSyncSelector.confirmLastExtendedBolusIdIfGreater(pair.updateRecordId) } .blockingGet() - rxBus.send(EventNSClientNewLog("DBADD", "Acked ExtendedBolus " + pair.value.interfaceIDs.nightscoutId, NsClient.Version.V1)) + rxBus.send(EventNSClientNewLog("DBADD", "Acked ExtendedBolus " + pair.value.interfaceIDs.nightscoutId)) // Send new if waiting dataSyncSelector.processChangedExtendedBolusesCompat() } @@ -254,7 +253,7 @@ class NSClientAddAckWorker( dataSyncSelector.confirmLastProfileSwitchIdIfGreater(pair.updateRecordId) } .blockingGet() - rxBus.send(EventNSClientNewLog("DBADD", "Acked ProfileSwitch " + pair.value.interfaceIDs.nightscoutId, NsClient.Version.V1)) + rxBus.send(EventNSClientNewLog("DBADD", "Acked ProfileSwitch " + pair.value.interfaceIDs.nightscoutId)) // Send new if waiting dataSyncSelector.processChangedProfileSwitchesCompat() } @@ -273,7 +272,7 @@ class NSClientAddAckWorker( dataSyncSelector.confirmLastEffectiveProfileSwitchIdIfGreater(pair.updateRecordId) } .blockingGet() - rxBus.send(EventNSClientNewLog("DBADD", "Acked EffectiveProfileSwitch " + pair.value.interfaceIDs.nightscoutId, NsClient.Version.V1)) + rxBus.send(EventNSClientNewLog("DBADD", "Acked EffectiveProfileSwitch " + pair.value.interfaceIDs.nightscoutId)) // Send new if waiting dataSyncSelector.processChangedEffectiveProfileSwitchesCompat() } @@ -292,14 +291,14 @@ class NSClientAddAckWorker( dataSyncSelector.confirmLastDeviceStatusIdIfGreater(deviceStatus.id) } .blockingGet() - rxBus.send(EventNSClientNewLog("DBADD", "Acked DeviceStatus " + deviceStatus.interfaceIDs.nightscoutId, NsClient.Version.V1)) + rxBus.send(EventNSClientNewLog("DBADD", "Acked DeviceStatus " + deviceStatus.interfaceIDs.nightscoutId)) // Send new if waiting dataSyncSelector.processChangedDeviceStatusesCompat() } is PairProfileStore -> { dataSyncSelector.confirmLastProfileStore(ack.originalObject.timestampSync) - rxBus.send(EventNSClientNewLog("DBADD", "Acked ProfileStore " + ack.id, NsClient.Version.V1)) + rxBus.send(EventNSClientNewLog("DBADD", "Acked ProfileStore " + ack.id)) } is PairOfflineEvent -> { @@ -316,7 +315,7 @@ class NSClientAddAckWorker( dataSyncSelector.confirmLastOfflineEventIdIfGreater(pair.updateRecordId) } .blockingGet() - rxBus.send(EventNSClientNewLog("DBADD", "Acked OfflineEvent " + pair.value.interfaceIDs.nightscoutId, NsClient.Version.V1)) + rxBus.send(EventNSClientNewLog("DBADD", "Acked OfflineEvent " + pair.value.interfaceIDs.nightscoutId)) // Send new if waiting dataSyncSelector.processChangedOfflineEventsCompat() } diff --git a/plugins/main/src/main/java/info/nightscout/plugins/sync/nsclient/workers/NSClientUpdateRemoveAckWorker.kt b/plugins/main/src/main/java/info/nightscout/plugins/sync/nsclient/workers/NSClientUpdateRemoveAckWorker.kt index 3b9902547f..4052d17fad 100644 --- a/plugins/main/src/main/java/info/nightscout/plugins/sync/nsclient/workers/NSClientUpdateRemoveAckWorker.kt +++ b/plugins/main/src/main/java/info/nightscout/plugins/sync/nsclient/workers/NSClientUpdateRemoveAckWorker.kt @@ -20,11 +20,10 @@ import info.nightscout.interfaces.sync.DataSyncSelector.PairProfileSwitch import info.nightscout.interfaces.sync.DataSyncSelector.PairTemporaryBasal import info.nightscout.interfaces.sync.DataSyncSelector.PairTemporaryTarget import info.nightscout.interfaces.sync.DataSyncSelector.PairTherapyEvent -import info.nightscout.interfaces.sync.NsClient -import info.nightscout.plugins.sync.nsShared.events.EventNSClientNewLog import info.nightscout.plugins.sync.nsclient.acks.NSUpdateAck import info.nightscout.rx.AapsSchedulers import info.nightscout.rx.bus.RxBus +import info.nightscout.rx.events.EventNSClientNewLog import info.nightscout.rx.logging.AAPSLogger import javax.inject.Inject @@ -51,7 +50,7 @@ class NSClientUpdateRemoveAckWorker( is PairTemporaryTarget -> { val pair = ack.originalObject dataSyncSelector.confirmLastTempTargetsIdIfGreater(pair.updateRecordId) - rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked TemporaryTarget" + ack._id, NsClient.Version.V1)) + rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked TemporaryTarget" + ack._id)) // Send new if waiting dataSyncSelector.processChangedTempTargetsCompat() ret = Result.success(workDataOf("ProcessedData" to pair.toString())) @@ -60,7 +59,7 @@ class NSClientUpdateRemoveAckWorker( is PairGlucoseValue -> { val pair = ack.originalObject dataSyncSelector.confirmLastGlucoseValueIdIfGreater(pair.updateRecordId) - rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked GlucoseValue " + ack._id, NsClient.Version.V1)) + rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked GlucoseValue " + ack._id)) // Send new if waiting dataSyncSelector.processChangedGlucoseValuesCompat() ret = Result.success(workDataOf("ProcessedData" to pair.toString())) @@ -69,7 +68,7 @@ class NSClientUpdateRemoveAckWorker( is PairFood -> { val pair = ack.originalObject dataSyncSelector.confirmLastFoodIdIfGreater(pair.updateRecordId) - rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked Food " + ack._id, NsClient.Version.V1)) + rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked Food " + ack._id)) // Send new if waiting dataSyncSelector.processChangedFoodsCompat() ret = Result.success(workDataOf("ProcessedData" to pair.toString())) @@ -78,7 +77,7 @@ class NSClientUpdateRemoveAckWorker( is PairTherapyEvent -> { val pair = ack.originalObject dataSyncSelector.confirmLastTherapyEventIdIfGreater(pair.updateRecordId) - rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked TherapyEvent " + ack._id, NsClient.Version.V1)) + rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked TherapyEvent " + ack._id)) // Send new if waiting dataSyncSelector.processChangedTherapyEventsCompat() ret = Result.success(workDataOf("ProcessedData" to pair.toString())) @@ -87,7 +86,7 @@ class NSClientUpdateRemoveAckWorker( is PairBolus -> { val pair = ack.originalObject dataSyncSelector.confirmLastBolusIdIfGreater(pair.updateRecordId) - rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked Bolus " + ack._id, NsClient.Version.V1)) + rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked Bolus " + ack._id)) // Send new if waiting dataSyncSelector.processChangedBolusesCompat() ret = Result.success(workDataOf("ProcessedData" to pair.toString())) @@ -96,7 +95,7 @@ class NSClientUpdateRemoveAckWorker( is PairCarbs -> { val pair = ack.originalObject dataSyncSelector.confirmLastCarbsIdIfGreater(pair.updateRecordId) - rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked Carbs " + ack._id, NsClient.Version.V1)) + rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked Carbs " + ack._id)) // Send new if waiting dataSyncSelector.processChangedCarbsCompat() ret = Result.success(workDataOf("ProcessedData" to pair.toString())) @@ -105,7 +104,7 @@ class NSClientUpdateRemoveAckWorker( is PairBolusCalculatorResult -> { val pair = ack.originalObject dataSyncSelector.confirmLastBolusCalculatorResultsIdIfGreater(pair.updateRecordId) - rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked BolusCalculatorResult " + ack._id, NsClient.Version.V1)) + rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked BolusCalculatorResult " + ack._id)) // Send new if waiting dataSyncSelector.processChangedBolusCalculatorResultsCompat() ret = Result.success(workDataOf("ProcessedData" to pair.toString())) @@ -114,7 +113,7 @@ class NSClientUpdateRemoveAckWorker( is PairTemporaryBasal -> { val pair = ack.originalObject dataSyncSelector.confirmLastTemporaryBasalIdIfGreater(pair.updateRecordId) - rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked TemporaryBasal " + ack._id, NsClient.Version.V1)) + rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked TemporaryBasal " + ack._id)) // Send new if waiting dataSyncSelector.processChangedTemporaryBasalsCompat() ret = Result.success(workDataOf("ProcessedData" to pair.toString())) @@ -123,7 +122,7 @@ class NSClientUpdateRemoveAckWorker( is PairExtendedBolus -> { val pair = ack.originalObject dataSyncSelector.confirmLastExtendedBolusIdIfGreater(pair.updateRecordId) - rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked ExtendedBolus " + ack._id, NsClient.Version.V1)) + rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked ExtendedBolus " + ack._id)) // Send new if waiting dataSyncSelector.processChangedExtendedBolusesCompat() ret = Result.success(workDataOf("ProcessedData" to pair.toString())) @@ -132,7 +131,7 @@ class NSClientUpdateRemoveAckWorker( is PairProfileSwitch -> { val pair = ack.originalObject dataSyncSelector.confirmLastProfileSwitchIdIfGreater(pair.updateRecordId) - rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked ProfileSwitch " + ack._id, NsClient.Version.V1)) + rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked ProfileSwitch " + ack._id)) // Send new if waiting dataSyncSelector.processChangedProfileSwitchesCompat() ret = Result.success(workDataOf("ProcessedData" to pair.toString())) @@ -141,7 +140,7 @@ class NSClientUpdateRemoveAckWorker( is PairEffectiveProfileSwitch -> { val pair = ack.originalObject dataSyncSelector.confirmLastEffectiveProfileSwitchIdIfGreater(pair.updateRecordId) - rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked EffectiveProfileSwitch " + ack._id, NsClient.Version.V1)) + rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked EffectiveProfileSwitch " + ack._id)) // Send new if waiting dataSyncSelector.processChangedEffectiveProfileSwitchesCompat() ret = Result.success(workDataOf("ProcessedData" to pair.toString())) @@ -150,7 +149,7 @@ class NSClientUpdateRemoveAckWorker( is PairOfflineEvent -> { val pair = ack.originalObject dataSyncSelector.confirmLastOfflineEventIdIfGreater(pair.updateRecordId) - rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked OfflineEvent" + ack._id, NsClient.Version.V1)) + rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked OfflineEvent" + ack._id)) // Send new if waiting dataSyncSelector.processChangedOfflineEventsCompat() ret = Result.success(workDataOf("ProcessedData" to pair.toString())) diff --git a/plugins/main/src/main/java/info/nightscout/plugins/sync/nsclientV3/NSClientV3Plugin.kt b/plugins/main/src/main/java/info/nightscout/plugins/sync/nsclientV3/NSClientV3Plugin.kt index 252b76dee1..1db450f092 100644 --- a/plugins/main/src/main/java/info/nightscout/plugins/sync/nsclientV3/NSClientV3Plugin.kt +++ b/plugins/main/src/main/java/info/nightscout/plugins/sync/nsclientV3/NSClientV3Plugin.kt @@ -25,7 +25,6 @@ import info.nightscout.interfaces.sync.Sync import info.nightscout.interfaces.utils.HtmlHelper import info.nightscout.plugins.R import info.nightscout.plugins.sync.nsShared.NSClientFragment -import info.nightscout.plugins.sync.nsShared.events.EventNSClientNewLog import info.nightscout.plugins.sync.nsShared.events.EventNSClientResend import info.nightscout.plugins.sync.nsShared.events.EventNSClientStatus import info.nightscout.plugins.sync.nsShared.events.EventNSClientUpdateGUI @@ -39,6 +38,7 @@ import info.nightscout.plugins.sync.nsclientV3.workers.LoadStatusWorker import info.nightscout.rx.AapsSchedulers import info.nightscout.rx.bus.RxBus import info.nightscout.rx.events.EventChargingState +import info.nightscout.rx.events.EventNSClientNewLog import info.nightscout.rx.events.EventNetworkChange import info.nightscout.rx.events.EventPreferenceChange import info.nightscout.rx.events.EventSWSyncStatus @@ -145,12 +145,10 @@ class NSClientV3Plugin @Inject constructor( .toObservable(EventNSClientStatus::class.java) .observeOn(aapsSchedulers.io) .subscribe({ event -> - if (event.version == NsClient.Version.V3) { status = event.getStatus(context) rxBus.send(EventNSClientUpdateGUI()) // Pass to setup wizard rxBus.send(EventSWSyncStatus(event.getStatus(context))) - } }, fabricPrivacy::logException) disposable += rxBus .toObservable(EventNetworkChange::class.java) @@ -168,7 +166,6 @@ class NSClientV3Plugin @Inject constructor( .toObservable(EventNSClientNewLog::class.java) .observeOn(aapsSchedulers.io) .subscribe({ event -> - if (event.version != NsClient.Version.V3) return@subscribe addToLog(event) aapsLogger.debug(LTag.NSCLIENT, event.action + " " + event.logText) }, fabricPrivacy::logException) @@ -291,9 +288,9 @@ class NSClientV3Plugin @Inject constructor( fun test() { if (workIsRunning(arrayOf(JOB_NAME))) - rxBus.send(EventNSClientNewLog("RUN", "Already running", NsClient.Version.V3)) + rxBus.send(EventNSClientNewLog("RUN", "Already running")) else { - rxBus.send(EventNSClientNewLog("RUN", "Starting next round", NsClient.Version.V3)) + rxBus.send(EventNSClientNewLog("RUN", "Starting next round")) WorkManager.getInstance(context) .beginUniqueWork( "NSCv3Load", diff --git a/plugins/main/src/main/java/info/nightscout/plugins/sync/nsclientV3/workers/LoadBgWorker.kt b/plugins/main/src/main/java/info/nightscout/plugins/sync/nsclientV3/workers/LoadBgWorker.kt index a2f8135e05..38185cd1c3 100644 --- a/plugins/main/src/main/java/info/nightscout/plugins/sync/nsclientV3/workers/LoadBgWorker.kt +++ b/plugins/main/src/main/java/info/nightscout/plugins/sync/nsclientV3/workers/LoadBgWorker.kt @@ -9,13 +9,12 @@ import androidx.work.WorkerParameters import androidx.work.workDataOf import dagger.android.HasAndroidInjector import info.nightscout.core.utils.receivers.DataWorkerStorage -import info.nightscout.interfaces.sync.NsClient import info.nightscout.plugins.R import info.nightscout.plugins.source.NSClientSourcePlugin import info.nightscout.plugins.sync.nsShared.StoreDataForDb -import info.nightscout.plugins.sync.nsShared.events.EventNSClientNewLog import info.nightscout.plugins.sync.nsclientV3.NSClientV3Plugin import info.nightscout.rx.bus.RxBus +import info.nightscout.rx.events.EventNSClientNewLog import info.nightscout.rx.logging.AAPSLogger import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.utils.DateUtil @@ -52,8 +51,7 @@ class LoadBgWorker( rxBus.send( EventNSClientNewLog( "RCV", - "${sgvs.size} SVGs from ${dateUtil.dateAndTimeAndSecondsString(nsClientV3Plugin.lastFetched.collections.entries)}", - NsClient.Version.V3 + "${sgvs.size} SVGs from ${dateUtil.dateAndTimeAndSecondsString(nsClientV3Plugin.lastFetched.collections.entries)}" ) ) // Objective0 @@ -65,7 +63,7 @@ class LoadBgWorker( OneTimeWorkRequest.Builder(NSClientSourcePlugin.NSClientSourceWorker::class.java).setInputData(dataWorkerStorage.storeInputData(sgvs)).build() ).then(OneTimeWorkRequest.Builder(LoadBgWorker::class.java).build()).enqueue() } else { - rxBus.send(EventNSClientNewLog("END", "No SGVs from ${dateUtil.dateAndTimeAndSecondsString(nsClientV3Plugin.lastFetched.collections.entries)}", NsClient.Version.V3)) + rxBus.send(EventNSClientNewLog("END", "No SGVs from ${dateUtil.dateAndTimeAndSecondsString(nsClientV3Plugin.lastFetched.collections.entries)}")) WorkManager.getInstance(context) .beginUniqueWork( NSClientV3Plugin.JOB_NAME, @@ -80,7 +78,7 @@ class LoadBgWorker( ret = Result.failure(workDataOf("Error" to error.toString())) } else { - rxBus.send(EventNSClientNewLog("END", "No new SGVs from ${dateUtil.dateAndTimeAndSecondsString(nsClientV3Plugin.lastFetched.collections.entries)}", NsClient.Version.V3)) + rxBus.send(EventNSClientNewLog("END", "No new SGVs from ${dateUtil.dateAndTimeAndSecondsString(nsClientV3Plugin.lastFetched.collections.entries)}")) WorkManager.getInstance(context) .beginUniqueWork( NSClientV3Plugin.JOB_NAME, diff --git a/plugins/main/src/main/java/info/nightscout/plugins/sync/nsclientV3/workers/LoadDeviceStatusWorker.kt b/plugins/main/src/main/java/info/nightscout/plugins/sync/nsclientV3/workers/LoadDeviceStatusWorker.kt index e204e429b7..b75fcde257 100644 --- a/plugins/main/src/main/java/info/nightscout/plugins/sync/nsclientV3/workers/LoadDeviceStatusWorker.kt +++ b/plugins/main/src/main/java/info/nightscout/plugins/sync/nsclientV3/workers/LoadDeviceStatusWorker.kt @@ -6,11 +6,10 @@ import androidx.work.WorkerParameters import androidx.work.workDataOf import dagger.android.HasAndroidInjector import info.nightscout.core.utils.receivers.DataWorkerStorage -import info.nightscout.interfaces.sync.NsClient -import info.nightscout.plugins.sync.nsShared.events.EventNSClientNewLog import info.nightscout.plugins.sync.nsclient.data.NSDeviceStatusHandler import info.nightscout.plugins.sync.nsclientV3.NSClientV3Plugin import info.nightscout.rx.bus.RxBus +import info.nightscout.rx.events.EventNSClientNewLog import info.nightscout.rx.logging.AAPSLogger import info.nightscout.shared.utils.DateUtil import info.nightscout.shared.utils.T @@ -39,10 +38,10 @@ class LoadDeviceStatusWorker( val deviceStatuses = nsClientV3Plugin.nsAndroidClient.getDeviceStatusModifiedSince(from) aapsLogger.debug("DEVICESTATUSES: $deviceStatuses") if (deviceStatuses.isNotEmpty()) { - rxBus.send(EventNSClientNewLog("RCV", "${deviceStatuses.size} DSs from ${dateUtil.dateAndTimeAndSecondsString(from)}", NsClient.Version.V3)) - nsDeviceStatusHandler.handleNewData(deviceStatuses.toTypedArray(), NsClient.Version.V3) + rxBus.send(EventNSClientNewLog("RCV", "${deviceStatuses.size} DSs from ${dateUtil.dateAndTimeAndSecondsString(from)}")) + nsDeviceStatusHandler.handleNewData(deviceStatuses.toTypedArray()) } else { - rxBus.send(EventNSClientNewLog("END", "No DSs from ${dateUtil.dateAndTimeAndSecondsString(from)}", NsClient.Version.V3)) + rxBus.send(EventNSClientNewLog("END", "No DSs from ${dateUtil.dateAndTimeAndSecondsString(from)}")) } } catch (error: Exception) { aapsLogger.error("Error: ", error) diff --git a/plugins/main/src/main/java/info/nightscout/plugins/sync/nsclientV3/workers/LoadTreatmentsWorker.kt b/plugins/main/src/main/java/info/nightscout/plugins/sync/nsclientV3/workers/LoadTreatmentsWorker.kt index 477a3b257a..f9df107d31 100644 --- a/plugins/main/src/main/java/info/nightscout/plugins/sync/nsclientV3/workers/LoadTreatmentsWorker.kt +++ b/plugins/main/src/main/java/info/nightscout/plugins/sync/nsclientV3/workers/LoadTreatmentsWorker.kt @@ -9,11 +9,10 @@ import androidx.work.WorkerParameters import androidx.work.workDataOf import dagger.android.HasAndroidInjector import info.nightscout.core.utils.receivers.DataWorkerStorage -import info.nightscout.interfaces.sync.NsClient import info.nightscout.plugins.sync.nsShared.StoreDataForDb -import info.nightscout.plugins.sync.nsShared.events.EventNSClientNewLog import info.nightscout.plugins.sync.nsclientV3.NSClientV3Plugin import info.nightscout.rx.bus.RxBus +import info.nightscout.rx.events.EventNSClientNewLog import info.nightscout.rx.logging.AAPSLogger import info.nightscout.shared.utils.DateUtil import kotlinx.coroutines.runBlocking @@ -44,8 +43,7 @@ class LoadTreatmentsWorker( rxBus.send( EventNSClientNewLog( "RCV", - "${treatments.size} TRs from ${dateUtil.dateAndTimeAndSecondsString(nsClientV3Plugin.lastFetched.collections.treatments)}", - NsClient.Version.V3 + "${treatments.size} TRs from ${dateUtil.dateAndTimeAndSecondsString(nsClientV3Plugin.lastFetched.collections.treatments)}" ) ) // Schedule processing of fetched data and continue of loading @@ -61,8 +59,7 @@ class LoadTreatmentsWorker( } else { rxBus.send( EventNSClientNewLog( - "END", "No TRs from ${dateUtil.dateAndTimeAndSecondsString(nsClientV3Plugin.lastFetched.collections.treatments)}", - NsClient.Version.V3 + "END", "No TRs from ${dateUtil.dateAndTimeAndSecondsString(nsClientV3Plugin.lastFetched.collections.treatments)}" ) ) storeDataForDb.storeTreatmentsToDb() @@ -78,7 +75,7 @@ class LoadTreatmentsWorker( ret = Result.failure(workDataOf("Error" to error.toString())) } else { - rxBus.send(EventNSClientNewLog("END", "No new TRs from ${dateUtil.dateAndTimeAndSecondsString(nsClientV3Plugin.lastFetched.collections.treatments)}", NsClient.Version.V3)) + rxBus.send(EventNSClientNewLog("END", "No new TRs from ${dateUtil.dateAndTimeAndSecondsString(nsClientV3Plugin.lastFetched.collections.treatments)}")) storeDataForDb.storeTreatmentsToDb() WorkManager.getInstance(context) .enqueueUniqueWork( diff --git a/plugins/main/src/main/res/values/strings.xml b/plugins/main/src/main/res/values/strings.xml index e3e8297217..cbc0c28a40 100644 --- a/plugins/main/src/main/res/values/strings.xml +++ b/plugins/main/src/main/res/values/strings.xml @@ -409,7 +409,6 @@ Pump Definition Bolus: Step=%1$s\nExtended Bolus: [Step=%2$s, Duration=%3$smin-%4$sh]\nBasal: Step=%5$s\nTBR: %6$s (by %7$s), Duration=%8$smin-%9$sh\n%10$s - Virtual Pump VPUMP Pump integration for pumps which don\'t have any driver yet (Open Loop) VIRTUAL PUMP @@ -537,7 +536,6 @@ APS Request After processed constraints - Constraints Temp basal request time Temp basal execution time Temp basal set by pump