Merge branch 'mesh/bugfix_v3.3_cont' into 'master'

mesh: bugfix

See merge request idf/esp-idf!4009
This commit is contained in:
Jiang Jiang Jian 2018-12-28 14:08:18 +08:00
commit 97eecfa1b2
3 changed files with 38 additions and 5 deletions

View file

@ -624,6 +624,7 @@ esp_err_t esp_mesh_stop(void);
* - If the packet is to an external IP network, set this parameter to the IPv4:PORT combination.
* This packet will be delivered to the root firstly, then the root will forward this packet to the final IP server address.
* @param[in] data pointer to a sending mesh packet
* - Field size should not exceed MESH_MPS. Note that the size of one mesh packet should not exceed MESH_MTU.
* - Field proto should be set to data protocol in use (default is MESH_PROTO_BIN for binary).
* - Field tos should be set to transmission tos (type of service) in use (default is MESH_TOS_P2P for point-to-point reliable).
* @param[in] flag bitmap for data sent
@ -1440,6 +1441,14 @@ esp_err_t esp_mesh_disconnect(void);
*/
esp_err_t esp_mesh_connect(void);
/**
* @brief Flush scan result
*
* @return
* - ESP_OK
*/
esp_err_t esp_mesh_flush_scan_result(void);
/**
* @brief Cause the root device to add Channel Switch Announcement Element (CSA IE) to beacon
* - Set the new channel
@ -1457,6 +1466,18 @@ esp_err_t esp_mesh_connect(void);
*/
esp_err_t esp_mesh_switch_channel(const uint8_t *new_bssid, int csa_newchan, int csa_count);
/**
* @brief Get the router BSSID
*
* @param[out] router_bssid pointer to the router BSSID
*
* @return
* - ESP_OK
* - ESP_ERR_WIFI_NOT_INIT
* - ESP_ERR_WIFI_ARG
*/
esp_err_t esp_mesh_get_router_bssid(uint8_t *router_bssid);
#ifdef __cplusplus
}
#endif

@ -1 +1 @@
Subproject commit a709618051ef9da220b3b8a8b860e76d854d0e2f
Subproject commit 9e729f3065e5b074a92e7515562f7d5a4e087777

View file

@ -69,6 +69,7 @@ void mesh_scan_done_handler(int num)
i, record.ssid, assoc.layer, assoc.layer_cap, assoc.assoc,
assoc.assoc_cap, assoc.layer2_cap, MAC2STR(record.bssid),
record.primary, record.rssi, MAC2STR(assoc.mesh_id), assoc.encrypted ? "IE Encrypted" : "IE Unencrypted");
#ifdef MESH_SET_NODE
if (assoc.mesh_type != MESH_IDLE && assoc.layer_cap
&& assoc.assoc < assoc.assoc_cap && record.rssi > -70) {
@ -82,6 +83,7 @@ void mesh_scan_done_handler(int num)
my_type = MESH_LEAF;
}
my_layer = parent_assoc.layer + 1;
break;
}
}
#endif
@ -99,7 +101,7 @@ void mesh_scan_done_handler(int num)
#endif
}
}
esp_mesh_flush_scan_result();
if (parent_found) {
/*
* parent
@ -110,11 +112,20 @@ void mesh_scan_done_handler(int num)
sizeof(parent_record.ssid));
parent.sta.bssid_set = 1;
memcpy(&parent.sta.bssid, parent_record.bssid, 6);
ESP_ERROR_CHECK(esp_mesh_set_ap_authmode(parent_record.authmode));
if (my_type == MESH_ROOT) {
if (parent_record.authmode != WIFI_AUTH_OPEN) {
memcpy(&parent.sta.password, CONFIG_MESH_ROUTER_PASSWD,
strlen(CONFIG_MESH_ROUTER_PASSWD));
}
ESP_LOGW(MESH_TAG, "<PARENT>%s, "MACSTR", channel:%u, rssi:%d",
parent_record.ssid, MAC2STR(parent_record.bssid),
parent_record.primary, parent_record.rssi);
} else {
if (parent_record.authmode != WIFI_AUTH_OPEN) {
memcpy(&parent.sta.password, CONFIG_MESH_AP_PASSWD,
strlen(CONFIG_MESH_AP_PASSWD));
}
ESP_LOGW(MESH_TAG,
"<PARENT>%s, layer:%d/%d, assoc:%d/%d, %d, "MACSTR", channel:%u, rssi:%d",
parent_record.ssid, parent_assoc.layer,
@ -131,13 +142,14 @@ void mesh_scan_done_handler(int num)
if (CONFIG_MESH_IE_CRYPTO_FUNCS) {
/* modify IE crypto key */
ESP_LOGW(MESH_TAG, "<Config>modify IE crypto key to %s", CONFIG_MESH_IE_CRYPTO_KEY);
ESP_ERROR_CHECK(esp_mesh_set_ie_crypto_funcs(&g_wifi_default_mesh_crypto_funcs));
ESP_ERROR_CHECK(esp_mesh_set_ie_crypto_key(CONFIG_MESH_IE_CRYPTO_KEY, strlen(CONFIG_MESH_IE_CRYPTO_KEY)));
} else {
/* disable IE crypto */
ESP_LOGW(MESH_TAG, "<Config>disable IE crypto");
ESP_ERROR_CHECK(esp_mesh_set_ie_crypto_funcs(NULL));
}
ESP_ERROR_CHECK(esp_wifi_scan_stop());
esp_wifi_scan_stop();
scan_config.show_hidden = 1;
scan_config.scan_type = WIFI_SCAN_TYPE_PASSIVE;
ESP_ERROR_CHECK(esp_wifi_scan_start(&scan_config, 0));
@ -156,7 +168,7 @@ void mesh_event_handler(mesh_event_t event)
ESP_LOGI(MESH_TAG, "<MESH_EVENT_STARTED>ID:"MACSTR"", MAC2STR(id.addr));
mesh_layer = esp_mesh_get_layer();
ESP_ERROR_CHECK(esp_mesh_set_self_organized(0, 0));
ESP_ERROR_CHECK(esp_wifi_scan_stop());
esp_wifi_scan_stop();
wifi_scan_config_t scan_config = { 0 };
/* mesh softAP is hidden */
scan_config.show_hidden = 1;
@ -214,7 +226,7 @@ void mesh_event_handler(mesh_event_t event)
mesh_disconnected_indicator();
mesh_layer = esp_mesh_get_layer();
if (event.info.disconnected.reason == WIFI_REASON_ASSOC_TOOMANY) {
ESP_ERROR_CHECK(esp_wifi_scan_stop());
esp_wifi_scan_stop();
scan_config.show_hidden = 1;
scan_config.scan_type = WIFI_SCAN_TYPE_PASSIVE;
ESP_ERROR_CHECK(esp_wifi_scan_start(&scan_config, 0));