From a5086e302dab8e5a6cf2b92afc228589a1939d4a Mon Sep 17 00:00:00 2001 From: Kapil Gupta Date: Thu, 20 May 2021 11:14:26 +0530 Subject: [PATCH] esp_wifi: Add support for regdomain database --- components/esp_wifi/include/esp_wifi.h | 64 ++++++++++++++++++++++---- components/esp_wifi/lib | 2 +- 2 files changed, 56 insertions(+), 10 deletions(-) diff --git a/components/esp_wifi/include/esp_wifi.h b/components/esp_wifi/include/esp_wifi.h index 150d3123e7..725b85562f 100644 --- a/components/esp_wifi/include/esp_wifi.h +++ b/components/esp_wifi/include/esp_wifi.h @@ -605,19 +605,20 @@ esp_err_t esp_wifi_get_channel(uint8_t *primary, wifi_second_chan_t *second); /** * @brief configure country info * - * @attention 1. The default country is {.cc="CN", .schan=1, .nchan=13, policy=WIFI_COUNTRY_POLICY_AUTO} - * @attention 2. When the country policy is WIFI_COUNTRY_POLICY_AUTO, the country info of the AP to which + * @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. + * Please use esp_wifi_set_country_code instead. + * @attention 2. The default country is world safe mode {.cc="01", .schan=1, .nchan=11, policy=WIFI_COUNTRY_POLICY_MANUAL} + * @attention 3. 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="USA", .schan=1, .nchan=11} * 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 - * from the AP the country info is set back 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. - * @attention 3. When the country policy is WIFI_COUNTRY_POLICY_MANUAL, always use the configured country info. - * @attention 4. 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 changed also. - * @attention 5. The country configuration is stored into flash. - * @attention 6. This API doesn't validate the per-country rules, it's up to the user to fill in all fields according to - * local regulations. + * @attention 4. 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 + * 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. When this API is called, the PHY init data will switch to the PHY init data type corresponding to the * country info. * @@ -1243,6 +1244,51 @@ esp_err_t esp_wifi_config_espnow_rate(wifi_interface_t ifx, wifi_phy_rate_t rate */ esp_err_t esp_wifi_set_connectionless_wake_interval(uint16_t interval); +/** + * @brief configure country + * + * @attention 1. When ieee80211d_enabled, the country info of the AP to which + * the station is connected is used. E.g. if the configured country is US + * and the country info of the AP to which the station is connected is JP + * then the country info that will be used is JP. If the station disconnected + * from the AP the country info is set back to the country info of the station automatically, + * US in the example. + * @attention 2. When ieee80211d_enabled is disabled, then the configured country info is used always. + * @attention 3. 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. + * @attention 4. The country configuration is stored into flash. + * @attention 5. When this API is called, the PHY init data will switch to the PHY init data type corresponding to the + * country info. + * @attention 6. Supported country codes are "01"(world safe mode) "AT","AU","BE","BG","BR", + * "CA","CH","CN","CY","CZ","DE","DK","EE","ES","FI","FR","GB","GR","HK","HR","HU", + * "IE","IN","IS","IT","JP","KR","LI","LT","LU","LV","MT","MX","NL","NO","NZ","PL","PT", + * "RO","SE","SI","SK","TW","US" + * + * @attention 7. When country code "01" (world safe mode) is set, SoftAP mode won't contain country IE. + * @attention 8. The default country is world safe mode {.cc="01", .schan=1, .nchan=11, policy=WIFI_COUNTRY_POLICY_MANUAL} + * + * @param country the configured country ISO code + * @param ieee80211d_enabled 802.11d is enabled or not + * + * @return + * - ESP_OK: succeed + * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init + * - ESP_ERR_INVALID_ARG: invalid argument + */ +esp_err_t esp_wifi_set_country_code(const char *country, bool ieee80211d_enabled); + +/** + * @brief get the current country code + * + * @param country country code + * + * @return + * - ESP_OK: succeed + * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init + * - ESP_ERR_INVALID_ARG: invalid argument + */ +esp_err_t esp_wifi_get_country_code(char *country); + #ifdef __cplusplus } #endif diff --git a/components/esp_wifi/lib b/components/esp_wifi/lib index dfdccf010e..8bdee7d79b 160000 --- a/components/esp_wifi/lib +++ b/components/esp_wifi/lib @@ -1 +1 @@ -Subproject commit dfdccf010e79e217faeff1bcf0dd1f40d67388b3 +Subproject commit 8bdee7d79b54488f1732121233d8b93561842971