Skip to content

报错

I (411006) wifi:new:<6,0>, old:<11,0>, ap:<255,255>, sta:<6,0>, prof:1 I (411006) wifi:state: init -> auth (b0) I (411016) wifi:state: auth -> assoc (0) I (411096) wifi:state: assoc -> run (10) I (411126) wifi:connected with duruofu, aid = 1, channel 6, BW20, bssid = be:af:8b:d5:85:f5 I (411136) wifi:security: WPA2-PSK, phy: bgn, rssi: -41 I (411146) wifi:pm start, type: 1 W (411166) wifi:<ba-add>idx:0 (ifx:0, be:af:8b:d5:85:f5), tid:0, ssn:0, winSize:64 I (411206) wifi:AP's beacon interval = 102400 us, DTIM period = 2 W (411216) wifi:<ba-add>idx:1 (ifx:0, be:af:8b:d5:85:f5), tid:6, ssn:2, winSize:64 I (412056) scan: got ip:192.168.134.126 


I (412056) scan: Initializing SNTP 
assert failed: sntp_setoperatingmode IDF/components/lwip/lwip/src/apps/sntp/sntp.c:724 (Operating mode must not be set while SNTP client is running) 


Backtrace: 0x40081ad6:0x3ffbe2e0 0x400885f5:0x3ffbe300 0x4008f935:0x3ffbe320 0x400e8a7d:0x3ffbe440 0x400d7397:0x3ffbe460 0x400d73b3:0x3ffbe480 0x400d7504:0x3ffbe520 0x4015dccd:0x3ffbe550 0x4015d75f:0x3ffbe580 0x4015d819:0x3ffbe5c0 0x4008be71:0x3ffbe5e0 ELF file SHA256: afe42c272d60814a Rebooting...

原因: “wifi:connected”表示设备已成功连接到网络,并且“wifi:security”列出了网络的加密类型、物理层和信号强度等。而“scan: got ip”表示设备已分配到IP地址。然而,在运行SNTP客户端程序时,发生了一个assert失败错误,这可能是由于SNTP客户端正在运行时尝试更改操作模式引起的。

解决: 在初始化SNTP时加入

c
    // 处理wifi断开的情况,防止sntp重复初始化

    if ( sntp_enabled()) {

    sntp_stop();

    }

整体:

c
//初始化ntp

static void initialize_sntp(void)

{

    ESP_LOGI(TAG, "Initializing SNTP");

  

    // 处理wifi断开的情况,防止sntp重复初始化

    if ( sntp_enabled()) {

    sntp_stop();

    }

  

    sntp_setoperatingmode(SNTP_OPMODE_POLL);

    sntp_setservername(0, "pool.ntp.org");

    sntp_set_time_sync_notification_cb(time_sync_notification_cb);

#ifdef CONFIG_SNTP_TIME_SYNC_METHOD_SMOOTH

    sntp_set_sync_mode(SNTP_SYNC_MODE_SMOOTH);

#endif

    sntp_init();

}

参考:

https://github.com/Azure/azure-c-shared-utility/issues/294https://github.com/nodemcu/nodemcu-firmware/issues/2897https://github.com/VSChina/ESP32_AzureIoT_Arduino/issues/5

最后更新时间: