Store heart rate events from watch in local storage.
This commit is contained in:
parent
411ec8bd68
commit
7f14535852
1 changed files with 17 additions and 0 deletions
|
@ -19,6 +19,7 @@ import info.nightscout.database.ValueWrapper
|
||||||
import info.nightscout.database.entities.Bolus
|
import info.nightscout.database.entities.Bolus
|
||||||
import info.nightscout.database.entities.BolusCalculatorResult
|
import info.nightscout.database.entities.BolusCalculatorResult
|
||||||
import info.nightscout.database.entities.GlucoseValue
|
import info.nightscout.database.entities.GlucoseValue
|
||||||
|
import info.nightscout.database.entities.HeartRate
|
||||||
import info.nightscout.database.entities.TemporaryBasal
|
import info.nightscout.database.entities.TemporaryBasal
|
||||||
import info.nightscout.database.entities.TemporaryTarget
|
import info.nightscout.database.entities.TemporaryTarget
|
||||||
import info.nightscout.database.entities.TotalDailyDose
|
import info.nightscout.database.entities.TotalDailyDose
|
||||||
|
@ -28,6 +29,7 @@ import info.nightscout.database.entities.interfaces.end
|
||||||
import info.nightscout.database.impl.AppRepository
|
import info.nightscout.database.impl.AppRepository
|
||||||
import info.nightscout.database.impl.transactions.CancelCurrentTemporaryTargetIfAnyTransaction
|
import info.nightscout.database.impl.transactions.CancelCurrentTemporaryTargetIfAnyTransaction
|
||||||
import info.nightscout.database.impl.transactions.InsertAndCancelCurrentTemporaryTargetTransaction
|
import info.nightscout.database.impl.transactions.InsertAndCancelCurrentTemporaryTargetTransaction
|
||||||
|
import info.nightscout.database.impl.transactions.InsertOrUpdateHeartRateTransaction
|
||||||
import info.nightscout.interfaces.Config
|
import info.nightscout.interfaces.Config
|
||||||
import info.nightscout.interfaces.Constants
|
import info.nightscout.interfaces.Constants
|
||||||
import info.nightscout.interfaces.GlucoseUnit
|
import info.nightscout.interfaces.GlucoseUnit
|
||||||
|
@ -308,6 +310,10 @@ class DataHandlerMobile @Inject constructor(
|
||||||
aapsLogger.debug(LTag.WEAR, "WearException received $it from ${it.sourceNodeId}")
|
aapsLogger.debug(LTag.WEAR, "WearException received $it from ${it.sourceNodeId}")
|
||||||
fabricPrivacy.logWearException(it)
|
fabricPrivacy.logWearException(it)
|
||||||
}, fabricPrivacy::logException)
|
}, fabricPrivacy::logException)
|
||||||
|
disposable += rxBus
|
||||||
|
.toObservable(EventData.ActionHeartRate::class.java)
|
||||||
|
.observeOn(aapsSchedulers.io)
|
||||||
|
.subscribe({ handleHeartRate(it) }, fabricPrivacy::logException)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun handleTddStatus() {
|
private fun handleTddStatus() {
|
||||||
|
@ -1230,4 +1236,15 @@ class DataHandlerMobile @Inject constructor(
|
||||||
@Synchronized private fun sendError(errorMessage: String) {
|
@Synchronized private fun sendError(errorMessage: String) {
|
||||||
rxBus.send(EventMobileToWear(EventData.ConfirmAction(rh.gs(info.nightscout.core.ui.R.string.error), errorMessage, returnCommand = EventData.Error(dateUtil.now())))) // ignore return path
|
rxBus.send(EventMobileToWear(EventData.ConfirmAction(rh.gs(info.nightscout.core.ui.R.string.error), errorMessage, returnCommand = EventData.Error(dateUtil.now())))) // ignore return path
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Stores heart rate events coming from the Wear device. */
|
||||||
|
private fun handleHeartRate(actionHeartRate: EventData.ActionHeartRate) {
|
||||||
|
aapsLogger.debug(LTag.WEAR, "Heart rate received $actionHeartRate from ${actionHeartRate.sourceNodeId}")
|
||||||
|
val hr = HeartRate(
|
||||||
|
duration = actionHeartRate.samplingEndMillis - actionHeartRate.samplingStartMillis,
|
||||||
|
timestamp = actionHeartRate.samplingEndMillis,
|
||||||
|
beatsPerMinute = actionHeartRate.beatsPerMinute.toDouble(),
|
||||||
|
device = actionHeartRate.device)
|
||||||
|
repository.runTransaction(InsertOrUpdateHeartRateTransaction(hr))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue