espressif / esp-mdf

Espressif Mesh Development Framework, limited maintain, recommend to use https://github.com/espressif/esp-mesh-lite
Other
779 stars 253 forks source link

ESP32在信道13出现设备掉线的问题 #286

Open zhuangqingshu opened 2 years ago

zhuangqingshu commented 2 years ago

Environment

Problem Description

ESP32在信道13出现设备掉线的问题 ESP32 has the problem of device disconnection on channel 13

Expected Behavior

设备在掉线后能够重新连接网络 The device is able to reconnect to the network after being dropped

Actual Behavior

设备在掉线后不能重新连接网络 The device cannot reconnect to the network after being dropped

Steps to repropduce

  1. MESH网络配置好,所有设备正常连接,路由器WIFI“信道13,不隐藏SSID”
  2. 把路由器WIFI参数配置为“信道13,隐藏SSID”,所有设备都掉线,
  3. 把路由器WIFI参数 从 “信道13,隐藏SSID” -> “信道13,不隐藏SSID”, 一个设备掉线,其余设备正常连接。

再次切换路由器WIFI信道,其它设备能正常连接,掉线的设备还是连不上。 对掉线设备断电重启,无效。 所有设备断电重启,所有设备连接正常。 在信道12上也出现这个问题,其余信道没测到这个问题。

  1. MESH network configuration is good, all devices are connected normally, router WIFI "channel 13, do not hide SSID"
  2. Configure the router WIFI parameter to "channel 13, hide SSID", all devices are disconnected,
  3. Change the router WIFI parameters from "channel 13, hide SSID" -> "channel 13, do not hide SSID", one device is disconnected, and the rest are connected normally.

Switch the WIFI channel of the router again, other devices can be connected normally, but the dropped device still cannot be connected. Power off and restart the disconnected device, it is invalid. All devices are powered off and restarted, and all devices are connected normally. This problem also occurs on channel 12, the other channels have not detected this problem.

Code to reproduce this issue


/**
 * @brief All module events will be sent to this task in esp-mdf
 *
 * @Note:
 *     1. Do not block or lengthy operations in the callback function.
 *     2. Do not consume a lot of memory in the callback function.
 *        The task memory of the callback function is only 4KB.
 */
