Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@
<action android:name="cn.diyaps.sharing.SI_APP" />
<!-- Receiver from patched Sino app -->
<action android:name="cn.diyaps.sharing.SINO_APP" />
<!-- Receiver from patched SIB App -->
<action android:name="com.diyaps.sharing.SIBIO_APP" />
</intent-filter>
</receiver>

Expand Down
7 changes: 7 additions & 0 deletions app/src/main/kotlin/app/aaps/di/PluginsListModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import app.aaps.plugins.source.PatchedSiAppPlugin
import app.aaps.plugins.source.PatchedSinoAppPlugin
import app.aaps.plugins.source.PoctechPlugin
import app.aaps.plugins.source.RandomBgPlugin
import app.aaps.plugins.source.SibionicsPlugin
import app.aaps.plugins.source.SyaiPlugin
import app.aaps.plugins.source.TomatoPlugin
import app.aaps.plugins.source.XdripSourcePlugin
Expand Down Expand Up @@ -451,6 +452,12 @@ abstract class PluginsListModule {
@IntKey(476)
abstract fun bindPatchedSinoAppPlugin(plugin: PatchedSinoAppPlugin): PluginBase

@Binds
@AllConfigs
@IntoMap
@IntKey(477)
abstract fun bindSibionicsPlugin(plugin: SibionicsPlugin): PluginBase

@Binds
@AllConfigs
@IntoMap
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/kotlin/app/aaps/receivers/DataReceiver.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import app.aaps.plugins.source.DexcomPlugin
import app.aaps.plugins.source.GlimpPlugin
import app.aaps.plugins.source.MM640gPlugin
import app.aaps.plugins.source.PatchedSiAppPlugin
import app.aaps.plugins.source.SibionicsPlugin
import app.aaps.plugins.source.PatchedSinoAppPlugin
import app.aaps.plugins.source.PoctechPlugin
import app.aaps.plugins.source.SyaiPlugin
Expand Down Expand Up @@ -91,6 +92,13 @@ open class DataReceiver : DaggerBroadcastReceiver() {
it.copyString("data", bundle)
}.build()).build()

Intents.SIB_APP ->
OneTimeWorkRequest.Builder(SibionicsPlugin.SibionicsWorker::class.java)
.setInputData(Data.Builder().also {
it.copyString("collection", bundle)
it.copyString("data", bundle)
}.build()).build()

