Commit graph

190 commits

Author SHA1 Message Date
eddy
d6d6f6674a Combined flash + key exchange flow with version check and USB permission persistence
- Firmware: add VERSION? command returning BUILD_NR for version check
- Android: flash button checks firmware version first, skips flash if current
- After flash: auto key exchange via reboot detection (expectingReboot flag)
- device_filter.xml + intent-filter: USB permission 'always allow' checkbox
- singleTop + onNewIntent prevents unwanted SettingsActivity launch on USB connect
- platformio.ini: upload_port updated to /dev/ttyACM1
2026-07-29 22:56:40 +02:00
eddy
96162a16be Fix BLE scan: add neverForLocation to BLUETOOTH_SCAN (results suppressed without it on API 31+) 2026-07-29 22:26:43 +02:00
eddy
3ce2610bc8 Fix hasPermissions: remove ACCESS_FINE_LOCATION from API>=S check (maxSdkVersion=30 excludes it) 2026-07-29 22:10:15 +02:00
eddy
a025e66b61 Simplify permission flow: standard ActivityCompat pattern with one-shot guard 2026-07-29 22:04:46 +02:00
eddy
ecdd693ffa Reset permissionsRequested flag after deny and on return from settings 2026-07-29 22:01:07 +02:00
eddy
ac2767c2b6 Fix permission dialog flash loop in onResume 2026-07-29 21:58:44 +02:00
eddy
d005fef3f6 Remove manual download-mode instructions, library auto-resets ESP 2026-07-29 21:55:06 +02:00
eddy
106bd25e41 Replace magic numbers with named constants, move remaining hardcoded strings to strings.xml 2026-07-29 20:56:00 +02:00
eddy
c46db32cc7 Move all user-facing strings to strings.xml, add user-facing-text.md reference 2026-07-29 20:48:20 +02:00
eddy
5fb67fdcf0 Button color: gray default, green pressed via setBackgroundColor 2026-07-29 20:42:03 +02:00
eddy
5a1f1da329 Button color: GradientDrawable swap (teal/green), no tint magic 2026-07-29 20:34:58 +02:00
eddy
817f9a0602 Fix button background restore: save/restore original Drawable instead of tint list null -> gray -> teal → grijs blijft grijs na loslaten 2026-07-29 20:29:30 +02:00
eddy
a3142ea85b Add user-defined button labels with color change on press
- PrefsHelper: PREF_LABEL1, PREF_LABEL2 constants
- SettingsActivity: EditText fields with Done-keyboard action to save labels
- MainActivity: buttons show user label, colorAccent on press, textAllCaps disabled
- activity_main.xml: textAllCaps=false for case-sensitive labels
2026-07-29 20:25:27 +02:00
eddy
a6e5df0052 fix: thread safety, GATT cleanup, onResume guard, relay2 docs 2026-07-29 20:05:26 +02:00
eddy
404f46acf8 refactor: extract BLE logic from MainActivity to BleRelayManager 2026-07-29 19:58:44 +02:00
eddy
0f3b695140 feat: add BleRelayManager sendRelayCommand and disconnect 2026-07-29 19:56:40 +02:00
eddy
a60f6cdc1c feat: add BleRelayManager GATT callback (connect, UUID verify, notifications) 2026-07-29 19:54:31 +02:00
eddy
92585455c8 feat: add BleRelayManager scan logic with permissions 2026-07-29 19:51:11 +02:00
eddy
82852e086e feat: add BleRelayManager key/HMAC helpers and loadState 2026-07-29 19:49:00 +02:00
eddy
f41f1c3380 feat: add BleRelayManager class skeleton 2026-07-29 19:47:20 +02:00
eddy
61c5c1de32 feat: add BleStatus enum and BleCallbacks interface 2026-07-29 19:45:11 +02:00
eddy
cd89604c9b docs: add BLE refactor implementation plan (8 tasks) 2026-07-29 19:44:17 +02:00
eddy
459dc5f201 docs: add BLE refactor design spec (BleRelayManager extraction) 2026-07-29 19:40:30 +02:00
eddy
d6e37322f3 fix: NimBLE 128-bit UUID scan response + Android key/UUID loading
- Firmware: add explicit setScanResponseData with setCompleteServices for
  128-bit service UUID so Android ScanFilter finds the device
- Android: hexStringToBytes accepts any even-length hex (fixes UUID=32chars
  failing the hardcoded 64-char check)
- Android: onActivityResult matches SettingsActivity.RESULT_SCAN instead of
  Activity.RESULT_OK
