Commit graph Project_SylDa/README.md
Author SHA1 Message Date
eddy
0833327cea fix: code review fixes — SharedPreferences docs, Log.e, dead notify code 2026-07-29 23:51:16 +02:00
eddy
36a20899be docs: README volledig bijgewerkt — hardware, BLE, combined flow, serial output, NL vertalingen, ESP→module 2026-07-29 23:31:51 +02:00
eddy
7497019f0c Update README title: Sylvia Touch Relay -> Project SylDa 2026-07-29 23:25:03 +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
2bea06d14b Update README with coroutine Job cancellation for EspFlasher 2026-07-26 22:58:28 +02:00
eddy
ece115fbd6 Update README with RECEIVER_EXPORTED note 2026-07-26 22:51:54 +02:00
eddy
11ba8f3b8f Update README with sequence counter persistence 2026-07-26 22:34:23 +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
81abf2d824 Replace BLE encryption with HMAC-only auth, add buildnr, fix post-flash flow
BLE bonding/encryption removed — HMAC-SHA256 on application level provides
authentication + replay protection. Eliminates bonding state bugs, write
queue issues, and GATT_INSUFFICIENT_AUTHENTICATION complexity.

Firmware:
- Remove BLESecurity, setRespEncryptionKey, ESP_GATT_PERM_WRITE_ENCRYPTED
- Characteristic permission: ESP_GATT_PERM_WRITE (no encryption required)
- Characteristic property: PROPERTY_WRITE_NR (Write Without Response)
  Enables direct ON/OFF sequences without ACK wait time

Android:
- Remove bondReceiver, createBond, bonding state handling
- Remove write queue / pendingRelayState / writeInProgress
- Use WRITE_TYPE_NO_RESPONSE for minimal latency
- Post-flash dialog auto-dismisses on USB detach (currentAction = NONE)
- Separate progressDialog (flash progress) from dialog (post-flash info)
- Detach during active action now calls cleanupAction()

Build number:
- BuildConfig.BUILD_NUMBER in build.gradle as yyyyMMddHHmmss timestamp
- buildFeatures.buildConfig enabled
- Displayed in SettingsActivity bottom (12sp, secondary color)

Gradle:
- Wrapper upgraded 8.5 → 8.14
- minSdk 24 → 26 (Android 8+)

README updated to reflect HMAC-only security model.
2026-07-26 15:46:28 +02:00
eddy
ff419d9f36 Update README for USB key provisioning architecture
- Unified toast message to 'Beveiligingssleutel gelezen' throughout
- Updated key management section with bidirectional provisioning flow
- Added provisioning flow diagram (ASCII sequence)
- Updated security analysis: key no longer in APK, extracted from
  SharedPreferences requiring root; added USB key extraction risk
  and NVS wiping notes
- Added serial monitor example for unprovisioned ESP (no-key case)
- Added factory reset instructions (pio run -t erase)
- Added setup scenarios: existing ESP + new phone, new ESP + existing phone
- Updated projectstructuur: removed stale usb-serial-for-android references
- Updated technische notities: raw USB API justification, CDC control
  interface setup, retry behavior
2026-07-26 09:40:38 +02:00
eddy
9a84b05b8a Replace compile-time HMAC key with USB provisioning
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
2026-07-26 09:30:21 +02:00
eddy
4518aec34e Add USB auto-read key transfer + UI redesign
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
2026-07-26 08:39:28 +02:00
eddy
7f68e9ad70 Add BLE security: Just Works pairing + HMAC-SHA256 authentication
Two-layer security for the BLE relay:

1. BLE Just Works pairing (link-layer encryption)
   - ESP32 requires bonding before accepting writes
   - Characteristic permissions set to ESP_GATT_PERM_WRITE_ENCRYPTED
   - IO capability NO_INPUT_NO_OUTPUT (no passkey needed)
   - LE Secure Connections with bonding (ESP_LE_AUTH_REQ_SC_BOND)

2. HMAC-SHA256 authentication (application-level)
   - 32-byte shared secret in src/hmac_key.h (generated, gitignored)
   - Each command signed: HMAC-SHA256(key, command || sequence)
   - 37-byte packet format: [cmd:1][seq:4][hmac:32]
   - Sequence counter prevents replay (strictly increasing, starts at 1)
   - mbedtls on ESP, javax.crypto.Mac on Android

Key management:
- tools/generate_hmac_key.py generates random key + writes src/hmac_key.h
- ESP prints hex key to serial 5 seconds after boot
- Android app: SettingsActivity with eye-toggle password field
- Key stored in SharedPreferences, supports multiple ESP modules

Other changes:
- Android app: bonding flow (createBond -> BOND_BONDED -> discover)
- Android app: MTU negotiation (request 256)
- Android app: settings button (gear icon) in main screen
- Fix: sequence counter starts at 1 to prevent first-packet rejection
- Updated README with full security documentation
2026-07-26 08:18:52 +02:00
eddy
7c9dde172a Initial commit: BLE relay controller for Atom VoiceS3R 2026-07-26 01:17:31 +02:00