static mdf_err_t event_loop_cb(mdf_event_loop_t event, void *ctx)
{
    MDF_LOGI("event_loop_cb, event: 0x%x", event);
    mdf_err_t ret = MDF_OK;
    static bool s_button_key_push_flag = false;
    static bool s_mwifi_connect_flag = true;

    switch (event) {
        case MDF_EVENT_MWIFI_STARTED:
            MDF_LOGI("MESH is started");
            led_indicator_start(status_led_handle, BLINK_CONNECTING);
            break;

        case MDF_EVENT_MWIFI_PARENT_CONNECTED:
            MDF_LOGI("Parent is connected on station interface");
            led_indicator_stop(status_led_handle, BLINK_CONNECTING);
            if(switch_dev.backlight_disable){
                led_indicator_stop(status_led_handle, BLINK_CONNECTED);
                led_indicator_start(status_led_handle, BLINK_PROVISIONED);
            }else{
                led_indicator_start(status_led_handle, BLINK_CONNECTED);
            }
            s_mwifi_connect_flag = true;

            if (esp_mesh_is_root()) {
                esp_netif_dhcpc_start(sta_netif);
                mesh_root_task_init();
                ret = mwifi_post_root_status(true);
                MDF_ERROR_BREAK(ret != MDF_OK, "<%s> mwifi_post_root_status", mdf_err_to_name(ret));
            }else{
                if(mwifi_get_root_status() && is_need_obtain_time()){
                    mlink_request_get_time();
                }
            }

#ifdef CONFIG_DEVICE_NETWORKING_TIME_OPTIMIZE_ENABLE

            if (esp_mesh_is_root_fixed()) {
                /**
                 * TODO:Fix the problem that esp_mesh does not update at the bottom,
                 *       IE does not update. This is a temporary solution. This code
                 *       needs to be deleted after esp-idf is fixed.
                 */
                extern mesh_assoc_t g_mesh_ie;
                g_mesh_ie.rc_rssi = mwifi_get_parent_rssi();

                esp_mesh_fix_root(false);
                ESP_ERROR_CHECK(esp_mesh_set_self_organized(true, false));
            }

            mwifi_node_type_t mesh_type = MWIFI_MESH_IDLE;

            if (esp_mesh_is_root()) {
                mesh_type = MWIFI_MESH_ROOT;
            } else {
                mesh_type = MWIFI_MESH_IDLE;
            }

            mwifi_config_t ap_config  = {0x0};
            mdf_info_load(DEVICE_MESH_AP_CONFIG_STORE_KEY, &ap_config, sizeof(mwifi_config_t));

            if (esp_mesh_get_type() != MESH_LEAF && esp_mesh_get_layer() == CONFIG_MWIFI_MAX_LAYER) {
                ESP_ERROR_CHECK(esp_mesh_set_type(MESH_LEAF));
            }

            if (ap_config.mesh_type != mesh_type) {
                ap_config.mesh_type = mesh_type;
                mdf_info_save(DEVICE_MESH_AP_CONFIG_STORE_KEY, &ap_config, sizeof(mwifi_config_t));
            }

#endif /**< CONFIG_DEVICE_NETWORKING_TIME_OPTIMIZE_ENABLE */

#ifdef CONFIG_DEVICE_BLE_GATEWAY

            if (!esp_mesh_is_root()) {
                mlink_ble_config_t config = {
                    .company_id = MCOMMON_ESPRESSIF_ID,
                    /**
                     * @brief  This custom_data is for iBeacon definitions. https://developer.apple.com/ibeacon/
                     *         Espressif WeChat official account can be found using WeChat "Yao Yi Yao Zhou Bian"
                     */
                    .custom_data = {
                        0x02, 0x01, 0x06, 0x1A, 0xFF, 0x4C, 0x00, 0x02,
                        0x15, 0xFD, 0xA5, 0x06, 0x93, 0xA4, 0xE2, 0x4F,
                        0xB1, 0xAF, 0xCF, 0xC6, 0xEB, 0x07, 0x64, 0x78,
                        0x25, 0x27, 0xB7, 0xF2, 0x06, 0xC5
                    },
                    .custom_size = 30,
                };

                memcpy(config.name, mlink_device_get_name(), sizeof(config.name) - 1);
                MDF_ERROR_ASSERT(mlink_ble_init(&config));
                mlink_ble_set_cb(NULL, mlink_ble_write);
            } else {
                MDF_ERROR_ASSERT(mlink_ble_deinit());
            }

#endif /**< CONFIG_DEVICE_BLE_GATEWAY */

            break;

        case MDF_EVENT_MWIFI_PARENT_DISCONNECTED:
            MDF_LOGI("Parent is disconnected on station interface");
            if(s_mwifi_connect_flag){
                s_mwifi_connect_flag = false;
                led_indicator_stop(status_led_handle, BLINK_CONNECTED);
                led_indicator_start(status_led_handle, BLINK_CONNECTING);
            }

            mesh_root_task_deinit();

            if (esp_mesh_is_root()) {
                ret = mwifi_post_root_status(false);
                MDF_ERROR_BREAK(ret != MDF_OK, "<%s> mwifi_post_root_status", mdf_err_to_name(ret));
            }
            break;

        case MDF_EVENT_MWIFI_FIND_NETWORK: {
            MDF_LOGI("the root connects to another router with the same SSID");
            mwifi_config_t ap_config  = {0x0};
            wifi_second_chan_t second = 0;

            mdf_info_load(DEVICE_MESH_AP_CONFIG_STORE_KEY, &ap_config, sizeof(mwifi_config_t));
            esp_wifi_get_channel(&ap_config.channel, &second);
            esp_mesh_get_parent_bssid((mesh_addr_t *)ap_config.router_bssid);
            mwifi_set_config(&ap_config);
            mdf_info_save(DEVICE_MESH_AP_CONFIG_STORE_KEY, &ap_config, sizeof(mwifi_config_t));
            break;
        }

        case MDF_EVENT_MWIFI_ROUTING_TABLE_ADD:
        case MDF_EVENT_MWIFI_ROUTING_TABLE_REMOVE: {
            MDF_LOGI("total_num: %d", esp_mesh_get_total_node_num());

            if (esp_mesh_is_root()) {
                uint8_t sta_mac[MWIFI_ADDR_LEN] = {0x0};
                MDF_ERROR_ASSERT(esp_wifi_get_mac(ESP_IF_WIFI_STA, sta_mac));

                ret = mlink_notice_write("http", strlen("http"), sta_mac);
                MDF_ERROR_BREAK(ret != MDF_OK, "<%s> mlink_httpd_write", mdf_err_to_name(ret));

#ifdef CONFIG_MQTT_ENABLE
                mdf_err_t err = mesh_mqtt_update_topo();
                if (err != MDF_OK) {
                    MDF_LOGE("Update topo failed");
                }
#endif
            }

            break;
        }

#if 0
        case MDF_EVENT_MWIFI_ROOT_GOT_IP: {
            MDF_LOGI("Root obtains the IP address");
            led_indicator_stop(status_led_handle, BLINK_CONNECTING);
            if(switch_dev.backlight_disable){
                led_indicator_stop(status_led_handle, BLINK_CONNECTED);
                led_indicator_start(status_led_handle, BLINK_PROVISIONED);
            }else{
                led_indicator_start(status_led_handle, BLINK_CONNECTED);
            }
            mesh_root_task_init();

            /**
             * @brief Initialization mlink notice for inform the mobile phone that there is a mesh root device
             */
            ret = mlink_notice_init();
            MDF_ERROR_BREAK(ret != MDF_OK, "<%s> mlink_notice_init", mdf_err_to_name(ret));

            uint8_t sta_mac[MWIFI_ADDR_LEN] = {0x0};
            MDF_ERROR_ASSERT(esp_wifi_get_mac(ESP_IF_WIFI_STA, sta_mac));

            ret = mlink_notice_write("http", strlen("http"), sta_mac);
            MDF_ERROR_BREAK(ret != MDF_OK, "<%s> mlink_httpd_write", mdf_err_to_name(ret));

            /**
             * @brief start mlink http server for handle data between device and moblie phone.
             */
            ret = mlink_httpd_start();
            MDF_ERROR_BREAK(ret != MDF_OK, "<%s> mlink_httpd_start", mdf_err_to_name(ret));

            /**
             * @brief start root read/write task for hand data between mesh network and extern ip network.
             */
            if (!g_root_write_task_handle) {
                xTaskCreate(root_write_task, "root_write", 4 * 1024,
                            NULL, CONFIG_MDF_TASK_DEFAULT_PRIOTY, &g_root_write_task_handle);
            }

            if (!g_root_read_task_handle) {
                xTaskCreate(root_read_task, "root_read", 4 * 1024,
                            NULL, CONFIG_MDF_TASK_DEFAULT_PRIOTY, &g_root_read_task_handle);
            }
#ifdef CONFIG_MQTT_ENABLE
            /**
             * @brief start mqtt clent.
             */
            mesh_mqtt_start(mqtt_get_url(), mqtt_get_port());

            if (!g_root_mqtt_read_task_handle) {
                xTaskCreate(root_mqtt_read_task, "root_mqtt_read", 4 * 1024,
                            NULL, CONFIG_MDF_TASK_DEFAULT_PRIOTY, &g_root_mqtt_read_task_handle);
            }
#endif
            sntp_start_obtain_time();

            ret = mwifi_post_root_status(true);
            MDF_ERROR_BREAK(ret != MDF_OK, "<%s> mwifi_post_root_status", mdf_err_to_name(ret));

            break;
        }

        case MDF_EVENT_MWIFI_ROUTER_SWITCH:
        case MDF_EVENT_MWIFI_ROOT_LOST_IP:
            /** When the root node switches, sometimes no disconnected packets are received */
            led_indicator_stop(status_led_handle, BLINK_CONNECTED);
            led_indicator_start(status_led_handle, BLINK_CONNECTING);
            mesh_root_task_deinit();

            ret = mlink_notice_deinit();
            MDF_ERROR_BREAK(ret != MDF_OK, "<%s> mlink_notice_deinit", mdf_err_to_name(ret));

            ret = mlink_httpd_stop();
            MDF_ERROR_BREAK(ret != MDF_OK, "<%s> mlink_httpd_stop", mdf_err_to_name(ret));
#ifdef CONFIG_MQTT_ENABLE
            ret = mesh_mqtt_stop();
            MDF_ERROR_BREAK(ret != MDF_OK, "<%s> mesh_mqtt_stop", mdf_err_to_name(ret));
#endif
            sntp_stop_obtain_time();
            break;
#endif
        case MDF_EVENT_MWIFI_ROUTER_SWITCH:
        case MDF_EVENT_MWIFI_ROOT_LOST_IP:
            if(s_mwifi_connect_flag){
                s_mwifi_connect_flag = false;
                led_indicator_stop(status_led_handle, BLINK_CONNECTED);
                led_indicator_start(status_led_handle, BLINK_CONNECTING);
            }
            mesh_root_task_deinit();
            ret = mwifi_post_root_status(false);
            MDF_ERROR_BREAK(ret != MDF_OK, "<%s> mwifi_post_root_status", mdf_err_to_name(ret));
            break;

        case MDF_EVENT_MCONFIG_BLUFI_STA_DISCONNECTED:
            //light_driver_led_blink_start(128, 128, 0, 2000); /**< yellow blink */
            break;

        case MDF_EVENT_MCONFIG_BLUFI_STA_CONNECTED:
            //light_driver_led_blink_start(255, 128, 0, 2000); /**< orange blink */
            break;

        case MDF_EVENT_MCONFIG_BLUFI_FINISH:
            g_config_from_blufi_flag = true;
            __attribute__((fallthrough));

        case MDF_EVENT_MCONFIG_CHAIN_FINISH:
            //light_driver_led_blink_start(0, 255, 0, 2000); /**< green blink */
            break;

        case MDF_EVENT_MUPGRADE_STARTED:
            MDF_LOGI("Enter upgrade mode");
            led_indicator_start(status_led_handle, BLINK_UPDATING);
            break;

        case MDF_EVENT_MUPGRADE_STATUS: {
            MDF_LOGI("The upgrade progress is: %d%%", (int)ctx);
            mwifi_data_type_t mwifi_type = {
                .protocol = MLINK_PROTO_NOTICE,
            };
            ret = mwifi_write(NULL, &mwifi_type, "ota_status", strlen("ota_status"), true);
            MDF_ERROR_BREAK(ret != MDF_OK, "<%s> mwifi_write", mdf_err_to_name(ret));
            break;
        }

        case MDF_EVENT_MUPGRADE_FINISH:
            MDF_LOGI("Upgrade completed waiting for restart");
            led_indicator_stop(status_led_handle, BLINK_UPDATING);
            break;

        case MDF_EVENT_MLINK_SYSTEM_RESET:
            MDF_LOGW("Erase information saved in flash and system restart");

            ret = mdf_info_erase(MDF_SPACE_NAME);
            MDF_ERROR_BREAK(ret != 0, "Erase the information");
            device_default_record();
            device_save_record();
            esp_restart();
            break;

        case MDF_EVENT_MLINK_SYSTEM_REBOOT:
            MDF_LOGW("Restart PRO and APP CPUs");
            esp_restart();
            break;

        case MDF_EVENT_MLINK_SET_STATUS:
            xEventGroupSetBits(g_event_group_trigger, EVENT_GROUP_MLINK_SET_STATUS);
            #if 0
            /**
             * @brief Waiting for adjacent packets to be processed, avoiding loops
             */
            vTaskDelay(pdMS_TO_TICKS(50));

            /**
             * @brief Trigger handler
             */
            ret = mlink_trigger_handle(MLINK_COMMUNICATE_MESH);
            MDF_ERROR_BREAK(ret != MDF_OK, "<%s> mlink_trigger_handle", mdf_err_to_name(ret));
            #endif
            break;

        case MDF_EVENT_MLINK_BUFFER_FULL: {
            MDF_LOGI("Receive data from sniffer");

            /**
             * @brief Notify the APP to actively request the sniffer data received by the device
             */
            mwifi_data_type_t mwifi_type = {
                .protocol = MLINK_PROTO_NOTICE,
            };
            ret = mwifi_write(NULL, &mwifi_type, "sniffer", strlen("sniffer"), true);
            MDF_ERROR_BREAK(ret != MDF_OK, "<%s> mwifi_write", mdf_err_to_name(ret));
            break;
        }

        case MDF_EVENT_BUTTON_KEY_PUSH:{
            bool bTriggerHandle = false;
            int key_index = (int)ctx;
            MDF_LOGI("EVENT: %d push\r\n", key_index);
            buzzer_driver_start(1,100);
            //esp_mesh_waive_root(NULL, MESH_VOTE_REASON_ROOT_INITIATED);

            if(key_index != BUTTON_E_KEY_SET && key_index != BUTTON_E_KEY_SET2) {
                if(device_button_is_enable(key_index)) {
                    switch_driver_set_switch(key_index, !switch_driver_get_switch(key_index));
                    bTriggerHandle = true;
                }
            }

            if(bTriggerHandle) {
                mdf_event_loop_send(MDF_EVENT_MLINK_SET_STATUS, (void *)NULL);
            }
            s_button_key_push_flag = true;
        }
        break;

        case MDF_EVENT_BUTTON_KEY_RELEASE:
            s_button_key_push_flag = false;
        break;

        case MDF_EVENT_BUTTON_KEY_LONG_PRESS_PUSH:{
            int key_index = (int)ctx;
            MDF_LOGI("EVENT: %d long press\r\n", key_index);
            buzzer_driver_start(1,100);
            switch(key_index){
                case BUTTON_E_KEY_SET:
                case BUTTON_E_KEY_SET2:
                    if(device_button_is_enable(DEVICE_KEY_DIS_BIT_NETKEY) || key_index == BUTTON_E_KEY_SET2)
                        led_indicator_start(status_led_handle, BLINK_PROVISIONING);
                    break;

                default:
                    break;
            }
        }
        break;

        case MDF_EVENT_BUTTON_KEY_LONG_PRESS_RELEASE: {
            int key_index = (int)ctx;
            MDF_LOGI("EVENT: %d long release\r\n", key_index);
            switch(key_index){
                case BUTTON_E_KEY_SET:
                case BUTTON_E_KEY_SET2:
                    // send reset system event
                    if( device_button_is_enable(DEVICE_KEY_DIS_BIT_NETKEY) || (key_index == BUTTON_E_KEY_SET2) ){
                        mdf_event_loop_send(MDF_EVENT_MLINK_SYSTEM_RESET, (void *)NULL);
                    }
                break;

                default:
                    break;
            }
        }
        break;

        case MDF_EVENT_BUTTON_KEY_LONG_PRESS_INVAILD:
            buzzer_driver_start(1,100);
            led_indicator_stop(status_led_handle, BLINK_PROVISIONING);
            break;

        case MDF_EVENT_APP_SNTP_TIME_SYNC:
            mlink_time_broadcast();
            break;

#ifdef CONFIG_MQTT_ENABLE
        case MDF_EVENT_CUSTOM_MQTT_CONNECTED:
            MDF_LOGI("MQTT connect");
            mdf_err_t err = mesh_mqtt_subscribe();
            if (err != MDF_OK) {
                MDF_LOGE("Subscribe failed");
            }
            err = mesh_mqtt_update_topo();
            if (err != MDF_OK) {
                MDF_LOGE("Update topo failed");
            }
            break;

        case MDF_EVENT_CUSTOM_MQTT_DISCONNECTED:
            MDF_LOGI("MQTT disconnected");
            break;
#endif

        default:
            break;
    }

    if(s_button_key_push_flag){

    }else{
        //light_led_show_key_release();
    }

    return MDF_OK;
}