2026-07-29 19:30:46 +02:00
eddy
96d3620535 feat: migrate BLE to NimBLE — 45% flash, 33% RAM reduction
- Replaced ESP32 BLE Arduino with h2zero/NimBLE-Arduino@^2
- -DCONFIG_BT_NIMBLE_ENABLED to disable built-in Bluedroid
- NIMBLE_PROPERTY::* replaces BLECharacteristic::PROPERTY_* + setAccessPermissions
- BLE2902 descriptor removed (NimBLE auto-creates it)
- pService->start() removed (NimBLE starts services with server)
- setMinPreferred → setMinInterval/setMaxInterval
- onConnect/onDisconnect/onWrite get extra NimBLEConnInfo& param
- Re-advertise: BLEDevice → NimBLEDevice::startAdvertising()
- Firmware: 533KB flash (was 964KB), 29KB RAM (was 44KB)
2026-07-29 18:58:49 +02:00
eddy
42b8092807 fix: replace EncryptedSharedPreferences with plain MODE_PRIVATE for update survival 2026-07-29 18:51:35 +02:00
eddy
348c55d830 feat: add device UUID pairing — unique identity per ESP-phone pair
- Firmware: auto-generate 16-byte UUID on first boot (NVS), new READ characteristic
- BLE name: AtomS3R-Relay → SylDa_Server
- KEY? now returns DEVICE_ID + HMAC_KEY, SET_ID command for UUID provisioning
- App: UUID+HMAC loaded from prefs, scan by service UUID, verify UUID after connect
- UUID mismatch → disconnect + skip address + rescan
- Key conflict dialog: keep ESP keys, overwrite ESP (with checkbox confirm), or cancel
- NO_KEY with existing app keys: send existing pair instead of generating new
- Added design spec doc
2026-07-29 18:12:13 +02:00
eddy
73b3c0eaa0 docs: add device UUID pairing design spec 2026-07-29 17:56:48 +02:00
eddy
804a728550 docs: mark 5.3 empty catch blocks as resolved 2026-07-27 17:16:29 +02:00
eddy
f88b17cae5 Merge branch 'fix/magic-numbers': extract magic numbers to named constants (review 4.3) 2026-07-27 13:12:31 +02:00
eddy
f676eb259d Extract magic numbers to named constants (review 4.3)
- MainActivity: RECONNECT_DELAY_MS, POST_SETTINGS_RESCAN_MS, ON_RESUME_SCAN_DELAY_MS
- SettingsActivity: FLUSH_TIMEOUT_MS, READ_CHUNK_TIMEOUT_MS, CDC_CONTROL_TIMEOUT_MS
- UsbSerialTransport: CONTROL_LINE_TIMEOUT_MS
- UsbUtils: shared CDC request constants (REQUEST_TYPE, SET_LINE_CODING, SET_CONTROL_LINE_STATE, DTR, RTS)

Pure refactor — no behavior change. All literals replaced by named private const val in companion objects or shared via UsbUtils.
2026-07-27 12:39:41 +02:00
eddy
9c520f57c2 Add .worktrees/ to .gitignore 2026-07-27 12:32:40 +02:00
eddy
c977dc25a2 Voeg thema-selector toe (DayNight, Radiogroep, teal accent) 2026-07-27 00:22:43 +02:00
eddy
5a0dee77b3 Update README with scan retry feature 2026-07-26 23:37:20 +02:00
eddy
7c054a7021 Add scan retry button on timeout 2026-07-26 23:37:02 +02:00
eddy
954264fe37 Add proguard rules for esp32-flash-lib 2026-07-26 23:31:14 +02:00
eddy
05036a5060 Move user-facing strings to strings.xml 2026-07-26 23:21:25 +02:00
eddy
fffc5165a4 Extract magic numbers to named constants 2026-07-26 23:07:11 +02:00
eddy
2bea06d14b Update README with coroutine Job cancellation for EspFlasher 2026-07-26 22:58:28 +02:00
eddy
71b13c51ee Replace volatile cancel flag with coroutine Job cancellation in EspFlasher 2026-07-26 22:58:08 +02:00
eddy
ece115fbd6 Update README with RECEIVER_EXPORTED note 2026-07-26 22:51:54 +02:00
eddy
2dd3f00de4 Use RECEIVER_EXPORTED for USB system broadcasts on API 34+ 2026-07-26 22:51:36 +02:00
eddy
11ba8f3b8f Update README with sequence counter persistence 2026-07-26 22:34:23 +02:00
eddy
af3810554e Persist sequence counter in EncryptedSharedPreferences 2026-07-26 22:33:43 +02:00
eddy
bbf01946ac Convert Thread+Handler to lifecycle-aware coroutines, add GPL-3.0 license 2026-07-26 20:43:37 +02:00
eddy
4a9a15bca5 Update README with all code review changes 2026-07-26 17:29:23 +02:00
eddy
a80abc5c0c Merge branch 'fix/espflasher-cancellable': cancellable flasher + dialog fixes + key exchange reliability 2026-07-26 17:24:40 +02:00
eddy
d21a560d0c Shorten key exchange error toast text 2026-07-26 17:23:55 +02:00
eddy
1d17251341 Add retry hint to key exchange errors and cancel button to flash dialog
1. Append 'probeer het opnieuw' to key exchange error toasts.
2. Add 'Annuleren' button to flash progress dialog that calls
   flasher.cancel() and cleanupAction().
2026-07-26 17:20:49 +02:00
eddy
5acde17efb Fix flash dialog stacking and key exchange reliability
1. Dismiss waiting dialog when flash progress dialog starts,
   preventing orphaned spinner dialog after flash completes.
2. Increase key exchange retries from 3 to 5 and initial delay
   from 500ms to 1000ms to give ESP more time to be ready
   after USB permission grant.
2026-07-26 17:14:50 +02:00