nodemcu / nodemcu-firmware

Lua based interactive firmware for ESP8266, ESP8285 and ESP32
https://nodemcu.readthedocs.io
MIT License
7.64k stars 3.12k forks source link

System crash on sntp.sync() call when wifi in SOFTAP mode. Is it intended behavior? #3449

Closed AlexIII closed 3 years ago

AlexIII commented 3 years ago

Expected behavior

Not to crash? Or if it is intended behavior, maybe it is useful to add a few words in the docs that it's the user's responsibility to check wifi mode is STATION before calling sntp.sync().

Actual behavior

A crash

Test code

Provide a Minimal, Complete, and Verifiable example which will reproduce the problem.

wifi.setmode(wifi.SOFTAP)
wifi.ap.config({
    ...
})
sntp.sync()

NodeMCU startup banner

NodeMCU 3.0.0.0 built on nodemcu-build.com provided by frightanic.com branch: release commit: d4ae3c364bd8ae3ded8b77d35745b7f07879f5f9 release: release DTS: 202105102018 SSL: false build type: float LFS: 0x0 bytes total capacity modules: file,gpio,net,node,rtctime,sjson,sntp,tmr,uart,wifi build 2021-07-24 15:53 powered by Lua 5.1.4 on SDK 3.0.1-dev(fce080e)

Hardware

ESP8266MOD (ESP-12)

vsky279 commented 3 years ago

Hi, it is a bug that has a simple fix:

-    if (iface->dhcp && iface->dhcp->offered_ntp_addr.addr) {
+    if (iface && iface->dhcp && iface->dhcp->offered_ntp_addr.addr) {

I'll post a PR shortly.