add SerialNumInquirePacket.kt

fix time difference error
ble waitmilis time change
This commit is contained in:
miyeongkim 2022-07-21 16:05:47 +09:00
parent 9e4864e93c
commit e4d36c9fca
11 changed files with 167 additions and 53 deletions

View file

@ -19,7 +19,9 @@ class DiaconnG8Pump @Inject constructor(
private val aapsLogger: AAPSLogger, private val aapsLogger: AAPSLogger,
private val dateUtil: DateUtil private val dateUtil: DateUtil
) { ) {
//var bleResultInfo: Pair<Int?, Boolean> = Pair(null, false)
var bolusConfirmMessage: Byte = 0
var isReadyToBolus: Boolean = false
var maxBolusePerDay: Double = 0.0 var maxBolusePerDay: Double = 0.0
var pumpIncarnationNum: Int = 65536 var pumpIncarnationNum: Int = 65536
var isPumpVersionGe2_63: Boolean = false // is pumpVersion higher then 2.63 var isPumpVersionGe2_63: Boolean = false // is pumpVersion higher then 2.63

View file

@ -77,6 +77,8 @@ abstract class DiaconnG8PacketModule {
@ContributesAndroidInjector abstract fun contributesLanguageInquireResponsePacket(): LanguageInquireResponsePacket @ContributesAndroidInjector abstract fun contributesLanguageInquireResponsePacket(): LanguageInquireResponsePacket
@ContributesAndroidInjector abstract fun contributesBigAPSMainInfoInquirePacket(): BigAPSMainInfoInquirePacket @ContributesAndroidInjector abstract fun contributesBigAPSMainInfoInquirePacket(): BigAPSMainInfoInquirePacket
@ContributesAndroidInjector abstract fun contributesBigAPSMainInfoInquireResponsePacket(): BigAPSMainInfoInquireResponsePacket @ContributesAndroidInjector abstract fun contributesBigAPSMainInfoInquireResponsePacket(): BigAPSMainInfoInquireResponsePacket
@ContributesAndroidInjector abstract fun contributesSerialNumInquirePacket(): SerialNumInquirePacket
@ContributesAndroidInjector abstract fun contributesSerialNumInquireResponsePacket(): SerialNumInquireResponsePacket
} }

View file

