These scripts validate the **CYW43439 emulator** (`src/cyw43_emulator.ts`)
against the public gSPI / SDPCM / IOCTL contracts the real
`cyw43-driver` exercises. They are **not** wired into Velxio's
frontend yet — the goal is to prove every layer works in isolation
before promoting the code into `frontend/src/simulation/cyw43/`.
The emulator implements the design from
`../autosearch/04_emulation_design.md`:
| Tier | What runs | Status |
|---|---|---|
| 0 | Bus handshake (`0xFEEDBEAD`), F0/F1 register state, on-board LED IOCTL | ✅ |
| 1 | Full IOCTL surface (UP/DOWN/SET_INFRA/SET_AUTH/GET_VAR/SET_VAR/SCAN/SET_SSID/DISASSOC), SDPCM event injection, `Velxio-GUEST` AP, `cur_etheraddr` MAC reply | ✅ |
| 2 | Outbound Ethernet frames on F2 fire `onPacketOut`; inbound frames accepted via `injectPacket()`. Ready to be wired to a backend WS bridge. | ✅ chip side; net bridge is the production seam |
| 3 | Bluetooth, monitor mode, WPA3-SAE | ⏭ out of scope |
## Layout
```
test_code/
├── README.md ← this file
├── package.json ← local Node deps + npm scripts
├── tsconfig.json ← strict TS, ESM
├── src/
│ ├── pio_bus_sniffer.ts ← decodes 32-bit gSPI command words
## Real-world IoT projects covered by `07_picow_iot_projects.test.ts`
Each test drives the Cyw43Emulator with the **exact** network workflow
of one of the Pico W projects in
`wokwi-libs/100_Days_100_IoT_Projects/`:
| # | Project | What's exercised | Result |
|---|---|---|---|
| 1 | `Pico_W_Async_LED_Control_(MicroPython)` | asyncio HTTP server on :80, on-board LED IOCTL on `Pin('LED')` | ✅ inbound GET /on/off → outbound 200 OK, LED toggles match |
| 2 | `IoT_Relay_Control_Web_Server_(Raspberry_Pi_Pico_2W)` | TCP server :80, GPIO 2 relay (host-side, no chip path) | ✅ HTTP request through, 200 OK out |
| 3 | `Pico_2_W_Dht11_Http_Csv_Logger` | `urequests.post()` → outbound HTTP with JSON body | ✅ POST /data with `"temperature":24` reaches `onPacketOut` |
| 4 | `Raspberry_Pi_Pico_2_W_ThingsBoard_IoT` | umqtt CONNECT + PUBLISH on TCP :1883 | ✅ control packet types `0x10` and `0x30` recognised on the wire |