Commit graph

221 commits

Author SHA1 Message Date
eddy
e0b2750c2e fix: critical security issues from code review
All checks were successful
CI / build (pull_request) Successful in 1m10s
- Thread safety: Add @Synchronized methods for ECDH buffer access
- Crypto: Use X509EncodedKeySpec instead of hard-coded EC curve params
- Sensitive data: Make aes_key/shared_secret private in CryptoECDH
- Credential storage: Migrate PSK/UUID to EncryptedSharedPreferences
2026-08-04 20:56:52 +02:00
eddy
ec310c1bcb Merge pull request 'fix: auto-detect upload port fails with active log output' (#24) from fix/issue-16-auto-detect-port into main
All checks were successful
CI / build (push) Successful in 58s
2026-08-04 19:18:35 +02:00
eddy
7b59d36bd7 fix: cast CONFIG_LOG_DEFAULT_LEVEL to esp_log_level_t
All checks were successful
CI / build (pull_request) Successful in 1m3s
2026-08-04 19:04:37 +02:00
eddy
3c6b378b9b fix(client): add serial mute during ID? response 2026-08-04 19:03:54 +02:00
eddy
ae5028503f fix(server): add serial mute during ID? response 2026-08-04 19:03:21 +02:00
eddy
99fd6b21d4 fix(script): filter ID response in query_id() 2026-08-04 19:02:51 +02:00
eddy
2030b42ba2 docs: add implementation plan for issue #16 2026-08-04 19:01:57 +02:00
eddy
30fc7532ae docs: add design spec for issue #16 auto-detect port fix 2026-08-04 18:59:14 +02:00
09b6ff6823 Merge pull request 'fix: remove outdated ble_client.py, add test_ota_notify.py to tools' (#22) from fix/cleanup-outdated-scripts into main
All checks were successful
CI / build (push) Successful in 1m16s
2026-08-04 18:48:54 +02:00
31f1def3da Merge pull request 'fix: add SPDX license headers to firmware files' (#21) from fix/minor-firmware-issues into main
All checks were successful
CI / build (push) Successful in 1m16s
2026-08-04 18:46:47 +02:00
7829528e89 Merge pull request 'fix: critical issues from code review' (#20) from fix/code-review-critical-issues into main
All checks were successful
CI / build (push) Successful in 1m27s
2026-08-04 18:44:55 +02:00
91739002ef Merge pull request 'fix: use Activity Result API instead of deprecated methods' (#23) from fix/minor-android-issues into main
All checks were successful
CI / build (push) Successful in 1m22s
2026-08-04 18:41:26 +02:00
eddy
ce1a53eee6 fix: use Activity Result API instead of deprecated methods
All checks were successful
CI / build (pull_request) Successful in 1m25s
- Replace onActivityResult with registerForActivityResult
- Replace onRequestPermissionsResult with permissionLauncher
- Remove deprecated @Suppress annotations
2026-08-04 18:34:26 +02:00
eddy
c36ca10edd fix: remove outdated ble_client.py, add test_ota_notify.py to tools
All checks were successful
CI / build (pull_request) Successful in 1m22s
- Remove scripts/ble_client.py (uses old UUIDs, incompatible)
- Move test_ota_notify.py to tools/ directory
- Make serial port configurable via SYLDA_CLIENT_PORT env var
2026-08-04 18:33:35 +02:00
eddy
8aeb609b2e fix: add SPDX license headers to firmware files
All checks were successful
CI / build (pull_request) Successful in 1m12s
2026-08-04 18:32:15 +02:00
eddy
64ade7ff10 fix: critical issues from code review
All checks were successful
CI / build (pull_request) Successful in 1m20s
- Fix README touch sensor docs (active LOW, INPUT_PULLUP)
- Fix README LED pin (G46 -> G35 WS2812)
- Fix release.sh to copy server/ and client/ firmware
- Remove stale firmware.bin from root assets
- Reduce OTA START wait from 10s to 500ms
- Close bluetoothGatt before new connection
- Use kotlinx.coroutines.CompletableDeferred
2026-08-04 18:27:38 +02:00
eddy
e03067c5f4 crypto: zero public_key in CryptoECDH::free()
All checks were successful
CI / build (push) Successful in 1m2s
2026-08-04 01:34:07 +02:00
eddy
18469538ae docs: HS-S43A actief LOW, !t1Active logica gedocumenteerd
All checks were successful
CI / build (push) Successful in 1m15s
2026-08-04 01:21:36 +02:00
eddy
3b17f1fe50 touch: INPUT_PULLUP, !t1Active logica (sensor actief LOW)
Some checks failed
CI / build (push) Has been cancelled
2026-08-04 01:20:47 +02:00
eddy
3c87990a9c fix(client): connectTimeout in ms, NVS addr byte order, onScanEnd callback
All checks were successful
CI / build (push) Successful in 1m14s
- setConnectTimeout(5000ms) instead of 10ms (NimBLE-Arduino v2 uses ms)
- Fix NVS stored address: use ble_addr_t struct constructor to avoid
  double byte-reversal, and correct type BLE_ADDR_PUBLIC
- Use onScanEnd callback to defer connect until scan fully terminated
- Separate foundAddr to avoid race between scan callback and loop
2026-08-04 01:00:35 +02:00
eddy
a51936f819 feat(client): scan+connect statemachine replaces hardcoded MAC 2026-08-04 00:31:38 +02:00
eddy
67979ecce6 feat(client): extend MyScanCallbacks with UUID prefix matching 2026-08-04 00:29:32 +02:00
eddy
f07d305621 feat(client): add scan constants, NVS addr key, and state globals 2026-08-04 00:29:07 +02:00
eddy
3be06b7469 Fix BLE ECDH handshake: wait for CCCD write before sending pubkey
All checks were successful
CI / build (push) Successful in 1m5s
BleRelayManager.kt: Android's gatt.writeCharacteristic() returns false when a
previous GATT operation (CCCD writeDescriptor) is still pending. Split
startEcdhHandshake() into two phases: CCCD setup (with ecdhCccdPending flag)
and sendEcdhHandshake() triggered from onDescriptorWrite callback.

main.cpp: After SET_ID over USB, update BLE advertising scan response
manufacturer data so Android can find the server by its new UUID prefix.
2026-08-04 00:11:36 +02:00
eddy
a242bfa58a Merge branch 'feature/aes-ecdh-ble' into main
- AES-256-GCM + ECDH key exchange vervangt HMAC-SHA256 (issue #2)
- NVS namespace 'hmac' -> 'syl', key 'key' -> 'psk'
- ECDH-UUID characteristic toegevoegd voor key agreement
- Android: PSK key exchange via USB CDC, ECDH handshake in BleRelayManager
- Conflictoplossingen:
  - pUuidChar + pEcdhChar beide globaal, INPUT voor touch pins
  - client.cpp: serverFound + MyScanCallbacks behouden voor ECDH compat
  - SettingsActivity.kt: PSK detectie + debug log gecombineerd
  - version.txt: HEAD versie (20/5) behouden
  - version.h: verwijderd (auto-gegenereerd)
2026-08-03 23:45:15 +02:00
eddy
c1729e17d1 Revert "Add auto-detected upload_port for both ESP32s"
All checks were successful
CI / build (push) Successful in 1m14s
This reverts commit 5b05fabdae.
2026-08-03 23:34:31 +02:00
eddy
5b05fabdae Add auto-detected upload_port for both ESP32s
Some checks failed
CI / build (push) Has been cancelled
2026-08-03 23:34:04 +02:00
eddy
3cd4a6211d Add device UUID prefix to BLE scan response and filter in scan callback
All checks were successful
CI / build (push) Successful in 1m6s
ESP32 server: include 4-byte device UUID prefix as manufacturer data
(company 0xFFFF) in BLE scan response, allowing pre-connection filtering.

Android: check manufacturer data in ScanCallback.onScanResult before
connecting. Skips devices with non-matching UUID prefix, preventing
wasted connections to wrong SylDa devices. Backward compatible with
old firmware (proceeds if no manufacturer data present).
2026-08-03 23:30:35 +02:00
eddy
290ce0a027 Remove version check from CI (needs Gradle, not available)
All checks were successful
CI / build (push) Successful in 1m31s
2026-08-03 16:55:32 +02:00
eddy
62d27bf8b4 Simplify CI to firmware build + version check only
Some checks failed
CI / build (push) Failing after 1m26s
2026-08-03 16:53:00 +02:00
eddy
cc1de38ca4 Fix release artifact paths for firmware subdirectories
Some checks failed
CI / firmware (push) Failing after 1m32s
CI / android (push) Has been skipped
Release / build (push) Successful in 1m47s
v1.2
2026-08-03 16:44:46 +02:00
eddy
2eccced6fb Remove debug logging from scan callback
Some checks failed
CI / firmware (push) Failing after 1m45s
CI / android (push) Has been skipped
Release / build (push) Failing after 1m23s
2026-08-03 16:39:36 +02:00
eddy
cd2d949f87 Fix BLE scan + touch logic + UUID + version read
Some checks failed
CI / android (push) Has been cancelled
CI / firmware (push) Has been cancelled
- Client: change passive BLE scan to active scan (setActiveScan(true))
  Server puts name/UUID in scan response; passive scan never
  received them, so isAdvertisingService() and getName() failed.
- Server: add INPUT_PULLUP on touch pins to prevent floating
  triggers when sensors disconnected
- Server: update BLE UUID characteristic in SET_ID handler
  (pUuidChar->setValue) so reconnecting clients see correct UUID
- Server: touch logic changed from t1Active/t2Active to
  !t1Active/!t2Active (door closed = relay ON)
- Android: flushReadBuffer before VERSION? to discard stale
  boot log output; use Regex for BUILD_NR parsing
- copy_firmware.sh: copy to firmware/server/ and firmware/client/
  subdirectories to match EspFlasher.assetPath()
- version.txt: server=20 client=5
2026-08-03 16:38:26 +02:00
eddy
6a07505d02 ci: add version consistency check and fully automate release pipeline
Some checks failed
CI / firmware (push) Successful in 1m13s
CI / android (push) Failing after 13s
- New tools/check_versions.sh: verifies version.txt, version.h, SylDaVersions.kt match
- release.yml: 'Verify version consistency' step after build, aborts release if mismatch
- ci.yml: same check after debug APK build
- scripts/release.sh: now runs full pipeline (pio run -> copy firmware -> gradle -> check)
  and refuses dirty working tree
- Untrack version.h, SylDaVersions.kt, release/ — always regenerated fresh from version.txt

Prevents the v1.1 bug where stale generated files caused version mismatch
and infinite re-flash loop.
2026-08-03 15:28:00 +02:00
eddy
1d94f088fd chore: update v1.1 release AAB and checksums
Some checks failed
CI / firmware (push) Successful in 1m36s
Release / build (push) Failing after 1m33s
CI / android (push) Successful in 11s
v1.1
2026-08-03 15:20:33 +02:00
eddy
07a2d22f76 fix: sync firmware version.h (16->17) and SylDaVersions.kt (18->17) with version.txt
Some checks failed
CI / firmware (push) Has been cancelled
CI / android (push) Has been cancelled
Release / build (push) Has been cancelled
Root cause: version.h and SylDaVersions.kt were stale, causing
app to expect BUILD_NR:18 while firmware reports BUILD_NR:16.
This triggered infinite re-flash loop on every 'Module bijwerken'.

Rebuilt firmware and APK so all versions agree on server=17/client=3.
Replace v1.1 release with corrected builds.
2026-08-03 15:19:12 +02:00
eddy
d952730566 fix(workflow): match signing.properties keys with build.gradle
All checks were successful
CI / firmware (push) Successful in 1m24s
CI / android (push) Successful in 14s
Release / build (push) Successful in 1m44s
2026-08-03 14:47:16 +02:00
eddy
edd391620a fix(workflow): create keystore dir before decoding
Some checks failed
CI / firmware (push) Successful in 1m32s
Release / build (push) Failing after 1m24s
CI / android (push) Successful in 21s
2026-08-03 14:43:00 +02:00
eddy
e4c80d4955 fix(release): replace missing forgejo-release action with direct Forgejo API calls
Some checks failed
CI / firmware (push) Successful in 58s
CI / android (push) Successful in 51s
Release / build (push) Failing after 1m17s
The forgejo-release@v1 action was never published to the Forgejo
packages registry, causing the release workflow to fail with a 404
when cloning the action. Replace it with curl calls to the Forgejo
API: POST /releases to create the release, then POST /assets for
each artifact file.
2026-08-03 14:24:21 +02:00
eddy
2b7c2b8450 fix(release): replace missing forgejo-release action with direct Forgejo API calls
The forgejo-release@v1 action was never published to the Forgejo
packages registry, causing the release workflow to fail with a 404
when cloning the action. Replace it with curl calls to the Forgejo
API: POST /releases to create the release, then POST /assets for
each artifact file.
2026-08-03 14:23:20 +02:00
eddy
d6f1062a44 Replace HMAC-SHA256 with AES-256-GCM + ECDH key exchange for BLE relay commands (issue #2)
- New: src/ecdh_helper.h — ECDH keypair gen, shared secret, pubkey HMAC sign/verify
- Server (src/main.cpp): ECDH handshake callback, AES-GCM decrypt, PSK from NVS
- Client (src/main.cpp→client.cpp): ECDH after connect, AES-GCM encrypt, PSK from NVS
- Android: ECDH (KeyAgreement) + AES-GCM (Cipher) in BleRelayManager.kt
- PSK provisioned via USB CDC SET_KEY (SettingsActivity.kt)
- PrefsHelper: hmac_key → psk
- Bumped versions: server=18, client=4
- NVS namespace: hmac→syl, key:hmac_key→psk
- BLE ECDH characteristic: beb5483e-...-f26dc (WRITE_NR|NOTIFY)
2026-08-03 04:34:26 +02:00
eddy
8b2dfcbfd0 Add app icon from icon.png (all densities)
All checks were successful
CI / firmware (push) Successful in 1m16s
CI / android (push) Successful in 5s
2026-08-02 21:37:05 +02:00
eddy
d0cf506fbe Release v1.1: server=17 client=3
Some checks failed
CI / firmware (push) Successful in 1m23s
CI / android (push) Successful in 5s
Release / build (push) Failing after 1s
2026-08-02 21:31:25 +02:00
68aec28fe2 Merge pull request 'Scan on service UUID instead of device name (issue #10)' (#14) from fix/issue-10-ble-scan-service-uuid into main
All checks were successful
CI / firmware (push) Successful in 1m11s
CI / android (push) Successful in 5s
2026-08-02 21:28:00 +02:00
eddy
7bdd50b16e Scan on service UUID instead of device name (issue #10)
All checks were successful
CI / firmware (pull_request) Successful in 1m16s
CI / android (pull_request) Successful in 5s
- Replace name-based scan filter (getName() == 'SylDa_Server') with
  isAdvertisingService(SERVICE_UUID) to prevent BLE name spoofing
- Post-connect UUID verification via UUID_CHAR_UUID was already in place
- Update log messages to reflect service-UUID-based scanning
2026-08-02 21:27:19 +02:00
eddy
faa4011fd1 Skip auto-detect when UPLOAD_PORT already set via CLI or config
All checks were successful
CI / firmware (push) Successful in 1m11s
CI / android (push) Successful in 5s
2026-08-02 21:23:44 +02:00
87eefe4a3c Merge pull request 'Auto-detect upload port via ID? serial query (issue #11)' (#13) from fix/issue-11-portable-upload-port into main
All checks were successful
CI / firmware (push) Successful in 1m27s
CI / android (push) Successful in 6s
2026-08-02 21:19:04 +02:00
eddy
bf6619aa54 Auto-detect upload port via ID? serial query (issue #11)
All checks were successful
CI / firmware (pull_request) Successful in 1m22s
CI / android (pull_request) Successful in 7s
- Add ID? command to firmware: server responds 'SylDa_Server', client 'SylDa_Client'
- Add tools/pio_upload_port.py POST-script that queries connected ESP32s
- Remove hardcoded upload_port from platformio.ini
- Script logic: 1 ESP32 → use directly, 2+ → ID? query, no match → prompt user
- Requires pyserial for serial queries (graceful fallback if missing)
2026-08-02 21:18:26 +02:00
f8d4e96241 Merge pull request 'Replace Serial.* logging with ESP_LOG* macros (issue #8)' (#12) from fix/issue-8-cleanup-logging into main
All checks were successful
CI / firmware (push) Successful in 1m12s
CI / android (push) Successful in 7s
2026-08-02 20:57:40 +02:00
eddy
4aa2a750d9 Review fixes: Serial ERROR→ESP_LOGE, heartbeat→ESP_LOGD
All checks were successful
CI / firmware (pull_request) Successful in 1m26s
CI / android (pull_request) Successful in 5s
- Replace remaining Serial.println("ERROR:...") with ESP_LOGE in client.cpp
- Add Serial.println("ERROR") for protocol response where needed
- Downgrade heartbeat from ESP_LOGI to ESP_LOGD (not needed in production)
2026-08-02 20:56:37 +02:00