Commit graph Project_SylDa/android
Author SHA1 Message Date
eddy
4c022b8259 Rename package com.eddy.atomrelay -> nl.eddydevink.sylda, Dutch translations, UI cleanup
- Package renamed to nl.eddydevink.sylda (matches eddydevink.nl domain + Sylda app name)
- All status texts translated to Dutch (Niet verbonden, Verbonden, Zoeken, etc.)
- Removed exchange key button, build number, and success toasts
- Button text: Firmware bijwerken, instruction text shortened
- App title changed to Sylda, 'instellingen' label next to settings gear
- ON/HOLD changed to AAN/VAST
2026-07-29 23:09:43 +02:00
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
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
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
c977dc25a2 Voeg thema-selector toe (DayNight, Radiogroep, teal accent) 2026-07-27 00:22:43 +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
71b13c51ee Replace volatile cancel flag with coroutine Job cancellation in EspFlasher 2026-07-26 22:58:08 +02:00
eddy
2dd3f00de4 Use RECEIVER_EXPORTED for USB system broadcasts on API 34+ 2026-07-26 22:51:36 +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
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
eddy
e116f2b493 Make EspFlasher cancellable to prevent resource leak
Add @Volatile cancelled flag with cancel() method. Check flag at 3
checkpoints (after initial sleep, after transport setup, before each
flash step) so the thread exits early and closes the USB connection
in the finally block. SettingsActivity.onDestroy now calls cancel().

Reviewed in codereview.md (recommendation 3.2).
2026-07-26 17:02:06 +02:00
eddy
aa13359125 Replace deprecated ProgressDialog with AlertDialog + custom layouts
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).
2026-07-26 16:57:07 +02:00
eddy
ce0c119416 Use named Runnable for scheduled BLE scans and cancel on pause
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).
2026-07-26 16:51:53 +02:00
eddy
ff091169f6 Handle denied BLE permissions with user feedback
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).
2026-07-26 16:46:15 +02:00
eddy
c62cbaa1c2 Add GATT status code logging in callbacks
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).
2026-07-26 16:44:21 +02:00
eddy
36856dabc6 Upgrade Kotlin from 1.9.24 to 2.0.21
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).
2026-07-26 16:40:21 +02:00
eddy
e712020a64 Upgrade AGP from 8.2.2 to 8.5.2
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).
2026-07-26 16:34:34 +02:00
eddy
9b7adabc59 Add onCharacteristicWrite callback for BLE write feedback
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).
2026-07-26 16:31:07 +02:00
eddy
68b15ce7f1 Fix CDC line coding parity byte
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).
2026-07-26 16:23:55 +02:00
eddy
3616f7162f Remove dead UsbKeyReceiver code
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).
2026-07-26 16:19:14 +02:00
eddy
b5d42d53ba Use EncryptedSharedPreferences for HMAC key storage
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).
2026-07-26 16:09:10 +02:00