velxio/test
David Montero Crespo 36ad2bef3f feat(i2c): cross-board bridging across all velxio boards (AVR/RP2040/ESP32 xtensa+riscv)
Closes the remaining gaps in cross-board I2C so any topology of
supported boards (Uno↔ESP32, two ESP32s, Uno↔Uno↔Uno, ESP32-C3
connected to anything, etc.) works end-to-end with all I2C
components including write-only sinks (SSD1306, PCF8574, LCD-I2C).

Implementation (6 phases):

1. **BFS routing in I2CBusManager**: connectToSlave + handleExternalConnect
   walk the bridge graph with a visited Set so multi-hop chains
   (A↔B↔C with the device on C) resolve transparently.  A new
   forwarder-device shim is installed at intermediate hops so the
   existing handleExternalWrite/Read/Stop machinery routes
   through without per-method visited tracking.

2. **Per-peer proxy ownership in Esp32BridgeShim**: replaces the
   global _proxiedAddrs Set with _proxiedByPeer Map so concurrent
   bridges to the same ESP32 (e.g. wired to both Uno and Pico)
   don't wipe each other's proxies on teardown.  Interconnect's
   per-wire teardown calls clearProxiesForPeer(peerBus) instead of
   clearAllProxies.

3. **BFS-aware proxy sync**: syncProxyFromPeer now walks the peer
   bus + its transitive bridges, so an ESP32 sees devices on
   boards two or more hops away.  _peerDeviceLookup keeps a flat
   addr → device map for write-forwarding and resync.

4. **Periodic resync (250 ms)**: Esp32BridgeShim runs a setInterval
   while any proxy is live, re-dumping each device with
   dumpRegisters() and pushing updateProxyI2c only when an XOR-
   stride hash changes.  This keeps RTC time advancing visible to
   ESP32 firmware without flooding the WS pipe with static
   calibration dumps.  Hash is primed during initial sync so the
   first tick doesn't push a redundant identical buffer.

5. **Write-forwarding ProxySlave → peer**: backend ProxySlave
   buffers write bytes during the transaction and emits a
   `proxy_i2c_complete` event on STOP / repeated-START.  Frontend
   Esp32Bridge dispatches the event to a new onProxyI2cComplete
   callback; the shim replays the byte sequence on the actual
   peer I2CDevice via writeByte() + stop().  Makes ESP32 firmware
   writes to peer SSD1306 actually repaint the OLED, peer PCF8574
   latch updates, peer I2CMemoryDevice register mutations propagate.

6. **ESP32-C3 routed as bridge**: Interconnect.isBrowserSim no
   longer claims c3/xiao-c3/c3-supermini — they were already
   going through Esp32Bridge per the store's ESP32_RISCV_KINDS
   routing, but Interconnect was treating them as browser sims
   which broke proxy install.  isEsp32Bridge now correctly
   includes c3 family + ESP32-S3 + Arduino Nano ESP32.

Defensive: addBoard now disposes any existing shim's proxies
before overwriting simulatorMap entry so test reruns don't leak
timers.

Tests:
- 4 BFS multi-hop tests (i2c-multi-board-slave-gap.test.ts)
- 11 cross-board scenarios + per-peer + write-forward + resync
  (i2c-esp32-multiboard-bridge.test.ts)
- 1 real-firmware E2E for write-forward via QEMU (compile +
  load + observe proxy_i2c_complete arriving with the byte)
- New sketch fixture: esp32_i2c_write_to_peer.ino

Result: 90 test files / 1295 tests pass / 0 fail.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-12 17:51:39 -03:00
..
autosearch feat: Add support for SSD168x ePaper panels 2026-04-29 22:23:00 -03:00
backend perf(compile): dedup, concurrency limits, and persistent build dir for ESP-IDF 2026-05-09 08:33:11 +02:00
esp32 Fix MPU6050Slave I2C handling and add comprehensive tests 2026-04-09 02:04:41 -03:00
esp32-emulator refactor: rename wokwi-libs/ → third-party/ 2026-05-03 00:58:57 -03:00
esp32_cam Refactor ESP32 library management and add regression tests for issue #129 2026-04-30 23:49:46 -03:00
multi_board feat: add multi-board integration tests for Raspberry Pi 3B and backend functionality 2026-03-13 00:15:14 -03:00
multi_board_esp32 feat(multi-board): add wire-aware cross-board interconnect router 2026-04-25 19:47:40 -03:00
pi_arduino_serial refactor: rename wokwi-libs/ → third-party/ 2026-05-03 00:58:57 -03:00
test-esp32-cam refactor: rename wokwi-libs/ → third-party/ 2026-05-03 00:58:57 -03:00
test-esp32-p4 docs: add ESP32-P4 research and feasibility report 2026-05-06 15:48:05 -03:00
test_100_days refactor: rename wokwi-libs/ → third-party/ 2026-05-03 00:58:57 -03:00
test_Raspberry_Pi_Pico_W refactor: rename wokwi-libs/ → third-party/ 2026-05-03 00:58:57 -03:00
test_chip_backend_runtime Add ESP32 chip demos and comprehensive tests for I2C, SPI, and UART interactions 2026-04-28 19:24:39 -03:00
test_circuit refactor: rename wokwi-libs/ → third-party/ 2026-05-03 00:58:57 -03:00
test_custom_chips feat(i2c): cross-board bridging across all velxio boards (AVR/RP2040/ESP32 xtensa+riscv) 2026-05-12 17:51:39 -03:00
test_custom_chips_boards Add ESP32 chip demos and comprehensive tests for I2C, SPI, and UART interactions 2026-04-28 19:24:39 -03:00
test_epaper feat: add support for UC8159c (ACeP 7-colour) display 2026-04-30 00:27:40 -03:00
test_intel refactor: rename wokwi-libs/ → third-party/ 2026-05-03 00:58:57 -03:00
docker-errors-2026-04-19.md docs: add Docker production error report (2026-04-19) 2026-04-19 00:37:07 +02:00