Commit Graph

3 Commits

Author SHA1 Message Date
a2nr 4a6ef8ce57 feat(firmware): serial bridge throttle, LED blink fix, re-deploy safety
serial_bridge.c + .h:
- Implement 20pkt/s throttle with 240-byte buffer
- serial_bridge_on_usb_data() for buffering USB serial data
- Flush every 50ms or 500ms stale timeout

led_button.c + .h:
- Per-color LED blink toggle in led_button_tick()
- BLUE_BLINK 200ms, RED_BLINK 100ms, GREEN_BLINK 200ms
- Fix: was set_led(true,true,true) for all blink patterns

main.c:
- Route USB serial data through serial_bridge_on_usb_data
- Add led_button_tick() call in main loop

state_machine.c:
- Add binary_parser_reset() on SERIAL_BRIDGE re-deploy
2026-06-30 18:13:42 +07:00
a2nr f6a04b81ba fix: re-deploy crash + readValue poll for INIT/DATA
Firmware (state_machine.c):
- Add EVENT_BLE_INIT handler to SERIAL_BRIDGE state
  -> transition back to RECEIVING for re-deploy
- Add EVENT_BLE_INIT handler to ERROR states
  -> allows re-deploy from error without pressing Retry

Frontend (ble-deployer.ts):
- Add readValue() state poll for INIT and DATA commands
  (same Android notify idle-drop bug affects these too)
- INIT success: firmware state >= 1 (RECEIVING+)
- DATA success: firmware state == 1 (RECEIVING)
- Error on state >= 5
2026-06-30 17:55:26 +07:00
a2nr 9918aafe41 fix: Phase B — readValue() state poll fallback for END ACK
Firmware:
- Add BLE_GATT_CHR_F_READ to flashing characteristic
- Read callback returns state_machine_get_current() as 1 byte
  (4=SERIAL_BRIDGE=success, 5/6=ERROR)

Frontend:
- Replace ineffective pendingAcks poll with readValue() poll
- CCCD refresh fire-and-forget (non-blocking)
- Race ackPromise (notify) vs readPoll (readValue)
- Clean up ackPromise resolver on readPoll win
- Cache v7 → v8
2026-06-30 17:35:23 +07:00