Include hal.h directly in scheduler.h instead of forward-declaring
millis_64(), which clang-tidy flags as redundant when both headers
are included in the same translation unit.
On ESP32, millis() truncates esp_timer_get_time() to 32-bit, then
Scheduler::millis_64_() reconstructs 64-bit using 193 bytes of
CAS/atomic/lock rollover tracking code. This is unnecessary since
esp_timer_get_time() already provides native 64-bit microseconds.
Add millis_64() as a HAL-level function alongside millis():
- ESP32: native esp_timer_get_time()/1000 (26 bytes, lock-free)
- Other platforms: delegate to Scheduler::millis_64_impl_() which
retains the existing rollover tracking (renamed from millis_64_)
Saves 344 bytes flash and ~8 bytes RAM on ESP32 by eliminating the
rollover tracking code and associated atomic fields. External callers
(uptime, web_server) now use millis_64() directly instead of
App.scheduler.millis_64().
Restore the cyw43_wifi_set_up() call for STA mode that was incorrectly
removed. Without this, cyw43_wifi_scan() fails on initial boot because
the radio isn't initialized - scanning must work before the first
beginNoBlock() call.
Call cyw43_arch_enable_sta_mode() in wifi_mode_() when STA is requested.
Without this, cyw43_wifi_scan() fails on initial boot because the radio
isn't initialized yet - it only got enabled later inside beginNoBlock().
This caused the state machine to skip scanning, fall through to
RETRY_HIDDEN, and do a wasteful blind SSID-only connect for non-hidden
networks.
The cyw43_ev_scan_result_t ssid field is a 32-byte buffer that is
not guaranteed to be null-terminated. Use ssid_len to properly
terminate the string before passing it to string comparison functions.
This fixes false "should be marked hidden" warnings where the SSID
match failed due to garbage bytes after the actual SSID in the buffer.
Update the RP2040 Arduino-Pico framework to 5.5.0 (from 3.9.4) and
the platform to v1.4.0-gcc14-arduinopico460 (GCC 14 toolchain).
Breaking changes adapted:
- pico-sdk 2.0: padsbank0_hw renamed to pads_bank0_hw
- Arduino.h now defines NOPIN as a global macro (SerialPIO::NOPIN removed)
- WiFi: cyw43_tcpip_link_status() no longer works because the Arduino
framework's __wrap_cyw43_cb_tcpip_init is a no-op (the SDK's internal
netif is never initialized). Switched to cyw43_wifi_link_status() for
radio state + WiFi.status()/WiFi.connected() for IP-level state.
- WiFi: Use beginNoBlock() instead of begin() to avoid 20s+ blocking
- WiFi: Use WiFi.disconnect() for proper lwIP/DHCP cleanup
LibreTiny forces -O1 globally for BK72xx because the Beken SDK
has issues with higher optimization levels. ESPHome code works
fine with -Os (used on every other platform), so override it
for project source files only via build_src_flags.
Also show both optimization levels in the debug banner when they
differ (e.g., "Optimization: -Os, SDK: -O1").