diff --git a/core/src/main/java/info/nightscout/androidaps/plugins/configBuilder/RunningConfiguration.kt b/core/src/main/java/info/nightscout/androidaps/plugins/configBuilder/RunningConfiguration.kt
index 709ed1b71e..ae22cef02c 100644
--- a/core/src/main/java/info/nightscout/androidaps/plugins/configBuilder/RunningConfiguration.kt
+++ b/core/src/main/java/info/nightscout/androidaps/plugins/configBuilder/RunningConfiguration.kt
@@ -1,15 +1,16 @@
package info.nightscout.androidaps.plugins.configBuilder
+import info.nightscout.androidaps.core.BuildConfig
import info.nightscout.androidaps.core.R
-import info.nightscout.androidaps.interfaces.ActivePlugin
-import info.nightscout.androidaps.interfaces.ConfigBuilder
-import info.nightscout.androidaps.interfaces.Insulin
-import info.nightscout.androidaps.interfaces.PluginType
-import info.nightscout.androidaps.interfaces.Sensitivity
+import info.nightscout.androidaps.interfaces.*
import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag
+import info.nightscout.androidaps.plugins.bus.RxBusWrapper
+import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification
+import info.nightscout.androidaps.plugins.general.overview.notifications.Notification
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType
import info.nightscout.androidaps.utils.JsonHelper
+import info.nightscout.androidaps.utils.resources.ResourceHelper
import info.nightscout.androidaps.utils.sharedPreferences.SP
import org.json.JSONException
import org.json.JSONObject
@@ -21,7 +22,10 @@ class RunningConfiguration @Inject constructor(
private val activePlugin: ActivePlugin,
private val configBuilder: ConfigBuilder,
private val sp: SP,
- private val aapsLogger: AAPSLogger
+ private val aapsLogger: AAPSLogger,
+ private val config: Config,
+ private val resourceHelper: ResourceHelper,
+ private val rxBus: RxBusWrapper
) {
private var counter = 0
@@ -45,6 +49,7 @@ class RunningConfiguration @Inject constructor(
json.put("overviewConfiguration", overviewInterface.configuration())
json.put("safetyConfiguration", safetyInterface.configuration())
json.put("pump", pumpInterface.model().description)
+ json.put("version", config.VERSION_NAME)
} catch (e: JSONException) {
aapsLogger.error("Unhandled exception", e)
}
@@ -53,6 +58,10 @@ class RunningConfiguration @Inject constructor(
// called in NSClient mode only
fun apply(configuration: JSONObject) {
+ if (configuration.has("version")) {
+ if (config.VERSION_NAME.startsWith(configuration.getString("version")).not())
+ rxBus.send(EventNewNotification(Notification(Notification.NSCLIENT_VERSION_DOES_NOT_MATCH, resourceHelper.gs(R.string.nsclient_version_does_not_match), Notification.NORMAL)))
+ }
if (configuration.has("insulin")) {
val insulin = Insulin.InsulinType.fromInt(JsonHelper.safeGetInt(configuration, "insulin", Insulin.InsulinType.UNKNOWN.value))
for (p in activePlugin.getSpecificPluginsListByInterface(Insulin::class.java)) {
diff --git a/core/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/Notification.kt b/core/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/Notification.kt
index ea2e753fb5..ceaae53fe5 100644
--- a/core/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/Notification.kt
+++ b/core/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/Notification.kt
@@ -122,7 +122,8 @@ open class Notification {
const val OMNIPOD_STARTUP_STATUS_REFRESH_FAILED = 69
const val OMNIPOD_TIME_OUT_OF_SYNC = 70
const val UNSUPPORTED_ACTION_IN_PUMP = 71
- const val WRONG_PUMP_DATA = 71
+ const val WRONG_PUMP_DATA = 72
+ const val NSCLIENT_VERSION_DOES_NOT_MATCH = 73
const val USER_MESSAGE = 1000
diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml
index 512cfec8eb..539426f867 100644
--- a/core/src/main/res/values/strings.xml
+++ b/core/src/main/res/values/strings.xml
@@ -496,6 +496,7 @@
»%1$s« is out of hard limits
»%1$s« %2$.2f is out of hard limits
Basal value
+ NSClient version doesn\'t match to AndroidAPS. Please update.
- %1$d day
diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsMessageHashTableTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsMessageHashTableTest.kt
index 62244b0ba2..4fc446bd31 100644
--- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsMessageHashTableTest.kt
+++ b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsMessageHashTableTest.kt
@@ -8,7 +8,6 @@ import info.nightscout.androidaps.danars.encryption.BleEncryption
import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.Constraint
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
-import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage
import org.junit.Assert
import org.junit.Test
import org.mockito.Mock
@@ -42,7 +41,7 @@ class DanaRsMessageHashTableTest : DanaRSTestBase() {
`when`(constraintChecker.applyBolusConstraints(anyObject())).thenReturn(Constraint(0.0))
val danaRSMessageHashTable = DanaRSMessageHashTable(packetInjector)
- val forTesting: DanaRSPacket = DanaRSPacketAPSSetEventHistory(packetInjector, DanaPump.CARBS, 0, 0, 0)
+ val forTesting: DanaRSPacket = DanaRSPacketAPSSetEventHistory(packetInjector, DanaPump.HistoryEntry.CARBS.value, 0, 0, 0)
val testPacket: DanaRSPacket = danaRSMessageHashTable.findMessage(forTesting.command)
Assert.assertEquals(BleEncryption.DANAR_PACKET__OPCODE__APS_SET_EVENT_HISTORY.toLong(), testPacket.opCode.toLong())
}
diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketApsSetEventHistoryTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketApsSetEventHistoryTest.kt
index 584e6da3bb..b8f152d522 100644
--- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketApsSetEventHistoryTest.kt
+++ b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketApsSetEventHistoryTest.kt
@@ -2,6 +2,7 @@ package info.nightscout.androidaps.danars.comm
import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector
+import info.nightscout.androidaps.dana.DanaPump
import info.nightscout.androidaps.danars.DanaRSTestBase
import org.junit.Assert
import org.junit.Test
@@ -22,23 +23,23 @@ class DanaRsPacketApsSetEventHistoryTest : DanaRSTestBase() {
@Test fun runTest() { // test for negative carbs
val now = dateUtil.now()
- var historyTest = DanaRSPacketAPSSetEventHistory(packetInjector, info.nightscout.androidaps.dana.DanaPump.CARBS, now, -1, 0)
+ var historyTest = DanaRSPacketAPSSetEventHistory(packetInjector, DanaPump.HistoryEntry.CARBS.value, now, -1, 0)
var testParams = historyTest.getRequestParams()
Assert.assertEquals(0.toByte(), testParams[8])
// 5g carbs
- historyTest = DanaRSPacketAPSSetEventHistory(packetInjector, info.nightscout.androidaps.dana.DanaPump.CARBS, now, 5, 0)
+ historyTest = DanaRSPacketAPSSetEventHistory(packetInjector, DanaPump.HistoryEntry.CARBS.value, now, 5, 0)
testParams = historyTest.getRequestParams()
Assert.assertEquals(5.toByte(), testParams[8])
// 150g carbs
- historyTest = DanaRSPacketAPSSetEventHistory(packetInjector, info.nightscout.androidaps.dana.DanaPump.CARBS, now, 150, 0)
+ historyTest = DanaRSPacketAPSSetEventHistory(packetInjector, DanaPump.HistoryEntry.CARBS.value, now, 150, 0)
testParams = historyTest.getRequestParams()
Assert.assertEquals(150.toByte(), testParams[8])
// test message generation
- historyTest = DanaRSPacketAPSSetEventHistory(packetInjector, info.nightscout.androidaps.dana.DanaPump.CARBS, now, 5, 0)
+ historyTest = DanaRSPacketAPSSetEventHistory(packetInjector, DanaPump.HistoryEntry.CARBS.value, now, 5, 0)
testParams = historyTest.getRequestParams()
Assert.assertEquals(5.toByte(), testParams[8])
Assert.assertEquals(11, testParams.size)
- Assert.assertEquals(info.nightscout.androidaps.dana.DanaPump.CARBS.toByte(), testParams[0])
+ Assert.assertEquals(DanaPump.HistoryEntry.CARBS.value.toByte(), testParams[0])
// test message decoding
historyTest.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 0.toByte()))
Assert.assertEquals(false, historyTest.failed)