|
4 | 4 |
|
5 | 5 | import base64
|
6 | 6 | from pathlib import Path
|
7 |
| -from typing import Any, Optional, Union |
| 7 | +from typing import Any, Optional, Union, cast |
8 | 8 |
|
| 9 | +from wokwi_client.exceptions import ProtocolError |
9 | 10 | from wokwi_client.framebuffer import (
|
10 | 11 | read_framebuffer_png_bytes,
|
11 | 12 | save_framebuffer_png,
|
@@ -256,9 +257,17 @@ async def listen_pin(self, part: str, pin: str, listen: bool = True) -> Response
|
256 | 257 | """
|
257 | 258 | return await pin_listen(self._transport, part=part, pin=pin, listen=listen)
|
258 | 259 |
|
259 |
| - async def gpio_list(self) -> ResponseMessage: |
260 |
| - """Get a list of all GPIO pins available in the simulation.""" |
261 |
| - return await gpio_list(self._transport) |
| 260 | + async def gpio_list(self) -> list[str]: |
| 261 | + """Get a list of all GPIO pins available in the simulation. |
| 262 | +
|
| 263 | + Returns: |
| 264 | + list[str]: Example: ["esp32:GPIO0", "esp32:GPIO1", ...] |
| 265 | + """ |
| 266 | + resp = await gpio_list(self._transport) |
| 267 | + pins_val: Any = resp.get("result", {}).get("pins") |
| 268 | + if not isinstance(pins_val, list) or not all(isinstance(p, str) for p in pins_val): |
| 269 | + raise ProtocolError("Malformed gpio:list response: expected result.pins: list[str]") |
| 270 | + return cast(list[str], pins_val) |
262 | 271 |
|
263 | 272 | async def set_control(
|
264 | 273 | self, part: str, control: str, value: Union[int, bool, float]
|
|
0 commit comments