Warn if AAPS and NSC version is different
This commit is contained in:
parent
ddc37324a8
commit
c9e90193e7
5 changed files with 25 additions and 14 deletions
|
@ -1,15 +1,16 @@
|
||||||
package info.nightscout.androidaps.plugins.configBuilder
|
package info.nightscout.androidaps.plugins.configBuilder
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.core.BuildConfig
|
||||||
import info.nightscout.androidaps.core.R
|
import info.nightscout.androidaps.core.R
|
||||||
import info.nightscout.androidaps.interfaces.ActivePlugin
|
import info.nightscout.androidaps.interfaces.*
|
||||||
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.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
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.plugins.pump.common.defs.PumpType
|
||||||
import info.nightscout.androidaps.utils.JsonHelper
|
import info.nightscout.androidaps.utils.JsonHelper
|
||||||
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
import org.json.JSONException
|
import org.json.JSONException
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
|
@ -21,7 +22,10 @@ class RunningConfiguration @Inject constructor(
|
||||||
private val activePlugin: ActivePlugin,
|
private val activePlugin: ActivePlugin,
|
||||||
private val configBuilder: ConfigBuilder,
|
private val configBuilder: ConfigBuilder,
|
||||||
private val sp: SP,
|
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
|
private var counter = 0
|
||||||
|
@ -45,6 +49,7 @@ class RunningConfiguration @Inject constructor(
|
||||||
json.put("overviewConfiguration", overviewInterface.configuration())
|
json.put("overviewConfiguration", overviewInterface.configuration())
|
||||||
json.put("safetyConfiguration", safetyInterface.configuration())
|
json.put("safetyConfiguration", safetyInterface.configuration())
|
||||||
json.put("pump", pumpInterface.model().description)
|
json.put("pump", pumpInterface.model().description)
|
||||||
|
json.put("version", config.VERSION_NAME)
|
||||||
} catch (e: JSONException) {
|
} catch (e: JSONException) {
|
||||||
aapsLogger.error("Unhandled exception", e)
|
aapsLogger.error("Unhandled exception", e)
|
||||||
}
|
}
|
||||||
|
@ -53,6 +58,10 @@ class RunningConfiguration @Inject constructor(
|
||||||
|
|
||||||
// called in NSClient mode only
|
// called in NSClient mode only
|
||||||
fun apply(configuration: JSONObject) {
|
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")) {
|
if (configuration.has("insulin")) {
|
||||||
val insulin = Insulin.InsulinType.fromInt(JsonHelper.safeGetInt(configuration, "insulin", Insulin.InsulinType.UNKNOWN.value))
|
val insulin = Insulin.InsulinType.fromInt(JsonHelper.safeGetInt(configuration, "insulin", Insulin.InsulinType.UNKNOWN.value))
|
||||||
for (p in activePlugin.getSpecificPluginsListByInterface(Insulin::class.java)) {
|
for (p in activePlugin.getSpecificPluginsListByInterface(Insulin::class.java)) {
|
||||||
|
|
|
@ -122,7 +122,8 @@ open class Notification {
|
||||||
const val OMNIPOD_STARTUP_STATUS_REFRESH_FAILED = 69
|
const val OMNIPOD_STARTUP_STATUS_REFRESH_FAILED = 69
|
||||||
const val OMNIPOD_TIME_OUT_OF_SYNC = 70
|
const val OMNIPOD_TIME_OUT_OF_SYNC = 70
|
||||||
const val UNSUPPORTED_ACTION_IN_PUMP = 71
|
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
|
const val USER_MESSAGE = 1000
|
||||||
|
|
||||||
|
|
|
@ -496,6 +496,7 @@
|
||||||
<string name="valueoutofrange">»%1$s« is out of hard limits</string>
|
<string name="valueoutofrange">»%1$s« is out of hard limits</string>
|
||||||
<string name="value_out_of_hard_limits">»%1$s« %2$.2f is out of hard limits</string>
|
<string name="value_out_of_hard_limits">»%1$s« %2$.2f is out of hard limits</string>
|
||||||
<string name="basal_value">Basal value</string>
|
<string name="basal_value">Basal value</string>
|
||||||
|
<string name="nsclient_version_does_not_match">NSClient version doesn\'t match to AndroidAPS. Please update.</string>
|
||||||
|
|
||||||
<plurals name="days">
|
<plurals name="days">
|
||||||
<item quantity="one">%1$d day</item>
|
<item quantity="one">%1$d day</item>
|
||||||
|
|
|
@ -8,7 +8,6 @@ import info.nightscout.androidaps.danars.encryption.BleEncryption
|
||||||
import info.nightscout.androidaps.interfaces.ActivePlugin
|
import info.nightscout.androidaps.interfaces.ActivePlugin
|
||||||
import info.nightscout.androidaps.interfaces.Constraint
|
import info.nightscout.androidaps.interfaces.Constraint
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
|
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
|
||||||
import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage
|
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.mockito.Mock
|
import org.mockito.Mock
|
||||||
|
@ -42,7 +41,7 @@ class DanaRsMessageHashTableTest : DanaRSTestBase() {
|
||||||
`when`(constraintChecker.applyBolusConstraints(anyObject())).thenReturn(Constraint(0.0))
|
`when`(constraintChecker.applyBolusConstraints(anyObject())).thenReturn(Constraint(0.0))
|
||||||
|
|
||||||
val danaRSMessageHashTable = DanaRSMessageHashTable(packetInjector)
|
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)
|
val testPacket: DanaRSPacket = danaRSMessageHashTable.findMessage(forTesting.command)
|
||||||
Assert.assertEquals(BleEncryption.DANAR_PACKET__OPCODE__APS_SET_EVENT_HISTORY.toLong(), testPacket.opCode.toLong())
|
Assert.assertEquals(BleEncryption.DANAR_PACKET__OPCODE__APS_SET_EVENT_HISTORY.toLong(), testPacket.opCode.toLong())
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package info.nightscout.androidaps.danars.comm
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.dana.DanaPump
|
||||||
import info.nightscout.androidaps.danars.DanaRSTestBase
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
@ -22,23 +23,23 @@ class DanaRsPacketApsSetEventHistoryTest : DanaRSTestBase() {
|
||||||
|
|
||||||
@Test fun runTest() { // test for negative carbs
|
@Test fun runTest() { // test for negative carbs
|
||||||
val now = dateUtil.now()
|
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()
|
var testParams = historyTest.getRequestParams()
|
||||||
Assert.assertEquals(0.toByte(), testParams[8])
|
Assert.assertEquals(0.toByte(), testParams[8])
|
||||||
// 5g carbs
|
// 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()
|
testParams = historyTest.getRequestParams()
|
||||||
Assert.assertEquals(5.toByte(), testParams[8])
|
Assert.assertEquals(5.toByte(), testParams[8])
|
||||||
// 150g carbs
|
// 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()
|
testParams = historyTest.getRequestParams()
|
||||||
Assert.assertEquals(150.toByte(), testParams[8])
|
Assert.assertEquals(150.toByte(), testParams[8])
|
||||||
// test message generation
|
// 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()
|
testParams = historyTest.getRequestParams()
|
||||||
Assert.assertEquals(5.toByte(), testParams[8])
|
Assert.assertEquals(5.toByte(), testParams[8])
|
||||||
Assert.assertEquals(11, testParams.size)
|
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
|
// test message decoding
|
||||||
historyTest.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 0.toByte()))
|
historyTest.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 0.toByte()))
|
||||||
Assert.assertEquals(false, historyTest.failed)
|
Assert.assertEquals(false, historyTest.failed)
|
||||||
|
|
Loading…
Reference in a new issue