RS(UTC): update pump IC and ISF too
This commit is contained in:
parent
dac2241baa
commit
9e5da8aad9
3 changed files with 27 additions and 17 deletions
|
@ -20,8 +20,8 @@ class DanaRS_Packet_Bolus_Get_24_CIR_CF_Array(
|
|||
override fun handleMessage(data: ByteArray) {
|
||||
danaPump.units = byteArrayToInt(getBytes(data, DATA_START, 1))
|
||||
for (i in 0 .. 23) {
|
||||
val cf = byteArrayToInt(getBytes(data, DATA_START + 1 + 2 * i, 2)).toDouble()
|
||||
val cir = if (danaPump.units == DanaPump.UNITS_MGDL)
|
||||
val cir = byteArrayToInt(getBytes(data, DATA_START + 1 + 2 * i, 2)).toDouble()
|
||||
val cf = if (danaPump.units == DanaPump.UNITS_MGDL)
|
||||
byteArrayToInt(getBytes(data, DATA_START + 1 + 48 + 2 * i, 2)).toDouble()
|
||||
else
|
||||
byteArrayToInt(getBytes(data, DATA_START + 1 + 48 + 2 * i, 2)) / 100.0
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
package info.nightscout.androidaps.danars.comm
|
||||
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.Constants
|
||||
import info.nightscout.androidaps.dana.DanaPump
|
||||
import info.nightscout.androidaps.danars.encryption.BleEncryption
|
||||
import info.nightscout.androidaps.data.Profile
|
||||
import info.nightscout.androidaps.logging.LTag
|
||||
import javax.inject.Inject
|
||||
import kotlin.math.round
|
||||
|
||||
class DanaRS_Packet_Bolus_Set_24_CIR_CF_Array(
|
||||
injector: HasAndroidInjector,
|
||||
|
@ -25,12 +27,15 @@ class DanaRS_Packet_Bolus_Set_24_CIR_CF_Array(
|
|||
val cfStart = 24 * 2
|
||||
for (i in 0..23) {
|
||||
var isf = profile.getIsfMgdlTimeFromMidnight(i * 3600)
|
||||
if (danaPump.units == DanaPump.UNITS_MMOL) isf *= 10
|
||||
val ic = profile.getIcTimeFromMidnight(i * 3600) * 100
|
||||
request[2 * i] = (isf.toInt() and 0xff).toByte()
|
||||
request[2 * i] = (isf.toInt() ushr 8 and 0xff).toByte()
|
||||
request[cfStart + 2 * i] = (ic.toInt() and 0xff).toByte()
|
||||
request[cfStart + 2 * i] = (ic.toInt() ushr 8 and 0xff).toByte()
|
||||
if (danaPump.units == DanaPump.UNITS_MMOL) {
|
||||
isf = Profile.fromMgdlToUnits(isf, Constants.MMOL)
|
||||
isf *= 100
|
||||
}
|
||||
val ic = profile.getIcTimeFromMidnight(i * 3600)
|
||||
request[2 * i] = (round(ic).toInt() and 0xff).toByte()
|
||||
request[2 * i + 1] = (round(ic).toInt() ushr 8 and 0xff).toByte()
|
||||
request[cfStart + 2 * i] = (round(isf).toInt() and 0xff).toByte()
|
||||
request[cfStart + 2 * i + 1] = (round(isf).toInt() ushr 8 and 0xff).toByte()
|
||||
}
|
||||
return request
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import dagger.android.HasAndroidInjector
|
|||
import info.nightscout.androidaps.Constants
|
||||
import info.nightscout.androidaps.activities.ErrorHelperActivity
|
||||
import info.nightscout.androidaps.dana.DanaPump
|
||||
import info.nightscout.androidaps.dana.comm.RecordTypes
|
||||
import info.nightscout.androidaps.dana.events.EventDanaRNewStatus
|
||||
import info.nightscout.androidaps.danars.DanaRSPlugin
|
||||
import info.nightscout.androidaps.danars.R
|
||||
|
@ -411,6 +412,10 @@ class DanaRSService : DaggerService() {
|
|||
sendMessage(msgSet)
|
||||
val msgActivate = DanaRS_Packet_Basal_Set_Profile_Number(injector, 0)
|
||||
sendMessage(msgActivate)
|
||||
if (danaPump.profile24) {
|
||||
val msgProfile = DanaRS_Packet_Bolus_Set_24_CIR_CF_Array(injector, profile)
|
||||
sendMessage(msgProfile)
|
||||
}
|
||||
readPumpStatus()
|
||||
rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING))
|
||||
return true
|
||||
|
@ -421,15 +426,15 @@ class DanaRSService : DaggerService() {
|
|||
if (!isConnected) return result
|
||||
var msg: DanaRS_Packet_History_? = null
|
||||
when (type) {
|
||||
info.nightscout.androidaps.dana.comm.RecordTypes.RECORD_TYPE_ALARM -> msg = DanaRS_Packet_History_Alarm(injector)
|
||||
info.nightscout.androidaps.dana.comm.RecordTypes.RECORD_TYPE_PRIME -> msg = DanaRS_Packet_History_Prime(injector)
|
||||
info.nightscout.androidaps.dana.comm.RecordTypes.RECORD_TYPE_BASALHOUR -> msg = DanaRS_Packet_History_Basal(injector)
|
||||
info.nightscout.androidaps.dana.comm.RecordTypes.RECORD_TYPE_BOLUS -> msg = DanaRS_Packet_History_Bolus(injector)
|
||||
info.nightscout.androidaps.dana.comm.RecordTypes.RECORD_TYPE_CARBO -> msg = DanaRS_Packet_History_Carbohydrate(injector)
|
||||
info.nightscout.androidaps.dana.comm.RecordTypes.RECORD_TYPE_DAILY -> msg = DanaRS_Packet_History_Daily(injector)
|
||||
info.nightscout.androidaps.dana.comm.RecordTypes.RECORD_TYPE_GLUCOSE -> msg = DanaRS_Packet_History_Blood_Glucose(injector)
|
||||
info.nightscout.androidaps.dana.comm.RecordTypes.RECORD_TYPE_REFILL -> msg = DanaRS_Packet_History_Refill(injector)
|
||||
info.nightscout.androidaps.dana.comm.RecordTypes.RECORD_TYPE_SUSPEND -> msg = DanaRS_Packet_History_Suspend(injector)
|
||||
RecordTypes.RECORD_TYPE_ALARM -> msg = DanaRS_Packet_History_Alarm(injector)
|
||||
RecordTypes.RECORD_TYPE_PRIME -> msg = DanaRS_Packet_History_Prime(injector)
|
||||
RecordTypes.RECORD_TYPE_BASALHOUR -> msg = DanaRS_Packet_History_Basal(injector)
|
||||
RecordTypes.RECORD_TYPE_BOLUS -> msg = DanaRS_Packet_History_Bolus(injector)
|
||||
RecordTypes.RECORD_TYPE_CARBO -> msg = DanaRS_Packet_History_Carbohydrate(injector)
|
||||
RecordTypes.RECORD_TYPE_DAILY -> msg = DanaRS_Packet_History_Daily(injector)
|
||||
RecordTypes.RECORD_TYPE_GLUCOSE -> msg = DanaRS_Packet_History_Blood_Glucose(injector)
|
||||
RecordTypes.RECORD_TYPE_REFILL -> msg = DanaRS_Packet_History_Refill(injector)
|
||||
RecordTypes.RECORD_TYPE_SUSPEND -> msg = DanaRS_Packet_History_Suspend(injector)
|
||||
}
|
||||
if (msg != null) {
|
||||
sendMessage(DanaRS_Packet_General_Set_History_Upload_Mode(injector, 1))
|
||||
|
|
Loading…
Reference in a new issue