Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
241166e
libkeks: add the KEKS (J-PAKE) authentication code for Dexcom ONE+ / G7
Oct 28, 2026
c7a33c3
Add the Dexcom ONE+ source to the core enums, database and calibration
Oct 28, 2026
8ac6e78
dexcom_oneplus: add the native Dexcom ONE+ / G7 BLE driver
Oct 28, 2026
f9bebd4
Dexcom ONE+ / G7: add the BG source plugin, its screens and pre-soak …
Oct 28, 2026
12be718
Overview: show CGM warm-up and the second sensor in the status card
Oct 28, 2026
7419bb4
Dexcom ONE+ / G7: send fingerstick calibrations to the sensor
Oct 28, 2026
8f961dd
Dexcom ONE+ / G7: cancel a high temp basal while no reading arrives
Oct 28, 2026
7bfbe67
CGM sources: make the shared log screen and strings vendor neutral
Oct 29, 2026
4ffba70
Dexcom ONE+ / G7: start no work after the plugin is stopped
Oct 29, 2026
0a52b88
Merge branch 'dev' of nightscout/AndroidAPS into feature/dexcom-onepl…
Oct 30, 2026
c0e6557
Merge branch 'dev' of nightscout/AndroidAPS into feature/dexcom-onepl…
Oct 30, 2026
5538b84
Merge branch 'dev' of nightscout/AndroidAPS into feature/dexcom-onepl…
Oct 30, 2026
348a0d0
Merge branch 'dev' of nightscout/AndroidAPS into feature/dexcom-onepl…
Oct 30, 2026
85c1bc1
Merge branch 'dev' of nightscout/AndroidAPS into feature/dexcom-onepl…
Oct 30, 2026
5ab8ef3
Merge milos/dev (8 commits, up to 450068c427)
Oct 31, 2026
6e8e9a8
Merge milos/dev (up to 11681e46fea)
Nov 3, 2026
afd4740
Dexcom ONE+ / G7: refuse the Dexcom Stelo (DX01)
Nov 4, 2026
cd7de99
Merge milos/dev (up to 9668ca4795)
Nov 4, 2026
10ca47a
Dexcom ONE+ / G7: scanner rules (competing apps, free slot first, ref…
Nov 4, 2026
bf4e307
Dexcom ONE+ / G7: status recap and driver log in the plugin tab, appl…
Nov 4, 2026
f76433c
CGM alarms: one alarm layer for BG sources, used by Dexcom ONE+ / G7
Nov 5, 2026
60a6270
Dexcom ONE+ / G7: direct to watch on Wear OS
Nov 5, 2026
94b3999
Credit nightscout/AndroidAPS PR 5397 where its ideas are used
Nov 5, 2026
42ce390
CGM alarms: the missed readings alarm is also on when any glucose ala…
Nov 5, 2026
a7c91a9
Merge remote-tracking branch 'milos/dev' into feature/dexcom-oneplus-g7
Nov 5, 2026
31243b6
Dexcom ONE+ / G7: read the session length from the sensor, clearer st…
Nov 5, 2026
9694523
Dexcom ONE+ / G7: no "No signal" notification between two readings
Nov 5, 2026
78692e0
CGM screens: keep the bottom bar above the navigation bar
Nov 5, 2026
78c45e7
Merge remote-tracking branch 'milos/dev' into feature/dexcom-oneplus-g7
Nov 5, 2026
e979651
Merge remote-tracking branch 'milos/dev' into feature/dexcom-oneplus-g7
Nov 10, 2026
b61f7a0
Merge remote-tracking branch 'milos/dev' into feature/dexcom-oneplus-g7
Nov 10, 2026
6422f69
Fix Direct to Watch
stavlor Nov 9, 2026
2d799d4
Direct to watch: ask for unrestricted battery only when the watch has…
Nov 10, 2026
8857d69
Show the CGM alarm settings: give them their own settings card.
Nov 12, 2026
d5f9cb9
Call the CGM alarm button Snooze.
Nov 12, 2026
26b4659
Name a 15-day sensor G7, and say "ONE+ / G7" everywhere.
Nov 12, 2026
48a39ba
Take the start of a running G7 / ONE+ sensor from the sensor itself.
Nov 12, 2026
13005da
Merge remote-tracking branch 'milos/dev' into feature/dexcom-oneplus-g7
Nov 12, 2026
a047a27
Merge remote-tracking branch 'milos/dev' into feature/dexcom-oneplus-g7
Nov 16, 2026
bd1b437
ONE+ on generic Android phones (Cubot): do not lose cycles, and ask f…
Nov 16, 2026
5600251
ONE+ / G7: answer the review (fewer settings, Status first) and fix t…
Nov 17, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
10 changes: 10 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,16 @@
android:name="app.aaps.implementation.androidNotification.AlarmMuteReceiver"
android:exported="false" />

<!-- "Hypo treated" action on the low glucose alarm notification: holds the low alarms 20 min. -->
<receiver
android:name="app.aaps.implementation.androidNotification.HypoTreatedReceiver"
android:exported="false" />

<!-- "Acknowledge" action on a CGM alarm notification: quiet for the repeat time of the alarm. -->
<receiver
android:name="app.aaps.implementation.androidNotification.CgmAlarmAcknowledgeReceiver"
android:exported="false" />

<!-- "Time to eat" timer: its alarm (setAlarmClock) and the Stop / +5 min notification buttons. -->
<receiver
android:name="app.aaps.implementation.alerts.EatReminderReceiver"
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/kotlin/app/aaps/MainApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ class MainApp : Application(), MetroMemberInjector, MetroViewModelFactoryOwner,
private val uiInteraction get() = metroGraphs.uiInteraction
private val processLifecycleListener get() = metroGraphs.processLifecycleListener
private val localAlertUtils get() = metroGraphs.localAlertUtils
private val periodicMaintenance get() = metroGraphs.periodicMaintenance
private val notificationManager get() = metroGraphs.notificationManager
private val rh get() = metroGraphs.resourceHelper
private val loop get() = metroGraphs.loop
Expand Down Expand Up @@ -509,6 +510,9 @@ class MainApp : Application(), MetroMemberInjector, MetroViewModelFactoryOwner,
)
postSetupNotifications()
KeepAliveWorker.schedule(this@MainApp)
// The worker runs the periodic pass. This adds the check on each new reading, which iOS and
// desktop get from PeriodicMaintenance.start, so a low is not held back until the next pass.
periodicMaintenance.startGlucoseAlarmTrigger(appScope)
localAlertUtils.shortenSnoozeInterval()
localAlertUtils.preSnoozeAlarms()