@ -35,6 +35,10 @@ class AppConfirmSettingResponsePacket(
failed = true failed = true
return return
} }
// The bolus progress diallog opens only when the confirm result is successfull
if(diaconnG8Pump.bolusConfirmMessage == 0x07.toByte()) {
diaconnG8Pump.isReadyToBolus = true
}
} }
override fun getFriendlyName(): String { override fun getFriendlyName(): String {

View file

@ -25,7 +25,6 @@ class DiaconnG8ResponseMessageHashTable @Inject constructor(val injector: HasAnd
put(SneckLimitInquireResponsePacket(injector)) put(SneckLimitInquireResponsePacket(injector))
put(BasalLimitInquireResponsePacket(injector)) put(BasalLimitInquireResponsePacket(injector))
put(TempBasalInquireResponsePacket(injector)) put(TempBasalInquireResponsePacket(injector))
put(TimeInquirePacket(injector))
put(TimeInquireResponsePacket(injector)) put(TimeInquireResponsePacket(injector))
put(TimeReportPacket(injector)) put(TimeReportPacket(injector))
put(LogStatusInquireResponsePacket(injector)) put(LogStatusInquireResponsePacket(injector))
@ -34,6 +33,8 @@ class DiaconnG8ResponseMessageHashTable @Inject constructor(val injector: HasAnd
put(SoundInquireResponsePacket(injector)) put(SoundInquireResponsePacket(injector))
put(DisplayTimeInquireResponsePacket(injector)) put(DisplayTimeInquireResponsePacket(injector))
put(LanguageInquireResponsePacket(injector)) put(LanguageInquireResponsePacket(injector))
put(SerialNumInquireResponsePacket(injector))
// Report Packet // Report Packet
put(BasalPauseReportPacket(injector)) put(BasalPauseReportPacket(injector))

View file

@ -0,0 +1,29 @@
package info.nightscout.androidaps.diaconn.packet
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.diaconn.DiaconnG8Pump
import info.nightscout.shared.logging.LTag
import javax.inject.Inject
/**
* SerialNumInquirePacket
*/
class SerialNumInquirePacket(
injector: HasAndroidInjector
) : DiaconnG8Packet(injector ) {
@Inject lateinit var diaconnG8Pump: DiaconnG8Pump
init {
msgType = 0x6E
aapsLogger.debug(LTag.PUMPCOMM, "SeialNumInquirePacket init")
}
override fun encode(msgSeq:Int): ByteArray {
val buffer = prefixEncode(msgType, msgSeq, MSG_CON_END)
return suffixEncode(buffer)
}
override fun getFriendlyName(): String {
return "PUMP_SERIAL_NUM_INQUIRE"
}
}

View file

@ -0,0 +1,69 @@
package info.nightscout.androidaps.diaconn.packet
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.diaconn.DiaconnG8Pump
import info.nightscout.androidaps.diaconn.R
import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.shared.logging.LTag
import info.nightscout.shared.sharedPreferences.SP
import javax.inject.Inject
/**
* SerialNumInquireResponsePacket
*/
class SerialNumInquireResponsePacket(injector: HasAndroidInjector) : DiaconnG8Packet(injector ) {
@Inject lateinit var diaconnG8Pump: DiaconnG8Pump
@Inject lateinit var sp: SP
@Inject lateinit var rh: ResourceHelper
init {
msgType = 0xAE.toByte()
aapsLogger.debug(LTag.PUMPCOMM, "SerialNumInquireResponsePacket init")
}
override fun handleMessage(data: ByteArray?) {
val result = defect(data)
if (result != 0) {
aapsLogger.debug(LTag.PUMPCOMM, "SerialNumInquireResponsePacket Got some Error")
failed = true
return
} else failed = false
val bufferData = prefixDecode(data)
val result2 = getByteToInt(bufferData)
if(!isSuccInquireResponseResult(result2)) {
failed = true
return
}
diaconnG8Pump.country = getByteToInt(bufferData).toChar().toString().toInt() // ASCII
diaconnG8Pump.productType = getByteToInt(bufferData).toChar().toString().toInt() // ASCII
diaconnG8Pump.makeYear = getByteToInt(bufferData)
diaconnG8Pump.makeMonth = getByteToInt(bufferData)
diaconnG8Pump.makeDay = getByteToInt(bufferData)
diaconnG8Pump.lotNo = getByteToInt(bufferData)// LOT NO
diaconnG8Pump.serialNo = getShortToInt(bufferData)
diaconnG8Pump.majorVersion = getByteToInt(bufferData)
diaconnG8Pump.minorVersion = getByteToInt(bufferData)
aapsLogger.debug(LTag.PUMPCOMM, "Result --> ${diaconnG8Pump.result}")
aapsLogger.debug(LTag.PUMPCOMM, "country --> ${diaconnG8Pump.country}")
aapsLogger.debug(LTag.PUMPCOMM, "productType --> ${diaconnG8Pump.productType}")
aapsLogger.debug(LTag.PUMPCOMM, "makeYear --> ${diaconnG8Pump.makeYear}")
aapsLogger.debug(LTag.PUMPCOMM, "makeMonth --> ${diaconnG8Pump.makeMonth}")
aapsLogger.debug(LTag.PUMPCOMM, "makeDay --> ${diaconnG8Pump.makeDay}")
aapsLogger.debug(LTag.PUMPCOMM, "lotNo --> ${diaconnG8Pump.lotNo}")
aapsLogger.debug(LTag.PUMPCOMM, "serialNo --> ${diaconnG8Pump.serialNo}")
aapsLogger.debug(LTag.PUMPCOMM, "majorVersion --> ${diaconnG8Pump.majorVersion}")
aapsLogger.debug(LTag.PUMPCOMM, "minorVersion --> ${diaconnG8Pump.minorVersion}")
sp.putString(rh.gs(R.string.pumpversion), diaconnG8Pump.majorVersion.toString() + "." + diaconnG8Pump.minorVersion.toString())
}
override fun getFriendlyName(): String {
return "PUMP_SERIAL_NUM_INQUIRE_RESPONSE"
}
}

View file

@ -15,24 +15,30 @@ class TimeInquireResponsePacket(
@Inject lateinit var diaconnG8Pump: DiaconnG8Pump @Inject lateinit var diaconnG8Pump: DiaconnG8Pump
init { init {
msgType = 0x50.toByte() msgType = 0x8F.toByte()
aapsLogger.debug(LTag.PUMPCOMM, "TimeInquireResponsePacket init") aapsLogger.debug(LTag.PUMPCOMM, "TimeInquireResponsePacket init")
} }
override fun handleMessage(data: ByteArray?) { override fun handleMessage(data: ByteArray?) {
val result = defect(data) val defectCheck = defect(data)
if (result != 0) { if (defectCheck != 0) {
aapsLogger.debug(LTag.PUMPCOMM, "TimeInquireResponsePacket Got some Error") aapsLogger.debug(LTag.PUMPCOMM, "TimeInquireResponsePacket Got some Error")
failed = true failed = true
return return
} else failed = false } else failed = false
val bufferData = prefixDecode(data) val bufferData = prefixDecode(data)
val result2 = getByteToInt(bufferData) val result = getByteToInt(bufferData)
if(!isSuccInquireResponseResult(result2)) { if(!isSuccInquireResponseResult(result)) {
failed = true failed = true
return return
} }
diaconnG8Pump.year = getByteToInt(bufferData) + 2000 // 년 (18~99)
diaconnG8Pump.month = getByteToInt(bufferData) // 월 (1~12)
diaconnG8Pump.day = getByteToInt(bufferData) // 일 (1~31)
diaconnG8Pump.hour = getByteToInt(bufferData) // 시 (0~23)
diaconnG8Pump.minute = getByteToInt(bufferData) // 분 (0~59)
diaconnG8Pump.second = getByteToInt(bufferData) // 초 (0~59)
} }
override fun getFriendlyName(): String { override fun getFriendlyName(): String {

View file

@ -133,6 +133,9 @@ class BLECommonService @Inject internal constructor(
aapsLogger.debug(LTag.PUMPBTCOMM, "onServicesDiscovered") aapsLogger.debug(LTag.PUMPBTCOMM, "onServicesDiscovered")
if (status == BluetoothGatt.GATT_SUCCESS) { if (status == BluetoothGatt.GATT_SUCCESS) {
findCharacteristic() findCharacteristic()
SystemClock.sleep(1600)
isConnected = true
isConnecting = false
} }
} }
@ -206,6 +209,7 @@ class BLECommonService @Inject internal constructor(
uartIndicate = gattCharacteristic uartIndicate = gattCharacteristic
//setCharacteristicNotification(uartIndicate, true) //setCharacteristicNotification(uartIndicate, true)
bluetoothGatt?.setCharacteristicNotification(uartIndicate, true) bluetoothGatt?.setCharacteristicNotification(uartIndicate, true)
// nRF Connect 참고하여 추가함 // nRF Connect 참고하여 추가함
val descriptor: BluetoothGattDescriptor = uartIndicate!!.getDescriptor(UUID.fromString(CHARACTERISTIC_CONFIG_UUID)) val descriptor: BluetoothGattDescriptor = uartIndicate!!.getDescriptor(UUID.fromString(CHARACTERISTIC_CONFIG_UUID))
descriptor.value = BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE descriptor.value = BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE
@ -223,8 +227,6 @@ class BLECommonService @Inject internal constructor(
aapsLogger.debug(LTag.PUMPBTCOMM, "onConnectionStateChange newState : $newState") aapsLogger.debug(LTag.PUMPBTCOMM, "onConnectionStateChange newState : $newState")
if (newState == BluetoothProfile.STATE_CONNECTED) { if (newState == BluetoothProfile.STATE_CONNECTED) {
gatt.discoverServices() gatt.discoverServices()
isConnected = true
isConnecting = false
rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.CONNECTED)) rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.CONNECTED))
} else if (newState == BluetoothProfile.STATE_DISCONNECTED) { } else if (newState == BluetoothProfile.STATE_DISCONNECTED) {
close() close()
@ -268,6 +270,7 @@ class BLECommonService @Inject internal constructor(
// process common packet response // process common packet response
private fun processResponseMessage(data: ByteArray) { private fun processResponseMessage(data: ByteArray) {
isConnected = true isConnected = true
isConnecting = false
//요청정보 //요청정보
val originalMessageSeq = processedMessage?.getSeq(processedMessageByte) val originalMessageSeq = processedMessage?.getSeq(processedMessageByte)

View file

@ -136,13 +136,14 @@ class DiaconnG8Service : DaggerService() {
} }
private fun sendMessage(message: DiaconnG8Packet) { private fun sendMessage(message: DiaconnG8Packet) {
bleCommonService.sendMessage(message, 2000) bleCommonService.sendMessage(message, 5000)
} }
fun readPumpStatus() { fun readPumpStatus() {
try { try {
val pump = activePlugin.activePump val pump = activePlugin.activePump
rxBus.send(EventPumpStatusChanged(rh.gs(R.string.gettingpumpsettings))) rxBus.send(EventPumpStatusChanged(rh.gs(R.string.gettingpumpsettings)))
sendMessage(SerialNumInquirePacket(injector))
val pumpFirmwareVersion = sp.getString(rh.gs(R.string.pumpversion), "") val pumpFirmwareVersion = sp.getString(rh.gs(R.string.pumpversion), "")
@ -170,6 +171,7 @@ class DiaconnG8Service : DaggerService() {
// 시간 설정 // 시간 설정
rxBus.send(EventPumpStatusChanged(rh.gs(R.string.gettingpumptime))) rxBus.send(EventPumpStatusChanged(rh.gs(R.string.gettingpumptime)))
sendMessage(TimeInquirePacket(injector))
var timeDiff = (diaconnG8Pump.getPumpTime() - System.currentTimeMillis()) / 1000L var timeDiff = (diaconnG8Pump.getPumpTime() - System.currentTimeMillis()) / 1000L
if (diaconnG8Pump.getPumpTime() == 0L) { if (diaconnG8Pump.getPumpTime() == 0L) {
// initial handshake was not successful // initial handshake was not successful
@ -239,14 +241,12 @@ class DiaconnG8Service : DaggerService() {
} }
fun loadHistory(): PumpEnactResult { fun loadHistory(): PumpEnactResult {
if (!diaconnG8Plugin.isInitialized()) { if (!diaconnG8Plugin.isInitialized()) {
val result = PumpEnactResult(injector).success(false) val result = PumpEnactResult(injector).success(false)
result.comment = "pump not initialized" result.comment = "pump not initialized"
return result return result
} }
sendMessage(LogStatusInquirePacket(injector)) sendMessage(LogStatusInquirePacket(injector))
// pump version check // pump version check
if (diaconnG8Pump.isPumpVersionGe2_63) { if (diaconnG8Pump.isPumpVersionGe2_63) {
sendMessage(IncarnationInquirePacket(injector)) sendMessage(IncarnationInquirePacket(injector))
@ -257,7 +257,7 @@ class DiaconnG8Service : DaggerService() {
var apsWrappingCount = -1 var apsWrappingCount = -1
// get saved last loginfo // get saved last loginfo
val diaconnHistoryRecord = diaconnHistoryRecordDao.getLastRecord(diaconnG8Pump.pumpUid) val diaconnHistoryRecord = diaconnHistoryRecordDao.getLastRecord(diaconnG8Pump.pumpUid)
aapsLogger.error(LTag.PUMPCOMM, "diaconnHistoryRecord :: $diaconnHistoryRecord") aapsLogger.debug(LTag.PUMPCOMM, "diaconnHistoryRecord :: $diaconnHistoryRecord")
if(diaconnHistoryRecord != null) { if(diaconnHistoryRecord != null) {
apsLastLogNum = diaconnHistoryRecord.lognum apsLastLogNum = diaconnHistoryRecord.lognum
@ -306,7 +306,6 @@ class DiaconnG8Service : DaggerService() {
result.success(true) result.success(true)
diaconnG8Pump.lastConnection = System.currentTimeMillis() diaconnG8Pump.lastConnection = System.currentTimeMillis()
} }
// upload pump log to Diaconn Cloud // upload pump log to Diaconn Cloud
if (sp.getBoolean(R.string.key_diaconn_g8_cloudsend, true)) { if (sp.getBoolean(R.string.key_diaconn_g8_cloudsend, true)) {
SystemClock.sleep(1000) SystemClock.sleep(1000)
@ -399,13 +398,6 @@ class DiaconnG8Service : DaggerService() {
fun bolus(insulin: Double, carbs: Int, carbTime: Long, t: EventOverviewBolusProgress.Treatment): Boolean { fun bolus(insulin: Double, carbs: Int, carbTime: Long, t: EventOverviewBolusProgress.Treatment): Boolean {
if (!isConnected) return false if (!isConnected) return false
if (BolusProgressDialog.stopPressed) return false if (BolusProgressDialog.stopPressed) return false
// Only Carbs
if (carbs > 0 && insulin == 0.0) {
pumpSync.syncCarbsWithTimestamp(carbTime, carbs.toDouble(), null, PumpType.DIACONN_G8, diaconnG8Pump.serialNo.toString())
return true
}
rxBus.send(EventPumpStatusChanged(rh.gs(R.string.startingbolus))) rxBus.send(EventPumpStatusChanged(rh.gs(R.string.startingbolus)))
// bolus speed setting // bolus speed setting
@ -435,7 +427,7 @@ class DiaconnG8Service : DaggerService() {
val bolusStart = System.currentTimeMillis() val bolusStart = System.currentTimeMillis()
if (insulin > 0) { if (insulin > 0) {
if (!diaconnG8Pump.bolusStopped) { if (!diaconnG8Pump.bolusStopped) {
sendMessage(start) sendMessage(start, 100)
// otp process // otp process
if (!processConfirm(start.msgType)) return false if (!processConfirm(start.msgType)) return false
} else { } else {
@ -460,11 +452,12 @@ class DiaconnG8Service : DaggerService() {
} }
val bolusDurationInMSec = (insulin * speed * 1000).toLong() val bolusDurationInMSec = (insulin * speed * 1000).toLong()
val expectedEnd = bolusStart + bolusDurationInMSec + 7500L val expectedEnd = bolusStart + bolusDurationInMSec + 3500L
val totalwaitTime = (expectedEnd - System.currentTimeMillis()) / 1000 val totalwaitTime = (expectedEnd - System.currentTimeMillis()) / 1000
if(diaconnG8Pump.isReadyToBolus) {
while (!diaconnG8Pump.bolusDone) { while (!diaconnG8Pump.bolusDone) {
val waitTime = (expectedEnd - System.currentTimeMillis()) / 1000 val waitTime = (expectedEnd - System.currentTimeMillis()) / 1000
bolusingEvent.status = rh.gs(R.string.waitingforestimatedbolusend, if (waitTime < 0) 0 else waitTime) bolusingEvent.status = String.format(rh.gs(R.string.waitingforestimatedbolusend), if (waitTime < 0) 0 else waitTime)
var progressPecent = 0 var progressPecent = 0
if (totalwaitTime > waitTime) { if (totalwaitTime > waitTime) {
progressPecent = ((totalwaitTime - waitTime) * 100 / totalwaitTime).toInt() progressPecent = ((totalwaitTime - waitTime) * 100 / totalwaitTime).toInt()
@ -473,13 +466,15 @@ class DiaconnG8Service : DaggerService() {
rxBus.send(bolusingEvent) rxBus.send(bolusingEvent)
SystemClock.sleep(200) SystemClock.sleep(200)
} }
}
diaconnG8Pump.isReadyToBolus = false
// do not call loadHistory() directly, reconnection may be needed // do not call loadHistory() directly, reconnection may be needed
commandQueue.loadEvents(object : Callback() { commandQueue.loadEvents(object : Callback() {
override fun run() { override fun run() {
// reread bolus status // reread bolus status
rxBus.send(EventPumpStatusChanged(rh.gs(R.string.gettingbolusstatus))) rxBus.send(EventPumpStatusChanged(rh.gs(R.string.gettingbolusstatus)))
sendMessage(InjectionSnackInquirePacket(injector), 1000) // last bolus sendMessage(InjectionSnackInquirePacket(injector), 2000) // last bolus
// 볼러스 결과 보고패킷에서 처리함. // 볼러스 결과 보고패킷에서 처리함.
bolusingEvent.percent = 100 bolusingEvent.percent = 100
rxBus.send(EventPumpStatusChanged(rh.gs(R.string.disconnecting))) rxBus.send(EventPumpStatusChanged(rh.gs(R.string.disconnecting)))
@ -492,7 +487,7 @@ class DiaconnG8Service : DaggerService() {
val stop = InjectionCancelSettingPacket(injector, 0x07.toByte()) val stop = InjectionCancelSettingPacket(injector, 0x07.toByte())
diaconnG8Pump.bolusStopForced = true diaconnG8Pump.bolusStopForced = true
if (isConnected) { if (isConnected) {
sendMessage(stop) sendMessage(stop, 100)
// otp process // otp process
if (!processConfirm(stop.msgType)) return if (!processConfirm(stop.msgType)) return
while (!diaconnG8Pump.bolusStopped) { while (!diaconnG8Pump.bolusStopped) {
@ -513,7 +508,7 @@ class DiaconnG8Service : DaggerService() {
rxBus.send(EventPumpStatusChanged(rh.gs(R.string.stoppingtempbasal))) rxBus.send(EventPumpStatusChanged(rh.gs(R.string.stoppingtempbasal)))
val msgPacket = TempBasalSettingPacket(injector, 2, diaconnG8Pump.tbTime, diaconnG8Pump.tbInjectRateRatio) val msgPacket = TempBasalSettingPacket(injector, 2, diaconnG8Pump.tbTime, diaconnG8Pump.tbInjectRateRatio)
// tempbasal stop // tempbasal stop
sendMessage(msgPacket) sendMessage(msgPacket, 100)
// otp process // otp process
if (!processConfirm(msgPacket.msgType)) return false if (!processConfirm(msgPacket.msgType)) return false
diaconnG8Pump.tempBasalStart = dateUtil.now() diaconnG8Pump.tempBasalStart = dateUtil.now()
@ -521,7 +516,7 @@ class DiaconnG8Service : DaggerService() {
rxBus.send(EventPumpStatusChanged(rh.gs(R.string.settingtempbasal))) rxBus.send(EventPumpStatusChanged(rh.gs(R.string.settingtempbasal)))
val tbInjectRate = ((absoluteRate * 100) + 1000).toInt() val tbInjectRate = ((absoluteRate * 100) + 1000).toInt()
val msgTBR = TempBasalSettingPacket(injector, 1, ((durationInHours * 60) / 15).toInt(), tbInjectRate) val msgTBR = TempBasalSettingPacket(injector, 1, ((durationInHours * 60) / 15).toInt(), tbInjectRate)
sendMessage(msgTBR) sendMessage(msgTBR, 100)
// otp process // otp process
if (!processConfirm(msgTBR.msgType)) return false if (!processConfirm(msgTBR.msgType)) return false
// pump tempbasal status inquire // pump tempbasal status inquire
@ -545,7 +540,7 @@ class DiaconnG8Service : DaggerService() {
rxBus.send(EventPumpStatusChanged(rh.gs(R.string.stoppingtempbasal))) rxBus.send(EventPumpStatusChanged(rh.gs(R.string.stoppingtempbasal)))
val msgPacket = TempBasalSettingPacket(injector, 2, diaconnG8Pump.tbTime, diaconnG8Pump.tbInjectRateRatio) val msgPacket = TempBasalSettingPacket(injector, 2, diaconnG8Pump.tbTime, diaconnG8Pump.tbInjectRateRatio)
// tempbasal stop // tempbasal stop
sendMessage(msgPacket) sendMessage(msgPacket, 100)
// otp process // otp process
if (!processConfirm(msgPacket.msgType)) return false if (!processConfirm(msgPacket.msgType)) return false
SystemClock.sleep(500) SystemClock.sleep(500)
@ -553,7 +548,7 @@ class DiaconnG8Service : DaggerService() {
rxBus.send(EventPumpStatusChanged(rh.gs(R.string.settingtempbasal))) rxBus.send(EventPumpStatusChanged(rh.gs(R.string.settingtempbasal)))
val tbInjectRate = absoluteRate * 100 + 1000 val tbInjectRate = absoluteRate * 100 + 1000
val msgTBR = TempBasalSettingPacket(injector, 1, 2, tbInjectRate.toInt()) val msgTBR = TempBasalSettingPacket(injector, 1, 2, tbInjectRate.toInt())
sendMessage(msgTBR) sendMessage(msgTBR, 100)
// otp process // otp process
if (!processConfirm(msgTBR.msgType)) return false if (!processConfirm(msgTBR.msgType)) return false
sendMessage(TempBasalInquirePacket(injector)) sendMessage(TempBasalInquirePacket(injector))
@ -577,7 +572,7 @@ class DiaconnG8Service : DaggerService() {
diaconnG8Pump.tbInjectRateRatio diaconnG8Pump.tbInjectRateRatio
) )
// tempbasal stop // tempbasal stop
sendMessage(msgPacket) sendMessage(msgPacket, 500)
// otp process // otp process
if (!processConfirm(msgPacket.msgType)) return false if (!processConfirm(msgPacket.msgType)) return false
SystemClock.sleep(500) SystemClock.sleep(500)
@ -593,7 +588,7 @@ class DiaconnG8Service : DaggerService() {
fun extendedBolus(insulin: Double, durationInMinutes: Int): Boolean { fun extendedBolus(insulin: Double, durationInMinutes: Int): Boolean {
if (!isConnected) return false if (!isConnected) return false
rxBus.send(EventPumpStatusChanged(rh.gs(R.string.settingextendedbolus))) rxBus.send(EventPumpStatusChanged(rh.gs(R.string.settingextendedbolus)))
aapsLogger.error(LTag.PUMPCOMM, "insulin: $insulin durationInMinutes: $durationInMinutes") aapsLogger.debug(LTag.PUMPCOMM, "insulin: $insulin durationInMinutes: $durationInMinutes")
val msgExtended = InjectionExtendedBolusSettingPacket(injector, (insulin * 100).toInt(), durationInMinutes, dateUtil.now()) val msgExtended = InjectionExtendedBolusSettingPacket(injector, (insulin * 100).toInt(), durationInMinutes, dateUtil.now())
sendMessage(msgExtended) sendMessage(msgExtended)
@ -672,6 +667,7 @@ class DiaconnG8Service : DaggerService() {
(basalList[23] * 100).toInt() (basalList[23] * 100).toInt()
) )
// setting basal pattern 1,2,3,4 // setting basal pattern 1,2,3,4
sendMessage(SerialNumInquirePacket(injector), 2000)
sendMessage(requestReqPacket1, 500) sendMessage(requestReqPacket1, 500)
sendMessage(requestReqPacket2, 500) sendMessage(requestReqPacket2, 500)
sendMessage(requestReqPacket3, 500) sendMessage(requestReqPacket3, 500)
@ -694,22 +690,22 @@ class DiaconnG8Service : DaggerService() {
private fun processConfirm(msgType: Byte): Boolean { private fun processConfirm(msgType: Byte): Boolean {
// pump confirm // pump confirm
var loopCnt = 0
// waiting 2 seconds for otp
while(loopCnt < 20) {
if (diaconnG8Pump.otpNumber == 0) {
SystemClock.sleep(100)
aapsLogger.error(LTag.PUMPCOMM, "OTP waiting 100ms $loopCnt / 20")
}
loopCnt++
}
// after 2 second
if (diaconnG8Pump.otpNumber == 0) { if (diaconnG8Pump.otpNumber == 0) {
aapsLogger.error(LTag.PUMPCOMM, "otp is not received yet") aapsLogger.error(LTag.PUMPCOMM, "otp is not received yet")
// Comments are made as dialogs are exposed twice each in the event of an error.
// Thread {
// val i = Intent(context, ErrorHelperActivity::class.java)
// i.putExtra("soundid", R.raw.boluserror)
// i.putExtra("status", rh.gs(R.string.diaconn_g8_errotpreceivedyet))
// i.putExtra("title", rh.gs(R.string.pumperror))
// i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
// context.startActivity(i)
// }.start()
return false return false
} }
sendMessage(AppConfirmSettingPacket(injector, msgType, diaconnG8Pump.otpNumber)) diaconnG8Pump.bolusConfirmMessage = msgType
sendMessage(AppConfirmSettingPacket(injector, msgType, diaconnG8Pump.otpNumber), 2000)
diaconnG8Pump.otpNumber = 0 diaconnG8Pump.otpNumber = 0
return true return true
} }

View file

@ -89,6 +89,8 @@
<string name="diaconn_g8_logcanulachange_title">바늘 교체</string> <string name="diaconn_g8_logcanulachange_title">바늘 교체</string>
<string name="diaconn_g8_logcanulachange_summary">로그 동기화 시 케어포털 \"위치 교체\" 정보 자동 업로드</string> <string name="diaconn_g8_logcanulachange_summary">로그 동기화 시 케어포털 \"위치 교체\" 정보 자동 업로드</string>
<string name="diaconn_g8_logbatterychange_summary">로그 동기화 시 케어포털 \"베터리 교체\" 정보 자동 업로드</string> <string name="diaconn_g8_logbatterychange_summary">로그 동기화 시 케어포털 \"베터리 교체\" 정보 자동 업로드</string>
<string name="diaconn_g8_cloudsend_summary">펌프 로그정보를 \"디아콘 클라우드\"로 자동 업로드</string>
<string name="diaconn_g8_cloudsend_title">디아콘 클라우드 전송</string>
<string name="diaconn_g8_logbatterychange_title">베터리 교체</string> <string name="diaconn_g8_logbatterychange_title">베터리 교체</string>
<string name="diaconn_g8_logsyncinprogress">로그 동기화 진행 중</string> <string name="diaconn_g8_logsyncinprogress">로그 동기화 진행 중</string>
<string name="diaconn_g8_loginsulinshorage">인슐린 부족 경고</string> <string name="diaconn_g8_loginsulinshorage">인슐린 부족 경고</string>

View file

@ -169,5 +169,5 @@
<string name="diaconn_g8_errorcode_36">Tempbasal stop is rejected when tempbasal is not running</string> <string name="diaconn_g8_errorcode_36">Tempbasal stop is rejected when tempbasal is not running</string>
<string name="diaconn_g8_cloudsend_summary">Send pump logs to the Diaconn Cloud.</string> <string name="diaconn_g8_cloudsend_summary">Send pump logs to the Diaconn Cloud.</string>
<string name="diaconn_g8_cloudsend_title">Diaconn Cloud Sync</string> <string name="diaconn_g8_cloudsend_title">Diaconn Cloud Sync</string>
<string name="key_diaconn_g8_appuid" translatable="false">diaconn_g8_appuid</string> <string name="key_diaconn_g8_appuid">diaconn_g8_appuid</string>
</resources> </resources>