44import typing as t
55from pathlib import Path
66
7- from packaging .version import Version
87from pytest_embedded .log import DuplicateStdoutPopen , MessageQueue
98from pytest_embedded .utils import Meta
109from wokwi_client import GET_TOKEN_URL , WokwiClientSync
1110
12- from pytest_embedded_wokwi import WOKWI_CLI_MINIMUM_VERSION
13-
1411from .idf import IDFFirmwareResolver
1512
1613if t .TYPE_CHECKING : # pragma: no cover
@@ -61,24 +58,14 @@ def __init__(
6158 # Initialize synchronous Wokwi client
6259 self .client = WokwiClientSync (token )
6360
64- # Check version compatibility
65- if Version (self .client .version ) < Version (WOKWI_CLI_MINIMUM_VERSION ):
66- logging .warning (
67- 'Wokwi client version %s < required %s (compatibility not guaranteed)' ,
68- self .client .version ,
69- WOKWI_CLI_MINIMUM_VERSION ,
70- )
71- logging .info ('Wokwi client library version: %s' , self .client .version )
72-
7361 # Prepare diagram file if not supplied
7462 if wokwi_diagram is None :
7563 self .create_diagram_json ()
7664 wokwi_diagram = os .path .join (self .app .app_path , 'diagram.json' )
7765
7866 # Connect and start simulation
7967 try :
80- flasher_args = firmware_resolver .resolve_firmware (app )
81- firmware_path = Path (flasher_args ).as_posix ()
68+ firmware_path = Path (firmware_resolver .resolve_firmware (app )).as_posix ()
8269 elf_path = Path (app .elf_file ).as_posix ()
8370
8471 self ._setup_simulation (wokwi_diagram , firmware_path , elf_path )
@@ -93,16 +80,17 @@ def _setup_simulation(self, diagram: str, firmware_path: str, elf_path: str):
9380 logging .info ('Connected to Wokwi Simulator, server version: %s' , hello .get ('version' , 'unknown' ))
9481
9582 # Upload files
96- self .client .upload_file ('diagram.json' , diagram )
97- firmware = self .client .upload_file ('pytest.bin' , firmware_path )
98-
99- self .client .upload_file ('pytest.elf' , elf_path )
83+ self .client .upload_file ('diagram.json' , Path (diagram ))
84+ self .client .upload_file ('pytest.elf' , Path (elf_path ))
85+ if firmware_path .endswith ('flasher_args.json' ):
86+ firmware = self .client .upload_idf_firmware (firmware_path )
87+ self .client .start_simulation (firmware .firmware , elf = 'pytest.elf' )
88+ else :
89+ firmware = self .client .upload_file ('pytest.bin' , Path (firmware_path ))
90+ self .client .start_simulation (firmware , elf = 'pytest.elf' )
10091
10192 logging .info ('Uploaded diagram and firmware to Wokwi. Starting simulation...' )
10293
103- # Start simulation
104- self .client .start_simulation (firmware , elf = 'pytest.elf' )
105-
10694 def _start_serial_monitoring (self ):
10795 """Start monitoring serial output and forward to stdout and message queue."""
10896
0 commit comments