Skip to content

AyresWiFiManager 2.5.0

Latest

Choose a tag to compare

@IdefixRC IdefixRC released this 03 Oct 12:09
· 3 commits to main since this release

Overview

AyresWiFiManager 2.5.0 is a feature release of the IdefixRC fork. The time sync no longer blocks your loop: update() drives it in the background, reconnects never wait for the time, and the HTTP Date fallback runs in a short-lived task of its own. AWM also stops overriding your timezone, and new calls tell you whether the clock can be trusted.

This fork tracks ayresnet/AyresWiFiManager.

Highlights

  • Non-blocking time sync: the same NTP servers, rotation and HTTP Date fallback as before, without freezing the caller. Before, a connection without internet could hold the caller for about 45 seconds.
  • Your choice at boot: run() still waits for the time by default. setTimeSyncWait(ms) caps the wait; setTimeSyncWait(0) returns at once.
  • Reliable reconnect sync: every reconnect re-syncs the time, and never waits.
  • Your timezone stays: AWM no longer forces UTC0. Set TZ once and local time survives every sync.
  • Know when the clock is real: isTimeSynced() and getTimeSyncStatus() (IDLE, SYNCING, SYNCED, FAILED).
  • Off switch: setTimeSync(false) for applications that run their own NTP client.

User guide: time sync

void setup() {
  setenv("TZ", "AEST-10", 1); // optional: your local timezone
  tzset();

  wifi.setTimeSyncWait(0);    // don't hold up setup() for the time
  wifi.begin();
  wifi.run();
}

void loop() {
  wifi.update();
  wifi.reintentarConexionSiNecesario();

  if (wifi.isTimeSynced()) {
    // the clock is real: HTTPS certificate checks and timestamps work
  }
}
Call What it does Default
setTimeSync(bool) Turns AWM's time sync on or off. Off: AWM never touches the clock or TZ. true
setTimeSyncWait(ms) How long run() waits for the time after connecting. TIME_SYNC_WAIT_FULL: until the sync succeeds or gives up
isTimeSynced() true once the system clock is valid (2017 or later).
getTimeSyncStatus() IDLE, SYNCING, SYNCED or FAILED. FAILED can still become SYNCED, because SNTP keeps retrying in the background.

Compatibility

  • ESP32 with the Arduino framework, Arduino-ESP32 core 2.x and 3.x (CI builds both examples on both).
  • ArduinoJson 6.21.2 or newer within major version 6.
  • Tested on hardware with an ESP32-C6 on core 3.3.11.
  • One extra FreeRTOS task (8 KB stack) exists only while the HTTP Date fallback runs. That's only when NTP fails, and for at most 60 seconds. On the ESP32-C6 it used at most about 2.9 KB of that stack (minimum free 5256 bytes over 15+ runs), and the heap stayed flat across 11 back-to-back fallback runs.
  • Core 2.x: the core's DNS lookup (hostByName) is not safe to run from two tasks at once. While the HTTP fallback runs, a DNS lookup in your loop() may wait or, rarely, fail; retry it. Core 3.x is not affected.

Upgrade Notes

  • run() waits as before; nothing to do unless you want a shorter wait.
  • Reconnects now re-sync the time and never wait. In 2.4.0, the reconnect sync almost never ran.
  • AWM no longer sets TZ to UTC0. If you never set TZ, nothing changes. If you set your own TZ, it now survives every sync.
  • getTimestamp() returns 0 until the clock reads 2017 or later (before: 1970-01-02).
  • The "Hora sincronizada" log line now shows local time when you set TZ.
  • The setBusyCallback() callback is now also called while run() waits for the time.