:plugins:sync module

This commit is contained in:
Milos Kozak 2022-11-28 09:25:19 +01:00
parent ae52eb3402
commit 27733a2dc5
154 changed files with 719 additions and 493 deletions

View file

@ -202,6 +202,7 @@ dependencies {
implementation project(':plugins:openhumans') implementation project(':plugins:openhumans')
implementation project(':plugins:sensitivity') implementation project(':plugins:sensitivity')
implementation project(':plugins:support') implementation project(':plugins:support')
implementation project(':plugins:sync')
implementation project(':implementation') implementation project(':implementation')
implementation project(':database:entities') implementation project(':database:entities')
implementation project(':database:impl') implementation project(':database:impl')

View file

@ -23,7 +23,7 @@ import info.nightscout.androidaps.receivers.TimeDateOrTZChangeReceiver
import info.nightscout.androidaps.services.AlarmSoundServiceHelper import info.nightscout.androidaps.services.AlarmSoundServiceHelper
import info.nightscout.implementation.lifecycle.ProcessLifecycleListener import info.nightscout.implementation.lifecycle.ProcessLifecycleListener
import info.nightscout.core.ui.locale.LocaleHelper import info.nightscout.core.ui.locale.LocaleHelper
import info.nightscout.core.utils.receivers.NetworkChangeReceiver import info.nightscout.implementation.receivers.NetworkChangeReceiver
import info.nightscout.interfaces.versionChecker.VersionCheckerUtils import info.nightscout.interfaces.versionChecker.VersionCheckerUtils
import info.nightscout.database.entities.TherapyEvent import info.nightscout.database.entities.TherapyEvent
import info.nightscout.database.entities.UserEntry import info.nightscout.database.entities.UserEntry

View file

@ -23,6 +23,7 @@ import info.nightscout.implementation.di.ImplementationModule
import info.nightscout.plugins.aps.di.ApsModule import info.nightscout.plugins.aps.di.ApsModule
import info.nightscout.plugins.di.PluginsModule import info.nightscout.plugins.di.PluginsModule
import info.nightscout.plugins.support.di.PluginsSupportModule import info.nightscout.plugins.support.di.PluginsSupportModule
import info.nightscout.plugins.sync.di.SyncModule
import info.nightscout.pump.combo.di.ComboModule import info.nightscout.pump.combo.di.ComboModule
import info.nightscout.pump.combov2.di.ComboV2Module import info.nightscout.pump.combov2.di.ComboV2Module
import info.nightscout.pump.common.di.PumpCommonModule import info.nightscout.pump.common.di.PumpCommonModule
@ -50,24 +51,20 @@ import javax.inject.Singleton
// Gradle modules // Gradle modules
AutomationModule::class, AutomationModule::class,
AutomationModule.Bindings::class,
ApsModule::class, ApsModule::class,
ConfigurationModule::class, ConfigurationModule::class,
ConfigurationModule.Bindings::class,
CoreModule::class, CoreModule::class,
DatabaseModule::class, DatabaseModule::class,
ImplementationModule::class, ImplementationModule::class,
ImplementationModule.Bindings::class,
OpenHumansModule::class, OpenHumansModule::class,
PluginsModule::class, PluginsModule::class,
PluginsModule.Bindings::class,
RxModule::class, RxModule::class,
SharedModule::class, SharedModule::class,
SharedImplModule::class, SharedImplModule::class,
UiModule::class, UiModule::class,
ValidatorsModule::class, ValidatorsModule::class,
PluginsSupportModule::class, PluginsSupportModule::class,
PluginsSupportModule.Bindings::class, SyncModule::class,
// pumps // pumps
ComboModule::class, ComboModule::class,

View file

@ -10,10 +10,12 @@ import info.nightscout.androidaps.MainApp
import info.nightscout.androidaps.implementations.ActivityNamesImpl import info.nightscout.androidaps.implementations.ActivityNamesImpl
import info.nightscout.androidaps.implementations.ConfigImpl import info.nightscout.androidaps.implementations.ConfigImpl
import info.nightscout.androidaps.workflow.CalculationWorkflowImpl import info.nightscout.androidaps.workflow.CalculationWorkflowImpl
import info.nightscout.androidaps.workflow.WorkerClassesImpl
import info.nightscout.core.workflow.CalculationWorkflow import info.nightscout.core.workflow.CalculationWorkflow
import info.nightscout.interfaces.Config import info.nightscout.interfaces.Config
import info.nightscout.interfaces.plugin.PluginBase import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.ActivityNames
import info.nightscout.interfaces.workflow.WorkerClasses
@Suppress("unused") @Suppress("unused")
@Module( @Module(
@ -48,8 +50,9 @@ open class AppModule {
@Binds fun bindInjector(mainApp: MainApp): HasAndroidInjector @Binds fun bindInjector(mainApp: MainApp): HasAndroidInjector
@Binds fun bindConfigInterface(config: ConfigImpl): Config @Binds fun bindConfigInterface(config: ConfigImpl): Config
@Binds fun bindActivityNamesInterface(activityNames: ActivityNamesImpl): ActivityNames @Binds fun bindActivityNames(activityNames: ActivityNamesImpl): ActivityNames
@Binds fun bindCalculationWorkflowInterface(calculationWorkflow: CalculationWorkflowImpl): CalculationWorkflow @Binds fun bindWorkerClasses(workerClassesImpl: WorkerClassesImpl): WorkerClasses
@Binds fun bindCalculationWorkflow(calculationWorkflow: CalculationWorkflowImpl): CalculationWorkflow
} }
} }

View file

@ -6,6 +6,7 @@ import android.os.Bundle
import androidx.annotation.RawRes import androidx.annotation.RawRes
import androidx.annotation.StringRes import androidx.annotation.StringRes
import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentManager
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.MainActivity import info.nightscout.androidaps.MainActivity
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.activities.HistoryBrowseActivity import info.nightscout.androidaps.activities.HistoryBrowseActivity
@ -15,7 +16,9 @@ import info.nightscout.androidaps.services.AlarmSoundService
import info.nightscout.configuration.activities.SingleFragmentActivity import info.nightscout.configuration.activities.SingleFragmentActivity
import info.nightscout.core.events.EventNewNotification import info.nightscout.core.events.EventNewNotification
import info.nightscout.interfaces.notifications.Notification import info.nightscout.interfaces.notifications.Notification
import info.nightscout.interfaces.nsclient.NSAlarm
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.ActivityNames
import info.nightscout.plugins.general.overview.notifications.NotificationWithAction
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
import info.nightscout.ui.activities.BolusProgressHelperActivity import info.nightscout.ui.activities.BolusProgressHelperActivity
import info.nightscout.ui.activities.ErrorHelperActivity import info.nightscout.ui.activities.ErrorHelperActivity
@ -168,4 +171,8 @@ class ActivityNamesImpl @Inject constructor(
override fun addNotificationValidTo(id: Int, date: Long, text: String, level: Int, validTo: Long) { override fun addNotificationValidTo(id: Int, date: Long, text: String, level: Int, validTo: Long) {
rxBus.send(EventNewNotification(Notification(id, System.currentTimeMillis(), text, level,validTo))) rxBus.send(EventNewNotification(Notification(id, System.currentTimeMillis(), text, level,validTo)))
} }
override fun addNotificationWithAction(injector: HasAndroidInjector, nsAlarm: NSAlarm) {
rxBus.send(EventNewNotification(NotificationWithAction(injector, nsAlarm)))
}
} }

View file

@ -5,7 +5,7 @@ import android.content.Intent
import android.content.IntentFilter import android.content.IntentFilter
import android.os.BatteryManager import android.os.BatteryManager
import dagger.android.DaggerBroadcastReceiver import dagger.android.DaggerBroadcastReceiver
import info.nightscout.core.utils.receivers.ReceiverStatusStore import info.nightscout.interfaces.receivers.ReceiverStatusStore
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.EventChargingState import info.nightscout.rx.events.EventChargingState
import info.nightscout.rx.logging.AAPSLogger import info.nightscout.rx.logging.AAPSLogger

View file