Debug Logs

I (584639) wifi:state: run -> init (fc0)
I (584641) wifi:new:<13,0>, old:<13,2>, ap:<13,2>, sta:<13,2>, prof:13
W (584643) wifi:rm mis
I (584644) wifi:new:<13,0>, old:<13,0>, ap:<13,2>, sta:<13,2>, prof:13
I (584658) [mwifi, 188]: Parent is disconnected, reason: 15
I (584659) [switch, 747]: event_loop_cb, event: 0x8
I (584660) mesh: [wifi]disconnected reason:15(4-way handshake timeout), continuous:4/max:12, non-root, vote(,stopped)<><>
I (584660) [switch, 847]: Parent is disconnected on station interface
I (584673) wifi:new:<13,2>, old:<13,0>, ap:<13,2>, sta:<13,2>, prof:13
I (584685) wifi:state: init -> auth (b0)
W (584686) [mesh_mqtt, 426]: <MDF_OK> MQTT client has not been started
I (584713) wifi:state: auth -> assoc (0)
I (584731) wifi:state: assoc -> run (10)
I (584735) mesh: <MESH_NWK_MIE_CHANGE><><><><ROOT ADDR><><><>
I (584736) mesh: <MESH_NWK_ROOT_ADDR>from assoc, layer:3, root_addr:a4:cf:12:0a:9b:15, root_cap:17
I (584739) mesh: <MESH_NWK_ROOT_ADDR>idle, layer:3, root_addr:a4:cf:12:0a:9b:15, conflict_roots.num:0<>
I (584751) [switch, 747]: event_loop_cb, event: 0xe
I (585850) [mesh_com, 605]: The current date/time in Shanghai is: Mon Apr 25 07:34:30 2022
I (587731) wifi:state: run -> init (fc0)
I (587732) wifi:new:<13,0>, old:<13,2>, ap:<13,2>, sta:<13,2>, prof:13
W (587734) wifi:rm mis
I (587735) wifi:new:<13,0>, old:<13,0>, ap:<13,2>, sta:<13,2>, prof:13
I (587748) [mwifi, 188]: Parent is disconnected, reason: 15
I (587749) [switch, 747]: event_loop_cb, event: 0x8
I (587750) mesh: [wifi]disconnected reason:15(4-way handshake timeout), continuous:5/max:12, non-root, vote(,stopped)<><>
I (587751) [switch, 847]: Parent is disconnected on station interface
I (587763) wifi:new:<13,2>, old:<13,0>, ap:<13,2>, sta:<13,2>, prof:13
I (587786) wifi:state: init -> auth (b0)
W (587774) [mesh_mqtt, 426]: <MDF_OK> MQTT client has not been started
I (587792) wifi:state: auth -> assoc (0)
I (587804) wifi:state: assoc -> run (10)
I (587809) mesh: <MESH_NWK_MIE_CHANGE><><><><ROOT ADDR><><><>
I (587810) mesh: <MESH_NWK_ROOT_ADDR>from assoc, layer:3, root_addr:a4:cf:12:0a:9b:15, root_cap:17
I (587822) mesh: <MESH_NWK_ROOT_ADDR>idle, layer:3, root_addr:a4:cf:12:0a:9b:15, conflict_roots.num:0<>
I (587824) [switch, 747]: event_loop_cb, event: 0xe
W (588858) [mwifi, 707]: <UNKNOWN ERROR> Node failed to send packets, dest_addr: ff:00:00:01:00:00, flag: 0x28, opt->type: 0x08, opt->len: 13, data->tos: 0, data: 0x3ffba07c, size: 149
W (588873) [mwifi, 960]: <UNKNOWN ERROR> Node failed to send packets, data_flag: 0x28, dest_mac: ff:00:00:01:00:00
W (588885) [device, 619]: <UNKNOWN ERROR> <UNKNOWN ERROR> mwifi_write
W (588886) [device, 712]: Report message fail
I (590807) wifi:state: run -> init (fc0)
I (590809) wifi:new:<13,0>, old:<13,2>, ap:<13,2>, sta:<13,2>, prof:13
W (590811) wifi:rm mis
I (590812) wifi:new:<13,0>, old:<13,0>, ap:<13,2>, sta:<13,2>, prof:13
I (590825) [mwifi, 188]: Parent is disconnected, reason: 15
I (590826) [switch, 747]: event_loop_cb, event: 0x8
I (590827) mesh: [wifi]disconnected reason:15(4-way handshake timeout), continuous:6/max:12, non-root, vote(,stopped)<><>
I (590827) [switch, 847]: Parent is disconnected on station interface
I (590840) wifi:new:<13,2>, old:<13,0>, ap:<13,2>, sta:<13,2>, prof:13
I (590852) wifi:state: init -> auth (b0)
W (590853) [mesh_mqtt, 426]: <MDF_OK> MQTT client has not been started
I (590870) wifi:state: auth -> assoc (0)
I (590883) wifi:state: assoc -> run (10)
I (590887) mesh: <MESH_NWK_MIE_CHANGE><><><><ROOT ADDR><><><>
I (590890) mesh: <MESH_NWK_ROOT_ADDR>from assoc, layer:3, root_addr:a4:cf:12:0a:9b:15, root_cap:17
I (590892) mesh: <MESH_NWK_ROOT_ADDR>idle, layer:3, root_addr:a4:cf:12:0a:9b:15, conflict_roots.num:0<>
I (590905) [switch, 747]: event_loop_cb, event: 0xe
I (591850) [mesh_utils, 150]: System information, channel: [13/2], layer: -1, self mac: c4:4f:33:04:5a:55, parent bssid: 94:b9:7e:f0:ab:e5, parent rssi: -47, node num: 17, free heap: 116092
I (593883) wifi:state: run -> init (fc0)
I (593885) wifi:new:<13,0>, old:<13,2>, ap:<13,2>, sta:<13,2>, prof:13
W (593887) wifi:rm mis
I (593888) wifi:new:<13,0>, old:<13,0>, ap:<13,2>, sta:<13,2>, prof:13
I (593902) [mwifi, 188]: Parent is disconnected, reason: 15
I (593903) [switch, 747]: event_loop_cb, event: 0x8
I (593904) mesh: [wifi]disconnected reason:15(4-way handshake timeout), continuous:7/max:12, non-root, vote(,stopped)<><>
I (593904) [switch, 847]: Parent is disconnected on station interface
I (593917) wifi:new:<13,2>, old:<13,0>, ap:<13,2>, sta:<13,2>, prof:13
I (593929) wifi:state: init -> auth (b0)
W (593930) [mesh_mqtt, 426]: <MDF_OK> MQTT client has not been started
I (593945) wifi:state: auth -> assoc (0)
I (593956) wifi:state: assoc -> run (10)
I (593958) mesh: <MESH_NWK_MIE_CHANGE><><><><ROOT ADDR><><><>
I (593959) mesh: <MESH_NWK_ROOT_ADDR>from assoc, layer:3, root_addr:a4:cf:12:0a:9b:15, root_cap:17
I (593965) mesh: <MESH_NWK_ROOT_ADDR>idle, layer:3, root_addr:a4:cf:12:0a:9b:15, conflict_roots.num:0<>
I (593977) [switch, 747]: event_loop_cb, event: 0xe
I (596958) wifi:state: run -> init (fc0)
I (596960) wifi:new:<13,0>, old:<13,2>, ap:<13,2>, sta:<13,2>, prof:13
W (596962) wifi:rm mis
I (596962) wifi:new:<13,0>, old:<13,0>, ap:<13,2>, sta:<13,2>, prof:13
I (596975) [mwifi, 188]: Parent is disconnected, reason: 15
I (596977) [switch, 747]: event_loop_cb, event: 0x8
I (596978) mesh: [wifi]disconnected reason:15(4-way handshake timeout), continuous:8/max:12, non-root, vote(,stopped)<><>
I (596989) [switch, 847]: Parent is disconnected on station interface
I (596991) wifi:new:<13,2>, old:<13,0>, ap:<13,2>, sta:<13,2>, prof:13
I (597013) wifi:state: init -> auth (b0)
W (597001) [mesh_mqtt, 426]: <MDF_OK> MQTT client has not been started
I (597018) wifi:state: auth -> assoc (0)
I (597030) wifi:state: assoc -> run (10)
I (597031) mesh: <MESH_NWK_MIE_CHANGE><><><><ROOT ADDR><><><>
I (597032) mesh: <MESH_NWK_ROOT_ADDR>from assoc, layer:3, root_addr:a4:cf:12:0a:9b:15, root_cap:17
I (597040) mesh: <MESH_NWK_ROOT_ADDR>idle, layer:3, root_addr:a4:cf:12:0a:9b:95, conflict_roots.num:0<>
I (597052) [switch, 747]: event_loop_cb, event: 0xe
Jiangyafeng commented 2 years ago

