nodemcu / nodemcu-firmware

Lua based interactive firmware for ESP8266, ESP8285 and ESP32

Home Page:https://nodemcu.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

AlexIII opened this issue · comments

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

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.