fix: critical issues from code review #20
6 changed files with 22 additions and 24 deletions
fix: critical issues from code review
All checks were successful
CI / build (pull_request) Successful in 1m20s
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
commit
64ade7ff10
10
README.md
10
README.md
|
|
@ -12,10 +12,10 @@ De BLE-verbinding is beveiligd met **HMAC-SHA256 authenticatie** (application-le
|
|||
|---|---|
|
||||
| Relais 1 | Op **G1** |
|
||||
| Relais 2 | Op **G2** |
|
||||
| Touch sensor 1 | HS-S43A Digital Capacitive Switch Module op **G8** (actief HIGH) |
|
||||
| Touch sensor 2 | HS-S43A Digital Capacitive Switch Module op **G6** (actief HIGH) |
|
||||
| Touch sensor 1 | HS-S43A Digital Capacitive Switch Module op **G8** (actief LOW) |
|
||||
| Touch sensor 2 | HS-S43A Digital Capacitive Switch Module op **G6** (actief LOW) |
|
||||
| Knop | Op **G41** (active low) |
|
||||
| Status LED | Op **G46** (rood = geen verbinding, geel = verbinding <60s, uit = stabiel) |
|
||||
| Status LED | Op **G35** (WS2812 RGB, rood = geen verbinding, geel = verbinding <60s, uit = stabiel) |
|
||||
|
||||
### Pinout
|
||||
|
||||
|
|
@ -25,7 +25,7 @@ G2 = RELAY2
|
|||
G6 = TOUCH2 (INPUT)
|
||||
G8 = TOUCH1 (INPUT)
|
||||
G41 = BUTTON (INPUT, active low)
|
||||
G46 = LED (OUTPUT)
|
||||
G35 = LED (WS2812 RGB, OUTPUT)
|
||||
```
|
||||
|
||||
### Aansluiting
|
||||
|
|
@ -39,7 +39,7 @@ Relais + → G1 / G2
|
|||
Relais - → GND
|
||||
```
|
||||
|
||||
> **HS-S43A touch sensor:** Digitale output (actief HIGH). Geen pullup nodig — de sensor geeft actief 0V of 3.3V.
|
||||
> **HS-S43A touch sensor:** Digitale output (actief LOW — pin naar GND bij aanraking). Gebruik `INPUT_PULLUP` modus. De sensor trekt de pin actief laag bij detectie.
|
||||
|
||||
## LED-signalering
|
||||
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
|
|
@ -32,6 +32,7 @@ import javax.crypto.Mac
|
|||
import javax.crypto.spec.GCMParameterSpec
|
||||
import javax.crypto.spec.SecretKeySpec
|
||||
import kotlin.text.Charsets
|
||||
import kotlinx.coroutines.CompletableDeferred
|
||||
|
||||
class BleRelayManager(
|
||||
private val context: Context,
|
||||
|
|
@ -83,14 +84,6 @@ class BleRelayManager(
|
|||
private var ecdhNotifyBuf: ByteArray = ByteArray(0)
|
||||
private var ecdhCccdPending = false
|
||||
|
||||
private class CompletableDeferred<T> {
|
||||
private var result: T? = null
|
||||
private var completed = false
|
||||
@Synchronized fun complete(value: T) { result = value; completed = true }
|
||||
@Synchronized fun isDone(): Boolean = completed
|
||||
@Synchronized fun get(): T? = result
|
||||
}
|
||||
|
||||
interface OtaNotifyCallback {
|
||||
fun onOtaNotify(status: Int, seq: Int)
|
||||
}
|
||||
|
|
@ -290,6 +283,7 @@ class BleRelayManager(
|
|||
private fun connectToDevice(device: android.bluetooth.BluetoothDevice) {
|
||||
handler.post { callbacks.onStatusChanged(BleStatus.Connecting) }
|
||||
Log.d(TAG, "Connecting to ${device.address}")
|
||||
bluetoothGatt?.close()
|
||||
bluetoothGatt = device.connectGatt(context, false, gattCallback)
|
||||
}
|
||||
|
||||
|
|
@ -500,10 +494,10 @@ class BleRelayManager(
|
|||
|
||||
Thread {
|
||||
val start = System.currentTimeMillis()
|
||||
while (!ecdhDeferred!!.isDone() && System.currentTimeMillis() - start < ECDH_TIMEOUT_MS) {
|
||||
while (!ecdhDeferred!!.isCompleted && System.currentTimeMillis() - start < ECDH_TIMEOUT_MS) {
|
||||
Thread.sleep(50)
|
||||
}
|
||||
if (!ecdhDeferred!!.isDone()) {
|
||||
if (!ecdhDeferred!!.isCompleted) {
|
||||
Log.w(TAG, "ECDH: notify timeout")
|
||||
handler.post {
|
||||
callbacks.onStatusChanged(BleStatus.CommError)
|
||||
|
|
|
|||
|
|
@ -98,11 +98,7 @@ class OtaManager(
|
|||
return@withContext false
|
||||
}
|
||||
|
||||
try {
|
||||
withTimeout(OTA_START_TIMEOUT_MS) {
|
||||
while (true) { delay(100); ensureActive() }
|
||||
}
|
||||
} catch (_: kotlinx.coroutines.TimeoutCancellationException) {}
|
||||
delay(500)
|
||||
|
||||
val totalChunks = (fw.size + chunkDataSize - 1) / chunkDataSize
|
||||
var seq = 0
|
||||
|
|
|
|||
|
|
@ -66,10 +66,18 @@ mkdir -p "$RELEASE_DIR"
|
|||
|
||||
cp "$ANDROID_DIR/app/build/outputs/apk/release/app-release.apk" "$RELEASE_DIR/"
|
||||
cp "$ANDROID_DIR/app/build/outputs/bundle/release/app-release.aab" "$RELEASE_DIR/"
|
||||
cp "$FIRMWARE_DIR/bootloader.bin" "$RELEASE_DIR/"
|
||||
cp "$FIRMWARE_DIR/partitions.bin" "$RELEASE_DIR/"
|
||||
cp "$FIRMWARE_DIR/boot_app0.bin" "$RELEASE_DIR/"
|
||||
cp "$FIRMWARE_DIR/firmware.bin" "$RELEASE_DIR/"
|
||||
|
||||
# Server firmware
|
||||
cp "$FIRMWARE_DIR/server/bootloader.bin" "$RELEASE_DIR/server-bootloader.bin"
|
||||
cp "$FIRMWARE_DIR/server/partitions.bin" "$RELEASE_DIR/server-partitions.bin"
|
||||
cp "$FIRMWARE_DIR/server/boot_app0.bin" "$RELEASE_DIR/server-boot_app0.bin"
|
||||
cp "$FIRMWARE_DIR/server/firmware.bin" "$RELEASE_DIR/server-firmware.bin"
|
||||
|
||||
# Client firmware
|
||||
cp "$FIRMWARE_DIR/client/bootloader.bin" "$RELEASE_DIR/client-bootloader.bin"
|
||||
cp "$FIRMWARE_DIR/client/partitions.bin" "$RELEASE_DIR/client-partitions.bin"
|
||||
cp "$FIRMWARE_DIR/client/boot_app0.bin" "$RELEASE_DIR/client-boot_app0.bin"
|
||||
cp "$FIRMWARE_DIR/client/firmware.bin" "$RELEASE_DIR/client-firmware.bin"
|
||||
|
||||
log "Checksums..."
|
||||
cd "$RELEASE_DIR"
|
||||
|
|
|
|||
Loading…
Reference in a new issue