Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 73 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,33 +28,35 @@ jobs:
# TestNTPClient
- name: TestNTPClient (ESP8266)
fqbn: esp8266:esp8266:nodemcuv2
sketch_dir: examples/TestNTPClient
sketch: examples/TestNTPClient/TestNTPClient.ino
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_dir: examples/TestNTPClient
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_dir: examples/NodeMCU
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_dir: examples/ArduinoEspWifiShield
sketch: examples/ArduinoEspWifiShield/ArduinoEspWifiShield.ino
platforms: |
- name: arduino:avr
artifact_name: example-arduinouno

steps:
- uses: actions/checkout@v6
Expand All @@ -79,3 +81,66 @@ jobs:
libraries: |
- source-path: ./
- name: WiFiEsp
cli-compile-flags: |
- --export-binaries

- name: Tree sketch directory
run: tree -L 5 ${{ matrix.config.sketch_dir }}

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: 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:
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

- name: Tree sketch directory
run: tree -L 5 examples/TestNTPClient/

- name: Upload compiled binary
uses: actions/upload-artifact@v4
with:
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: Cat serial log
run: cat wokwi-serial.log
2 changes: 1 addition & 1 deletion .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches:
- master
pull_request:
# pull_request:
workflow_dispatch:

permissions:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/examples/**/build/
22 changes: 22 additions & 0 deletions examples/TestNTPClient/TestNTPClient.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
29 changes: 29 additions & 0 deletions examples/TestNTPClient/diagram.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"version": 1,
"author": "aharshac",
"editor": "wokwi",
"parts": [
{
"type": "board-esp32-devkit-c-v4",
"id": "esp",
"top": 0,
"left": 0,
"attrs": {}
}
],
"connections": [
[
"esp:TX",
"$serialMonitor:RX",
"",
[]
],
[
"esp:RX",
"$serialMonitor:TX",
"",
[]
]
],
"dependencies": {}
}
5 changes: 5 additions & 0 deletions examples/TestNTPClient/wokwi.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[wokwi]
version = 1
firmware = "build/esp32.esp32.esp32/TestNTPClient.ino.bin"
elf = "build/esp32.esp32.esp32/TestNTPClient.ino.elf"
rfc2217ServerPort = 4000
Loading