From 1bce4dc521b1bb8ab1e02b549dedfb32e3d63850 Mon Sep 17 00:00:00 2001 From: aharshac Date: Sun, 10 May 2026 19:12:29 +0530 Subject: [PATCH 01/10] feat: add initial Wokwi sim files for ESP32 --- examples/TestNTPClient/diagram.json | 16 ++++++++++++++++ examples/TestNTPClient/wokwi.toml | 4 ++++ 2 files changed, 20 insertions(+) create mode 100644 examples/TestNTPClient/diagram.json create mode 100644 examples/TestNTPClient/wokwi.toml diff --git a/examples/TestNTPClient/diagram.json b/examples/TestNTPClient/diagram.json new file mode 100644 index 0000000..889cdb9 --- /dev/null +++ b/examples/TestNTPClient/diagram.json @@ -0,0 +1,16 @@ +{ + "version": 1, + "author": "aharshac", + "editor": "wokwi", + "parts": [ + { + "type": "board-esp32-devkit-c-v4", + "id": "esp32", + "top": 0, + "left": 0, + "attrs": {} + } + ], + "connections": [], + "dependencies": {} +} diff --git a/examples/TestNTPClient/wokwi.toml b/examples/TestNTPClient/wokwi.toml new file mode 100644 index 0000000..54e0024 --- /dev/null +++ b/examples/TestNTPClient/wokwi.toml @@ -0,0 +1,4 @@ +[wokwi] +version = 1 +firmware = "build/TestNTPClient.ino.bin" +elf = "build/TestNTPClient.ino.elf" From 725072cc46ff8f9787bc6aa8419f237374e9505f Mon Sep 17 00:00:00 2001 From: aharshac Date: Sun, 10 May 2026 19:34:22 +0530 Subject: [PATCH 02/10] feat: simulate with Wokwi --- .github/workflows/ci.yml | 72 +++++++++++++++++++++++++++++++++++----- 1 file changed, 64 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 70228b1..528a286 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,29 +32,27 @@ jobs: platforms: | - name: esp8266:esp8266 source-url: https://arduino.esp8266.com/stable/package_esp8266com_index.json - - name: TestNTPClient (ESP32) - fqbn: esp32:esp32:esp32 - sketch: examples/TestNTPClient/TestNTPClient.ino - platforms: | - - name: esp32:esp32 - source-url: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json + artifact_name: testntp-esp8266 - name: TestNTPClient (Uno+ESP-01) fqbn: arduino:avr:uno sketch: examples/TestNTPClient/TestNTPClient.ino platforms: | - name: arduino:avr + artifact_name: testntp-uno # examples - - name: NodeMCU (ESP8266) + - name: Example - NodeMCU (ESP8266) fqbn: esp8266:esp8266:nodemcuv2 sketch: examples/NodeMCU/NodeMCU.ino platforms: | - name: esp8266:esp8266 source-url: https://arduino.esp8266.com/stable/package_esp8266com_index.json - - name: Arduino UNO + artifact_name: example-nodemcu-esp8266 + - name: Example - Arduino UNO + ESP-01 fqbn: arduino:avr:uno sketch: examples/ArduinoEspWifiShield/ArduinoEspWifiShield.ino platforms: | - name: arduino:avr + artifact_name: example-arduinouno steps: - uses: actions/checkout@v6 @@ -79,3 +77,61 @@ jobs: libraries: | - source-path: ./ - name: WiFiEsp + cli-compile-flags: | + - --export-binaries + - --output-dir ${{ github.workspace }}/build + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.config.artifact_name }} + path: build/ + + simulate: + name: Simulate / TestNTPClient (ESP32) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + + - name: Cache Arduino platforms and libraries + uses: actions/cache@v5 + with: + path: | + ~/.arduino15/packages + ~/Arduino/libraries + key: ${{ runner.os }}-arduino-esp32:esp32:esp32-${{ hashFiles('.github/workflows/ci.yml') }} + restore-keys: | + ${{ runner.os }}-arduino-esp32:esp32:esp32- + + - name: Compile sketch + uses: arduino/compile-sketches@v1 + with: + fqbn: esp32:esp32:esp32 + platforms: | + - name: esp32:esp32 + source-url: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json + sketch-paths: | + - examples/TestNTPClient/TestNTPClient.ino + libraries: | + - source-path: ./ + - name: WiFiEsp + cli-compile-flags: | + - --export-binaries + - --output-dir ${{ github.workspace }}/examples/TestNTPClient/build + + - name: Simulate with Wokwi + uses: wokwi/wokwi-ci-action@v1 + with: + token: ${{ secrets.WOKWI_TOKEN }} + path: examples/TestNTPClient + timeout: 150000 + expect_text: "0 failed" + fail_text: "[FAIL]" + serial_log_file: wokwi-serial.log + + - name: Upload serial log on failure + if: failure() + uses: actions/upload-artifact@v4 + with: + name: wokwi-serial-log + path: wokwi-serial.log From 0ce70ba46837ad955c4217ba951b4bb9a6c92912 Mon Sep 17 00:00:00 2001 From: aharshac Date: Sun, 10 May 2026 19:41:53 +0530 Subject: [PATCH 03/10] fix: remove broken output-dir flag --- .github/workflows/ci.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 528a286..b683de0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -79,7 +79,6 @@ jobs: - name: WiFiEsp cli-compile-flags: | - --export-binaries - - --output-dir ${{ github.workspace }}/build - name: Upload artifact uses: actions/upload-artifact@v4 @@ -117,7 +116,9 @@ jobs: - name: WiFiEsp cli-compile-flags: | - --export-binaries - - --output-dir ${{ github.workspace }}/examples/TestNTPClient/build + + - name: Tree the compiled sketch + run: tree -L 5 build/ - name: Simulate with Wokwi uses: wokwi/wokwi-ci-action@v1 From eeaa67d3d2fb95e3e1b3fd9dc1e59884ea996740 Mon Sep 17 00:00:00 2001 From: aharshac Date: Sun, 10 May 2026 19:44:29 +0530 Subject: [PATCH 04/10] fix: update sketch directory path for tree command --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b683de0..bad6887 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,7 +4,7 @@ on: push: branches: - master - pull_request: + # pull_request: workflow_dispatch: jobs: @@ -117,8 +117,8 @@ jobs: cli-compile-flags: | - --export-binaries - - name: Tree the compiled sketch - run: tree -L 5 build/ + - name: Tree sketch directory + run: tree -L 5 examples/TestNTPClient/ - name: Simulate with Wokwi uses: wokwi/wokwi-ci-action@v1 From cf4686c2019e2e978695b5171df4598d7cbb320d Mon Sep 17 00:00:00 2001 From: aharshac Date: Sun, 10 May 2026 19:45:43 +0530 Subject: [PATCH 05/10] fix: disable PR trigger for release-please workflow --- .github/workflows/ci.yml | 2 +- .github/workflows/release-please.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bad6887..16196d5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,7 +4,7 @@ on: push: branches: - master - # pull_request: + pull_request: workflow_dispatch: jobs: diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index 42f8048..bc4c48f 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -4,7 +4,7 @@ on: push: branches: - master - pull_request: + # pull_request: workflow_dispatch: permissions: From 1be2de859bea2d0058d017fb4e480d3ef1e5b50d Mon Sep 17 00:00:00 2001 From: aharshac Date: Sun, 10 May 2026 19:52:20 +0530 Subject: [PATCH 06/10] fix: update firmware and ELF paths for ESP32 simulation --- examples/TestNTPClient/wokwi.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/TestNTPClient/wokwi.toml b/examples/TestNTPClient/wokwi.toml index 54e0024..4f36b79 100644 --- a/examples/TestNTPClient/wokwi.toml +++ b/examples/TestNTPClient/wokwi.toml @@ -1,4 +1,4 @@ [wokwi] version = 1 -firmware = "build/TestNTPClient.ino.bin" -elf = "build/TestNTPClient.ino.elf" +firmware = "build/esp32.esp32.esp32/TestNTPClient.ino.bin" +elf = "build/esp32.esp32.esp32/TestNTPClient.ino.elf" From 0a2f7b209e71adaf314ca8f13d57e8b483efbaa7 Mon Sep 17 00:00:00 2001 From: aharshac Date: Sun, 10 May 2026 20:12:51 +0530 Subject: [PATCH 07/10] ci: patch Wokwi-GUEST credentials --- .github/workflows/ci.yml | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 16196d5..d702239 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,6 +28,7 @@ jobs: # TestNTPClient - name: TestNTPClient (ESP8266) fqbn: esp8266:esp8266:nodemcuv2 + sketch_dir: examples/TestNTPClient sketch: examples/TestNTPClient/TestNTPClient.ino platforms: | - name: esp8266:esp8266 @@ -35,6 +36,7 @@ jobs: artifact_name: testntp-esp8266 - name: TestNTPClient (Uno+ESP-01) fqbn: arduino:avr:uno + sketch_dir: examples/TestNTPClient sketch: examples/TestNTPClient/TestNTPClient.ino platforms: | - name: arduino:avr @@ -42,6 +44,7 @@ jobs: # examples - name: Example - NodeMCU (ESP8266) fqbn: esp8266:esp8266:nodemcuv2 + sketch_dir: examples/NodeMCU sketch: examples/NodeMCU/NodeMCU.ino platforms: | - name: esp8266:esp8266 @@ -49,6 +52,7 @@ jobs: artifact_name: example-nodemcu-esp8266 - name: Example - Arduino UNO + ESP-01 fqbn: arduino:avr:uno + sketch_dir: examples/ArduinoEspWifiShield sketch: examples/ArduinoEspWifiShield/ArduinoEspWifiShield.ino platforms: | - name: arduino:avr @@ -80,11 +84,8 @@ jobs: cli-compile-flags: | - --export-binaries - - name: Upload artifact - uses: actions/upload-artifact@v4 - with: - name: ${{ matrix.config.artifact_name }} - path: build/ + - name: Tree sketch directory + run: tree -L 5 ${{ matrix.config.sketch_dir }} simulate: name: Simulate / TestNTPClient (ESP32) @@ -102,6 +103,11 @@ jobs: restore-keys: | ${{ runner.os }}-arduino-esp32:esp32:esp32- + - name: Patch WiFi credentials for Wokwi + run: | + sed -i -E 's/(WIFI_SSID\s*=\s*)"[^"]*"/\1"Wokwi-GUEST"/' examples/TestNTPClient/TestNTPClient.ino + sed -i -E 's/(WIFI_PASSWORD\s*=\s*)"[^"]*"/\1""/' examples/TestNTPClient/TestNTPClient.ino + - name: Compile sketch uses: arduino/compile-sketches@v1 with: @@ -125,7 +131,7 @@ jobs: with: token: ${{ secrets.WOKWI_TOKEN }} path: examples/TestNTPClient - timeout: 150000 + timeout: 300000 expect_text: "0 failed" fail_text: "[FAIL]" serial_log_file: wokwi-serial.log From b7965d55be218c1418d513cc9f0af032353236aa Mon Sep 17 00:00:00 2001 From: aharshac Date: Sun, 10 May 2026 20:25:37 +0530 Subject: [PATCH 08/10] fix: update ESP32 simulation workflow to upload compiled binary --- .github/workflows/ci.yml | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d702239..20f25c3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -126,19 +126,25 @@ jobs: - name: Tree sketch directory run: tree -L 5 examples/TestNTPClient/ - - name: Simulate with Wokwi - uses: wokwi/wokwi-ci-action@v1 - with: - token: ${{ secrets.WOKWI_TOKEN }} - path: examples/TestNTPClient - timeout: 300000 - expect_text: "0 failed" - fail_text: "[FAIL]" - serial_log_file: wokwi-serial.log - - - name: Upload serial log on failure - if: failure() + - name: Upload compiled binary uses: actions/upload-artifact@v4 with: - name: wokwi-serial-log - path: wokwi-serial.log + name: testntp-esp32-bin + path: examples/TestNTPClient/ + + # - name: Simulate with Wokwi + # uses: wokwi/wokwi-ci-action@v1 + # with: + # token: ${{ secrets.WOKWI_TOKEN }} + # path: examples/TestNTPClient + # timeout: 300000 + # expect_text: "0 failed" + # fail_text: "[FAIL]" + # serial_log_file: wokwi-serial.log + + # - name: Upload serial log on failure + # if: failure() + # uses: actions/upload-artifact@v4 + # with: + # name: wokwi-serial-log + # path: wokwi-serial.log From 3e9e308ad9202b4fca87186b21d4ce699f6031d3 Mon Sep 17 00:00:00 2001 From: aharshac Date: Mon, 11 May 2026 00:47:24 +0530 Subject: [PATCH 09/10] fix: update ESP32 simulation config --- .github/workflows/ci.yml | 26 +++++++++++--------------- .gitignore | 1 + examples/TestNTPClient/diagram.json | 17 +++++++++++++++-- examples/TestNTPClient/wokwi.toml | 1 + 4 files changed, 28 insertions(+), 17 deletions(-) create mode 100644 .gitignore diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 20f25c3..0363f7e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -132,19 +132,15 @@ jobs: name: testntp-esp32-bin path: examples/TestNTPClient/ - # - name: Simulate with Wokwi - # uses: wokwi/wokwi-ci-action@v1 - # with: - # token: ${{ secrets.WOKWI_TOKEN }} - # path: examples/TestNTPClient - # timeout: 300000 - # expect_text: "0 failed" - # fail_text: "[FAIL]" - # serial_log_file: wokwi-serial.log + - name: Simulate with Wokwi + uses: wokwi/wokwi-ci-action@v1 + with: + token: ${{ secrets.WOKWI_TOKEN }} + path: examples/TestNTPClient + timeout: 300000 + expect_text: "0 failed" + fail_text: "[FAIL]" + serial_log_file: wokwi-serial.log - # - name: Upload serial log on failure - # if: failure() - # uses: actions/upload-artifact@v4 - # with: - # name: wokwi-serial-log - # path: wokwi-serial.log + - name: Cat serial log + run: cat wokwi-serial.log diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2aca916 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/examples/**/build/ diff --git a/examples/TestNTPClient/diagram.json b/examples/TestNTPClient/diagram.json index 889cdb9..29e192c 100644 --- a/examples/TestNTPClient/diagram.json +++ b/examples/TestNTPClient/diagram.json @@ -5,12 +5,25 @@ "parts": [ { "type": "board-esp32-devkit-c-v4", - "id": "esp32", + "id": "esp", "top": 0, "left": 0, "attrs": {} } ], - "connections": [], + "connections": [ + [ + "esp:TX", + "$serialMonitor:RX", + "", + [] + ], + [ + "esp:RX", + "$serialMonitor:TX", + "", + [] + ] + ], "dependencies": {} } diff --git a/examples/TestNTPClient/wokwi.toml b/examples/TestNTPClient/wokwi.toml index 4f36b79..da6b343 100644 --- a/examples/TestNTPClient/wokwi.toml +++ b/examples/TestNTPClient/wokwi.toml @@ -2,3 +2,4 @@ version = 1 firmware = "build/esp32.esp32.esp32/TestNTPClient.ino.bin" elf = "build/esp32.esp32.esp32/TestNTPClient.ino.elf" +rfc2217ServerPort = 4000 From d32b084e4f1d9bcf042dcd6efd606521b7a5016f Mon Sep 17 00:00:00 2001 From: aharshac Date: Mon, 11 May 2026 00:52:01 +0530 Subject: [PATCH 10/10] fix: configure ESP32 watchdog timer --- examples/TestNTPClient/TestNTPClient.ino | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/examples/TestNTPClient/TestNTPClient.ino b/examples/TestNTPClient/TestNTPClient.ino index 098b090..5bf45dc 100644 --- a/examples/TestNTPClient/TestNTPClient.ino +++ b/examples/TestNTPClient/TestNTPClient.ino @@ -230,6 +230,23 @@ void test_stale_time() { Serial.print(g_failed - _f); Serial.println(F(" failed")); \ } while (0) +#if defined(ESP32) +void setupEsp32Watchdog() { + // 30 s — long enough for slow NTP in Wokwi simulation; still catches infinite loops. + esp_task_wdt_config_t twdt_config = { + .timeout_ms = 30000, + .idle_core_mask = 0, + .trigger_panic = true + }; + // Arduino framework may have already initialized TWDT with a 5 s timeout. + // esp_task_wdt_init() fails in that case, so use reconfigure() first. + if (esp_task_wdt_reconfigure(&twdt_config) != ESP_OK) + esp_task_wdt_init(&twdt_config); + // ESP_ERR_INVALID_ARG means already subscribed by the framework — still fine. + esp_task_wdt_add(NULL); +} +#endif + void setup() { Serial.begin(115200); delay(100); @@ -240,6 +257,11 @@ void setup() { WiFi.init(&esp_serial); #endif +#if defined(ESP32) + setupEsp32Watchdog(); + Serial.println(F("ESP32 watchdog timer configured (30 s timeout)")); +#endif + wifi_connect(); RUN(1, test_constants);