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