Intents.SINO_APP ->
OneTimeWorkRequest.Builder(PatchedSinoAppPlugin.PatchedSinoAppWorker::class.java)
.setInputData(Data.Builder().also {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ enum class SourceSensor(val text: String) {
OTTAI("Ottai"),
SIBIONIC_GS1_NATIVE("GS1 Native"),
SIBIONIC("SI App"),
SIBIONICS("Sibionics"),
SINO("Sino App"),
EVERSENSE("Eversense"),
AIDEX("GlucoRx Aidex"),
Expand Down
1 change: 1 addition & 0 deletions core/data/src/main/kotlin/app/aaps/core/data/ue/Sources.kt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ enum class Sources {
SyaiTag,
SiBionic,
Sino,
Sibionics, //From SiBionics Plugin
LocalProfile, //From LocalProfile plugin
Loop, //From Loop plugin
Maintenance, //From Maintenance plugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,8 @@ interface Intents {
const val SINO_APP = "cn.diyaps.sharing.SINO_APP"
// Patched Syai Tag App -> AAPS
const val SYAI_APP = "info.nightscout.androidaps.action.SYAI_TAG_APP"

// Patched Sib App -> AAPS
const val SIB_APP = "com.diyaps.sharing.SIBIO_APP"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ data class GlucoseValue(
OTTAI,
SIBIONIC_GS1_NATIVE,
SIBIONIC,
SIBIONICS,
SINO,
SYAI_TAG,
IOB_PREDICTION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ data class UserEntry(
SyaiTag, //From Syai Tag plugin
SiBionic,
Sino,
Sibionics, // From Sibionics plugin
Stats, //From Stat Activity
Aaps, // MainApp
BgFragment,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ fun GlucoseValue.SourceSensor.fromDb(): SourceSensor =
GlucoseValue.SourceSensor.SIBIONIC_GS1_NATIVE -> SourceSensor.SIBIONIC_GS1_NATIVE
GlucoseValue.SourceSensor.SIBIONIC -> SourceSensor.SIBIONIC
GlucoseValue.SourceSensor.SINO -> SourceSensor.SINO
GlucoseValue.SourceSensor.SIBIONICS -> SourceSensor.SIBIONICS
GlucoseValue.SourceSensor.IOB_PREDICTION -> SourceSensor.IOB_PREDICTION
GlucoseValue.SourceSensor.A_COB_PREDICTION -> SourceSensor.A_COB_PREDICTION
GlucoseValue.SourceSensor.COB_PREDICTION -> SourceSensor.COB_PREDICTION
Expand Down Expand Up @@ -82,6 +83,7 @@ fun SourceSensor.toDb(): GlucoseValue.SourceSensor =
SourceSensor.SIBIONIC_GS1_NATIVE -> GlucoseValue.SourceSensor.SIBIONIC_GS1_NATIVE
SourceSensor.SIBIONIC -> GlucoseValue.SourceSensor.SIBIONIC
SourceSensor.SINO -> GlucoseValue.SourceSensor.SINO
SourceSensor.SIBIONICS -> GlucoseValue.SourceSensor.SIBIONICS
SourceSensor.IOB_PREDICTION -> GlucoseValue.SourceSensor.IOB_PREDICTION
SourceSensor.A_COB_PREDICTION -> GlucoseValue.SourceSensor.A_COB_PREDICTION
SourceSensor.COB_PREDICTION -> GlucoseValue.SourceSensor.COB_PREDICTION
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ fun UserEntry.Sources.fromDb(): Sources =
UserEntry.Sources.SyaiTag -> Sources.SyaiTag
UserEntry.Sources.SiBionic -> Sources.SiBionic
UserEntry.Sources.Sino -> Sources.Sino
UserEntry.Sources.Sibionics -> Sources.Sibionics
UserEntry.Sources.LocalProfile -> Sources.LocalProfile
UserEntry.Sources.Loop -> Sources.Loop
UserEntry.Sources.Maintenance -> Sources.Maintenance
Expand Down Expand Up @@ -127,6 +128,7 @@ fun Sources.toDb(): UserEntry.Sources =
Sources.SyaiTag -> UserEntry.Sources.SyaiTag
Sources.SiBionic -> UserEntry.Sources.SiBionic
Sources.Sino -> UserEntry.Sources.Sino
Sources.Sibionics -> UserEntry.Sources.Sibionics
Sources.LocalProfile -> UserEntry.Sources.LocalProfile
Sources.Loop -> UserEntry.Sources.Loop
Sources.Maintenance -> UserEntry.Sources.Maintenance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class UserEntryPresentationHelperImpl @Inject constructor(
Sources.SyaiTag -> R.drawable.ic_syai_tag
Sources.SiBionic -> R.drawable.ic_generic_cgm
Sources.Sino -> R.drawable.ic_generic_cgm
Sources.Sibionics -> R.drawable.ic_generic_cgm
Sources.LocalProfile -> R.drawable.ic_local_profile
Sources.Loop -> R.drawable.ic_loop_closed_white
Sources.Maintenance -> app.aaps.core.ui.R.drawable.ic_maintenance
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
package app.aaps.plugins.source

import android.annotation.SuppressLint
import android.content.Context
import androidx.work.WorkerParameters
import androidx.work.workDataOf
import app.aaps.core.data.model.GV
import app.aaps.core.data.model.SourceSensor
import app.aaps.core.data.model.TrendArrow
import app.aaps.core.data.plugin.PluginType
import app.aaps.core.data.ue.Sources
import app.aaps.core.interfaces.db.PersistenceLayer
import app.aaps.core.interfaces.logging.AAPSLogger
import app.aaps.core.interfaces.logging.LTag
import app.aaps.core.interfaces.plugin.PluginDescription
import app.aaps.core.interfaces.resources.ResourceHelper
import app.aaps.core.interfaces.source.BgSource
import app.aaps.core.keys.interfaces.Preferences
import app.aaps.core.objects.workflow.LoggingWorker
import kotlinx.coroutines.Dispatchers
import org.json.JSONArray
import org.json.JSONException
import javax.inject.Inject
import javax.inject.Singleton

@Singleton
class SibionicsPlugin @Inject constructor(
rh: ResourceHelper,
aapsLogger: AAPSLogger,
preferences: Preferences
) : AbstractBgSourcePlugin(
PluginDescription()
.mainType(PluginType.BGSOURCE)
.fragmentClass(BGSourceFragment::class.java.name)
.pluginIcon(app.aaps.core.objects.R.drawable.ic_generic_cgm)
.preferencesId(PluginDescription.PREFERENCE_SCREEN)
.pluginName(R.string.sibionics)
.preferencesVisibleInSimpleMode(false)
.description(R.string.description_source_sibionics),
ownPreferences = emptyList(),
aapsLogger, rh, preferences
), BgSource {

class SibionicsWorker(
context: Context,
params: WorkerParameters
) : LoggingWorker(context, params, Dispatchers.IO) {

@Inject lateinit var sibionicsPlugin: SibionicsPlugin
@Inject lateinit var persistenceLayer: PersistenceLayer

@SuppressLint("CheckResult")
override suspend fun doWorkAndLog(): Result {
var ret = Result.success()
if (!sibionicsPlugin.isEnabled()) return Result.success(workDataOf("Result" to "Plugin not enabled"))
val collection = inputData.getString("collection") ?: return Result.failure(workDataOf("Error" to "missing collection"))
if (collection == "entries") {
val data = inputData.getString("data")
aapsLogger.debug(LTag.BGSOURCE, "Received SIB App Data $data")
if (!data.isNullOrEmpty()) {
try {
val glucoseValues = mutableListOf<GV>()
val jsonArray = JSONArray(data)
for (i in 0 until jsonArray.length()) {
val jsonObject = jsonArray.getJSONObject(i)
when (val type = jsonObject.getString("type")) {
"sgv" ->
glucoseValues += GV(
timestamp = jsonObject.getLong("date"),
value = jsonObject.getDouble("sgv"),
raw = null,
noise = null,
trendArrow = TrendArrow.fromString(jsonObject.getString("direction")),
sourceSensor = SourceSensor.SIBIONICS
)

else -> aapsLogger.debug(LTag.BGSOURCE, "Unknown entries type: $type")
}
}
persistenceLayer.insertCgmSourceData(Sources.Sibionics, glucoseValues, emptyList(), null)
.doOnError { ret = Result.failure(workDataOf("Error" to it.toString())) }
.blockingGet()
} catch (e: JSONException) {
aapsLogger.error("Exception: ", e)
ret = Result.failure(workDataOf("Error" to e.toString()))
}
}
} else {
ret = Result.failure(workDataOf("Error" to "missing input data"))
}
return ret
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import app.aaps.plugins.source.NSClientSourcePlugin
import app.aaps.plugins.source.PatchedSiAppPlugin
import app.aaps.plugins.source.PatchedSinoAppPlugin
import app.aaps.plugins.source.PoctechPlugin
import app.aaps.plugins.source.SibionicsPlugin
import app.aaps.plugins.source.SyaiPlugin
import app.aaps.plugins.source.TomatoPlugin
import app.aaps.plugins.source.XdripSourcePlugin
Expand Down Expand Up @@ -39,6 +40,7 @@ abstract class SourceModule {
@ContributesAndroidInjector abstract fun contributesSyaiWorker(): SyaiPlugin.SyaiWorker
@ContributesAndroidInjector abstract fun contributesSiAppWorker(): PatchedSiAppPlugin.PatchedSiAppWorker
@ContributesAndroidInjector abstract fun contributesSinoAppWorker(): PatchedSinoAppPlugin.PatchedSinoAppWorker
@ContributesAndroidInjector abstract fun contributesSibionicsWorker(): SibionicsPlugin.SibionicsWorker

@ContributesAndroidInjector abstract fun contributesRequestDexcomPermissionActivity(): RequestDexcomPermissionActivity

Expand Down
3 changes: 3 additions & 0 deletions plugins/source/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@
<!-- Patched Sino App -->
<string name="patched_sino_app">爱看补丁版</string>
<string name="description_source_patched_sino_app">从爱看补丁版App接收血糖值。</string>
<!-- SIB App -->
<string name="sibionics">硅基(Sibionics)</string>
<string name="description_source_sibionics">从硅基(Sibionics)应用接收血糖值</string>
</resources>
3 changes: 3 additions & 0 deletions plugins/source/src/main/res/values-zh-rTW/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,7 @@
<!-- Patched Sino App -->
<string name="patched_sino_app">Sino App</string>
<string name="description_source_patched_sino_app">從修改版 Sino App 接收血糖資料。</string>
<!-- SIB App -->
<string name="sibionics">硅基(Sibionics)</string>
<string name="description_source_sibionics">接收來自硅基(Sibionic)應用的血糖值</string>
</resources>
3 changes: 3 additions & 0 deletions plugins/source/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,8 @@
<!-- Patched Sino App -->
<string name="patched_sino_app">Sino App</string>
<string name="description_source_patched_sino_app">Receive glucose data from Patched Sino App.</string>
<!-- Patched SIB App -->
<string name="sibionics">Sibionics</string>
<string name="description_source_sibionics">>Receive values from Sibionics App</string>

</resources>
Loading