Version: 2.5.13 (versionCode 46)
Release Date: January 18, 2026
Type: Bug fix + enhancements
This release fixes a critical service startup issue where the app would fail to auto-start BLE scanning when launched via the main UI (MainActivity). It also adds enhanced state visibility to help diagnose Bluetooth and scanning state issues.
Issue: When the app was launched manually (not from boot), plugins would fail to connect despite the service toggle showing "ON".
Technical Details:
- MainActivity sends
START_WEB_SERVERaction to BaseBleService - v2.5.12 had no handler for this action, so it fell through to the
nullaction case - The
nullcase only scheduled keepalive timer without initializing plugins - Result: Service appeared "running" (notification shown) but never scanned or connected
Affected Scenarios:
- Manual app launch after power outage (service didn't auto-start from boot)
- Manual app launch during testing/development
- Any restart of the app when service was not previously running
Enhancement: onStartCommand() now handles both null and START_WEB_SERVER actions by:
- Checking
serviceEnabledpreference from AppSettings - Auto-starting BLE scanning if service was previously enabled
- Ensuring consistent behavior regardless of how service was started
Code Location: BaseBleService.kt
null, "START_WEB_SERVER" -> {
// Service restarted (null) or app launched (START_WEB_SERVER)
// Check if service should auto-start based on settings
Log.i(TAG, "⚙️ Service started with action=$action - checking if service should auto-start")
serviceScope.launch {
val serviceEnabled = AppSettings(this@BaseBleService).serviceEnabled.first()
if (serviceEnabled) {
Log.i(TAG, "⚙️ Service was enabled in settings - auto-starting BLE scanning")
initializeMultiplePlugins()
} else {
Log.i(TAG, "⚙️ Service disabled in settings - not auto-starting")
updateNotification("Service disabled - toggle to start")
}
}
scheduleKeepalive("onStartCommand($action)")
}New StateFlow: bleScanningActive - Tracks whether BLE scanner is actually running (distinct from service preference)
Purpose: Distinguish between:
- Service enabled preference (persisted setting)
- Service process running (foreground service active)
- BLE scanner actively scanning (new visibility)
Updates:
- Set to
trueinstartScanning()after successful scan start - Set to
falseinstopScanning(),onScanFailed(), and when Bluetooth turns off - Exposed to UI via SettingsViewModel
New StateFlow: bluetoothAvailable - Tracks whether Bluetooth adapter is enabled
Purpose: Differentiate between:
- BLE scanning disabled by user
- BLE scanning stopped due to Bluetooth being OFF
- BLE scanning failed due to other issues
Updates:
- Set to
truewhen Bluetooth turns ON - Set to
falsewhen Bluetooth turns OFF - Exposed to UI via SettingsViewModel
3-State Service Indicator:
- ⚫ Stopped: Service disabled (
serviceEnabled=false) ⚠️ Bluetooth OFF: Service enabled but BT adapter disabled- 🟢 Scanning: Service enabled, BT on, scanner active
- 🟡 Running (not scanning): Service enabled, BT on, but scanner inactive
Warning Message: Shows yellow warning when service is enabled but not scanning, suggesting to toggle Bluetooth or service.
Code Location: SettingsScreen.kt
Test Device: Android device at 10.115.19.214
Test Date: January 18, 2026
- ✅ Force-stopped app
- ✅ Launched via MainActivity (sends
START_WEB_SERVERaction) - ✅ Service detected
serviceEnabled=truein settings - ✅ Service auto-started BLE scanning
- ✅ All plugins initialized and connected:
- onecontrol_ed1e0a: Connected, authenticated, data healthy
- easytouch_b1241e: Connected, authenticated, data healthy
- gopower_1325be: Connected, authenticated, data healthy
- mopeka_29effd: Data healthy (passive scan)
- mopeka_aa12f9: Data healthy (passive scan)
- ✅
bleScanningActivecorrectly set totruewhen scanning starts - ✅
bluetoothAvailablecorrectly reflects BT adapter state - ✅ UI shows "🟢 Scanning" when all conditions met
- ✅ UI would show "
⚠️ Bluetooth OFF" if BT disabled (not tested live) - ✅ UI would show "🟡 Running (not scanning)" if scanner fails (not tested live)
No action required. This is a bug fix release with backward-compatible changes.
Settings: All existing settings and plugin configurations are preserved.
Data: No database or storage format changes.
app/build.gradle.kts- Version bump to 2.5.13app/src/main/java/com/blemqttbridge/core/BaseBleService.kt:- Added
_bleScanningActiveand_bluetoothAvailableStateFlows - Updated
onStartCommand()to handleSTART_WEB_SERVER/nullactions - Updated
startScanning()to set_bleScanningActive = true - Updated
stopScanning()to set_bleScanningActive = false - Updated
onScanFailed()to set_bleScanningActive = false - Updated
handleBluetoothStateChange()to manage both StateFlows
- Added
app/src/main/java/com/blemqttbridge/ui/viewmodel/SettingsViewModel.kt:- Added
bleScanningActiveproperty exposure - Added
bluetoothAvailableproperty exposure - Added StateFlow collectors in init block
- Added
app/src/main/java/com/blemqttbridge/ui/SettingsScreen.kt:- Updated service status display with 3-state indicator
- Added warning message for out-of-sync state
- Collect
bleScanningActiveandbluetoothAvailablestates
None identified in this release.
See docs/PLANNING_CONFIG_BACKUP_AND_AUTOUPDATE.md for planned features:
- Configuration backup/restore to external storage
- Auto-update from GitHub releases
- Power outage causing app not to auto-start: FIXED (root cause was BT stack corruption, unrelated to this release)
- Plugins not connecting after manual launch: FIXED (this release addresses the startup path bug)
- BT state visibility: ENHANCED (new StateFlows provide better observability)