Expand Down
17 changes: 17 additions & 0 deletions app/src/main/kotlin/app/aaps/di/metro/AppReceiversBindings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package app.aaps.di.metro
import app.aaps.core.interfaces.di.FeatureMemberInjectors
import app.aaps.implementation.alerts.EatReminderReceiver
import app.aaps.implementation.androidNotification.AlarmMuteReceiver
import app.aaps.implementation.androidNotification.CgmAlarmAcknowledgeReceiver
import app.aaps.implementation.androidNotification.HypoTreatedReceiver
import app.aaps.implementation.receivers.BTReceiver
import app.aaps.implementation.receivers.ChargingStateReceiver
import app.aaps.implementation.receivers.NetworkChangeReceiver
Expand Down Expand Up @@ -44,6 +46,21 @@ object AppReceiversBindings {
@ClassKey(AlarmMuteReceiver::class)
fun bindAlarmMuteReceiver(injector: MembersInjector<AlarmMuteReceiver>): MembersInjector<*> = injector

// "Hypo treated" action on the low glucose alarm notification. Same reason as AlarmMuteReceiver:
// without this entry, tapping the button would crash with "No Metro binding".
@Provides
@FeatureMemberInjectors
@IntoMap
@ClassKey(HypoTreatedReceiver::class)
fun bindHypoTreatedReceiver(injector: MembersInjector<HypoTreatedReceiver>): MembersInjector<*> = injector

// "Acknowledge" action on a CGM alarm notification. Same reason as AlarmMuteReceiver.
@Provides
@FeatureMemberInjectors
@IntoMap
@ClassKey(CgmAlarmAcknowledgeReceiver::class)
fun bindCgmAlarmAcknowledgeReceiver(injector: MembersInjector<CgmAlarmAcknowledgeReceiver>): MembersInjector<*> = injector

// The "time to eat" alarm and its notification buttons - same story as AlarmMuteReceiver above.
@Provides
@FeatureMemberInjectors
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/kotlin/app/aaps/di/metro/AppRootGraph.kt
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ import app.aaps.database.AppRepository
import app.aaps.database.di.DatabaseConfig
import app.aaps.di.ExternalOptionsOverride
import app.aaps.implementation.lifecycle.ProcessLifecycleListener
import app.aaps.implementation.maintenance.PeriodicMaintenance
import app.aaps.implementation.maintenance.cloud.CloudStorageManager
import app.aaps.implementation.notifications.SnackbarNotificationFallback
import app.aaps.implementation.plugin.PluginStore
Expand Down Expand Up @@ -338,6 +339,7 @@ interface AppRootGraph : MetroViewModelMultibindings {
val commandQueue: CommandQueue
val commandExecutor: CommandExecutor
val localAlertUtils: LocalAlertUtils
val periodicMaintenance: PeriodicMaintenance
val bolusProgressData: BolusProgressData
val persistenceLayer: PersistenceLayer
val cloudStorageManager: CloudStorageManager
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/kotlin/app/aaps/di/metro/MetroGraphs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import app.aaps.di.ExternalOptionsOverride
import app.aaps.di.PluginSource
import app.aaps.di.mergePlugins
import app.aaps.implementation.lifecycle.ProcessLifecycleListener
import app.aaps.implementation.maintenance.PeriodicMaintenance
import app.aaps.implementation.notifications.SnackbarNotificationFallback
import app.aaps.implementation.plugin.PluginStore
import app.aaps.implementation.profile.ProfileSwitchScheduler
Expand Down Expand Up @@ -279,6 +280,7 @@ class MetroGraphs(
val widgetUpdater: WidgetUpdater get() = root.widgetUpdater
val commandQueue: CommandQueue get() = root.commandQueue
val localAlertUtils: LocalAlertUtils get() = root.localAlertUtils
val periodicMaintenance: PeriodicMaintenance get() = root.periodicMaintenance
val persistenceLayer: PersistenceLayer get() = root.persistenceLayer
val appRepository: AppRepository get() = root.appRepository
val constraintsChecker: ConstraintsChecker get() = root.constraintsChecker
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class ContributedPluginsTest {
// sensitivity
100, 110, 120,
200, 210, 220, 230, 240,
400, 410, 420, 430, 440, 450, 460, 470, 480, 490, 500, 510, 520, 530, 540, 550,
400, 410, 420, 430, 440, 446, 450, 460, 470, 480, 490, 500, 510, 520, 530, 540, 550,
// sync - the every-build part of the 300 block. SmsCommunicator 300 and Tidepool 320 are
// @NotNSClient; 340 (OpenHumans) comes from its own graph extension.
310, 330, 350, 360, 370,
Expand Down
14 changes: 14 additions & 0 deletions app/src/test/kotlin/app/aaps/di/metro/ReceiverInjectorsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package app.aaps.di.metro

import app.aaps.implementation.alerts.EatReminderReceiver
import app.aaps.implementation.androidNotification.AlarmMuteReceiver
import app.aaps.implementation.androidNotification.CgmAlarmAcknowledgeReceiver
import app.aaps.implementation.androidNotification.HypoTreatedReceiver
import app.aaps.persistentNotification.DummyService
import app.aaps.plugins.automation.TimerReminderReceiver
import app.aaps.plugins.automation.services.LocationService
Expand Down Expand Up @@ -48,6 +50,18 @@ class ReceiverInjectorsTest {
assertThat(injectors.keys).contains(AlarmMuteReceiver::class)
}

/** Same case for the "Hypo treated" button on the low glucose alarm notification. */
@Test
fun `the hypo treated receiver has an injector`() {
assertThat(injectors.keys).contains(HypoTreatedReceiver::class)
}

/** Same case for the "Acknowledge" button on a CGM alarm notification. */
@Test
fun `the cgm alarm acknowledge receiver has an injector`() {
assertThat(injectors.keys).contains(CgmAlarmAcknowledgeReceiver::class)
}

/** The "time to eat" alarm and its Stop / +5 min buttons; a missing entry is a crash when the timer ends. */
@Test
fun `the eat reminder receiver has an injector`() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ class GraphScopeStabilityTest {
"pairingOfferFetcher",
"pairingOfferPublisher",
"passwordCheck",
"periodicMaintenance",
"persistenceLayer",
"pluginPermissions",
"pluginStore",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,15 @@ class RawPreferenceStoreScanTest {
"pump/combov2/src/main/kotlin/info/nightscout/pump/combov2/Delegates.kt" to "ComboV2, same migration",
"pump/insight/src/main/kotlin/app/aaps/pump/insight/utils/PairingDataStorage.kt" to
"Insight pump pairing. Open question 6.2: moving it into registered keys would make 'restore pump configuration' work after a reinstall, but it would also put a pump secret in the export file. Needs an answer before it moves.",
// Added with the Dexcom ONE+ / G7 driver. This file stores the driver's own sensor state: the
// sensor identity and the pairing key, in one preference file per sensor slot. It is in this
// list and not in `allowed` because it fits none of the reasons there: registered composed
// keys (one argument per sensor slot) could hold it. It can move to registered keys later,
// with a migration that copies the values from the old file.
// The store itself is shared code and never touches the file. This small Android adapter is the
// only place that opens it.
"plugins/dexcom_oneplus/src/androidMain/kotlin/app/aaps/plugins/dexcomoneplus/identity/OnePlusSensorPrefsAndroid.kt" to
"Dexcom ONE+ / G7 sensor identity, including the pairing key. Live device state like the Insight pairing above, so it needs a migration, not a removal. 14 keys, in one file per sensor slot (production or pre-soak sensor), so the move needs registered per-slot keys plus a migration that copies from the old file and keeps it until the move is confirmed on a real sensor. Whether the keys are exportable (a sensor would then survive a change of phone, but the pairing key would be in the export file) needs an answer before it moves.",
)

@Test
Expand Down
55 changes: 55 additions & 0 deletions app/src/testFull/resources/prefs-schema.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,37 @@ active_scene|StringNonKey|false
actual_basal_profile|MedtrumStringNonKey|true
age|StringKey|true
alarm_setting|MedtrumStringKey|true
alert_cgm_expiring_lead_hours|IntKey|true
alert_cgm_fall_rate_repeat_minutes|IntKey|true
alert_cgm_fall_rate_sound|StringKey|true
alert_cgm_high_delay_minutes|IntKey|true
alert_cgm_high_repeat_minutes|IntKey|true
alert_cgm_high_sound|StringKey|true
alert_cgm_low_repeat_minutes|IntKey|true
alert_cgm_low_sound|StringKey|true
alert_cgm_rise_rate_repeat_minutes|IntKey|true
alert_cgm_rise_rate_sound|StringKey|true
alert_cgm_sensor_ended_sound|StringKey|true
alert_cgm_sensor_expired_repeat_minutes|IntKey|true
alert_cgm_sensor_failed_repeat_minutes|IntKey|true
alert_cgm_sensor_failed_sound|StringKey|true
alert_cgm_sensor_issue_minutes|IntKey|true
alert_cgm_sensor_issue_repeat_minutes|IntKey|true
alert_cgm_sensor_issue_sound|StringKey|true
alert_cgm_signal_loss_sound|StringKey|true
alert_cgm_signal_lost_minutes|IntKey|true
alert_cgm_signal_lost_repeat_minutes|IntKey|true
alert_cgm_urgent_low_repeat_minutes|IntKey|true
alert_cgm_urgent_low_soon_repeat_minutes|IntKey|true
alert_cgm_urgent_low_soon_sound|StringKey|true
alert_cgm_urgent_low_sound|StringKey|true
alert_hyper_threshold|UnitDoubleKey|true
alert_hypo_threshold|UnitDoubleKey|true
alert_override_dnd|BooleanKey|true
alert_rapid_fall_drop_mgdl|IntKey|true
alert_rapid_fall_window|IntKey|true
alert_rapid_rise_mgdl|IntKey|true
alert_rapid_rise_window|IntKey|true
allow_hardware_pump|BooleanNonKey|true
always_use_shortavg|BooleanKey|true
app_expiration_%s|LongComposedKey|true
Expand Down Expand Up @@ -108,6 +138,7 @@ bolussnooze_dia_divisor|DoubleKey|true
boluswizard_percentage|IntKey|true
bt_watchdog_last|LongNonKey|true
bt_watchdog|BooleanKey|true
calibration_entries_valid_from|CalibrationLongKey|false
carbsReqThreshold|IntKey|true
carbs_button_increment_1|IntKey|true
carbs_button_increment_2|IntKey|true
Expand All @@ -122,6 +153,10 @@ carelevo_patch_info|CarelevoStringNonKey|false
carelevo_temp_basal_infusion_info|CarelevoStringNonKey|false
carelevo_user_setting_info|CarelevoStringNonKey|false
categorize_uam_as_basal|BooleanKey|true
cgmAlarmRuntime|LocalAlertStringKey|false
cgmAlarmSource|LocalAlertStringKey|false
cgmAlarmsMutedUntil|LocalAlertLongKey|false
cgm_alarm_controls|CgmAlarmIntentKey|false
combov2-bt-address-key|ComboStringNonKey|true
combov2-cp-cipher-key|ComboStringNonKey|true
combov2-key-response-address-key|ComboIntNonKey|true
Expand Down Expand Up @@ -159,6 +194,13 @@ danars_v3_randompairing_key_%s|DanaStringComposedKey|true
danars_v3_randomsync_key_%s|DanaStringComposedKey|true
device_type|MedtrumIntNonKey|true
dexcom_lognssensorchange|BooleanKey|true
dexcom_oneplus_own_sensor_change_at|DexcomOnePlusLongKey|false
dexcom_oneplus_send_calibration_to_sensor|DexcomOnePlusBooleanKey|false
dexcom_oneplus_staging_auto_promote_hours|DexcomOnePlusIntKey|true
dexcom_oneplus_staging_auto_promote|DexcomOnePlusBooleanKey|false
dexcom_oneplus_start|DexcomOnePlusIntentKey|false
dexcom_oneplus_warmup|DexcomOnePlusIntentKey|false
dexcom_oneplus_watch_direct|DexcomOnePlusBooleanKey|false
dexcomg5_nsupload|BooleanKey|true
diaconn_bt_selector|DiaconnIntentKey|false
diaconn_g8_appuid|DiaconnStringNonKey|true
Expand All @@ -178,9 +220,22 @@ enableSMB_with_COB|BooleanKey|true
enableSMB_with_high_temptarget|BooleanKey|true
enableSMB_with_temptarget|BooleanKey|true
enable_carbs_required_alert_local|BooleanKey|true
enable_cgm_rise_rate_alert|BooleanKey|true
enable_cgm_second_sensor_ready_alert|BooleanKey|true
enable_cgm_sensor_expired_alert|BooleanKey|true
enable_cgm_sensor_expiring_alert|BooleanKey|true
enable_cgm_sensor_failed_alert|BooleanKey|true
enable_cgm_sensor_issue_alert|BooleanKey|true
enable_cgm_signal_lost_alert|BooleanKey|true
enable_cgm_urgent_low_alert|BooleanKey|true
enable_cgm_urgent_low_soon_alert|BooleanKey|true
enable_cgm_warmup_done_alert|BooleanKey|true
enable_fabric2|BooleanKey|true
enable_hyper_alert|BooleanKey|true
enable_hypo_alert|BooleanKey|true
enable_missed_bg_readings|BooleanKey|true
enable_pump_unreachable_alert|BooleanKey|true
enable_rapid_fall_alert|BooleanKey|true
enable_unattended_export|BooleanKey|true
eopatch_alarms|EopatchStringNonKey|true
eopatch_bolus_current|EopatchStringNonKey|true
Expand Down
15 changes: 14 additions & 1 deletion appshell/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@ plugins {
alias(libs.plugins.metro)
}

/**
* Modules under `:plugins:` that are libraries, not feature plugins. They register nothing into the
* plugin map, so this shell does not need them: the plugin that uses one depends on it directly.
* They are also left out because they have no Apple targets, and listing one in commonMain would make
* every iOS build of this module fail at dependency resolution.
*/
val PLUGIN_LIBRARIES = setOf(
// KEKS authentication for Dexcom ONE+ / G7 (Android and JVM only).
":plugins:libkeks",
// The Dexcom ONE+ / G7 BLE driver (Android only). The plugin itself is in :plugins:source.
":plugins:dexcom_oneplus",
)

/**
* The app's shell: navigation and the composable root.
*
Expand Down Expand Up @@ -52,7 +65,7 @@ kotlin {
// with the navigation graph that routes to them; `api` so `:app` still builds its
// graph against them. Adding or removing a plugin stays an edit in settings.gradle.
rootProject.subprojects
.filter { it.path.startsWith(":plugins:") && it.buildFile.exists() }
.filter { it.path.startsWith(":plugins:") && it.buildFile.exists() && it.path !in PLUGIN_LIBRARIES }
.forEach { api(project(it.path)) }

api(libs.jetbrains.compose.runtime)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ enum class SourceSensor(val text: String, val aliases: Set<String> = emptySet())
DEXCOM_UNKNOWN("Dexcom", setOf("AAPS-Dexcom", "Share Follow")),
DEXCOM_G6("Dexcom G6", setOf("AAPS-DexcomG6", "G6 Native")),
DEXCOM_G7("Dexcom G7", setOf("AAPS-DexcomG7", "G7 Native", "G7")),

/** Dexcom ONE+ and G7, read directly over Bluetooth by the AAPS Dexcom ONE+ / G7 source plugin. */
DEXCOM_ONEPLUS_NATIVE("AAPS-DexcomOnePlus"),
LIBRE_1(
"Libre1",
setOf("Other App", "Network libre", "BlueReader", "Transmiter PL", "Blucon", "Tomato", "Rfduino", "LimiTTer", "Bubble", "Atom", "Glimp")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ private val ADVANCED_FILTERING_SENSORS = setOf(
SourceSensor.DEXCOM_UNKNOWN,
SourceSensor.DEXCOM_G6,
SourceSensor.DEXCOM_G7,
// Dexcom ONE+ / G7 read by the AAPS native plugin. The sensor filters internally, as above.
SourceSensor.DEXCOM_ONEPLUS_NATIVE,
SourceSensor.LIBRE_2,
SourceSensor.LIBRE_3,
SourceSensor.SYAI_TAG,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ enum class Sources {
BG, //From BG plugin => Add One Source per BG Source for Calibration or Sensor Change
Aidex,
Dexcom,
DexcomOnePlus,
Eversense,
Glimp,
MM640g,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package app.aaps.core.data.model

import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertFalse
import kotlin.test.assertTrue

Expand All @@ -18,6 +19,13 @@ class SourceSensorExtensionsTest {
assertTrue(SourceSensor.DEXCOM_G6.advancedFilteringSupported())
assertTrue(SourceSensor.DEXCOM_G7.advancedFilteringSupported())
assertTrue(SourceSensor.DEXCOM_G7.advancedFilteringSupported())
assertTrue(SourceSensor.DEXCOM_ONEPLUS_NATIVE.advancedFilteringSupported())
}

@Test
fun `dexcom one plus native is found by its text`() {
assertEquals(SourceSensor.DEXCOM_ONEPLUS_NATIVE, SourceSensor.fromString("AAPS-DexcomOnePlus"))
assertEquals("AAPS-DexcomOnePlus", SourceSensor.DEXCOM_ONEPLUS_NATIVE.text)
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,4 +345,57 @@ class EventDataTest {
assertThat(old).doesNotContain("carbsType")
assertThat(EventData.deserialize(old)).isEqualTo(EventData.ActionWizardPreCheck(30, 100, CarbsType.BREAD))
}

@Test
fun cgmAlarmMessagesRoundTrip() {
listOf(
EventData.CgmAlarm(id = "urgent_low", title = "Urgent low", message = "52 mg/dL", vibrationSeconds = 10, urgent = true),
EventData.CgmAlarm(id = "high", title = "High", message = "", vibrationSeconds = 0, urgent = false),
EventData.CgmAlarmCancel("urgent_low"),
EventData.CgmAlarmAcknowledge("signal_loss")
).forEach {
assertThat(EventData.deserializeByte(it.serializeByte())).isEqualTo(it)
assertThat(EventData.deserialize(it.serialize())).isEqualTo(it)
}
}

@Test
fun directToWatchMessagesSurviveBothWireFormats() {
listOf(
EventData.CgmWatchDirect(active = true, pairingCode = "1234", address = "AA:BB:CC:DD:EE:FF", serial = "SN1", sensorName = "DXCM12"),
EventData.CgmWatchDirect(active = false),
EventData.CgmWatchStatus(EventData.CgmWatchState.CONNECTED, address = "AA:BB:CC:DD:EE:FF", latestReadingAt = 5L, batteryRestricted = true),
EventData.CgmWatchStatus(EventData.CgmWatchState.REFUSED, detail = "slot in use")
).forEach {
assertThat(EventData.deserializeByte(it.serializeByte())).isEqualTo(it)
assertThat(EventData.deserialize(it.serialize())).isEqualTo(it)
}
}

@Test
fun cgmAlarmMessagesDoNotChangeTheEncodingOfOlderMessages() {
// The CGM alarm messages are appended at the end of EventData. An older message must still
// decode to itself, and must not decode to one of the new ones.
val old = EventData.AlarmStopped(5L)
assertThat(EventData.deserializeByte(old.serializeByte())).isEqualTo(old)
assertThat(EventData.deserialize(old.serialize())).isEqualTo(old)
assertThat(EventData.CgmAlarmCancel("x").serialize()).contains("CgmAlarmCancel")
}

@Test
fun directToWatchNeverPrintsThePairingCode() {
val message = EventData.CgmWatchDirect(active = true, pairingCode = "9876", address = "AA:BB")
assertThat(message.toString()).doesNotContain("9876")
}

@Test
fun aReadingFromTheSensorKeepsItsMarkAndAnOldReadingHasNone() {
val fromWatch = EventData.SingleBg(dataset = 0, timeStamp = 1L, sgv = 100.0, high = 180.0, low = 70.0, fromSensor = true)
assertThat((EventData.deserializeByte(fromWatch.serializeByte()) as EventData.SingleBg).fromSensor).isTrue()
assertThat((EventData.deserialize(fromWatch.serialize()) as EventData.SingleBg).fromSensor).isTrue()
// A phone without direct-to-watch sends no such field: the value is the phone's own.
val fromPhone = EventData.SingleBg(dataset = 0, timeStamp = 1L, sgv = 100.0, high = 180.0, low = 70.0)
assertThat(fromPhone.serialize()).doesNotContain("fromSensor")
assertThat((EventData.deserialize(fromPhone.serialize()) as EventData.SingleBg).fromSensor).isFalse()
}
}
Loading
Loading