@ -17,7 +17,7 @@ import info.nightscout.androidaps.R
import info.nightscout.configuration.maintenance.MaintenancePlugin import info.nightscout.configuration.maintenance.MaintenancePlugin
import info.nightscout.core.profile.ProfileSealed import info.nightscout.core.profile.ProfileSealed
import info.nightscout.core.utils.fabric.FabricPrivacy import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.core.utils.receivers.ReceiverStatusStore import info.nightscout.interfaces.receivers.ReceiverStatusStore
import info.nightscout.database.impl.AppRepository import info.nightscout.database.impl.AppRepository
import info.nightscout.interfaces.Config import info.nightscout.interfaces.Config
import info.nightscout.interfaces.LocalAlertUtils import info.nightscout.interfaces.LocalAlertUtils
@ -29,7 +29,6 @@ import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.profile.ProfileFunction import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.queue.Command import info.nightscout.interfaces.queue.Command
import info.nightscout.interfaces.queue.CommandQueue import info.nightscout.interfaces.queue.CommandQueue
import info.nightscout.plugins.sync.nsclient.extensions.buildDeviceStatus
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.EventProfileSwitchChanged import info.nightscout.rx.events.EventProfileSwitchChanged
import info.nightscout.rx.logging.AAPSLogger import info.nightscout.rx.logging.AAPSLogger
@ -168,7 +167,7 @@ class KeepAliveWorker(
else if (dateUtil.isOlderThan(activePlugin.activeAPS.lastAPSRun, 5)) shouldUploadStatus = true else if (dateUtil.isOlderThan(activePlugin.activeAPS.lastAPSRun, 5)) shouldUploadStatus = true
if (dateUtil.isOlderThan(lastIobUpload, IOB_UPDATE_FREQUENCY_IN_MINUTES) && shouldUploadStatus) { if (dateUtil.isOlderThan(lastIobUpload, IOB_UPDATE_FREQUENCY_IN_MINUTES) && shouldUploadStatus) {
lastIobUpload = dateUtil.now() lastIobUpload = dateUtil.now()
buildDeviceStatus( loop.buildDeviceStatus(
dateUtil, loop, iobCobCalculator, profileFunction, dateUtil, loop, iobCobCalculator, profileFunction,
activePlugin.activePump, receiverStatusStore, runningConfiguration, activePlugin.activePump, receiverStatusStore, runningConfiguration,
BuildConfig.VERSION_NAME + "-" + BuildConfig.BUILDVERSION BuildConfig.VERSION_NAME + "-" + BuildConfig.BUILDVERSION

View file

@ -0,0 +1,14 @@
package info.nightscout.androidaps.workflow
import info.nightscout.interfaces.workflow.WorkerClasses
import info.nightscout.plugins.general.food.FoodPlugin
import info.nightscout.plugins.profile.ProfilePlugin
import info.nightscout.plugins.source.NSClientSourcePlugin
import javax.inject.Inject
class WorkerClassesImpl @Inject constructor(): WorkerClasses{
override val nsClientSourceWorker = NSClientSourcePlugin.NSClientSourceWorker::class.java
override val nsProfileWorker = ProfilePlugin.NSProfileWorker::class.java
override val foodWorker = FoodPlugin.FoodWorker::class.java
}

View file

@ -7,7 +7,7 @@ import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.TestBase import info.nightscout.androidaps.TestBase
import info.nightscout.interfaces.logging.UserEntryLogger import info.nightscout.interfaces.logging.UserEntryLogger
import info.nightscout.core.utils.receivers.ReceiverStatusStore import info.nightscout.interfaces.receivers.ReceiverStatusStore
import info.nightscout.core.utils.fabric.FabricPrivacy import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.database.impl.AppRepository import info.nightscout.database.impl.AppRepository
import info.nightscout.interfaces.Config import info.nightscout.interfaces.Config

View file

@ -8,7 +8,6 @@ import dagger.Provides
@Module( @Module(
includes = [ includes = [
CoreReceiversModule::class,
CoreDataClassesModule::class, CoreDataClassesModule::class,
PreferencesModule::class PreferencesModule::class
] ]

View file

@ -1,11 +0,0 @@
package info.nightscout.core.di
import dagger.Module
import dagger.android.ContributesAndroidInjector
import info.nightscout.core.utils.receivers.NetworkChangeReceiver
@Module
abstract class CoreReceiversModule {
@ContributesAndroidInjector abstract fun contributesNetworkChangeReceiver(): NetworkChangeReceiver
}

View file

@ -30,6 +30,9 @@ dependencies {
// Dagger // Dagger
api "com.google.dagger:dagger:$dagger_version" api "com.google.dagger:dagger:$dagger_version"
api "com.google.dagger:dagger-android:$dagger_version" api "com.google.dagger:dagger-android:$dagger_version"
// WorkerClasses
api "androidx.work:work-runtime-ktx:$work_version"
} }
allOpen { allOpen {

View file

@ -1,9 +1,16 @@
package info.nightscout.interfaces.aps package info.nightscout.interfaces.aps
import info.nightscout.database.entities.DeviceStatus
import info.nightscout.database.entities.OfflineEvent import info.nightscout.database.entities.OfflineEvent
import info.nightscout.interfaces.configBuilder.RunningConfiguration
import info.nightscout.interfaces.constraints.Constraint import info.nightscout.interfaces.constraints.Constraint
import info.nightscout.interfaces.iob.IobCobCalculator
import info.nightscout.interfaces.profile.Profile import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.pump.Pump
import info.nightscout.interfaces.pump.PumpEnactResult import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.receivers.ReceiverStatusStore
import info.nightscout.shared.utils.DateUtil
interface Loop { interface Loop {
@ -40,4 +47,14 @@ interface Loop {
fun goToZeroTemp(durationInMinutes: Int, profile: Profile, reason: OfflineEvent.Reason) fun goToZeroTemp(durationInMinutes: Int, profile: Profile, reason: OfflineEvent.Reason)
fun suspendLoop(durationInMinutes: Int) fun suspendLoop(durationInMinutes: Int)
fun disableCarbSuggestions(durationMinutes: Int) fun disableCarbSuggestions(durationMinutes: Int)
fun buildDeviceStatus(
dateUtil: DateUtil,
loop: Loop,
iobCobCalculatorPlugin: IobCobCalculator,
profileFunction: ProfileFunction,
pump: Pump,
receiverStatusStore: ReceiverStatusStore,
runningConfiguration: RunningConfiguration,
version: String
): DeviceStatus?
} }

View file

@ -1,4 +1,4 @@
package info.nightscout.plugins.sync.nsclient.data package info.nightscout.interfaces.nsclient
import info.nightscout.interfaces.utils.JsonHelper import info.nightscout.interfaces.utils.JsonHelper
import org.json.JSONObject import org.json.JSONObject

View file

@ -1,4 +1,4 @@
package info.nightscout.plugins.sync.nsclient.data package info.nightscout.interfaces.nsclient
import info.nightscout.interfaces.utils.JsonHelper import info.nightscout.interfaces.utils.JsonHelper
import org.json.JSONObject import org.json.JSONObject

View file

@ -0,0 +1,7 @@
package info.nightscout.interfaces.nsclient
import info.nightscout.database.transactions.TransactionGlucoseValue
interface StoreDataForDb {
val glucoseValues: MutableList<TransactionGlucoseValue>
}

View file

@ -0,0 +1,20 @@
package info.nightscout.interfaces.receivers
import info.nightscout.rx.events.EventChargingState
import info.nightscout.rx.events.EventNetworkChange
interface ReceiverStatusStore {
var lastNetworkEvent: EventNetworkChange?
val isWifiConnected: Boolean
val isConnected: Boolean
fun updateNetworkStatus()
var lastChargingEvent: EventChargingState?
val isCharging: Boolean
val batteryLevel: Int
fun broadcastChargingState()
}

View file

@ -0,0 +1,7 @@
package info.nightscout.interfaces.source
import info.nightscout.database.entities.GlucoseValue
interface NSClientSource {
fun detectSource(glucoseValue: GlucoseValue)
}

View file

@ -1,6 +1,7 @@
package info.nightscout.interfaces.sync package info.nightscout.interfaces.sync
import android.text.Spanned import android.text.Spanned
import info.nightscout.interfaces.nsclient.NSAlarm
import org.json.JSONObject import org.json.JSONObject
interface NsClient : Sync { interface NsClient : Sync {
@ -19,6 +20,7 @@ interface NsClient : Sync {
fun updateLatestBgReceivedIfNewer(latestReceived: Long) fun updateLatestBgReceivedIfNewer(latestReceived: Long)
fun updateLatestTreatmentReceivedIfNewer(latestReceived: Long) fun updateLatestTreatmentReceivedIfNewer(latestReceived: Long)
fun handleClearAlarm(originalAlarm: NSAlarm, silenceTimeInMilliseconds: Long)
fun resetToFullSync() fun resetToFullSync()

View file

@ -4,6 +4,8 @@ import android.content.Context
import androidx.annotation.RawRes import androidx.annotation.RawRes
import androidx.annotation.StringRes import androidx.annotation.StringRes
import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentManager
import dagger.android.HasAndroidInjector
import info.nightscout.interfaces.nsclient.NSAlarm
/** /**
* Interface to use activities located in different modules * Interface to use activities located in different modules
@ -64,4 +66,5 @@ interface ActivityNames {
fun addNotificationValidFor(id: Int, text: String, level: Int, validMinutes: Int) fun addNotificationValidFor(id: Int, text: String, level: Int, validMinutes: Int)
fun addNotificationWithSound(id: Int, text: String, level: Int, @RawRes soundId: Int) fun addNotificationWithSound(id: Int, text: String, level: Int, @RawRes soundId: Int)
fun addNotificationValidTo(id: Int, date: Long, text: String, level: Int, validTo: Long) fun addNotificationValidTo(id: Int, date: Long, text: String, level: Int, validTo: Long)
fun addNotificationWithAction(injector: HasAndroidInjector, nsAlarm: NSAlarm)
} }

View file

@ -0,0 +1,9 @@
package info.nightscout.interfaces.workflow
import androidx.work.ListenableWorker
interface WorkerClasses {
val nsClientSourceWorker: Class<out ListenableWorker>
val nsProfileWorker: Class<out ListenableWorker>
val foodWorker: Class<out ListenableWorker>
}

View file

@ -32,6 +32,7 @@
<string name="patient_name_default" comment="This is default patient display name, when user does not provide real one">User</string> <string name="patient_name_default" comment="This is default patient display name, when user does not provide real one">User</string>
<string name="result">Result</string> <string name="result">Result</string>
<string name="settings">Settings</string> <string name="settings">Settings</string>
<string name="statuslights">Status lights</string>
<!-- Pumps --> <!-- Pumps -->
<string name="battery_label">Battery</string> <string name="battery_label">Battery</string>

View file

@ -114,5 +114,22 @@
<string name="key_wearwizard_trend" translatable="false">wearwizard_trend</string> <string name="key_wearwizard_trend" translatable="false">wearwizard_trend</string>
<string name="key_wearwizard_cob" translatable="false">wearwizard_cob</string> <string name="key_wearwizard_cob" translatable="false">wearwizard_cob</string>
<string name="key_wearwizard_iob" translatable="false">wearwizard_iob</string> <string name="key_wearwizard_iob" translatable="false">wearwizard_iob</string>
<string name="key_objectives_bg_is_available_in_ns" translatable="false">ObjectivesbgIsAvailableInNS</string>
<string name="key_objectives_pump_status_is_available_in_ns" translatable="false">ObjectivespumpStatusIsAvailableInNS</string>
<string name="key_statuslights_cage_warning" translatable="false">statuslights_cage_warning</string>
<string name="key_statuslights_cage_critical" translatable="false">statuslights_cage_critical</string>
<string name="key_statuslights_iage_warning" translatable="false">statuslights_iage_warning</string>
<string name="key_statuslights_iage_critical" translatable="false">statuslights_iage_critical</string>
<string name="key_statuslights_sage_warning" translatable="false">statuslights_sage_warning</string>
<string name="key_statuslights_sage_critical" translatable="false">statuslights_sage_critical</string>
<string name="key_statuslights_bage_warning" translatable="false">statuslights_bage_warning</string>
<string name="key_statuslights_bage_critical" translatable="false">statuslights_bage_critical</string>
<string name="key_ns_announcements" translatable="false">ns_announcements</string>
<string name="key_ns_alarms" translatable="false">ns_alarms</string>
<string name="key_ns_alarm_stale_data_value" translatable="false">ns_alarm_stale_data_value</string>
<string name="key_ns_alarm_urgent_stale_data_value" translatable="false">ns_alarm_urgent_stale_data_value</string>
<string name="key_snoozed_to" translatable="false">snoozedTo</string>
<string name="key_ns_receive_cgm" translatable="false">ns_receive_cgm</string>
<string name="key_ns_create_announcements_from_carbs_req" translatable="false">ns_create_announcements_from_carbs_req</string>
</resources> </resources>

View file

@ -0,0 +1,14 @@
package info.nightscout.database.transactions
import info.nightscout.database.entities.GlucoseValue
data class TransactionGlucoseValue(
val timestamp: Long,
val value: Double,
val raw: Double?,
val noise: Double?,
val trendArrow: GlucoseValue.TrendArrow,
val nightscoutId: String? = null,
val sourceSensor: GlucoseValue.SourceSensor,
val isValid: Boolean = true
)

View file

@ -2,6 +2,7 @@ package info.nightscout.database.impl.transactions
import info.nightscout.database.entities.GlucoseValue import info.nightscout.database.entities.GlucoseValue
import info.nightscout.database.entities.TherapyEvent import info.nightscout.database.entities.TherapyEvent
import info.nightscout.database.transactions.TransactionGlucoseValue
/** /**
* Inserts data from a CGM source into the database * Inserts data from a CGM source into the database
@ -78,17 +79,6 @@ class CgmSourceTransaction constructor(
return result return result
} }
data class TransactionGlucoseValue(
val timestamp: Long,
val value: Double,
val raw: Double?,
val noise: Double?,
val trendArrow: GlucoseValue.TrendArrow,
val nightscoutId: String? = null,
val sourceSensor: GlucoseValue.SourceSensor,
val isValid: Boolean = true
)
data class Calibration( data class Calibration(
val timestamp: Long, val timestamp: Long,
val value: Double, val value: Double,

View file

@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> <manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
</manifest> </manifest>

View file

@ -31,6 +31,8 @@ import info.nightscout.implementation.pump.PumpSyncImplementation
import info.nightscout.implementation.pump.TemporaryBasalStorageImpl import info.nightscout.implementation.pump.TemporaryBasalStorageImpl
import info.nightscout.implementation.pump.WarnColorsImpl import info.nightscout.implementation.pump.WarnColorsImpl
import info.nightscout.implementation.queue.CommandQueueImplementation import info.nightscout.implementation.queue.CommandQueueImplementation
import info.nightscout.implementation.receivers.NetworkChangeReceiver
import info.nightscout.implementation.receivers.ReceiverStatusStoreImpl
import info.nightscout.implementation.resources.IconsProviderImplementation import info.nightscout.implementation.resources.IconsProviderImplementation
import info.nightscout.implementation.resources.ResourceHelperImpl import info.nightscout.implementation.resources.ResourceHelperImpl
import info.nightscout.implementation.stats.DexcomTirCalculatorImpl import info.nightscout.implementation.stats.DexcomTirCalculatorImpl
@ -60,6 +62,7 @@ import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.interfaces.pump.TemporaryBasalStorage import info.nightscout.interfaces.pump.TemporaryBasalStorage
import info.nightscout.interfaces.pump.WarnColors import info.nightscout.interfaces.pump.WarnColors
import info.nightscout.interfaces.queue.CommandQueue import info.nightscout.interfaces.queue.CommandQueue
import info.nightscout.interfaces.receivers.ReceiverStatusStore
import info.nightscout.interfaces.stats.DexcomTirCalculator import info.nightscout.interfaces.stats.DexcomTirCalculator
import info.nightscout.interfaces.stats.TddCalculator import info.nightscout.interfaces.stats.TddCalculator
import info.nightscout.interfaces.stats.TirCalculator import info.nightscout.interfaces.stats.TirCalculator
@ -71,6 +74,7 @@ import info.nightscout.shared.interfaces.ResourceHelper
@Module( @Module(
includes = [ includes = [
ImplementationModule.Bindings::class,
CommandQueueModule::class CommandQueueModule::class
] ]
) )
@ -79,6 +83,7 @@ import info.nightscout.shared.interfaces.ResourceHelper
abstract class ImplementationModule { abstract class ImplementationModule {
@ContributesAndroidInjector abstract fun profileStoreInjector(): ProfileStoreObject @ContributesAndroidInjector abstract fun profileStoreInjector(): ProfileStoreObject
@ContributesAndroidInjector abstract fun contributesNetworkChangeReceiver(): NetworkChangeReceiver
@Module @Module
interface Bindings { interface Bindings {
@ -115,5 +120,6 @@ abstract class ImplementationModule {
@Binds fun bindsConstraints(constraintsImpl: ConstraintsImpl): Constraints @Binds fun bindsConstraints(constraintsImpl: ConstraintsImpl): Constraints
@Binds fun bindsProfileFunction(profileFunctionImpl: ProfileFunctionImpl): ProfileFunction @Binds fun bindsProfileFunction(profileFunctionImpl: ProfileFunctionImpl): ProfileFunction
@Binds fun bindsStorage(fileStorage: FileStorage): Storage @Binds fun bindsStorage(fileStorage: FileStorage): Storage
@Binds fun bindsReceiverStatusStore(receiverStatusStoreImpl: ReceiverStatusStoreImpl): ReceiverStatusStore
} }
} }

View file

@ -1,4 +1,4 @@
package info.nightscout.core.utils.receivers package info.nightscout.implementation.receivers
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
@ -10,6 +10,8 @@ import android.net.wifi.WifiManager
import android.os.Handler import android.os.Handler
import android.os.HandlerThread import android.os.HandlerThread
import dagger.android.DaggerBroadcastReceiver import dagger.android.DaggerBroadcastReceiver
import info.nightscout.core.utils.receivers.StringUtils
import info.nightscout.interfaces.receivers.ReceiverStatusStore
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.EventNetworkChange import info.nightscout.rx.events.EventNetworkChange
import info.nightscout.rx.logging.AAPSLogger import info.nightscout.rx.logging.AAPSLogger
@ -60,4 +62,4 @@ class NetworkChangeReceiver : DaggerBroadcastReceiver() {
receiverStatusStore.lastNetworkEvent = event receiverStatusStore.lastNetworkEvent = event
return event return event
} }
} }

View file

@ -1,8 +1,9 @@
package info.nightscout.core.utils.receivers package info.nightscout.implementation.receivers
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import info.nightscout.androidaps.annotations.OpenForTesting import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.interfaces.receivers.ReceiverStatusStore
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.EventChargingState import info.nightscout.rx.events.EventChargingState
import info.nightscout.rx.events.EventNetworkChange import info.nightscout.rx.events.EventNetworkChange
@ -11,29 +12,29 @@ import javax.inject.Singleton
@OpenForTesting @OpenForTesting
@Singleton @Singleton
class ReceiverStatusStore @Inject constructor(val context: Context, val rxBus: RxBus) { class ReceiverStatusStoreImpl @Inject constructor(val context: Context, val rxBus: RxBus) : ReceiverStatusStore {
var lastNetworkEvent: EventNetworkChange? = null override var lastNetworkEvent: EventNetworkChange? = null
val isWifiConnected: Boolean override val isWifiConnected: Boolean
get() = lastNetworkEvent?.wifiConnected ?: false get() = lastNetworkEvent?.wifiConnected ?: false
val isConnected: Boolean override val isConnected: Boolean
get() = lastNetworkEvent?.wifiConnected ?: false || lastNetworkEvent?.mobileConnected ?: false get() = lastNetworkEvent?.wifiConnected ?: false || lastNetworkEvent?.mobileConnected ?: false
fun updateNetworkStatus() { override fun updateNetworkStatus() {
context.sendBroadcast(Intent(context, NetworkChangeReceiver::class.java)) context.sendBroadcast(Intent(context, NetworkChangeReceiver::class.java))
} }
var lastChargingEvent: EventChargingState? = null override var lastChargingEvent: EventChargingState? = null
val isCharging: Boolean override val isCharging: Boolean
get() = lastChargingEvent?.isCharging ?: false get() = lastChargingEvent?.isCharging ?: false
val batteryLevel: Int override val batteryLevel: Int
get() = lastChargingEvent?.batterLevel ?: 0 get() = lastChargingEvent?.batterLevel ?: 0
fun broadcastChargingState() { override fun broadcastChargingState() {
lastChargingEvent?.let { rxBus.send(it) } lastChargingEvent?.let { rxBus.send(it) }
} }
} }

View file

@ -49,7 +49,11 @@ import info.nightscout.automation.triggers.TriggerTimeRange
import info.nightscout.automation.triggers.TriggerWifiSsid import info.nightscout.automation.triggers.TriggerWifiSsid
import info.nightscout.interfaces.automation.Automation import info.nightscout.interfaces.automation.Automation
@Module @Module(
includes = [
AutomationModule.Bindings::class
]
)
@Suppress("unused") @Suppress("unused")
abstract class AutomationModule { abstract class AutomationModule {

View file

@ -3,7 +3,7 @@ package info.nightscout.automation.triggers
import android.widget.LinearLayout import android.widget.LinearLayout
import com.google.common.base.Optional import com.google.common.base.Optional
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.core.utils.receivers.ReceiverStatusStore import info.nightscout.interfaces.receivers.ReceiverStatusStore
import info.nightscout.interfaces.utils.JsonHelper import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.automation.R import info.nightscout.automation.R
import info.nightscout.automation.elements.Comparator import info.nightscout.automation.elements.Comparator

View file

@ -8,7 +8,7 @@ import info.nightscout.androidaps.TestPumpPlugin
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider
import info.nightscout.automation.AutomationPlugin import info.nightscout.automation.AutomationPlugin
import info.nightscout.automation.services.LastLocationDataContainer import info.nightscout.automation.services.LastLocationDataContainer
import info.nightscout.core.utils.receivers.ReceiverStatusStore import info.nightscout.interfaces.receivers.ReceiverStatusStore
import info.nightscout.interfaces.aps.AutosensDataStore import info.nightscout.interfaces.aps.AutosensDataStore
import info.nightscout.interfaces.iob.IobCobCalculator import info.nightscout.interfaces.iob.IobCobCalculator
import info.nightscout.interfaces.plugin.ActivePlugin import info.nightscout.interfaces.plugin.ActivePlugin

View file

@ -19,6 +19,7 @@ import info.nightscout.interfaces.maintenance.PrefFileListProvider
@Module( @Module(
includes = [ includes = [
ConfigurationModule.Bindings::class,
SetupWizardModule::class SetupWizardModule::class
] ]
) )

View file

@ -7,6 +7,7 @@ import android.app.PendingIntent
import android.app.TaskStackBuilder import android.app.TaskStackBuilder
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.os.Build
import android.os.Handler import android.os.Handler
import android.os.HandlerThread import android.os.HandlerThread
import android.os.SystemClock import android.os.SystemClock
@ -17,9 +18,10 @@ import info.nightscout.androidaps.extensions.convertedToAbsolute
import info.nightscout.androidaps.extensions.convertedToPercent import info.nightscout.androidaps.extensions.convertedToPercent
import info.nightscout.androidaps.extensions.plannedRemainingMinutes import info.nightscout.androidaps.extensions.plannedRemainingMinutes
import info.nightscout.core.events.EventNewNotification import info.nightscout.core.events.EventNewNotification
import info.nightscout.core.iob.json
import info.nightscout.core.utils.fabric.FabricPrivacy import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.core.utils.receivers.ReceiverStatusStore
import info.nightscout.database.ValueWrapper import info.nightscout.database.ValueWrapper
import info.nightscout.database.entities.DeviceStatus
import info.nightscout.database.entities.OfflineEvent import info.nightscout.database.entities.OfflineEvent
import info.nightscout.database.entities.UserEntry.Action import info.nightscout.database.entities.UserEntry.Action
import info.nightscout.database.entities.UserEntry.Sources import info.nightscout.database.entities.UserEntry.Sources
@ -32,6 +34,7 @@ import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.aps.APSResult import info.nightscout.interfaces.aps.APSResult
import info.nightscout.interfaces.aps.Loop import info.nightscout.interfaces.aps.Loop
import info.nightscout.interfaces.aps.Loop.LastRun import info.nightscout.interfaces.aps.Loop.LastRun
import info.nightscout.interfaces.configBuilder.RunningConfiguration
import info.nightscout.interfaces.constraints.Constraint import info.nightscout.interfaces.constraints.Constraint
import info.nightscout.interfaces.constraints.Constraints import info.nightscout.interfaces.constraints.Constraints
import info.nightscout.interfaces.iob.IobCobCalculator import info.nightscout.interfaces.iob.IobCobCalculator
@ -44,20 +47,21 @@ import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.profile.Profile import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.profile.ProfileFunction import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.pump.DetailedBolusInfo import info.nightscout.interfaces.pump.DetailedBolusInfo
import info.nightscout.interfaces.pump.Pump
import info.nightscout.interfaces.pump.PumpEnactResult import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.pump.PumpSync import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.interfaces.pump.defs.PumpDescription import info.nightscout.interfaces.pump.defs.PumpDescription
import info.nightscout.interfaces.queue.Callback import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.queue.CommandQueue import info.nightscout.interfaces.queue.CommandQueue
import info.nightscout.interfaces.receivers.ReceiverStatusStore
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.ActivityNames
import info.nightscout.interfaces.utils.HardLimits import info.nightscout.interfaces.utils.HardLimits
import info.nightscout.interfaces.utils.Round
import info.nightscout.plugins.R import info.nightscout.plugins.R
import info.nightscout.plugins.aps.loop.events.EventLoopSetLastRunGui import info.nightscout.plugins.aps.loop.events.EventLoopSetLastRunGui
import info.nightscout.plugins.aps.loop.events.EventLoopUpdateGui import info.nightscout.plugins.aps.loop.events.EventLoopUpdateGui
import info.nightscout.plugins.aps.loop.events.EventNewOpenLoopNotification import info.nightscout.plugins.aps.loop.events.EventNewOpenLoopNotification
import info.nightscout.interfaces.configBuilder.RunningConfiguration
import info.nightscout.plugins.pump.virtual.VirtualPumpPlugin import info.nightscout.plugins.pump.virtual.VirtualPumpPlugin
import info.nightscout.plugins.sync.nsclient.extensions.buildDeviceStatus
import info.nightscout.rx.AapsSchedulers import info.nightscout.rx.AapsSchedulers
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.EventAcceptOpenLoopChange import info.nightscout.rx.events.EventAcceptOpenLoopChange
@ -73,6 +77,7 @@ import info.nightscout.shared.utils.DateUtil
import info.nightscout.shared.utils.T import info.nightscout.shared.utils.T
import io.reactivex.rxjava3.disposables.CompositeDisposable import io.reactivex.rxjava3.disposables.CompositeDisposable
import io.reactivex.rxjava3.kotlin.plusAssign import io.reactivex.rxjava3.kotlin.plusAssign
import org.json.JSONObject
import javax.inject.Inject import javax.inject.Inject
import javax.inject.Singleton import javax.inject.Singleton
import kotlin.math.abs import kotlin.math.abs
@ -720,6 +725,90 @@ class LoopPlugin @Inject constructor(
}) })
} }
override fun buildDeviceStatus(
dateUtil: DateUtil,
loop: Loop,
iobCobCalculatorPlugin: IobCobCalculator,
profileFunction: ProfileFunction,
pump: Pump,
receiverStatusStore: ReceiverStatusStore,
runningConfiguration: RunningConfiguration,
version: String
): DeviceStatus? {
val profile = profileFunction.getProfile() ?: return null
val profileName = profileFunction.getProfileName()
val lastRun = loop.lastRun
var apsResult: JSONObject? = null
var iob: JSONObject? = null
var enacted: JSONObject? = null
if (lastRun != null && lastRun.lastAPSRun > dateUtil.now() - 300 * 1000L) {
// do not send if result is older than 1 min
apsResult = lastRun.request?.json()?.also {
it.put("timestamp", dateUtil.toISOString(lastRun.lastAPSRun))
}
iob = lastRun.request?.iob?.json(dateUtil)?.also {
it.put("time", dateUtil.toISOString(lastRun.lastAPSRun))
}
val requested = JSONObject()
if (lastRun.tbrSetByPump?.enacted == true) { // enacted
enacted = lastRun.request?.json()?.also {
it.put("rate", lastRun.tbrSetByPump!!.json(profile.getBasal())["rate"])
it.put("duration", lastRun.tbrSetByPump!!.json(profile.getBasal())["duration"])
it.put("received", true)
}
requested.put("duration", lastRun.request?.duration)
requested.put("rate", lastRun.request?.rate)
requested.put("temp", "absolute")
requested.put("smb", lastRun.request?.smb)
enacted?.put("requested", requested)
enacted?.put("smb", lastRun.tbrSetByPump?.bolusDelivered)
}
} else {
val calcIob = iobCobCalculatorPlugin.calculateIobArrayInDia(profile)
if (calcIob.isNotEmpty()) {
iob = calcIob[0].json(dateUtil)
iob.put("time", dateUtil.toISOString(dateUtil.now()))
}
}
return DeviceStatus(
timestamp = dateUtil.now(),
suggested = apsResult?.toString(),
iob = iob?.toString(),
enacted = enacted?.toString(),
device = "openaps://" + Build.MANUFACTURER + " " + Build.MODEL,
pump = pump.getJSONStatus(profile, profileName, version).toString(),
uploaderBattery = receiverStatusStore.batteryLevel,
configuration = runningConfiguration.configuration().toString()
)
}
fun PumpEnactResult.json(baseBasal: Double): JSONObject {
val result = JSONObject()
when {
bolusDelivered > 0 -> {
result.put("smb", bolusDelivered)
}
isTempCancel -> {
result.put("rate", 0)
result.put("duration", 0)
}
isPercent -> {
// Nightscout is expecting absolute value
val abs = Round.roundTo(baseBasal * percent / 100, 0.01)
result.put("rate", abs)
result.put("duration", duration)
}
else -> {
result.put("rate", absolute)
result.put("duration", duration)
}
}
return result
}
companion object { companion object {
private const val CHANNEL_ID = "AAPS-OpenLoop" private const val CHANNEL_ID = "AAPS-OpenLoop"

View file

@ -17,7 +17,7 @@ import androidx.recyclerview.widget.LinearSmoothScroller
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import dagger.android.support.DaggerFragment import dagger.android.support.DaggerFragment
import info.nightscout.interfaces.logging.UserEntryLogger import info.nightscout.interfaces.logging.UserEntryLogger
import info.nightscout.core.utils.receivers.ReceiverStatusStore import info.nightscout.interfaces.receivers.ReceiverStatusStore
import info.nightscout.core.ui.dialogs.OKDialog import info.nightscout.core.ui.dialogs.OKDialog
import info.nightscout.core.utils.fabric.FabricPrivacy import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.database.entities.UserEntry.Action import info.nightscout.database.entities.UserEntry.Action

View file

@ -5,25 +5,19 @@ import dagger.Module
import dagger.android.ContributesAndroidInjector import dagger.android.ContributesAndroidInjector
import info.nightscout.interfaces.aps.Loop import info.nightscout.interfaces.aps.Loop
import info.nightscout.interfaces.iob.IobCobCalculator import info.nightscout.interfaces.iob.IobCobCalculator
import info.nightscout.interfaces.nsclient.NSSettingsStatus
import info.nightscout.interfaces.nsclient.ProcessedDeviceStatusData
import info.nightscout.interfaces.smsCommunicator.SmsCommunicator import info.nightscout.interfaces.smsCommunicator.SmsCommunicator
import info.nightscout.interfaces.sync.DataSyncSelector
import info.nightscout.plugins.aps.loop.LoopPlugin import info.nightscout.plugins.aps.loop.LoopPlugin
import info.nightscout.plugins.general.smsCommunicator.SmsCommunicatorPlugin import info.nightscout.plugins.general.smsCommunicator.SmsCommunicatorPlugin
import info.nightscout.plugins.general.wear.WearFragment import info.nightscout.plugins.general.wear.WearFragment
import info.nightscout.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin import info.nightscout.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin
import info.nightscout.plugins.sync.nsclient.DataSyncSelectorImplementation
import info.nightscout.plugins.sync.nsclient.data.NSSettingsStatusImpl
import info.nightscout.plugins.sync.nsclient.data.ProcessedDeviceStatusDataImpl
@Module( @Module(
includes = [ includes = [
PluginsModule.Bindings::class,
InsulinModule::class, InsulinModule::class,
FoodModule::class, FoodModule::class,
SMSCommunicatorModule::class, SMSCommunicatorModule::class,
ProfileModule::class, ProfileModule::class,
SyncModule::class,
SourceModule::class, SourceModule::class,
VirtualPumpModule::class, VirtualPumpModule::class,
ObjectivesModule::class, ObjectivesModule::class,
@ -44,11 +38,8 @@ abstract class PluginsModule {
@Module @Module
interface Bindings { interface Bindings {
@Binds fun bindProcessedDeviceStatusData(processedDeviceStatusDataImpl: ProcessedDeviceStatusDataImpl): ProcessedDeviceStatusData
@Binds fun bindNSSettingsStatus(nsSettingsStatusImpl: NSSettingsStatusImpl): NSSettingsStatus
@Binds fun bindSmsCommunicator(smsCommunicatorPlugin: SmsCommunicatorPlugin): SmsCommunicator @Binds fun bindSmsCommunicator(smsCommunicatorPlugin: SmsCommunicatorPlugin): SmsCommunicator
@Binds fun bindIobCobCalculator(iobCobCalculatorPlugin: IobCobCalculatorPlugin): IobCobCalculator @Binds fun bindIobCobCalculator(iobCobCalculatorPlugin: IobCobCalculatorPlugin): IobCobCalculator
@Binds fun bindLoop(loopPlugin: LoopPlugin): Loop @Binds fun bindLoop(loopPlugin: LoopPlugin): Loop
@Binds fun bindDataSyncSelectorInterface(dataSyncSelectorImplementation: DataSyncSelectorImplementation): DataSyncSelector
} }
} }

View file

@ -1,7 +1,9 @@
package info.nightscout.plugins.di package info.nightscout.plugins.di
import dagger.Binds
import dagger.Module import dagger.Module
import dagger.android.ContributesAndroidInjector import dagger.android.ContributesAndroidInjector
import info.nightscout.interfaces.source.NSClientSource
import info.nightscout.plugins.profile.ProfilePlugin import info.nightscout.plugins.profile.ProfilePlugin
import info.nightscout.plugins.source.AidexPlugin import info.nightscout.plugins.source.AidexPlugin
import info.nightscout.plugins.source.BGSourceFragment import info.nightscout.plugins.source.BGSourceFragment
@ -15,14 +17,19 @@ import info.nightscout.plugins.source.TomatoPlugin
import info.nightscout.plugins.source.XdripPlugin import info.nightscout.plugins.source.XdripPlugin
import info.nightscout.plugins.source.activities.RequestDexcomPermissionActivity import info.nightscout.plugins.source.activities.RequestDexcomPermissionActivity
@Module @Module(
includes = [
SourceModule.Bindings::class
]
)
@Suppress("unused") @Suppress("unused")
abstract class SourceModule { abstract class SourceModule {
@ContributesAndroidInjector abstract fun contributesBGSourceFragment(): BGSourceFragment @ContributesAndroidInjector abstract fun contributesBGSourceFragment(): BGSourceFragment
@ContributesAndroidInjector abstract fun contributesNSProfileWorker(): ProfilePlugin.NSProfileWorker @ContributesAndroidInjector abstract fun contributesNSProfileWorker(): ProfilePlugin.NSProfileWorker
@ContributesAndroidInjector abstract fun contributesNSClientSourceWorker(): NSClientSourcePlugin.NSClientSourceWorker @ContributesAndroidInjector abstract fun contributesNSClientSourceWorker(): info.nightscout.plugins.source.NSClientSourcePlugin.NSClientSourceWorker
@ContributesAndroidInjector abstract fun contributesXdripWorker(): XdripPlugin.XdripWorker @ContributesAndroidInjector abstract fun contributesXdripWorker(): XdripPlugin.XdripWorker
@ContributesAndroidInjector abstract fun contributesDexcomWorker(): DexcomPlugin.DexcomWorker @ContributesAndroidInjector abstract fun contributesDexcomWorker(): DexcomPlugin.DexcomWorker
@ContributesAndroidInjector abstract fun contributesMM640gWorker(): MM640gPlugin.MM640gWorker @ContributesAndroidInjector abstract fun contributesMM640gWorker(): MM640gPlugin.MM640gWorker
@ -33,4 +40,9 @@ abstract class SourceModule {
@ContributesAndroidInjector abstract fun contributesAidexWorker(): AidexPlugin.AidexWorker @ContributesAndroidInjector abstract fun contributesAidexWorker(): AidexPlugin.AidexWorker
@ContributesAndroidInjector abstract fun contributesRequestDexcomPermissionActivity(): RequestDexcomPermissionActivity @ContributesAndroidInjector abstract fun contributesRequestDexcomPermissionActivity(): RequestDexcomPermissionActivity
@Module
interface Bindings {
@Binds fun bindNSClientSource(nsClientSourcePlugin: info.nightscout.plugins.source.NSClientSourcePlugin): NSClientSource
}
} }

View file

@ -1,12 +1,25 @@
package info.nightscout.plugins.di package info.nightscout.plugins.di
import dagger.Binds
import dagger.Module import dagger.Module
import dagger.android.ContributesAndroidInjector import dagger.android.ContributesAndroidInjector
import info.nightscout.interfaces.pump.VirtualPump
import info.nightscout.plugins.pump.virtual.VirtualPumpFragment import info.nightscout.plugins.pump.virtual.VirtualPumpFragment
import info.nightscout.plugins.pump.virtual.VirtualPumpPlugin
@Module @Module(
includes = [
VirtualPumpModule.Bindings::class
]
)
@Suppress("unused") @Suppress("unused")
abstract class VirtualPumpModule { abstract class VirtualPumpModule {
@ContributesAndroidInjector abstract fun contributesVirtualPumpFragment(): VirtualPumpFragment @ContributesAndroidInjector abstract fun contributesVirtualPumpFragment(): VirtualPumpFragment
@Module
interface Bindings {
@Binds fun bindVirtualPump(virtualPumpPlugin: VirtualPumpPlugin): VirtualPump
}
} }

View file

@ -10,7 +10,7 @@ import info.nightscout.androidaps.extensions.toStringFull
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider
import info.nightscout.core.iob.round import info.nightscout.core.iob.round
import info.nightscout.core.utils.fabric.FabricPrivacy import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.core.utils.receivers.ReceiverStatusStore import info.nightscout.interfaces.receivers.ReceiverStatusStore
import info.nightscout.interfaces.Config import info.nightscout.interfaces.Config
import info.nightscout.interfaces.aps.Loop import info.nightscout.interfaces.aps.Loop
import info.nightscout.interfaces.iob.IobCobCalculator import info.nightscout.interfaces.iob.IobCobCalculator

View file

@ -2,10 +2,10 @@ package info.nightscout.plugins.general.overview.notifications
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.interfaces.notifications.Notification import info.nightscout.interfaces.notifications.Notification
import info.nightscout.interfaces.nsclient.NSAlarm
import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.profile.DefaultValueHelper import info.nightscout.interfaces.profile.DefaultValueHelper
import info.nightscout.plugins.R import info.nightscout.plugins.R
import info.nightscout.plugins.sync.nsclient.NSClientPlugin
import info.nightscout.plugins.sync.nsclient.data.NSAlarm
import info.nightscout.rx.logging.AAPSLogger import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.rx.logging.LTag import info.nightscout.rx.logging.LTag
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper
@ -22,7 +22,7 @@ class NotificationWithAction constructor(
@Inject lateinit var rh: ResourceHelper @Inject lateinit var rh: ResourceHelper
@Inject lateinit var sp: SP @Inject lateinit var sp: SP
@Inject lateinit var defaultValueHelper: DefaultValueHelper @Inject lateinit var defaultValueHelper: DefaultValueHelper
@Inject lateinit var nsClientPlugin: NSClientPlugin @Inject lateinit var activePlugin: ActivePlugin
init { init {
injector.androidInjector().inject(this) injector.androidInjector().inject(this)
@ -61,7 +61,7 @@ class NotificationWithAction constructor(
} }
buttonText = R.string.snooze buttonText = R.string.snooze
action = Runnable { action = Runnable {
nsClientPlugin.handleClearAlarm(nsAlarm, 60 * 60 * 1000L) activePlugin.activeNsClient?.handleClearAlarm(nsAlarm, 60 * 60 * 1000L)
// Adding current time to snooze if we got staleData // Adding current time to snooze if we got staleData
aapsLogger.debug(LTag.NOTIFICATION, "Notification text is: $text") aapsLogger.debug(LTag.NOTIFICATION, "Notification text is: $text")
val msToSnooze = sp.getInt(R.string.key_ns_alarm_stale_data_value, 15) * 60 * 1000L val msToSnooze = sp.getInt(R.string.key_ns_alarm_stale_data_value, 15) * 60 * 1000L

View file

@ -5,9 +5,9 @@ import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import dagger.android.support.DaggerFragment import dagger.android.support.DaggerFragment
import info.nightscout.androidaps.plugins.general.wear.events.EventWearUpdateGui
import info.nightscout.core.utils.fabric.FabricPrivacy import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.plugins.databinding.WearFragmentBinding import info.nightscout.plugins.databinding.WearFragmentBinding
import info.nightscout.plugins.sync.nsShared.events.EventNSClientUpdateGUI
import info.nightscout.rx.AapsSchedulers import info.nightscout.rx.AapsSchedulers
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.EventMobileToWear import info.nightscout.rx.events.EventMobileToWear
@ -48,7 +48,7 @@ class WearFragment : DaggerFragment() {
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
disposable += rxBus disposable += rxBus
.toObservable(EventNSClientUpdateGUI::class.java) .toObservable(EventWearUpdateGui::class.java)
.observeOn(aapsSchedulers.main) .observeOn(aapsSchedulers.main)
.subscribe({ updateGui() }, fabricPrivacy::logException) .subscribe({ updateGui() }, fabricPrivacy::logException)
updateGui() updateGui()

View file

@ -14,7 +14,7 @@ import info.nightscout.core.iob.generateCOBString
import info.nightscout.core.iob.round import info.nightscout.core.iob.round
import info.nightscout.core.ui.toast.ToastUtils import info.nightscout.core.ui.toast.ToastUtils
import info.nightscout.core.utils.fabric.FabricPrivacy import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.core.utils.receivers.ReceiverStatusStore import info.nightscout.interfaces.receivers.ReceiverStatusStore
import info.nightscout.core.wizard.BolusWizard import info.nightscout.core.wizard.BolusWizard
import info.nightscout.core.wizard.QuickWizard import info.nightscout.core.wizard.QuickWizard
import info.nightscout.core.wizard.QuickWizardEntry import info.nightscout.core.wizard.QuickWizardEntry

View file

@ -17,7 +17,7 @@ import com.google.android.gms.wearable.WearableListenerService
import dagger.android.AndroidInjection import dagger.android.AndroidInjection
import info.nightscout.androidaps.plugins.general.wear.events.EventWearUpdateGui import info.nightscout.androidaps.plugins.general.wear.events.EventWearUpdateGui
import info.nightscout.core.utils.fabric.FabricPrivacy import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.core.utils.receivers.ReceiverStatusStore import info.nightscout.interfaces.receivers.ReceiverStatusStore
import info.nightscout.database.impl.AppRepository import info.nightscout.database.impl.AppRepository
import info.nightscout.interfaces.Config import info.nightscout.interfaces.Config
import info.nightscout.interfaces.aps.Loop import info.nightscout.interfaces.aps.Loop

View file

@ -9,6 +9,7 @@ import info.nightscout.core.utils.receivers.DataWorkerStorage
import info.nightscout.database.entities.GlucoseValue import info.nightscout.database.entities.GlucoseValue
import info.nightscout.database.impl.AppRepository import info.nightscout.database.impl.AppRepository
import info.nightscout.database.impl.transactions.CgmSourceTransaction import info.nightscout.database.impl.transactions.CgmSourceTransaction
import info.nightscout.database.transactions.TransactionGlucoseValue
import info.nightscout.interfaces.Config import info.nightscout.interfaces.Config
import info.nightscout.interfaces.Constants import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.plugin.PluginBase import info.nightscout.interfaces.plugin.PluginBase
@ -83,7 +84,7 @@ class AidexPlugin @Inject constructor(
if (bundle.containsKey(Intents.AIDEX_TRANSMITTER_SN)) aapsLogger.debug(LTag.BGSOURCE, "transmitterSerialNumber: " + bundle.getString(Intents.AIDEX_TRANSMITTER_SN)) if (bundle.containsKey(Intents.AIDEX_TRANSMITTER_SN)) aapsLogger.debug(LTag.BGSOURCE, "transmitterSerialNumber: " + bundle.getString(Intents.AIDEX_TRANSMITTER_SN))
if (bundle.containsKey(Intents.AIDEX_SENSOR_ID)) aapsLogger.debug(LTag.BGSOURCE, "sensorId: " + bundle.getString(Intents.AIDEX_SENSOR_ID)) if (bundle.containsKey(Intents.AIDEX_SENSOR_ID)) aapsLogger.debug(LTag.BGSOURCE, "sensorId: " + bundle.getString(Intents.AIDEX_SENSOR_ID))
val glucoseValues = mutableListOf<CgmSourceTransaction.TransactionGlucoseValue>() val glucoseValues = mutableListOf<TransactionGlucoseValue>()
val timestamp = bundle.getLong(Intents.AIDEX_TIMESTAMP, 0) val timestamp = bundle.getLong(Intents.AIDEX_TIMESTAMP, 0)
val bgType = bundle.getString(Intents.AIDEX_BG_TYPE, "mg/dl") val bgType = bundle.getString(Intents.AIDEX_BG_TYPE, "mg/dl")
@ -93,7 +94,7 @@ class AidexPlugin @Inject constructor(
aapsLogger.debug(LTag.BGSOURCE, "Received Aidex broadcast [time=$timestamp, bgType=$bgType, value=$bgValue, targetValue=$bgValueTarget") aapsLogger.debug(LTag.BGSOURCE, "Received Aidex broadcast [time=$timestamp, bgType=$bgType, value=$bgValue, targetValue=$bgValueTarget")
glucoseValues += CgmSourceTransaction.TransactionGlucoseValue( glucoseValues += TransactionGlucoseValue(
timestamp = timestamp, timestamp = timestamp,
value = bgValueTarget, value = bgValueTarget,
raw = null, raw = null,

View file

@ -19,6 +19,7 @@ import info.nightscout.database.entities.ValueWithUnit
import info.nightscout.database.impl.AppRepository import info.nightscout.database.impl.AppRepository
import info.nightscout.database.impl.transactions.CgmSourceTransaction import info.nightscout.database.impl.transactions.CgmSourceTransaction
import info.nightscout.database.impl.transactions.InvalidateGlucoseValueTransaction import info.nightscout.database.impl.transactions.InvalidateGlucoseValueTransaction
import info.nightscout.database.transactions.TransactionGlucoseValue
import info.nightscout.interfaces.Config import info.nightscout.interfaces.Config
import info.nightscout.interfaces.XDripBroadcast import info.nightscout.interfaces.XDripBroadcast
import info.nightscout.interfaces.plugin.PluginBase import info.nightscout.interfaces.plugin.PluginBase
@ -134,7 +135,7 @@ class DexcomPlugin @Inject constructor(
val now = dateUtil.now() val now = dateUtil.now()
val glucoseValuesBundle = bundle.getBundle("glucoseValues") val glucoseValuesBundle = bundle.getBundle("glucoseValues")
?: return Result.failure(workDataOf("Error" to "missing glucoseValues")) ?: return Result.failure(workDataOf("Error" to "missing glucoseValues"))
val glucoseValues = mutableListOf<CgmSourceTransaction.TransactionGlucoseValue>() val glucoseValues = mutableListOf<TransactionGlucoseValue>()
for (i in 0 until glucoseValuesBundle.size()) { for (i in 0 until glucoseValuesBundle.size()) {
val glucoseValueBundle = glucoseValuesBundle.getBundle(i.toString())!! val glucoseValueBundle = glucoseValuesBundle.getBundle(i.toString())!!
val timestamp = glucoseValueBundle.getLong("timestamp") * 1000 val timestamp = glucoseValueBundle.getLong("timestamp") * 1000
@ -146,7 +147,7 @@ class DexcomPlugin @Inject constructor(
if (sourceSensor == GlucoseValue.SourceSensor.DEXCOM_G6_NATIVE) if (sourceSensor == GlucoseValue.SourceSensor.DEXCOM_G6_NATIVE)
if ((now - timestamp) > T.hours(20).msecs()) valid = false if ((now - timestamp) > T.hours(20).msecs()) valid = false
if (valid) if (valid)
glucoseValues += CgmSourceTransaction.TransactionGlucoseValue( glucoseValues += TransactionGlucoseValue(
timestamp = timestamp, timestamp = timestamp,
value = glucoseValueBundle.getInt("glucoseValue").toDouble(), value = glucoseValueBundle.getInt("glucoseValue").toDouble(),
noise = null, noise = null,

View file

@ -11,6 +11,7 @@ import info.nightscout.database.entities.TherapyEvent
import info.nightscout.database.impl.AppRepository import info.nightscout.database.impl.AppRepository
import info.nightscout.database.impl.transactions.CgmSourceTransaction import info.nightscout.database.impl.transactions.CgmSourceTransaction
import info.nightscout.database.impl.transactions.InsertIfNewByTimestampTherapyEventTransaction import info.nightscout.database.impl.transactions.InsertIfNewByTimestampTherapyEventTransaction
import info.nightscout.database.transactions.TransactionGlucoseValue
import info.nightscout.interfaces.XDripBroadcast import info.nightscout.interfaces.XDripBroadcast
import info.nightscout.interfaces.plugin.PluginBase import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.plugin.PluginDescription import info.nightscout.interfaces.plugin.PluginDescription
@ -93,7 +94,7 @@ class EversensePlugin @Inject constructor(
if (bundle.containsKey("transmitterVersionNumber")) aapsLogger.debug(LTag.BGSOURCE, "transmitterVersionNumber: " + bundle.getString("transmitterVersionNumber")) if (bundle.containsKey("transmitterVersionNumber")) aapsLogger.debug(LTag.BGSOURCE, "transmitterVersionNumber: " + bundle.getString("transmitterVersionNumber"))
if (bundle.containsKey("transmitterConnectionState")) aapsLogger.debug(LTag.BGSOURCE, "transmitterConnectionState: " + bundle.getString("transmitterConnectionState")) if (bundle.containsKey("transmitterConnectionState")) aapsLogger.debug(LTag.BGSOURCE, "transmitterConnectionState: " + bundle.getString("transmitterConnectionState"))
if (bundle.containsKey("glucoseLevels")) { if (bundle.containsKey("glucoseLevels")) {
val glucoseValues = mutableListOf<CgmSourceTransaction.TransactionGlucoseValue>() val glucoseValues = mutableListOf<TransactionGlucoseValue>()
val glucoseLevels = bundle.getIntArray("glucoseLevels") val glucoseLevels = bundle.getIntArray("glucoseLevels")
val glucoseRecordNumbers = bundle.getIntArray("glucoseRecordNumbers") val glucoseRecordNumbers = bundle.getIntArray("glucoseRecordNumbers")
val glucoseTimestamps = bundle.getLongArray("glucoseTimestamps") val glucoseTimestamps = bundle.getLongArray("glucoseTimestamps")
@ -102,7 +103,7 @@ class EversensePlugin @Inject constructor(
aapsLogger.debug(LTag.BGSOURCE, "glucoseRecordNumbers" + Arrays.toString(glucoseRecordNumbers)) aapsLogger.debug(LTag.BGSOURCE, "glucoseRecordNumbers" + Arrays.toString(glucoseRecordNumbers))
aapsLogger.debug(LTag.BGSOURCE, "glucoseTimestamps" + Arrays.toString(glucoseTimestamps)) aapsLogger.debug(LTag.BGSOURCE, "glucoseTimestamps" + Arrays.toString(glucoseTimestamps))
for (i in glucoseLevels.indices) for (i in glucoseLevels.indices)
glucoseValues += CgmSourceTransaction.TransactionGlucoseValue( glucoseValues += TransactionGlucoseValue(
timestamp = glucoseTimestamps[i], timestamp = glucoseTimestamps[i],
value = glucoseLevels[i].toDouble(), value = glucoseLevels[i].toDouble(),
raw = glucoseLevels[i].toDouble(), raw = glucoseLevels[i].toDouble(),

View file

@ -9,6 +9,7 @@ import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.database.entities.GlucoseValue import info.nightscout.database.entities.GlucoseValue
import info.nightscout.database.impl.AppRepository import info.nightscout.database.impl.AppRepository
import info.nightscout.database.impl.transactions.CgmSourceTransaction import info.nightscout.database.impl.transactions.CgmSourceTransaction
import info.nightscout.database.transactions.TransactionGlucoseValue
import info.nightscout.interfaces.XDripBroadcast import info.nightscout.interfaces.XDripBroadcast
import info.nightscout.interfaces.plugin.PluginBase import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.plugin.PluginDescription import info.nightscout.interfaces.plugin.PluginDescription
@ -61,8 +62,8 @@ class GlimpPlugin @Inject constructor(
if (!glimpPlugin.isEnabled()) return Result.success(workDataOf("Result" to "Plugin not enabled")) if (!glimpPlugin.isEnabled()) return Result.success(workDataOf("Result" to "Plugin not enabled"))
aapsLogger.debug(LTag.BGSOURCE, "Received Glimp Data: $inputData}") aapsLogger.debug(LTag.BGSOURCE, "Received Glimp Data: $inputData}")
val glucoseValues = mutableListOf<CgmSourceTransaction.TransactionGlucoseValue>() val glucoseValues = mutableListOf<TransactionGlucoseValue>()
glucoseValues += CgmSourceTransaction.TransactionGlucoseValue( glucoseValues += TransactionGlucoseValue(
timestamp = inputData.getLong("myTimestamp", 0), timestamp = inputData.getLong("myTimestamp", 0),
value = inputData.getDouble("mySGV", 0.0), value = inputData.getDouble("mySGV", 0.0),
raw = inputData.getDouble("mySGV", 0.0), raw = inputData.getDouble("mySGV", 0.0),

View file

@ -13,6 +13,7 @@ import info.nightscout.database.entities.UserEntry
import info.nightscout.database.entities.ValueWithUnit import info.nightscout.database.entities.ValueWithUnit
import info.nightscout.database.impl.AppRepository import info.nightscout.database.impl.AppRepository
import info.nightscout.database.impl.transactions.CgmSourceTransaction import info.nightscout.database.impl.transactions.CgmSourceTransaction
import info.nightscout.database.transactions.TransactionGlucoseValue
import info.nightscout.interfaces.Constants import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.XDripBroadcast import info.nightscout.interfaces.XDripBroadcast
import info.nightscout.interfaces.plugin.PluginBase import info.nightscout.interfaces.plugin.PluginBase
@ -91,7 +92,7 @@ class GlunovoPlugin @Inject constructor(
try { try {
context.contentResolver.query(contentUri, null, null, null, null)?.let { cr -> context.contentResolver.query(contentUri, null, null, null, null)?.let { cr ->
val glucoseValues = mutableListOf<CgmSourceTransaction.TransactionGlucoseValue>() val glucoseValues = mutableListOf<TransactionGlucoseValue>()
val calibrations = mutableListOf<CgmSourceTransaction.Calibration>() val calibrations = mutableListOf<CgmSourceTransaction.Calibration>()
cr.moveToFirst() cr.moveToFirst()
@ -119,7 +120,7 @@ class GlunovoPlugin @Inject constructor(
} }
if (curr != 0.0) if (curr != 0.0)
glucoseValues += CgmSourceTransaction.TransactionGlucoseValue( glucoseValues += TransactionGlucoseValue(
timestamp = timestamp, timestamp = timestamp,
value = value * Constants.MMOLL_TO_MGDL, value = value * Constants.MMOLL_TO_MGDL,
raw = 0.0, raw = 0.0,

View file

@ -15,6 +15,7 @@ import info.nightscout.database.entities.UserEntry
import info.nightscout.database.entities.ValueWithUnit import info.nightscout.database.entities.ValueWithUnit
import info.nightscout.database.impl.AppRepository import info.nightscout.database.impl.AppRepository
import info.nightscout.database.impl.transactions.CgmSourceTransaction import info.nightscout.database.impl.transactions.CgmSourceTransaction
import info.nightscout.database.transactions.TransactionGlucoseValue
import info.nightscout.interfaces.Constants import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.XDripBroadcast import info.nightscout.interfaces.XDripBroadcast
import info.nightscout.interfaces.plugin.PluginBase import info.nightscout.interfaces.plugin.PluginBase
@ -102,7 +103,7 @@ class IntelligoPlugin @Inject constructor(
} }
context.contentResolver.query(contentUri, null, null, null, null)?.let { cr -> context.contentResolver.query(contentUri, null, null, null, null)?.let { cr ->
val glucoseValues = mutableListOf<CgmSourceTransaction.TransactionGlucoseValue>() val glucoseValues = mutableListOf<TransactionGlucoseValue>()
val calibrations = mutableListOf<CgmSourceTransaction.Calibration>() val calibrations = mutableListOf<CgmSourceTransaction.Calibration>()
cr.moveToFirst() cr.moveToFirst()
@ -130,7 +131,7 @@ class IntelligoPlugin @Inject constructor(
} }
if (curr != 0.0) if (curr != 0.0)
glucoseValues += CgmSourceTransaction.TransactionGlucoseValue( glucoseValues += TransactionGlucoseValue(
timestamp = timestamp, timestamp = timestamp,
value = value * Constants.MMOLL_TO_MGDL, value = value * Constants.MMOLL_TO_MGDL,
raw = 0.0, raw = 0.0,

View file

@ -9,6 +9,7 @@ import info.nightscout.core.utils.receivers.DataWorkerStorage
import info.nightscout.database.entities.GlucoseValue import info.nightscout.database.entities.GlucoseValue
import info.nightscout.database.impl.AppRepository import info.nightscout.database.impl.AppRepository
import info.nightscout.database.impl.transactions.CgmSourceTransaction import info.nightscout.database.impl.transactions.CgmSourceTransaction
import info.nightscout.database.transactions.TransactionGlucoseValue
import info.nightscout.interfaces.XDripBroadcast import info.nightscout.interfaces.XDripBroadcast
import info.nightscout.interfaces.plugin.PluginBase import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.plugin.PluginDescription import info.nightscout.interfaces.plugin.PluginDescription
@ -69,13 +70,13 @@ class MM640gPlugin @Inject constructor(
aapsLogger.debug(LTag.BGSOURCE, "Received MM640g Data: $data") aapsLogger.debug(LTag.BGSOURCE, "Received MM640g Data: $data")
if (!data.isNullOrEmpty()) { if (!data.isNullOrEmpty()) {
try { try {
val glucoseValues = mutableListOf<CgmSourceTransaction.TransactionGlucoseValue>() val glucoseValues = mutableListOf<TransactionGlucoseValue>()
val jsonArray = JSONArray(data) val jsonArray = JSONArray(data)
for (i in 0 until jsonArray.length()) { for (i in 0 until jsonArray.length()) {
val jsonObject = jsonArray.getJSONObject(i) val jsonObject = jsonArray.getJSONObject(i)
when (val type = jsonObject.getString("type")) { when (val type = jsonObject.getString("type")) {
"sgv" -> "sgv" ->
glucoseValues += CgmSourceTransaction.TransactionGlucoseValue( glucoseValues += TransactionGlucoseValue(
timestamp = jsonObject.getLong("date"), timestamp = jsonObject.getLong("date"),
value = jsonObject.getDouble("sgv"), value = jsonObject.getDouble("sgv"),
raw = jsonObject.getDouble("sgv"), raw = jsonObject.getDouble("sgv"),

View file

@ -8,18 +8,19 @@ import dagger.android.HasAndroidInjector
import info.nightscout.core.utils.receivers.DataWorkerStorage import info.nightscout.core.utils.receivers.DataWorkerStorage
import info.nightscout.database.entities.GlucoseValue import info.nightscout.database.entities.GlucoseValue
import info.nightscout.database.impl.AppRepository import info.nightscout.database.impl.AppRepository
import info.nightscout.database.impl.transactions.CgmSourceTransaction import info.nightscout.database.transactions.TransactionGlucoseValue
import info.nightscout.interfaces.Config import info.nightscout.interfaces.Config
import info.nightscout.interfaces.XDripBroadcast import info.nightscout.interfaces.XDripBroadcast
import info.nightscout.interfaces.notifications.Notification import info.nightscout.interfaces.notifications.Notification
import info.nightscout.interfaces.nsclient.NSSgv
import info.nightscout.interfaces.nsclient.StoreDataForDb
import info.nightscout.interfaces.plugin.ActivePlugin import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.plugin.PluginBase import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.plugin.PluginDescription import info.nightscout.interfaces.plugin.PluginDescription
import info.nightscout.interfaces.plugin.PluginType import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.source.BgSource import info.nightscout.interfaces.source.BgSource
import info.nightscout.interfaces.source.NSClientSource
import info.nightscout.plugins.R import info.nightscout.plugins.R
import info.nightscout.plugins.sync.nsShared.StoreDataForDb
import info.nightscout.plugins.sync.nsclient.data.NSSgv
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.EventDismissNotification import info.nightscout.rx.events.EventDismissNotification
import info.nightscout.rx.logging.AAPSLogger import info.nightscout.rx.logging.AAPSLogger
@ -49,7 +50,7 @@ class NSClientSourcePlugin @Inject constructor(
.shortName(R.string.ns_client_bg_short) .shortName(R.string.ns_client_bg_short)
.description(R.string.description_source_ns_client), .description(R.string.description_source_ns_client),
aapsLogger, rh, injector aapsLogger, rh, injector
), BgSource { ), BgSource, NSClientSource {
private var lastBGTimeStamp: Long = 0 private var lastBGTimeStamp: Long = 0
private var isAdvancedFilteringEnabled = false private var isAdvancedFilteringEnabled = false
@ -68,7 +69,7 @@ class NSClientSourcePlugin @Inject constructor(
override fun shouldUploadToNs(glucoseValue: GlucoseValue): Boolean = false override fun shouldUploadToNs(glucoseValue: GlucoseValue): Boolean = false
internal fun detectSource(glucoseValue: GlucoseValue) { override fun detectSource(glucoseValue: GlucoseValue) {
if (glucoseValue.timestamp > lastBGTimeStamp) { if (glucoseValue.timestamp > lastBGTimeStamp) {
isAdvancedFilteringEnabled = arrayOf( isAdvancedFilteringEnabled = arrayOf(
GlucoseValue.SourceSensor.DEXCOM_NATIVE_UNKNOWN, GlucoseValue.SourceSensor.DEXCOM_NATIVE_UNKNOWN,
@ -103,9 +104,9 @@ class NSClientSourcePlugin @Inject constructor(
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this) (context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
} }
private fun toGv(jsonObject: JSONObject): CgmSourceTransaction.TransactionGlucoseValue? { private fun toGv(jsonObject: JSONObject): TransactionGlucoseValue? {
val sgv = NSSgv(jsonObject) val sgv = NSSgv(jsonObject)
return CgmSourceTransaction.TransactionGlucoseValue( return TransactionGlucoseValue(
timestamp = sgv.mills ?: return null, timestamp = sgv.mills ?: return null,
value = sgv.mgdl?.toDouble() ?: return null, value = sgv.mgdl?.toDouble() ?: return null,
noise = null, noise = null,
@ -116,8 +117,8 @@ class NSClientSourcePlugin @Inject constructor(
) )
} }
private fun toGv(sgv: NSSgvV3): CgmSourceTransaction.TransactionGlucoseValue { private fun toGv(sgv: NSSgvV3): TransactionGlucoseValue {
return CgmSourceTransaction.TransactionGlucoseValue( return TransactionGlucoseValue(
timestamp = sgv.date, timestamp = sgv.date,
value = sgv.sgv, value = sgv.sgv,
noise = sgv.noise?.toDouble(), noise = sgv.noise?.toDouble(),
@ -140,7 +141,7 @@ class NSClientSourcePlugin @Inject constructor(
var latestDateInReceivedData: Long = 0 var latestDateInReceivedData: Long = 0
aapsLogger.debug(LTag.BGSOURCE, "Received NS Data: $sgvs") aapsLogger.debug(LTag.BGSOURCE, "Received NS Data: $sgvs")
val glucoseValues = mutableListOf<CgmSourceTransaction.TransactionGlucoseValue>() val glucoseValues = mutableListOf<TransactionGlucoseValue>()
try { try {
if (sgvs is JSONArray) { // V1 client if (sgvs is JSONArray) { // V1 client

View file

@ -8,6 +8,7 @@ import dagger.android.HasAndroidInjector
import info.nightscout.database.entities.GlucoseValue import info.nightscout.database.entities.GlucoseValue
import info.nightscout.database.impl.AppRepository import info.nightscout.database.impl.AppRepository
import info.nightscout.database.impl.transactions.CgmSourceTransaction import info.nightscout.database.impl.transactions.CgmSourceTransaction
import info.nightscout.database.transactions.TransactionGlucoseValue
import info.nightscout.interfaces.Constants import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.XDripBroadcast import info.nightscout.interfaces.XDripBroadcast
import info.nightscout.interfaces.plugin.PluginBase import info.nightscout.interfaces.plugin.PluginBase
@ -64,12 +65,12 @@ class PoctechPlugin @Inject constructor(
if (!poctechPlugin.isEnabled()) return Result.success(workDataOf("Result" to "Plugin not enabled")) if (!poctechPlugin.isEnabled()) return Result.success(workDataOf("Result" to "Plugin not enabled"))
aapsLogger.debug(LTag.BGSOURCE, "Received Poctech Data $inputData") aapsLogger.debug(LTag.BGSOURCE, "Received Poctech Data $inputData")
try { try {
val glucoseValues = mutableListOf<CgmSourceTransaction.TransactionGlucoseValue>() val glucoseValues = mutableListOf<TransactionGlucoseValue>()
val jsonArray = JSONArray(inputData.getString("data")) val jsonArray = JSONArray(inputData.getString("data"))
aapsLogger.debug(LTag.BGSOURCE, "Received Poctech Data size:" + jsonArray.length()) aapsLogger.debug(LTag.BGSOURCE, "Received Poctech Data size:" + jsonArray.length())
for (i in 0 until jsonArray.length()) { for (i in 0 until jsonArray.length()) {
val json = jsonArray.getJSONObject(i) val json = jsonArray.getJSONObject(i)
glucoseValues += CgmSourceTransaction.TransactionGlucoseValue( glucoseValues += TransactionGlucoseValue(
timestamp = json.getLong("date"), timestamp = json.getLong("date"),
value = if (safeGetString(json, "units", Constants.MGDL) == "mmol/L") json.getDouble("current") * Constants.MMOLL_TO_MGDL value = if (safeGetString(json, "units", Constants.MGDL) == "mmol/L") json.getDouble("current") * Constants.MMOLL_TO_MGDL
else json.getDouble("current"), else json.getDouble("current"),

View file

@ -8,6 +8,7 @@ import info.nightscout.core.utils.isRunningTest
import info.nightscout.database.entities.GlucoseValue import info.nightscout.database.entities.GlucoseValue
import info.nightscout.database.impl.AppRepository import info.nightscout.database.impl.AppRepository
import info.nightscout.database.impl.transactions.CgmSourceTransaction import info.nightscout.database.impl.transactions.CgmSourceTransaction
import info.nightscout.database.transactions.TransactionGlucoseValue
import info.nightscout.interfaces.Config import info.nightscout.interfaces.Config
import info.nightscout.interfaces.XDripBroadcast import info.nightscout.interfaces.XDripBroadcast
import info.nightscout.interfaces.plugin.PluginBase import info.nightscout.interfaces.plugin.PluginBase
@ -108,8 +109,8 @@ class RandomBgPlugin @Inject constructor(
cal[Calendar.MILLISECOND] = 0 cal[Calendar.MILLISECOND] = 0
cal[Calendar.SECOND] = 0 cal[Calendar.SECOND] = 0
cal[Calendar.MINUTE] -= cal[Calendar.MINUTE] % 5 cal[Calendar.MINUTE] -= cal[Calendar.MINUTE] % 5
val glucoseValues = mutableListOf<CgmSourceTransaction.TransactionGlucoseValue>() val glucoseValues = mutableListOf<TransactionGlucoseValue>()
glucoseValues += CgmSourceTransaction.TransactionGlucoseValue( glucoseValues += TransactionGlucoseValue(
timestamp = cal.timeInMillis, timestamp = cal.timeInMillis,
value = bgMgdl, value = bgMgdl,
raw = 0.0, raw = 0.0,

View file

@ -8,6 +8,7 @@ import dagger.android.HasAndroidInjector
import info.nightscout.database.entities.GlucoseValue import info.nightscout.database.entities.GlucoseValue
import info.nightscout.database.impl.AppRepository import info.nightscout.database.impl.AppRepository
import info.nightscout.database.impl.transactions.CgmSourceTransaction import info.nightscout.database.impl.transactions.CgmSourceTransaction
import info.nightscout.database.transactions.TransactionGlucoseValue
import info.nightscout.interfaces.XDripBroadcast import info.nightscout.interfaces.XDripBroadcast
import info.nightscout.interfaces.plugin.PluginBase import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.plugin.PluginDescription import info.nightscout.interfaces.plugin.PluginDescription
@ -61,8 +62,8 @@ class TomatoPlugin @Inject constructor(
var ret = Result.success() var ret = Result.success()
if (!tomatoPlugin.isEnabled()) return Result.success(workDataOf("Result" to "Plugin not enabled")) if (!tomatoPlugin.isEnabled()) return Result.success(workDataOf("Result" to "Plugin not enabled"))
val glucoseValues = mutableListOf<CgmSourceTransaction.TransactionGlucoseValue>() val glucoseValues = mutableListOf<TransactionGlucoseValue>()
glucoseValues += CgmSourceTransaction.TransactionGlucoseValue( glucoseValues += TransactionGlucoseValue(
timestamp = inputData.getLong("com.fanqies.tomatofn.Extras.Time", 0), timestamp = inputData.getLong("com.fanqies.tomatofn.Extras.Time", 0),
value = inputData.getDouble("com.fanqies.tomatofn.Extras.BgEstimate", 0.0), value = inputData.getDouble("com.fanqies.tomatofn.Extras.BgEstimate", 0.0),
raw = 0.0, raw = 0.0,

View file

@ -10,6 +10,7 @@ import info.nightscout.interfaces.receivers.Intents
import info.nightscout.database.entities.GlucoseValue import info.nightscout.database.entities.GlucoseValue
import info.nightscout.database.impl.AppRepository import info.nightscout.database.impl.AppRepository
import info.nightscout.database.impl.transactions.CgmSourceTransaction import info.nightscout.database.impl.transactions.CgmSourceTransaction
import info.nightscout.database.transactions.TransactionGlucoseValue
import info.nightscout.interfaces.plugin.PluginBase import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.plugin.PluginDescription import info.nightscout.interfaces.plugin.PluginDescription
import info.nightscout.interfaces.plugin.PluginType import info.nightscout.interfaces.plugin.PluginType
@ -79,8 +80,8 @@ class XdripPlugin @Inject constructor(
?: return Result.failure(workDataOf("Error" to "missing input data")) ?: return Result.failure(workDataOf("Error" to "missing input data"))
aapsLogger.debug(LTag.BGSOURCE, "Received xDrip data: $bundle") aapsLogger.debug(LTag.BGSOURCE, "Received xDrip data: $bundle")
val glucoseValues = mutableListOf<CgmSourceTransaction.TransactionGlucoseValue>() val glucoseValues = mutableListOf<TransactionGlucoseValue>()
glucoseValues += CgmSourceTransaction.TransactionGlucoseValue( glucoseValues += TransactionGlucoseValue(
timestamp = bundle.getLong(Intents.EXTRA_TIMESTAMP, 0), timestamp = bundle.getLong(Intents.EXTRA_TIMESTAMP, 0),
value = bundle.getDouble(Intents.EXTRA_BG_ESTIMATE, 0.0), value = bundle.getDouble(Intents.EXTRA_BG_ESTIMATE, 0.0),
raw = bundle.getDouble(Intents.EXTRA_RAW, 0.0), raw = bundle.getDouble(Intents.EXTRA_RAW, 0.0),

View file

@ -1,46 +0,0 @@
package info.nightscout.plugins.sync.nsShared.extensions
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.utils.Round
import org.json.JSONObject
fun PumpEnactResult.log(): String {
return "Success: " + success +
" Enacted: " + enacted +
" Comment: " + comment +
" Duration: " + duration +
" Absolute: " + absolute +
" Percent: " + percent +
" IsPercent: " + isPercent +
" IsTempCancel: " + isTempCancel +
" bolusDelivered: " + bolusDelivered +
" carbsDelivered: " + carbsDelivered +
" Queued: " + queued
}
fun PumpEnactResult.json(baseBasal: Double): JSONObject {
val result = JSONObject()
when {
bolusDelivered > 0 -> {
result.put("smb", bolusDelivered)
}
isTempCancel -> {
result.put("rate", 0)
result.put("duration", 0)
}
isPercent -> {
// Nightscout is expecting absolute value
val abs = Round.roundTo(baseBasal * percent / 100, 0.01)
result.put("rate", abs)
result.put("duration", duration)
}
else -> {
result.put("rate", absolute)
result.put("duration", duration)
}
}
return result
}

View file

@ -1,2 +0,0 @@
package info.nightscout.plugins.sync.nsclient.data

View file

@ -1,2 +0,0 @@
package info.nightscout.plugins.sync.nsclient.data

View file

@ -15,11 +15,11 @@ import info.nightscout.interfaces.pump.defs.PumpType
import info.nightscout.interfaces.stats.TddCalculator import info.nightscout.interfaces.stats.TddCalculator
import info.nightscout.interfaces.utils.DecimalFormatter import info.nightscout.interfaces.utils.DecimalFormatter
import info.nightscout.plugins.R import info.nightscout.plugins.R
import info.nightscout.plugins.sync.nsclient.extensions.age
import info.nightscout.shared.extensions.runOnUiThread import info.nightscout.shared.extensions.runOnUiThread
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.shared.utils.DateUtil import info.nightscout.shared.utils.DateUtil
import java.util.concurrent.TimeUnit
import javax.inject.Inject import javax.inject.Inject
import javax.inject.Singleton import javax.inject.Singleton
@ -143,4 +143,14 @@ class StatusLightHandler @Inject constructor(
} }
} }
} }
private fun TherapyEvent.age(useShortText: Boolean, rh: ResourceHelper, dateUtil: DateUtil): String {
val diff = dateUtil.computeDiff(timestamp, System.currentTimeMillis())
var days = " " + rh.gs(info.nightscout.core.main.R.string.days) + " "
var hours = " " + rh.gs(info.nightscout.core.main.R.string.hours) + " "
if (useShortText) {
days = rh.gs(info.nightscout.core.main.R.string.shortday)
hours = rh.gs(info.nightscout.core.main.R.string.shorthour)
}
return diff[TimeUnit.DAYS].toString() + days + diff[TimeUnit.HOURS] + hours
}
} }

View file

@ -196,9 +196,6 @@
<string name="basal_short">BAS</string> <string name="basal_short">BAS</string>
<!-- Objectives --> <!-- Objectives -->
<string name="key_objectives_bg_is_available_in_ns" translatable="false">ObjectivesbgIsAvailableInNS</string>
<string name="key_objectives_pump_status_is_available_in_ns" translatable="false">ObjectivespumpStatusIsAvailableInNS</string>
<string name="completed_well_done">Completed, well done!</string> <string name="completed_well_done">Completed, well done!</string>
<string name="not_completed_yet">Not completed yet</string> <string name="not_completed_yet">Not completed yet</string>
<string name="time_elapsed">Time elapsed</string> <string name="time_elapsed">Time elapsed</string>
@ -264,28 +261,19 @@
<string name="key_keep_screen_on" translatable="false">keep_screen_on</string> <string name="key_keep_screen_on" translatable="false">keep_screen_on</string>
<string name="key_short_tabtitles" translatable="false">short_tabtitles</string> <string name="key_short_tabtitles" translatable="false">short_tabtitles</string>
<string name="copy_existing_values">Copy NS settings (if exists)?</string>
<string name="key_show_statuslights" translatable="false">show_statuslights</string> <string name="key_show_statuslights" translatable="false">show_statuslights</string>
<string name="show_statuslights">Show status lights on home screen</string> <string name="show_statuslights">Show status lights on home screen</string>
<string name="key_statuslights_cage_warning" translatable="false">statuslights_cage_warning</string>
<string name="statuslights_cage_warning">Threshold warning cannula age [h]</string> <string name="statuslights_cage_warning">Threshold warning cannula age [h]</string>
<string name="key_statuslights_cage_critical" translatable="false">statuslights_cage_critical</string>
<string name="statuslights_cage_critical">Threshold critical cannula age [h]</string> <string name="statuslights_cage_critical">Threshold critical cannula age [h]</string>
<string name="key_statuslights_iage_warning" translatable="false">statuslights_iage_warning</string>
<string name="statuslights_iage_warning">Threshold warning insulin age [h]</string> <string name="statuslights_iage_warning">Threshold warning insulin age [h]</string>
<string name="key_statuslights_iage_critical" translatable="false">statuslights_iage_critical</string>
<string name="statuslights_iage_critical">Threshold critical insulin age [h]</string> <string name="statuslights_iage_critical">Threshold critical insulin age [h]</string>
<string name="key_statuslights_sage_warning" translatable="false">statuslights_sage_warning</string>
<string name="statuslights_sage_warning">Threshold warning sensor age [h]</string> <string name="statuslights_sage_warning">Threshold warning sensor age [h]</string>
<string name="key_statuslights_sage_critical" translatable="false">statuslights_sage_critical</string>
<string name="statuslights_sage_critical">Threshold critical sensor age [h]</string> <string name="statuslights_sage_critical">Threshold critical sensor age [h]</string>
<string name="key_statuslights_sbat_warning" translatable="false">statuslights_sbat_warning</string> <string name="key_statuslights_sbat_warning" translatable="false">statuslights_sbat_warning</string>
<string name="statuslights_sbat_warning">Threshold warning sensor battery level [%]</string> <string name="statuslights_sbat_warning">Threshold warning sensor battery level [%]</string>
<string name="key_statuslights_sbat_critical" translatable="false">statuslights_sbat_critical</string> <string name="key_statuslights_sbat_critical" translatable="false">statuslights_sbat_critical</string>
<string name="statuslights_sbat_critical">Threshold critical sensor battery level [%]</string> <string name="statuslights_sbat_critical">Threshold critical sensor battery level [%]</string>
<string name="key_statuslights_bage_warning" translatable="false">statuslights_bage_warning</string>
<string name="statuslights_bage_warning">Threshold warning pump battery age [h]</string> <string name="statuslights_bage_warning">Threshold warning pump battery age [h]</string>
<string name="key_statuslights_bage_critical" translatable="false">statuslights_bage_critical</string>
<string name="statuslights_bage_critical">Threshold critical pump battery age [h]</string> <string name="statuslights_bage_critical">Threshold critical pump battery age [h]</string>
<string name="key_statuslights_res_warning" translatable="false">statuslights_res_warning</string> <string name="key_statuslights_res_warning" translatable="false">statuslights_res_warning</string>
<string name="statuslights_res_warning">Threshold warning reservoir level [U]</string> <string name="statuslights_res_warning">Threshold warning reservoir level [U]</string>
@ -295,7 +283,6 @@
<string name="statuslights_bat_warning">Threshold warning pump battery level [%]</string> <string name="statuslights_bat_warning">Threshold warning pump battery level [%]</string>
<string name="key_statuslights_bat_critical" translatable="false">statuslights_bat_critical</string> <string name="key_statuslights_bat_critical" translatable="false">statuslights_bat_critical</string>
<string name="statuslights_bat_critical">Threshold critical pump battery level [%]</string> <string name="statuslights_bat_critical">Threshold critical pump battery level [%]</string>
<string name="statuslights">Status lights</string>
<string name="statuslights_copy_ns">Copy settings from NS</string> <string name="statuslights_copy_ns">Copy settings from NS</string>
<string name="a11y_graph">graph</string> <string name="a11y_graph">graph</string>
<string name="a11y_insulin_label">insulin</string> <string name="a11y_insulin_label">insulin</string>
@ -383,6 +370,7 @@
<string name="enablesuperbolus_summary">Enable superbolus functionality in wizard. Do not enable until you learn what it really does. IT MAY CAUSE INSULIN OVERDOSE IF USED BLINDLY!</string> <string name="enablesuperbolus_summary">Enable superbolus functionality in wizard. Do not enable until you learn what it really does. IT MAY CAUSE INSULIN OVERDOSE IF USED BLINDLY!</string>
<string name="enablebolusreminder">Enable bolus reminder</string> <string name="enablebolusreminder">Enable bolus reminder</string>
<string name="enablebolusreminder_summary">Use reminder to bolus later with wizard ("post-bolus")</string> <string name="enablebolusreminder_summary">Use reminder to bolus later with wizard ("post-bolus")</string>
<string name="run_question">Run %s?</string>
<!-- OverviewMenu--> <!-- OverviewMenu-->
<string name="key_graph_config" translatable="false">graphconfig</string> <string name="key_graph_config" translatable="false">graphconfig</string>
@ -410,108 +398,6 @@
<string name="graph_scale">Graph scale</string> <string name="graph_scale">Graph scale</string>
<string name="graph_menu_divider_header">Graph</string> <string name="graph_menu_divider_header">Graph</string>
<!-- NSClient -->
<string name="key_ns_client_autoscroll" translatable="false">ns_client_autoscroll</string>
<string name="key_ns_client_paused" translatable="false">ns_client_paused</string>
<string name="key_ns_log_app_started_event" translatable="false">ns_log_app_started_event</string>
<string name="no_write_permission">NSCLIENT has no write permission. Wrong API secret?</string>
<string name="ns_client_v3">NSClientV3</string>
<string name="ns_client_v3_short_name">NSV3</string>
<string name="ns_client">NSClient</string>
<string name="ns_client_short_name">NSCI</string>
<string name="ns_client_url">URL:</string>
<string name="ns_client_autoscroll">Autoscroll</string>
<string name="restart">Restart</string>
<string name="ns_client_internal_title">NSClient</string>
<string name="ns_client_url_title">Nightscout URL</string>
<string name="ns_client_url_dialog_message">Enter Your Nightscout URL</string>
<string name="ns_client_secret_title">NS API secret</string>
<string name="ns_client_secret_dialog_title">NS API secret</string>
<string name="ns_client_secret_dialog_message">Enter NS API secret (min 12 chars)</string>
<string name="nsclient_token_title">NS access token</string>
<string name="nsclient_token_dialog_title">NS access token</string>
<string name="nsclient_token_dialog_message">Access token generated on NS admin page (min 17 chars)</string>
<string name="deliver_now">Deliver now</string>
<string name="clear_queue">Clear queue</string>
<string name="show_queue">Show queue</string>
<string name="queue">Queue:</string>
<string name="status">Status:</string>
<string name="clear_log">Clear log</string>
<string name="full_sync">Full synchronization</string>
<string name="full_sync_comment">Full synchronization? It may take many hours and until finish you\'ll not see new data in NS.</string>
<string name="ns_sync_options">Synchronization</string>
<string name="key_ns_upload" translatable="false">ns_upload</string>
<string name="ns_upload_summary">Profiles, boluses, carbs, temporary basals are uploaded to NS</string>
<string name="ns_upload">Upload data to NS</string>
<string name="ns_receive_profile_store">Receive profile store</string>
<string name="ns_receive_profile_store_summary">Synchronize profiles from NS profile editor</string>
<string name="ns_receive_temp_target">Receive temporary targets</string>
<string name="ns_receive_temp_target_summary">Accept temporary targets entered through NS or NSClient</string>
<string name="ns_receive_profile_switch">Receive profile switches</string>
<string name="ns_receive_profile_switch_summary">Accept profile switches entered through NS or NSClient</string>
<string name="ns_receive_offline_event">Receive APS offline events</string>
<string name="ns_receive_offline_event_summary">Accept APS Offline events entered through NS or NSClient</string>
<string name="ns_receive_tbr_eb">Receive TBR and EB</string>
<string name="ns_receive_tbr_eb_summary">Accept TBR and EB entered through another instance</string>
<string name="ns_receive_insulin">Receive insulin</string>
<string name="ns_receive_insulin_summary">Accept insulin entered through NS or NSClient (it\'s not delivered, only calculated towards IOB)</string>
<string name="ns_receive_carbs">Receive carbs</string>
<string name="ns_receive_carbs_summary">Accept carbs entered through NS or NSClient</string>
<string name="key_ns_receive_tbr_eb" translatable="false">ns_receive_tbr_eb</string>
<string name="ns_receive_therapy_events">Receive therapy events</string>
<string name="ns_receive_therapy_events_summary">Accept therapy events (cannula, insulin, battery change etc) entered through NS or NSClient</string>
<string name="key_ns_receive_cgm" translatable="false">ns_receive_cgm</string>
<string name="ns_receive_cgm">Receive/backfill CGM data</string>
<string name="ns_receive_cgm_summary">Accept CGM data from NS</string>
<string name="run_question">Run %s?</string>
<string name="ns_sync_slow">Slow down uploads</string>
<string name="ns_alarm_options">Alarm options</string>
<string name="key_ns_announcements" translatable="false">ns_announcements</string>
<string name="key_ns_alarms" translatable="false">ns_alarms</string>
<string name="key_ns_alarm_stale_data_value" translatable="false">ns_alarm_stale_data_value</string>
<string name="key_ns_alarm_urgent_stale_data_value" translatable="false">ns_alarm_urgent_stale_data_value</string>
<string name="ns_alarms">Create notifications from NS alarms</string>
<string name="ns_announcements">Create notifications from NS announcements</string>
<string name="ns_alarm_stale_data_value_label">Stale data threshold [min]</string>
<string name="ns_alarm_urgent_stale_data_value_label">Urgent stale data threshold [min]</string>
<string name="ns_log_app_started_event">Log app start to NS</string>
<string name="ns_local_broadcasts">Enable broadcasts to other apps (like xDrip+). Do not enable if you have more than one instance of AAPS or AAPSClient installed!</string>
<string name="ns_local_broadcasts_title">Enable local Broadcasts.</string>
<!-- Tidepool -->
<string name="key_tidepool_username" translatable="false">tidepool_username</string>
<string name="key_tidepool_password" translatable="false">tidepool_password</string>
<string name="key_tidepool_dev_servers" translatable="false">tidepool_dev_servers</string>
<string name="key_tidepool_test_login" translatable="false">tidepool_test_login</string>
<string name="key_tidepool_only_while_charging" translatable="false">tidepool_only_while_charging</string>
<string name="key_tidepool_only_while_unmetered" translatable="false">tidepool_only_while_unmetered</string>
<string name="key_tidepool_last_end" translatable="false">tidepool_last_end</string>
<string name="key_tidepool_upload_profile" translatable="false">tidepool_upload_profile</string>
<string name="key_tidepool_upload_tbr" translatable="false">tidepool_upload_tbr</string>
<string name="key_tidepool_upload_cgm" translatable="false">tidepool_upload_cgm</string>
<string name="key_tidepool_upload_bolus" translatable="false">tidepool_upload_bolus</string>
<string name="key_tidepool_upload_bg" translatable="false">tidepool_upload_bg</string>
<string name="summary_tidepool_username">Your Tidepool login user name, normally your email address</string>
<string name="title_tidepool_username">Login User Name</string>
<string name="summary_tidepool_password">Your Tidepool login password</string>
<string name="title_tidepool_password">Login Password</string>
<string name="title_tidepool_test_login">Test Tidepool Login</string>
<string name="summary_tidepool_dev_servers">If enabled, uploads will go to https://int-app.tidepool.org instead of the regular https://app.tidepool.org/</string>
<string name="title_tidepool_dev_servers">Use Integration (test) servers</string>
<string name="tidepool">Tidepool</string>
<string name="tidepool_shortname">TDP</string>
<string name="description_tidepool">Uploads data to Tidepool</string>
<string name="tidepool_upload_cgm">Upload CGM data</string>
<string name="tidepool_upload_bolus">Upload treatments (insulin, carbs)</string>
<string name="tidepool_upload_tbr">Upload temporary basals</string>
<string name="tidepool_upload_profile">Upload profile switches, temp targets</string>
<string name="tidepool_upload_bg">Upload BG tests</string>
<string name="remove_all">Remove all</string>
<string name="reset_start">Reset start</string>
<string name="upload_now">Upload now</string>
<!-- VirtualPump --> <!-- VirtualPump -->
<string name="key_virtual_pump_upload_status" translatable="false">virtualpump_uploadstatus</string> <string name="key_virtual_pump_upload_status" translatable="false">virtualpump_uploadstatus</string>
<string name="virtual_pump_type">Virtual Pump Type</string> <string name="virtual_pump_type">Virtual Pump Type</string>
@ -568,54 +454,6 @@
<string name="dexcom_log_ns_sensor_change_title">Log sensor change to NS</string> <string name="dexcom_log_ns_sensor_change_title">Log sensor change to NS</string>
<string name="dexcom_log_ns_sensor_change_summary">Create event \"Sensor Change\" in NS automatically on sensor start</string> <string name="dexcom_log_ns_sensor_change_summary">Create event \"Sensor Change\" in NS automatically on sensor start</string>
<!-- NSClient -->
<string name="key_ns_temporary_target_last_synced_id" translatable="false">ns_temporary_target_last_sync</string>
<string name="key_ns_glucose_value_last_synced_id" translatable="false">ns_glucose_value_last_sync</string>
<string name="key_ns_food_last_synced_id" translatable="false">ns_food_last_sync</string>
<string name="key_ns_therapy_event_last_synced_id" translatable="false">ns_therapy_event_last_sync</string>
<string name="key_ns_bolus_calculator_result_last_synced_id" translatable="false">ns_bolus_calculator_result_last_synced_id</string>
<string name="key_ns_carbs_last_synced_id" translatable="false">ns_carbs_last_synced_id</string>
<string name="key_ns_bolus_last_synced_id" translatable="false">ns_bolus_last_synced_id</string>
<string name="key_ns_device_status_last_synced_id" translatable="false">ns_device_status_last_synced_id</string>
<string name="key_ns_temporary_basal_last_synced_id" translatable="false">ns_temporary_basal_last_synced_id</string>
<string name="key_ns_extended_bolus_last_synced_id" translatable="false">ns_extended_bolus_last_synced_id</string>
<string name="key_ns_profile_switch_last_synced_id" translatable="false">profile_switch_last_synced_id</string>
<string name="key_ns_effective_profile_switch_last_synced_id" translatable="false">ns_effective_profile_switch_last_synced_id</string>
<string name="key_ns_offline_event_last_synced_id" translatable="false">ns_offline_event_last_synced_id</string>
<string name="key_ns_profile_store_last_synced_timestamp" translatable="false">ns_profile_store_last_synced_timestamp</string>
<string name="key_ns_sync_slow" translatable="false">ns_sync_slow</string>
<string name="key_ns_client_token" translatable="false">nsclient_token</string>
<string name="key_ns_client_v3_last_modified" translatable="false">key_ns_client_v3_last_modified</string>
<string name="key_ns_create_announcements_from_carbs_req" translatable="false">ns_create_announcements_from_carbs_req</string>
<string name="key_ns_cellular" translatable="false">ns_cellular</string>
<string name="key_ns_wifi" translatable="false">ns_wifi</string>
<string name="key_ns_wifi_ssids" translatable="false">ns_wifi_ssids</string>
<string name="key_ns_allow_roaming" translatable="false">ns_allow_roaming</string>
<string name="key_ns_battery" translatable="false">ns_battery</string>
<string name="key_ns_charging" translatable="false">ns_charging</string>
<string name="key_snoozed_to" translatable="false">snoozedTo</string>
<string name="ns_cellular">Use Cellular connection</string>
<string name="ns_wifi">Use WiFi connection</string>
<string name="ns_wifi_ssids">WiFi SSID</string>
<string name="ns_charging">During charging</string>
<string name="ns_battery">On battery</string>
<string name="connection_settings_title">Connection settings</string>
<string name="ns_wifi_allowed_ssids">Allowed SSIDs (semicolon separated)</string>
<string name="ns_allow_roaming">Allow connection in roaming</string>
<string name="ns_create_announcements_from_errors_title">Create announcements from errors</string>
<string name="ns_create_announcements_from_carbs_req_title">Create announcements from carbs required alerts</string>
<string name="ns_create_announcements_from_errors_summary">Create Nightscout announcement for error dialogs and local alerts (also viewable in Careportal under Treatments)</string>
<string name="ns_create_announcements_from_carbs_req_summary">Create Nightscout announcements for carbs required alerts</string>
<string name="description_ns_client">Synchronizes your data with Nightscout</string>
<string name="description_ns_client_v3">Synchronizes your data with Nightscout using v3 API</string>
<string name="blocked_by_charging">Blocked by charging options</string>
<string name="blocked_by_connectivity">Blocked by connectivity options</string>
<string name="unsupported_ns_version">Unsupported version of Nightscout</string>
<string name="openaps_short">OAPS</string>
<string name="uploader_short">UPLD</string>
<string name="ns_malfunction">NSClient malfunction. Consider NS and NSClient restart.</string>
<!-- Skins --> <!-- Skins -->
<string name="key_skin" translatable="false">skin</string> <string name="key_skin" translatable="false">skin</string>

View file

@ -13,7 +13,7 @@ import org.mockito.Mock
class NSClientPluginTest : TestBase() { class NSClientPluginTest : TestBase() {
private lateinit var nsClientSourcePlugin: NSClientSourcePlugin private lateinit var nsClientSourcePlugin: info.nightscout.plugins.source.NSClientSourcePlugin
@Mock lateinit var rh: ResourceHelper @Mock lateinit var rh: ResourceHelper
@Mock lateinit var sp: SP @Mock lateinit var sp: SP
@ -21,7 +21,7 @@ class NSClientPluginTest : TestBase() {
@Before @Before
fun setup() { fun setup() {
nsClientSourcePlugin = NSClientSourcePlugin({ AndroidInjector { } }, rh, aapsLogger, config) nsClientSourcePlugin = info.nightscout.plugins.source.NSClientSourcePlugin({ AndroidInjector { } }, rh, aapsLogger, config)
} }
@Test fun advancedFilteringSupported() { @Test fun advancedFilteringSupported() {

View file

@ -2,7 +2,7 @@ package info.nightscout.plugins.sync.nsclient
import android.content.Context import android.content.Context
import info.nightscout.androidaps.TestBase import info.nightscout.androidaps.TestBase
import info.nightscout.core.utils.receivers.ReceiverStatusStore import info.nightscout.interfaces.receivers.ReceiverStatusStore
import info.nightscout.plugins.R import info.nightscout.plugins.R
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.EventChargingState import info.nightscout.rx.events.EventChargingState

View file

@ -2,7 +2,7 @@ package info.nightscout.plugins.constraints.versionChecker
import android.os.Build import android.os.Build
import dagger.Lazy import dagger.Lazy
import info.nightscout.core.utils.receivers.ReceiverStatusStore import info.nightscout.interfaces.receivers.ReceiverStatusStore
import info.nightscout.interfaces.Config import info.nightscout.interfaces.Config
import info.nightscout.interfaces.constraints.versionChecker.AllowedVersions import info.nightscout.interfaces.constraints.versionChecker.AllowedVersions
import info.nightscout.interfaces.notifications.Notification import info.nightscout.interfaces.notifications.Notification

View file

@ -9,6 +9,7 @@ import info.nightscout.plugins.constraints.versionChecker.VersionCheckerUtilsImp
@Module( @Module(
includes = [ includes = [
PluginsSupportModule.Bindings::class
] ]
) )

View file

@ -2,7 +2,7 @@ package info.nightscout.plugins.constraints.signatureVerifier
import dagger.Lazy import dagger.Lazy
import info.nightscout.androidaps.TestBase import info.nightscout.androidaps.TestBase
import info.nightscout.core.utils.receivers.ReceiverStatusStore import info.nightscout.interfaces.receivers.ReceiverStatusStore
import info.nightscout.interfaces.Config import info.nightscout.interfaces.Config
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.ActivityNames
import info.nightscout.interfaces.versionChecker.VersionCheckerUtils import info.nightscout.interfaces.versionChecker.VersionCheckerUtils

1
plugins/sync/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/build

58
plugins/sync/build.gradle Normal file
View file

@ -0,0 +1,58 @@
plugins {
id 'com.android.library'
id 'kotlin-android'
id 'kotlin-kapt'
id 'kotlin-allopen'
id 'com.hiya.jacoco-android'
}
apply from: "${project.rootDir}/core/core-main/android_dependencies.gradle"
apply from: "${project.rootDir}/core/core-main/android_module_dependencies.gradle"
apply from: "${project.rootDir}/core/core-main/test_dependencies.gradle"
apply from: "${project.rootDir}/core/core-main/allopen_dependencies.gradle"
apply from: "${project.rootDir}/core/core-main/jacoco_global.gradle"
android {
namespace 'info.nightscout.plugins.sync'
}
dependencies {
implementation project(':app-wear-shared:shared')
implementation project(':database:entities')
implementation project(':database:impl')
implementation project(':core:core-main')
implementation project(':core:graph')
implementation project(':core:graphview')
implementation project(':core:interfaces')
implementation project(':core:ns-sdk')
implementation project(':core:ui')
implementation project(':core:utils')
implementation project(':core:validators')
api "androidx.appcompat:appcompat:$appcompat_version"
api "com.google.android.material:material:$material_version"
// NSClient, Tidepool
api("io.socket:socket.io-client:1.0.0") {
// excluding org.json which is provided by Android
exclude group: "org.json", module: "json"
}
api "com.squareup.okhttp3:okhttp:$okhttp3_version"
api "com.squareup.okhttp3:logging-interceptor:$okhttp3_version"
//api "com.squareup.retrofit2:retrofit:$retrofit2_version"
api "com.squareup.retrofit2:adapter-rxjava3:$retrofit2_version"
api "com.squareup.retrofit2:converter-gson:$retrofit2_version"
//SmsCommunicator
api 'com.eatthepath:java-otp:0.4.0'
api 'com.github.kenglxn.QRGen:android:2.6.0'
// Overview
api 'com.google.android.flexbox:flexbox:3.0.0'
// Food
api "androidx.work:work-runtime-ktx:$work_version"
// DataLayerListenerService
api "com.google.android.gms:play-services-wearable:$play_services_wearable_version"
}

View file

21
plugins/sync/proguard-rules.pro vendored Normal file
View file

@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
</manifest>

View file

@ -1,9 +1,17 @@
package info.nightscout.plugins.di package info.nightscout.plugins.sync.di
import dagger.Binds
import dagger.Module import dagger.Module
import dagger.android.ContributesAndroidInjector import dagger.android.ContributesAndroidInjector
import info.nightscout.interfaces.nsclient.NSSettingsStatus
import info.nightscout.interfaces.nsclient.ProcessedDeviceStatusData
import info.nightscout.interfaces.nsclient.StoreDataForDb
import info.nightscout.interfaces.sync.DataSyncSelector
import info.nightscout.plugins.sync.nsShared.NSClientFragment import info.nightscout.plugins.sync.nsShared.NSClientFragment
import info.nightscout.plugins.sync.nsShared.StoreDataForDb import info.nightscout.plugins.sync.nsShared.StoreDataForDbImpl
import info.nightscout.plugins.sync.nsclient.DataSyncSelectorImplementation
import info.nightscout.plugins.sync.nsclient.data.NSSettingsStatusImpl
import info.nightscout.plugins.sync.nsclient.data.ProcessedDeviceStatusDataImpl
import info.nightscout.plugins.sync.nsclient.services.NSClientService import info.nightscout.plugins.sync.nsclient.services.NSClientService
import info.nightscout.plugins.sync.nsclient.workers.NSClientAddAckWorker import info.nightscout.plugins.sync.nsclient.workers.NSClientAddAckWorker
import info.nightscout.plugins.sync.nsclient.workers.NSClientAddUpdateWorker import info.nightscout.plugins.sync.nsclient.workers.NSClientAddUpdateWorker
@ -17,7 +25,12 @@ import info.nightscout.plugins.sync.nsclientV3.workers.LoadTreatmentsWorker
import info.nightscout.plugins.sync.nsclientV3.workers.ProcessTreatmentsWorker import info.nightscout.plugins.sync.nsclientV3.workers.ProcessTreatmentsWorker
import info.nightscout.plugins.sync.tidepool.TidepoolFragment import info.nightscout.plugins.sync.tidepool.TidepoolFragment
@Module @Module(
includes = [
SyncModule.Binding::class
]
)
@Suppress("unused") @Suppress("unused")
abstract class SyncModule { abstract class SyncModule {
@ -32,10 +45,20 @@ abstract class SyncModule {
@ContributesAndroidInjector abstract fun contributesLoadStatusWorker(): LoadStatusWorker @ContributesAndroidInjector abstract fun contributesLoadStatusWorker(): LoadStatusWorker
@ContributesAndroidInjector abstract fun contributesLoadLastModificationWorker(): LoadLastModificationWorker @ContributesAndroidInjector abstract fun contributesLoadLastModificationWorker(): LoadLastModificationWorker
@ContributesAndroidInjector abstract fun contributesLoadBgWorker(): LoadBgWorker @ContributesAndroidInjector abstract fun contributesLoadBgWorker(): LoadBgWorker
@ContributesAndroidInjector abstract fun contributesStoreBgWorker(): StoreDataForDb.StoreBgWorker @ContributesAndroidInjector abstract fun contributesStoreBgWorker(): StoreDataForDbImpl.StoreBgWorker
@ContributesAndroidInjector abstract fun contributesTreatmentWorker(): LoadTreatmentsWorker @ContributesAndroidInjector abstract fun contributesTreatmentWorker(): LoadTreatmentsWorker
@ContributesAndroidInjector abstract fun contributesProcessTreatmentsWorker(): ProcessTreatmentsWorker @ContributesAndroidInjector abstract fun contributesProcessTreatmentsWorker(): ProcessTreatmentsWorker
@ContributesAndroidInjector abstract fun contributesLoadDeviceStatusWorker(): LoadDeviceStatusWorker @ContributesAndroidInjector abstract fun contributesLoadDeviceStatusWorker(): LoadDeviceStatusWorker
@ContributesAndroidInjector abstract fun contributesTidepoolFragment(): TidepoolFragment @ContributesAndroidInjector abstract fun contributesTidepoolFragment(): TidepoolFragment
@Module
interface Binding {
@Binds fun bindProcessedDeviceStatusData(processedDeviceStatusDataImpl: ProcessedDeviceStatusDataImpl): ProcessedDeviceStatusData
@Binds fun bindNSSettingsStatus(nsSettingsStatusImpl: NSSettingsStatusImpl): NSSettingsStatus
@Binds fun bindDataSyncSelectorInterface(dataSyncSelectorImplementation: DataSyncSelectorImplementation): DataSyncSelector
@Binds fun bindStoreDataForDb(storeDataForDbImpl: StoreDataForDbImpl): StoreDataForDb
}
} }

View file

@ -23,8 +23,8 @@ import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.plugin.PluginFragment import info.nightscout.interfaces.plugin.PluginFragment
import info.nightscout.interfaces.sync.DataSyncSelector import info.nightscout.interfaces.sync.DataSyncSelector
import info.nightscout.interfaces.sync.NsClient import info.nightscout.interfaces.sync.NsClient
import info.nightscout.plugins.R import info.nightscout.plugins.sync.R
import info.nightscout.plugins.databinding.NsClientFragmentBinding import info.nightscout.plugins.sync.databinding.NsClientFragmentBinding
import info.nightscout.plugins.sync.nsShared.events.EventNSClientUpdateGUI import info.nightscout.plugins.sync.nsShared.events.EventNSClientUpdateGUI
import info.nightscout.plugins.sync.nsclientV3.NSClientV3Plugin import info.nightscout.plugins.sync.nsclientV3.NSClientV3Plugin
import info.nightscout.rx.AapsSchedulers import info.nightscout.rx.AapsSchedulers

View file

@ -31,14 +31,16 @@ import info.nightscout.database.impl.transactions.SyncNsProfileSwitchTransaction
import info.nightscout.database.impl.transactions.SyncNsTemporaryBasalTransaction import info.nightscout.database.impl.transactions.SyncNsTemporaryBasalTransaction
import info.nightscout.database.impl.transactions.SyncNsTemporaryTargetTransaction import info.nightscout.database.impl.transactions.SyncNsTemporaryTargetTransaction
import info.nightscout.database.impl.transactions.SyncNsTherapyEventTransaction import info.nightscout.database.impl.transactions.SyncNsTherapyEventTransaction
import info.nightscout.database.transactions.TransactionGlucoseValue
import info.nightscout.interfaces.Config import info.nightscout.interfaces.Config
import info.nightscout.interfaces.Constants import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.XDripBroadcast import info.nightscout.interfaces.XDripBroadcast
import info.nightscout.interfaces.logging.UserEntryLogger import info.nightscout.interfaces.logging.UserEntryLogger
import info.nightscout.interfaces.notifications.Notification import info.nightscout.interfaces.notifications.Notification
import info.nightscout.plugins.R import info.nightscout.interfaces.nsclient.StoreDataForDb
import info.nightscout.plugins.pump.virtual.VirtualPumpPlugin import info.nightscout.interfaces.pump.VirtualPump
import info.nightscout.plugins.source.NSClientSourcePlugin import info.nightscout.interfaces.source.NSClientSource
import info.nightscout.plugins.sync.R
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.EventNSClientNewLog import info.nightscout.rx.events.EventNSClientNewLog
import info.nightscout.rx.logging.AAPSLogger import info.nightscout.rx.logging.AAPSLogger
@ -60,7 +62,7 @@ import javax.inject.Inject
import javax.inject.Singleton import javax.inject.Singleton
@Singleton @Singleton
class StoreDataForDb @Inject constructor( class StoreDataForDbImpl @Inject constructor(
private val aapsLogger: AAPSLogger, private val aapsLogger: AAPSLogger,
private val rxBus: RxBus, private val rxBus: RxBus,
private val repository: AppRepository, private val repository: AppRepository,
@ -68,12 +70,12 @@ class StoreDataForDb @Inject constructor(
private val uel: UserEntryLogger, private val uel: UserEntryLogger,
private val dateUtil: DateUtil, private val dateUtil: DateUtil,
private val config: Config, private val config: Config,
private val nsClientSourcePlugin: NSClientSourcePlugin, private val nsClientSource: NSClientSource,
private val xDripBroadcast: XDripBroadcast, private val xDripBroadcast: XDripBroadcast,
private val virtualPumpPlugin: VirtualPumpPlugin private val virtualPump: VirtualPump
) { ) : StoreDataForDb {
val glucoseValues: MutableList<CgmSourceTransaction.TransactionGlucoseValue> = mutableListOf() override val glucoseValues: MutableList<TransactionGlucoseValue> = mutableListOf()
val boluses: MutableList<Bolus> = mutableListOf() val boluses: MutableList<Bolus> = mutableListOf()
val carbs: MutableList<Carbs> = mutableListOf() val carbs: MutableList<Carbs> = mutableListOf()
@ -102,7 +104,7 @@ class StoreDataForDb @Inject constructor(
params: WorkerParameters params: WorkerParameters
) : Worker(context, params) { ) : Worker(context, params) {
@Inject lateinit var storeDataForDb: StoreDataForDb @Inject lateinit var storeDataForDb: StoreDataForDbImpl
override fun doWork(): Result { override fun doWork(): Result {
storeDataForDb.storeGlucoseValuesToDb() storeDataForDb.storeGlucoseValuesToDb()
@ -131,19 +133,19 @@ class StoreDataForDb @Inject constructor(
glucoseValues.clear() glucoseValues.clear()
result.updated.forEach { result.updated.forEach {
xDripBroadcast.send(it) xDripBroadcast.send(it)
nsClientSourcePlugin.detectSource(it) nsClientSource.detectSource(it)
aapsLogger.debug(LTag.DATABASE, "Updated bg $it") aapsLogger.debug(LTag.DATABASE, "Updated bg $it")
updated.inc(GlucoseValue::class.java.simpleName) updated.inc(GlucoseValue::class.java.simpleName)
} }
result.inserted.forEach { result.inserted.forEach {
xDripBroadcast.send(it) xDripBroadcast.send(it)
nsClientSourcePlugin.detectSource(it) nsClientSource.detectSource(it)
aapsLogger.debug(LTag.DATABASE, "Inserted bg $it") aapsLogger.debug(LTag.DATABASE, "Inserted bg $it")
inserted.inc(GlucoseValue::class.java.simpleName) inserted.inc(GlucoseValue::class.java.simpleName)
} }
result.updatedNsId.forEach { result.updatedNsId.forEach {
xDripBroadcast.send(it) xDripBroadcast.send(it)
nsClientSourcePlugin.detectSource(it) nsClientSource.detectSource(it)
aapsLogger.debug(LTag.DATABASE, "Updated nsId bg $it") aapsLogger.debug(LTag.DATABASE, "Updated nsId bg $it")
nsIdUpdated.inc(GlucoseValue::class.java.simpleName) nsIdUpdated.inc(GlucoseValue::class.java.simpleName)
} }
@ -677,7 +679,7 @@ class StoreDataForDb @Inject constructor(
) )
) )
) )
if (it.isEmulatingTempBasal) virtualPumpPlugin.fakeDataDetected = true if (it.isEmulatingTempBasal) virtualPump.fakeDataDetected = true
aapsLogger.debug(LTag.DATABASE, "Inserted ExtendedBolus $it") aapsLogger.debug(LTag.DATABASE, "Inserted ExtendedBolus $it")
inserted.inc(NSExtendedBolus::class.java.simpleName) inserted.inc(NSExtendedBolus::class.java.simpleName)
} }

View file

@ -0,0 +1,19 @@
package info.nightscout.plugins.sync.nsShared.extensions
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.utils.Round
import org.json.JSONObject
fun PumpEnactResult.log(): String {
return "Success: " + success +
" Enacted: " + enacted +
" Comment: " + comment +
" Duration: " + duration +
" Absolute: " + absolute +
" Percent: " + percent +
" IsPercent: " + isPercent +
" IsTempCancel: " + isTempCancel +
" bolusDelivered: " + bolusDelivered +
" carbsDelivered: " + carbsDelivered +
" Queued: " + queued
}

View file

@ -19,8 +19,7 @@ import info.nightscout.database.impl.AppRepository
import info.nightscout.interfaces.plugin.ActivePlugin import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.profile.ProfileFunction import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.sync.DataSyncSelector import info.nightscout.interfaces.sync.DataSyncSelector
import info.nightscout.plugins.R import info.nightscout.plugins.sync.R
import info.nightscout.plugins.profile.ProfilePlugin
import info.nightscout.plugins.sync.nsclient.extensions.toJson import info.nightscout.plugins.sync.nsclient.extensions.toJson
import info.nightscout.rx.logging.AAPSLogger import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.rx.logging.LTag import info.nightscout.rx.logging.LTag
@ -37,7 +36,6 @@ class DataSyncSelectorImplementation @Inject constructor(
private val profileFunction: ProfileFunction, private val profileFunction: ProfileFunction,
private val activePlugin: ActivePlugin, private val activePlugin: ActivePlugin,
private val appRepository: AppRepository, private val appRepository: AppRepository,
private val profilePlugin: ProfilePlugin
) : DataSyncSelector { ) : DataSyncSelector {
class QueueCounter( class QueueCounter(
@ -905,8 +903,8 @@ class DataSyncSelectorImplementation @Inject constructor(
val lastChange = sp.getLong(R.string.key_local_profile_last_change, 0) val lastChange = sp.getLong(R.string.key_local_profile_last_change, 0)
if (lastChange == 0L) return if (lastChange == 0L) return
if (lastChange > lastSync) { if (lastChange > lastSync) {
if (profilePlugin.profile?.allProfilesValid != true) return if (activePlugin.activeProfileSource.profile?.allProfilesValid != true) return
val profileJson = profilePlugin.profile?.data ?: return val profileJson = activePlugin.activeProfileSource.profile?.data ?: return
activePlugin.activeNsClient?.nsClientService?.dbAdd("profile", profileJson, DataSyncSelector.PairProfileStore(profileJson, dateUtil.now()), "") activePlugin.activeNsClient?.nsClientService?.dbAdd("profile", profileJson, DataSyncSelector.PairProfileStore(profileJson, dateUtil.now()), "")
} }
} }

View file

@ -24,13 +24,13 @@ import info.nightscout.interfaces.sync.DataSyncSelector
import info.nightscout.interfaces.sync.NsClient import info.nightscout.interfaces.sync.NsClient
import info.nightscout.interfaces.sync.Sync import info.nightscout.interfaces.sync.Sync
import info.nightscout.interfaces.utils.HtmlHelper.fromHtml import info.nightscout.interfaces.utils.HtmlHelper.fromHtml
import info.nightscout.plugins.R import info.nightscout.plugins.sync.R
import info.nightscout.plugins.sync.nsShared.NSClientFragment import info.nightscout.plugins.sync.nsShared.NSClientFragment
import info.nightscout.plugins.sync.nsShared.events.EventNSClientResend import info.nightscout.plugins.sync.nsShared.events.EventNSClientResend
import info.nightscout.plugins.sync.nsShared.events.EventNSClientStatus import info.nightscout.plugins.sync.nsShared.events.EventNSClientStatus
import info.nightscout.plugins.sync.nsShared.events.EventNSClientUpdateGUI import info.nightscout.plugins.sync.nsShared.events.EventNSClientUpdateGUI
import info.nightscout.plugins.sync.nsclient.data.AlarmAck import info.nightscout.plugins.sync.nsclient.data.AlarmAck
import info.nightscout.plugins.sync.nsclient.data.NSAlarm import info.nightscout.interfaces.nsclient.NSAlarm
import info.nightscout.plugins.sync.nsclient.services.NSClientService import info.nightscout.plugins.sync.nsclient.services.NSClientService
import info.nightscout.rx.AapsSchedulers import info.nightscout.rx.AapsSchedulers
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
@ -204,7 +204,7 @@ class NSClientPlugin @Inject constructor(
override val address: String get() = nsClientService?.nsURL ?: "" override val address: String get() = nsClientService?.nsURL ?: ""
fun handleClearAlarm(originalAlarm: NSAlarm, silenceTimeInMilliseconds: Long) { override fun handleClearAlarm(originalAlarm: NSAlarm, silenceTimeInMilliseconds: Long) {
if (!isEnabled()) return if (!isEnabled()) return
if (!sp.getBoolean(R.string.key_ns_upload, true)) { if (!sp.getBoolean(R.string.key_ns_upload, true)) {
aapsLogger.debug(LTag.NSCLIENT, "Upload disabled. Message dropped") aapsLogger.debug(LTag.NSCLIENT, "Upload disabled. Message dropped")

View file

@ -1,7 +1,7 @@
package info.nightscout.plugins.sync.nsclient package info.nightscout.plugins.sync.nsclient
import info.nightscout.core.utils.receivers.ReceiverStatusStore import info.nightscout.interfaces.receivers.ReceiverStatusStore
import info.nightscout.plugins.R import info.nightscout.plugins.sync.R
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.EventChargingState import info.nightscout.rx.events.EventChargingState
import info.nightscout.rx.events.EventNetworkChange import info.nightscout.rx.events.EventNetworkChange

View file

@ -5,7 +5,7 @@ import info.nightscout.interfaces.configBuilder.RunningConfiguration
import info.nightscout.interfaces.nsclient.ProcessedDeviceStatusData import info.nightscout.interfaces.nsclient.ProcessedDeviceStatusData
import info.nightscout.interfaces.utils.HtmlHelper import info.nightscout.interfaces.utils.HtmlHelper
import info.nightscout.interfaces.utils.JsonHelper import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.plugins.R import info.nightscout.plugins.sync.R
import info.nightscout.sdk.remotemodel.RemoteDeviceStatus import info.nightscout.sdk.remotemodel.RemoteDeviceStatus
import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.shared.utils.DateUtil import info.nightscout.shared.utils.DateUtil

View file

@ -2,17 +2,17 @@ package info.nightscout.plugins.sync.nsclient.data
import android.content.Context import android.content.Context
import info.nightscout.androidaps.annotations.OpenForTesting import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.interfaces.logging.UserEntryLogger
import info.nightscout.core.events.EventNewNotification import info.nightscout.core.events.EventNewNotification
import info.nightscout.core.ui.dialogs.OKDialog import info.nightscout.core.ui.dialogs.OKDialog
import info.nightscout.database.entities.UserEntry import info.nightscout.database.entities.UserEntry
import info.nightscout.database.entities.UserEntry.Action import info.nightscout.database.entities.UserEntry.Action
import info.nightscout.interfaces.Config import info.nightscout.interfaces.Config
import info.nightscout.interfaces.logging.UserEntryLogger
import info.nightscout.interfaces.notifications.Notification import info.nightscout.interfaces.notifications.Notification
import info.nightscout.interfaces.nsclient.NSSettingsStatus import info.nightscout.interfaces.nsclient.NSSettingsStatus
import info.nightscout.interfaces.profile.DefaultValueHelper import info.nightscout.interfaces.profile.DefaultValueHelper
import info.nightscout.interfaces.utils.JsonHelper import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.plugins.R import info.nightscout.plugins.sync.R
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.EventDismissNotification import info.nightscout.rx.events.EventDismissNotification
import info.nightscout.rx.logging.AAPSLogger import info.nightscout.rx.logging.AAPSLogger

View file

@ -8,7 +8,7 @@ import info.nightscout.interfaces.nsclient.ProcessedDeviceStatusData
import info.nightscout.interfaces.utils.HtmlHelper import info.nightscout.interfaces.utils.HtmlHelper
import info.nightscout.interfaces.utils.JsonHelper import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.interfaces.utils.Round import info.nightscout.interfaces.utils.Round
import info.nightscout.plugins.R import info.nightscout.plugins.sync.R
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.shared.utils.DateUtil import info.nightscout.shared.utils.DateUtil

View file

@ -1,15 +1,6 @@
package info.nightscout.plugins.sync.nsclient.extensions package info.nightscout.plugins.sync.nsclient.extensions
import android.os.Build
import info.nightscout.core.utils.receivers.ReceiverStatusStore
import info.nightscout.core.iob.json
import info.nightscout.database.entities.DeviceStatus import info.nightscout.database.entities.DeviceStatus
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.interfaces.configBuilder.RunningConfiguration
import info.nightscout.plugins.sync.nsShared.extensions.json
import info.nightscout.shared.utils.DateUtil import info.nightscout.shared.utils.DateUtil
import org.json.JSONObject import org.json.JSONObject
@ -28,64 +19,6 @@ fun DeviceStatus.toJson(dateUtil: DateUtil): JSONObject =
configuration?.let { configuration -> it.put("configuration", JSONObject(configuration)) } configuration?.let { configuration -> it.put("configuration", JSONObject(configuration)) }
} }
fun buildDeviceStatus(
dateUtil: DateUtil,
loop: Loop,
iobCobCalculatorPlugin: IobCobCalculator,
profileFunction: ProfileFunction,
pump: Pump,
receiverStatusStore: ReceiverStatusStore,
runningConfiguration: RunningConfiguration,
version: String
): DeviceStatus? {
val profile = profileFunction.getProfile() ?: return null
val profileName = profileFunction.getProfileName()
val lastRun = loop.lastRun
var apsResult: JSONObject? = null
var iob: JSONObject? = null
var enacted: JSONObject? = null
if (lastRun != null && lastRun.lastAPSRun > dateUtil.now() - 300 * 1000L) {
// do not send if result is older than 1 min
apsResult = lastRun.request?.json()?.also {
it.put("timestamp", dateUtil.toISOString(lastRun.lastAPSRun))
}
iob = lastRun.request?.iob?.json(dateUtil)?.also {
it.put("time", dateUtil.toISOString(lastRun.lastAPSRun))
}
val requested = JSONObject()
if (lastRun.tbrSetByPump?.enacted == true) { // enacted
enacted = lastRun.request?.json()?.also {
it.put("rate", lastRun.tbrSetByPump!!.json(profile.getBasal())["rate"])
it.put("duration", lastRun.tbrSetByPump!!.json(profile.getBasal())["duration"])
it.put("received", true)
}
requested.put("duration", lastRun.request?.duration)
requested.put("rate", lastRun.request?.rate)
requested.put("temp", "absolute")
requested.put("smb", lastRun.request?.smb)
enacted?.put("requested", requested)
enacted?.put("smb", lastRun.tbrSetByPump?.bolusDelivered)
}
} else {
val calcIob = iobCobCalculatorPlugin.calculateIobArrayInDia(profile)
if (calcIob.isNotEmpty()) {
iob = calcIob[0].json(dateUtil)
iob.put("time", dateUtil.toISOString(dateUtil.now()))
}
}
return DeviceStatus(
timestamp = dateUtil.now(),
suggested = apsResult?.toString(),
iob = iob?.toString(),
enacted = enacted?.toString(),
device = "openaps://" + Build.MANUFACTURER + " " + Build.MODEL,
pump = pump.getJSONStatus(profile, profileName, version).toString(),
uploaderBattery = receiverStatusStore.batteryLevel,
configuration = runningConfiguration.configuration().toString()
)
}
/* /*
{ {
"_id": "576cfd15217b0bed77d63641", "_id": "576cfd15217b0bed77d63641",

View file

@ -1,27 +1,13 @@
package info.nightscout.plugins.sync.nsclient.extensions package info.nightscout.plugins.sync.nsclient.extensions
import info.nightscout.core.main.R
import info.nightscout.database.entities.TherapyEvent import info.nightscout.database.entities.TherapyEvent
import info.nightscout.interfaces.Constants import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.GlucoseUnit import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.utils.JsonHelper import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.plugins.sync.nsclient.data.NSMbg import info.nightscout.plugins.sync.nsclient.data.NSMbg
import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.utils.DateUtil import info.nightscout.shared.utils.DateUtil
import info.nightscout.shared.utils.T import info.nightscout.shared.utils.T
import org.json.JSONObject import org.json.JSONObject
import java.util.concurrent.TimeUnit
fun TherapyEvent.age(useShortText: Boolean, rh: ResourceHelper, dateUtil: DateUtil): String {
val diff = dateUtil.computeDiff(timestamp, System.currentTimeMillis())
var days = " " + rh.gs(R.string.days) + " "
var hours = " " + rh.gs(R.string.hours) + " "
if (useShortText) {
days = rh.gs(R.string.shortday)
hours = rh.gs(R.string.shorthour)
}
return diff[TimeUnit.DAYS].toString() + days + diff[TimeUnit.HOURS] + hours
}
fun TherapyEvent.GlucoseUnit.toMainUnit(): GlucoseUnit = fun TherapyEvent.GlucoseUnit.toMainUnit(): GlucoseUnit =
if (this == TherapyEvent.GlucoseUnit.MGDL) GlucoseUnit.MGDL if (this == TherapyEvent.GlucoseUnit.MGDL) GlucoseUnit.MGDL

View file

@ -22,17 +22,17 @@ import info.nightscout.core.utils.receivers.DataWorkerStorage
import info.nightscout.database.impl.AppRepository import info.nightscout.database.impl.AppRepository
import info.nightscout.interfaces.Config import info.nightscout.interfaces.Config
import info.nightscout.interfaces.notifications.Notification import info.nightscout.interfaces.notifications.Notification
import info.nightscout.interfaces.nsclient.NSAlarm
import info.nightscout.interfaces.nsclient.NSSettingsStatus
import info.nightscout.interfaces.sync.DataSyncSelector import info.nightscout.interfaces.sync.DataSyncSelector
import info.nightscout.interfaces.sync.NsClient import info.nightscout.interfaces.sync.NsClient
import info.nightscout.interfaces.ui.ActivityNames
import info.nightscout.interfaces.utils.JsonHelper.safeGetString import info.nightscout.interfaces.utils.JsonHelper.safeGetString
import info.nightscout.interfaces.utils.JsonHelper.safeGetStringAllowNull import info.nightscout.interfaces.utils.JsonHelper.safeGetStringAllowNull
import info.nightscout.plugins.R import info.nightscout.interfaces.workflow.WorkerClasses
import info.nightscout.plugins.general.food.FoodPlugin import info.nightscout.plugins.sync.R
import info.nightscout.plugins.general.overview.notifications.NotificationWithAction import info.nightscout.interfaces.nsclient.StoreDataForDb
import info.nightscout.plugins.profile.ProfilePlugin import info.nightscout.plugins.sync.nsShared.StoreDataForDbImpl
import info.nightscout.plugins.source.NSClientSourcePlugin
import info.nightscout.plugins.sync.nsShared.StoreDataForDb
import info.nightscout.rx.events.EventNSClientNewLog
import info.nightscout.plugins.sync.nsShared.events.EventNSClientStatus import info.nightscout.plugins.sync.nsShared.events.EventNSClientStatus
import info.nightscout.plugins.sync.nsShared.events.EventNSClientUpdateGUI import info.nightscout.plugins.sync.nsShared.events.EventNSClientUpdateGUI
import info.nightscout.plugins.sync.nsclient.NSClientPlugin import info.nightscout.plugins.sync.nsclient.NSClientPlugin
@ -40,9 +40,7 @@ import info.nightscout.plugins.sync.nsclient.acks.NSAddAck
import info.nightscout.plugins.sync.nsclient.acks.NSAuthAck import info.nightscout.plugins.sync.nsclient.acks.NSAuthAck
import info.nightscout.plugins.sync.nsclient.acks.NSUpdateAck import info.nightscout.plugins.sync.nsclient.acks.NSUpdateAck
import info.nightscout.plugins.sync.nsclient.data.AlarmAck import info.nightscout.plugins.sync.nsclient.data.AlarmAck
import info.nightscout.plugins.sync.nsclient.data.NSAlarm
import info.nightscout.plugins.sync.nsclient.data.NSDeviceStatusHandler import info.nightscout.plugins.sync.nsclient.data.NSDeviceStatusHandler
import info.nightscout.interfaces.nsclient.NSSettingsStatus
import info.nightscout.plugins.sync.nsclient.workers.NSClientAddAckWorker import info.nightscout.plugins.sync.nsclient.workers.NSClientAddAckWorker
import info.nightscout.plugins.sync.nsclient.workers.NSClientAddUpdateWorker import info.nightscout.plugins.sync.nsclient.workers.NSClientAddUpdateWorker
import info.nightscout.plugins.sync.nsclient.workers.NSClientMbgWorker import info.nightscout.plugins.sync.nsclient.workers.NSClientMbgWorker
@ -53,6 +51,7 @@ import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.EventAppExit import info.nightscout.rx.events.EventAppExit
import info.nightscout.rx.events.EventConfigBuilderChange import info.nightscout.rx.events.EventConfigBuilderChange
import info.nightscout.rx.events.EventDismissNotification import info.nightscout.rx.events.EventDismissNotification
import info.nightscout.rx.events.EventNSClientNewLog
import info.nightscout.rx.events.EventNSClientRestart import info.nightscout.rx.events.EventNSClientRestart
import info.nightscout.rx.events.EventPreferenceChange import info.nightscout.rx.events.EventPreferenceChange
import info.nightscout.rx.logging.AAPSLogger import info.nightscout.rx.logging.AAPSLogger
@ -91,6 +90,8 @@ class NSClientService : DaggerService(), NsClient.NSClientService {
@Inject lateinit var dataWorkerStorage: DataWorkerStorage @Inject lateinit var dataWorkerStorage: DataWorkerStorage
@Inject lateinit var dataSyncSelector: DataSyncSelector @Inject lateinit var dataSyncSelector: DataSyncSelector
@Inject lateinit var repository: AppRepository @Inject lateinit var repository: AppRepository
@Inject lateinit var activityNames: ActivityNames
@Inject lateinit var workerClasses: WorkerClasses
companion object { companion object {
@ -476,7 +477,7 @@ class NSClientService : DaggerService(), NsClient.NSClientService {
val profileStoreJson = profiles[profiles.length() - 1] as JSONObject val profileStoreJson = profiles[profiles.length() - 1] as JSONObject
rxBus.send(EventNSClientNewLog("PROFILE", "profile received")) rxBus.send(EventNSClientNewLog("PROFILE", "profile received"))
dataWorkerStorage.enqueue( dataWorkerStorage.enqueue(
OneTimeWorkRequest.Builder(ProfilePlugin.NSProfileWorker::class.java) OneTimeWorkRequest.Builder(workerClasses.nsProfileWorker)
.setInputData(dataWorkerStorage.storeInputData(profileStoreJson)) .setInputData(dataWorkerStorage.storeInputData(profileStoreJson))
.build() .build()
) )
@ -518,7 +519,7 @@ class NSClientService : DaggerService(), NsClient.NSClientService {
val foods = data.getJSONArray("food") val foods = data.getJSONArray("food")
if (foods.length() > 0) rxBus.send(EventNSClientNewLog("DATA", "received " + foods.length() + " foods")) if (foods.length() > 0) rxBus.send(EventNSClientNewLog("DATA", "received " + foods.length() + " foods"))
dataWorkerStorage.enqueue( dataWorkerStorage.enqueue(
OneTimeWorkRequest.Builder(FoodPlugin.FoodWorker::class.java) OneTimeWorkRequest.Builder(workerClasses.foodWorker)
.setInputData(dataWorkerStorage.storeInputData(foods)) .setInputData(dataWorkerStorage.storeInputData(foods))
.build() .build()
) )
@ -546,10 +547,10 @@ class NSClientService : DaggerService(), NsClient.NSClientService {
dataWorkerStorage dataWorkerStorage
.beginUniqueWork( .beginUniqueWork(
NSClientV3Plugin.JOB_NAME, NSClientV3Plugin.JOB_NAME,
OneTimeWorkRequest.Builder(NSClientSourcePlugin.NSClientSourceWorker::class.java) OneTimeWorkRequest.Builder(workerClasses.nsClientSourceWorker)
.setInputData(dataWorkerStorage.storeInputData(sgvs)) .setInputData(dataWorkerStorage.storeInputData(sgvs))
.build() .build()
).then(OneTimeWorkRequest.Builder(StoreDataForDb.StoreBgWorker::class.java).build()) ).then(OneTimeWorkRequest.Builder(StoreDataForDbImpl.StoreBgWorker::class.java).build())
.enqueue() .enqueue()
} }
} }
@ -634,8 +635,7 @@ class NSClientService : DaggerService(), NsClient.NSClientService {
val defaultVal = config.NSCLIENT val defaultVal = config.NSCLIENT
if (sp.getBoolean(R.string.key_ns_announcements, defaultVal)) { if (sp.getBoolean(R.string.key_ns_announcements, defaultVal)) {
val nsAlarm = NSAlarm(announcement) val nsAlarm = NSAlarm(announcement)
val notification: Notification = NotificationWithAction(injector, nsAlarm) activityNames.addNotificationWithAction(injector, nsAlarm)
rxBus.send(EventNewNotification(notification))
rxBus.send(EventNSClientNewLog("ANNOUNCEMENT", safeGetString(announcement, "message", "received"))) rxBus.send(EventNSClientNewLog("ANNOUNCEMENT", safeGetString(announcement, "message", "received")))
aapsLogger.debug(LTag.NSCLIENT, announcement.toString()) aapsLogger.debug(LTag.NSCLIENT, announcement.toString())
} }
@ -647,8 +647,7 @@ class NSClientService : DaggerService(), NsClient.NSClientService {
val snoozedTo = sp.getLong(R.string.key_snoozed_to, 0L) val snoozedTo = sp.getLong(R.string.key_snoozed_to, 0L)
if (snoozedTo == 0L || System.currentTimeMillis() > snoozedTo) { if (snoozedTo == 0L || System.currentTimeMillis() > snoozedTo) {
val nsAlarm = NSAlarm(alarm) val nsAlarm = NSAlarm(alarm)
val notification: Notification = NotificationWithAction(injector, nsAlarm) activityNames.addNotificationWithAction(injector, nsAlarm)
rxBus.send(EventNewNotification(notification))
} }
rxBus.send(EventNSClientNewLog("ALARM", safeGetString(alarm, "message", "received"))) rxBus.send(EventNSClientNewLog("ALARM", safeGetString(alarm, "message", "received")))
aapsLogger.debug(LTag.NSCLIENT, alarm.toString()) aapsLogger.debug(LTag.NSCLIENT, alarm.toString())
@ -661,8 +660,7 @@ class NSClientService : DaggerService(), NsClient.NSClientService {
val snoozedTo = sp.getLong(R.string.key_snoozed_to, 0L) val snoozedTo = sp.getLong(R.string.key_snoozed_to, 0L)
if (snoozedTo == 0L || System.currentTimeMillis() > snoozedTo) { if (snoozedTo == 0L || System.currentTimeMillis() > snoozedTo) {
val nsAlarm = NSAlarm(alarm) val nsAlarm = NSAlarm(alarm)
val notification: Notification = NotificationWithAction(injector, nsAlarm) activityNames.addNotificationWithAction(injector, nsAlarm)
rxBus.send(EventNewNotification(notification))
} }
rxBus.send(EventNSClientNewLog("URGENTALARM", safeGetString(alarm, "message", "received"))) rxBus.send(EventNSClientNewLog("URGENTALARM", safeGetString(alarm, "message", "received")))
aapsLogger.debug(LTag.NSCLIENT, alarm.toString()) aapsLogger.debug(LTag.NSCLIENT, alarm.toString())

View file

@ -36,7 +36,7 @@ import info.nightscout.interfaces.sync.DataSyncSelector.PairProfileSwitch
import info.nightscout.interfaces.sync.DataSyncSelector.PairTemporaryBasal import info.nightscout.interfaces.sync.DataSyncSelector.PairTemporaryBasal
import info.nightscout.interfaces.sync.DataSyncSelector.PairTemporaryTarget import info.nightscout.interfaces.sync.DataSyncSelector.PairTemporaryTarget
import info.nightscout.interfaces.sync.DataSyncSelector.PairTherapyEvent import info.nightscout.interfaces.sync.DataSyncSelector.PairTherapyEvent
import info.nightscout.plugins.R import info.nightscout.plugins.sync.R
import info.nightscout.plugins.sync.nsclient.acks.NSAddAck import info.nightscout.plugins.sync.nsclient.acks.NSAddAck
import info.nightscout.rx.AapsSchedulers import info.nightscout.rx.AapsSchedulers
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus

Some files were not shown because too many files have changed in this diff Show more