Skip to content

Commit c2a09c6

Browse files
committed
Merge remote-tracking branch 'origin/main' into refactor-client
2 parents 5eede30 + 6bf1c23 commit c2a09c6

File tree

3 files changed

+31
-6
lines changed

3 files changed

+31
-6
lines changed

.github/workflows/ci.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ on:
99
jobs:
1010
test:
1111
strategy:
12+
fail-fast: false
1213
matrix:
1314
py: ["3.9", "3.10", "3.11", "3.12", "3.13"]
15+
1416
runs-on: ubuntu-24.04
1517
steps:
1618
- uses: actions/checkout@v4
@@ -24,5 +26,6 @@ jobs:
2426
- name: Run a Wokwi CI server
2527
uses: wokwi/wokwi-ci-server-action@v1
2628
- run: hatch run dev:pytest
29+
if: env.WOKWI_CLI_TOKEN != ''
2730
env:
2831
WOKWI_CLI_TOKEN: ${{ secrets.WOKWI_CLI_TOKEN }}

src/wokwi_client/client.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@
66
from pathlib import Path
77
from typing import Any, Optional, Union, cast
88

9-
from wokwi_client.framebuffer import (
10-
read_framebuffer_png_bytes,
11-
save_framebuffer_png,
12-
)
13-
149
from .__version__ import get_version
1510
from .constants import DEFAULT_WS_URL
1611
from .control import set_control
1712
from .event_queue import EventQueue
13+
from .exceptions import ProtocolError
1814
from .file_ops import download, upload, upload_file
19-
from .pins import PinReadMessage, pin_listen, pin_read
15+
from .framebuffer import (
16+
read_framebuffer_png_bytes,
17+
save_framebuffer_png,
18+
)
19+
from .pins import PinReadMessage, gpio_list, pin_listen, pin_read
2020
from .protocol_types import EventMessage
2121
from .serial import monitor_lines, write_serial
2222
from .simulation import pause, restart, resume, start
@@ -237,6 +237,18 @@ async def listen_pin(self, part: str, pin: str, listen: bool = True) -> None:
237237
"""
238238
await pin_listen(self._transport, part=part, pin=pin, listen=listen)
239239

240+
async def gpio_list(self) -> list[str]:
241+
"""Get a list of all GPIO pins available in the simulation.
242+
243+
Returns:
244+
list[str]: Example: ["esp32:GPIO0", "esp32:GPIO1", ...]
245+
"""
246+
resp = await gpio_list(self._transport)
247+
pins_val: Any = resp.get("result", {}).get("pins")
248+
if not isinstance(pins_val, list) or not all(isinstance(p, str) for p in pins_val):
249+
raise ProtocolError("Malformed gpio:list response: expected result.pins: list[str]")
250+
return cast(list[str], pins_val)
251+
240252
async def set_control(self, part: str, control: str, value: Union[int, bool, float]) -> None:
241253
"""Set a control value (e.g. simulate button press).
242254

src/wokwi_client/pins.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,13 @@ async def pin_listen(transport: Transport, *, part: str, pin: str, listen: bool
6161
"""
6262

6363
await transport.request("pin:listen", {"part": part, "pin": pin, "listen": listen})
64+
65+
66+
async def gpio_list(transport: Transport) -> ResponseMessage:
67+
"""List all GPIO pins and their current states.
68+
69+
Args:
70+
transport: The active Transport instance.
71+
"""
72+
73+
return await transport.request("gpio:list", {})

0 commit comments

Comments
 (0)