Use AlertDialog with dialog_waiting.xml (spinner + message) and
dialog_progress.xml (horizontal ProgressBar + message) instead of
the deprecated ProgressDialog. Progress updates now use findViewById
on the dialog view.
Reviewed in codereview.md (recommendation 2.4).
Replace anonymous lambdas in handler.postDelayed with a shared
scanRunnable so that handler.removeCallbacks(scanRunnable) in onPause
cancels any pending scan. Prevents duplicate or orphaned scan starts
during rapid activity transitions.
Reviewed in codereview.md (recommendation 2.2).
When BLUETOOTH_SCAN, BLUETOOTH_CONNECT or ACCESS_FINE_LOCATION
permissions are denied, show 'Permissies geweigerd — open Instellingen'
and disable the relay button instead of silently hanging.
Reviewed in codereview.md (recommendation 2.1).
Log warning when status != GATT_SUCCESS in onConnectionStateChange,
onServicesDiscovered, and onMtuChanged. Service discovery failure now
shows 'Servicefout' and returns early to prevent MTU request on failed
discovery.
Reviewed in codereview.md (recommendation 5.2).
Kotlin 2.0 uses the K2 compiler for better build performance.
Compatible with AGP 8.5.2 which was upgraded previously.
Reviewed in codereview.md (recommendation 7.3).
AGP 8.5.2 is compatible with Gradle 8.14 and Kotlin 1.9.24.
Includes bug fixes and improved Kotlin support.
Reviewed in codereview.md (recommendation 7.1).
Implement onCharacteristicWrite in gattCallback to get confirmation
that packets are submitted to the local BLE stack. Logs success/failure
and shows 'Communicatiefout' on write failure. seq++ stays in
sendRelayCommand to ensure unique sequence numbers for rapid ON/OFF.
Reviewed in codereview.md (recommendation #5).
Change parity from 0x08 (SPACE) to 0x00 (NONE) to match 115200 8N1
specification. ESP32-S3 ignores this setting but the value was
technically incorrect.
Reviewed in codereview.md (recommendation #4).
UsbKeyReceiver was never registered in AndroidManifest or dynamically,
making it 318 lines of dead code duplicating SettingsActivity key-exchange
logic and UsbUtils USB helpers.
Reviewed in codereview.md (recommendation #3).
Replace plain-text SharedPreferences with AES256-GCM encrypted prefs
via androidx.security:security-crypto. Adds PrefsHelper utility to
centralize encrypted prefs access across MainActivity, SettingsActivity
and UsbKeyReceiver.
Reviewed in codereview.md (recommendation #2).
Replace full key values in Log.d() calls with length-only metadata
to prevent key material leakage via logcat access.
Reviewed in codereview.md (recommendation #1).
ESP firmware:
- Store HMAC key in NVS via Preferences library instead of compile-time
hmac_key.h
- KEY? responds with HMAC_KEY:<hex> (if provisioned) or NO_KEY
- New SET_KEY:<64-hex> command stores key in NVS and responds OK
- Boot messages updated to reflect provisioning state
Android app:
- UsbKeyReceiver detects NO_KEY response and auto-provisions:
generates random 32-byte key via SecureRandom, sends SET_KEY,
waits for OK, saves key to SharedPreferences
- Read loop now breaks on both HMAC_KEY: and NO_KEY responses
Cleanup:
- Removed tools/generate_hmac_key.py and src/hmac_key.h
- Removed hmac_key.h from .gitignore
- README updated for new provisioning flow
- Replaced usb-serial-for-android library with raw Android USB API
(UsbDeviceConnection.bulkTransfer) — the library's testConnection()
sent a get_status CDC request that the ESP32-S3 USB-JTAG/serial
controller does not support, causing read failures
- Added CDC control interface setup (line coding + DTR/RTS) to enable
data flow before sending KEY? command
- Added retry logic: 5 attempts, 1s delay between retries, to handle
other apps grabbing the USB device first (JTAG/serial debug unit
triggers multiple system dialogs before our app gets permission)
- Re-lookup ESP device on each retry to handle device path changes
- Removed usb-serial-for-android dependency and JitPack repository
USB auto-read:
- ESP responds to 'KEY?\n' over USB serial with 'HMAC_KEY:<hex>'
- Android UsbKeyReceiver (manifest BroadcastReceiver) catches USB_DEVICE_ATTACHED
- Filters on Espressif vendor 0x303a, requests USB permission
- Opens CDC-ACM serial (115200), sends KEY?, parses response, saves to SharedPreferences
- Works even when app not in foreground
- usb-serial-for-android v3.7.3 via JitPack
UI redesign:
- activity_main.xml: FrameLayout with settings icon top-right, relay button center, status bottom-left (14sp)
- Scan & Connect button moved to SettingsActivity
- SettingsActivity: hint text 'Voer de HMAC sleutel in of sluit de relaismodule aan op de telefoon'
- SettingsActivity: scan button saves key + returns RESULT_OK to trigger scanning
- MainActivity: removed scanButton, auto-scan on onResume when key is set
- Back button removed from settings (ActionBar up navigation only)
README updated with USB protocol docs, new UI description, and updated setup guide