esp_wifi: fix disconnect after set country issue

This commit is contained in:
muhaidong
2022-07-24 19:46:29 +08:00
parent 2f929685fc
commit 2dff79510d
2 changed files with 14 additions and 12 deletions

View File

@ -600,18 +600,19 @@ esp_err_t esp_wifi_get_channel(uint8_t *primary, wifi_second_chan_t *second);
* @attention 1. It is discouraged to call this API since this doesn't validate the per-country rules, * @attention 1. It is discouraged to call this API since this doesn't validate the per-country rules,
* it's up to the user to fill in all fields according to local regulations. * it's up to the user to fill in all fields according to local regulations.
* Please use esp_wifi_set_country_code instead. * Please use esp_wifi_set_country_code instead.
* @attention 2. The default country is CHINA {.cc="CN", .schan=1, .nchan=13, policy=WIFI_COUNTRY_POLICY_AUTO} * @attention 2. The default country is CHINA {.cc="CN", .schan=1, .nchan=13, .policy=WIFI_COUNTRY_POLICY_AUTO}.
* @attention 3. When the country policy is WIFI_COUNTRY_POLICY_AUTO, the country info of the AP to which * @attention 3. The third octect of country code string is one of the following: ' ', 'O', 'I', 'X', otherwise it is considered as ' '.
* the station is connected is used. E.g. if the configured country info is {.cc="USA", .schan=1, .nchan=11} * @attention 4. When the country policy is WIFI_COUNTRY_POLICY_AUTO, the country info of the AP to which
* the station is connected is used. E.g. if the configured country info is {.cc="US", .schan=1, .nchan=11}
* and the country info of the AP to which the station is connected is {.cc="JP", .schan=1, .nchan=14} * and the country info of the AP to which the station is connected is {.cc="JP", .schan=1, .nchan=14}
* then the country info that will be used is {.cc="JP", .schan=1, .nchan=14}. If the station disconnected * then the country info that will be used is {.cc="JP", .schan=1, .nchan=14}. If the station disconnected
* from the AP the country info is set back to the country info of the station automatically, * from the AP the country info is set back to the country info of the station automatically,
* {.cc="US", .schan=1, .nchan=11} in the example. * {.cc="US", .schan=1, .nchan=11} in the example.
* @attention 4. When the country policy is WIFI_COUNTRY_POLICY_MANUAL, then the configured country info is used always. * @attention 5. When the country policy is WIFI_COUNTRY_POLICY_MANUAL, then the configured country info is used always.
* @attention 5. When the country info is changed because of configuration or because the station connects to a different * @attention 6. When the country info is changed because of configuration or because the station connects to a different
* external AP, the country IE in probe response/beacon of the soft-AP is also changed. * external AP, the country IE in probe response/beacon of the soft-AP is also changed.
* @attention 6. The country configuration is stored into flash. * @attention 7. The country configuration is stored into flash.
* @attention 7. When this API is called, the PHY init data will switch to the PHY init data type corresponding to the * @attention 8. When this API is called, the PHY init data will switch to the PHY init data type corresponding to the
* country info. * country info.
* *
* @param country the configured country info * @param country the configured country info
@ -909,7 +910,7 @@ esp_err_t esp_wifi_set_vendor_ie_cb(esp_vendor_ie_cb_t cb, void *ctx);
* @return * @return
* - ESP_OK: succeed * - ESP_OK: succeed
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
* - ESP_ERR_WIFI_NOT_START: WiFi is not started by esp_wifi_start * - ESP_ERR_WIFI_NOT_STARTED: WiFi is not started by esp_wifi_start
* - ESP_ERR_WIFI_ARG: invalid argument, e.g. parameter is out of range * - ESP_ERR_WIFI_ARG: invalid argument, e.g. parameter is out of range
*/ */
esp_err_t esp_wifi_set_max_tx_power(int8_t power); esp_err_t esp_wifi_set_max_tx_power(int8_t power);
@ -922,7 +923,7 @@ esp_err_t esp_wifi_set_max_tx_power(int8_t power);
* @return * @return
* - ESP_OK: succeed * - ESP_OK: succeed
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
* - ESP_ERR_WIFI_NOT_START: WiFi is not started by esp_wifi_start * - ESP_ERR_WIFI_NOT_STARTED: WiFi is not started by esp_wifi_start
* - ESP_ERR_WIFI_ARG: invalid argument * - ESP_ERR_WIFI_ARG: invalid argument
*/ */
esp_err_t esp_wifi_get_max_tx_power(int8_t *power); esp_err_t esp_wifi_get_max_tx_power(int8_t *power);
@ -1018,7 +1019,7 @@ esp_err_t esp_wifi_set_csi_rx_cb(wifi_csi_cb_t cb, void *ctx);
* return * return
* - ESP_OK: succeed * - ESP_OK: succeed
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
* - ESP_ERR_WIFI_NOT_START: WiFi is not started by esp_wifi_start or promiscuous mode is not enabled * - ESP_ERR_WIFI_NOT_STARTED: WiFi is not started by esp_wifi_start or promiscuous mode is not enabled
* - ESP_ERR_INVALID_ARG: invalid argument * - ESP_ERR_INVALID_ARG: invalid argument
*/ */
esp_err_t esp_wifi_set_csi_config(const wifi_csi_config_t *config); esp_err_t esp_wifi_set_csi_config(const wifi_csi_config_t *config);
@ -1031,7 +1032,7 @@ esp_err_t esp_wifi_set_csi_config(const wifi_csi_config_t *config);
* return * return
* - ESP_OK: succeed * - ESP_OK: succeed
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
* - ESP_ERR_WIFI_NOT_START: WiFi is not started by esp_wifi_start or promiscuous mode is not enabled * - ESP_ERR_WIFI_NOT_STARTED: WiFi is not started by esp_wifi_start or promiscuous mode is not enabled
* - ESP_ERR_INVALID_ARG: invalid argument * - ESP_ERR_INVALID_ARG: invalid argument
*/ */
esp_err_t esp_wifi_set_csi(bool en); esp_err_t esp_wifi_set_csi(bool en);
@ -1244,6 +1245,7 @@ esp_err_t esp_wifi_set_connectionless_wake_interval(uint16_t interval);
* *
* @attention 7. When country code "01" (world safe mode) is set, SoftAP mode won't contain country IE. * @attention 7. When country code "01" (world safe mode) is set, SoftAP mode won't contain country IE.
* @attention 8. The default country is "CN" and ieee80211d_enabled is TRUE. * @attention 8. The default country is "CN" and ieee80211d_enabled is TRUE.
* @attention 9. The third octect of country code string is one of the following: ' ', 'O', 'I', 'X', otherwise it is considered as ' '.
* *
* @param country the configured country ISO code * @param country the configured country ISO code
* @param ieee80211d_enabled 802.11d is enabled or not * @param ieee80211d_enabled 802.11d is enabled or not