OBJECTIVES: Better detect existing BGs

This commit is contained in:
Milos Kozak 2021-12-30 19:29:18 +01:00
parent a3b8c12c27
commit 5d74f71d0a
2 changed files with 13 additions and 11 deletions

View file

@ -16,8 +16,6 @@ import info.nightscout.androidaps.events.EventConfigBuilderChange
import info.nightscout.androidaps.events.EventPreferenceChange import info.nightscout.androidaps.events.EventPreferenceChange
import info.nightscout.androidaps.interfaces.Config import info.nightscout.androidaps.interfaces.Config
import info.nightscout.androidaps.interfaces.DataSyncSelector import info.nightscout.androidaps.interfaces.DataSyncSelector
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag
import info.nightscout.androidaps.plugins.bus.RxBus import info.nightscout.androidaps.plugins.bus.RxBus
import info.nightscout.androidaps.plugins.general.food.FoodPlugin.FoodWorker import info.nightscout.androidaps.plugins.general.food.FoodPlugin.FoodWorker
import info.nightscout.androidaps.plugins.general.nsclient.* import info.nightscout.androidaps.plugins.general.nsclient.*
@ -48,6 +46,8 @@ import info.nightscout.androidaps.utils.XDripBroadcast
import info.nightscout.androidaps.utils.buildHelper.BuildHelper import info.nightscout.androidaps.utils.buildHelper.BuildHelper
import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.resources.ResourceHelper
import info.nightscout.androidaps.utils.rx.AapsSchedulers import info.nightscout.androidaps.utils.rx.AapsSchedulers
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag
import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.sharedPreferences.SP
import io.reactivex.disposables.CompositeDisposable import io.reactivex.disposables.CompositeDisposable
import io.socket.client.IO import io.socket.client.IO
@ -540,13 +540,17 @@ class NSClientService : DaggerService() {
} }
if (data.has("sgvs")) { if (data.has("sgvs")) {
val sgvs = data.getJSONArray("sgvs") val sgvs = data.getJSONArray("sgvs")
if (sgvs.length() > 0) rxBus.send(EventNSClientNewLog("DATA", "received " + sgvs.length() + " sgvs")) if (sgvs.length() > 0) {
dataWorker.enqueue( rxBus.send(EventNSClientNewLog("DATA", "received " + sgvs.length() + " sgvs"))
OneTimeWorkRequest.Builder(NSClientSourceWorker::class.java) // Objective0
.setInputData(dataWorker.storeInputData(sgvs, null)) sp.putBoolean(R.string.key_ObjectivesbgIsAvailableInNS, true)
.build() dataWorker.enqueue(
) OneTimeWorkRequest.Builder(NSClientSourceWorker::class.java)
xDripBroadcast.sendSgvs(sgvs) .setInputData(dataWorker.storeInputData(sgvs, null))
.build()
)
xDripBroadcast.sendSgvs(sgvs)
}
} }
rxBus.send(EventNSClientNewLog("LAST", dateUtil.dateAndTimeString(latestDateInReceivedData))) rxBus.send(EventNSClientNewLog("LAST", dateUtil.dateAndTimeString(latestDateInReceivedData)))
} catch (e: JSONException) { } catch (e: JSONException) {

View file

@ -162,8 +162,6 @@ class NSClientSourcePlugin @Inject constructor(
aapsLogger.error("Unhandled exception", e) aapsLogger.error("Unhandled exception", e)
ret = Result.failure(workDataOf("Error" to e.toString())) ret = Result.failure(workDataOf("Error" to e.toString()))
} }
// Objectives 0
sp.putBoolean(R.string.key_ObjectivesbgIsAvailableInNS, true)
return ret return ret
} }
} }