@zhuangqingshu 对于路由器 WIFI “信道13,隐藏SSID”,这个时候的话, 如果路由器设置为隐藏 ssid 并且处于 12 13 14 信道 默认情况下确实是连不上的。需要将国家码配置成手动,CN 1-13。 你可以通过 esp_wifi_set_country 这个API来设置。

更为详细的文档描述,可以查看链接:https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/wifi.html#wi-fi-country-code,这里的说明。

zhuangqingshu commented 2 years ago

对于隐藏SSID连不上这个问题,我是能够接受的。 问题是第三步:把路由器WIFI参数 从 “信道13,隐藏SSID” -> “信道13,不隐藏SSID”, 一个设备掉线,其余设备正常连接。 这个掉线的问题就比较奇怪,而且单独重启设备也不能恢复。 提供的日志也是掉线设备的日志。

Jiangyafeng commented 2 years ago

从你的log来看,I (590807) wifi:state: run -> init (fc0),可以看出 0x0f 是代表 4次 握手失败,详细的你可以查看Wi-Fi Reason Code链接:https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/wifi.html#wi-fi-reason-code 0xC0代表着 DAUTH(解认证帧)。

所以你需要查询一下,是不是该节点的 wifi ssid 和 pwd 不正确导致的一直无法链接成功。一般四次握手失败,都是wifi 的ssid 或者pwd 输入错误导致的。