From 8737038c166adc540ae351d1c2aabb0288149ede Mon Sep 17 00:00:00 2001 From: Hossain Khan Date: Sat, 31 Jan 2026 16:15:04 -0500 Subject: [PATCH] fix: Include deviceId when saving config after validation The device ID was being fetched and saved to DataStore during BYOD device validation, but it wasn't included in the TrmnlDeviceConfig object when saving the full configuration. This caused the device ID to be null in the loaded config, resulting in battery reporting being skipped with 'device ID is null' warnings. Now we retrieve the device ID from DataStore before saving the full config and include it in the TrmnlDeviceConfig object for BYOD devices. --- .../ink/trmnl/android/ui/settings/AppSettingsScreen.kt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/src/main/java/ink/trmnl/android/ui/settings/AppSettingsScreen.kt b/app/src/main/java/ink/trmnl/android/ui/settings/AppSettingsScreen.kt index fea972c..1161821 100644 --- a/app/src/main/java/ink/trmnl/android/ui/settings/AppSettingsScreen.kt +++ b/app/src/main/java/ink/trmnl/android/ui/settings/AppSettingsScreen.kt @@ -552,6 +552,14 @@ class AppSettingsPresenter TrmnlDeviceType.TRMNL -> false } + // For BYOD devices, retrieve the device ID that was fetched during validation + val deviceId = + if (deviceType == TrmnlDeviceType.BYOD) { + deviceConfigStore.getDeviceId() + } else { + null + } + deviceConfigStore.saveDeviceConfig( TrmnlDeviceConfig( type = deviceType, @@ -566,6 +574,8 @@ class AppSettingsPresenter // We still persist the token here; any invalid or expired token will be // detected and surfaced via downstream API error handling. userApiToken = userApiToken.ifBlank { null }, + // Include device ID for BYOD devices (fetched during validation) + deviceId = deviceId, ), ) trmnlWorkScheduler.updateRefreshInterval(result.refreshRateSecs)