esp32: support wifi country code
1. Add completed support for WiFi country code 2. Modify esp_wifi_set_country API
This commit is contained in:
parent
fd02668d8b
commit
762f8da078
3 changed files with 29 additions and 13 deletions
|
@ -517,23 +517,34 @@ esp_err_t esp_wifi_set_channel(uint8_t primary, wifi_second_chan_t second);
|
|||
esp_err_t esp_wifi_get_channel(uint8_t *primary, wifi_second_chan_t *second);
|
||||
|
||||
/**
|
||||
* @brief Set country code
|
||||
* The default value is WIFI_COUNTRY_CN
|
||||
* @brief configure country info
|
||||
*
|
||||
* @param country country type
|
||||
* @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, use the country info of AP to which
|
||||
* the station is connected. E.g. if the configured country info is {.cc="USA", .schan=1, .nchan=11},
|
||||
* the country info of the AP to which the station is connected is {.cc="JP", .schan=1, .nchan=14},
|
||||
* then our country info is {.cc="JP", .schan=1, .nchan=14}. If the station disconnected
|
||||
* from the AP, the country info back to {.cc="USA", .schan=1, .nchan=11} again.
|
||||
* @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 not 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.
|
||||
*
|
||||
* @param country the configured country info
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: succeed
|
||||
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
|
||||
* - ESP_ERR_WIFI_ARG: invalid argument
|
||||
* - others: refer to error code in esp_err.h
|
||||
*/
|
||||
esp_err_t esp_wifi_set_country(wifi_country_t country);
|
||||
esp_err_t esp_wifi_set_country(wifi_country_t *country);
|
||||
|
||||
/**
|
||||
* @brief Get country code
|
||||
* @brief get the current country info
|
||||
*
|
||||
* @param country store current country
|
||||
* @param country country info
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: succeed
|
||||
|
@ -542,6 +553,7 @@ esp_err_t esp_wifi_set_country(wifi_country_t country);
|
|||
*/
|
||||
esp_err_t esp_wifi_get_country(wifi_country_t *country);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Set MAC address of the ESP32 WiFi station or the soft-AP interface.
|
||||
*
|
||||
|
|
|
@ -40,11 +40,15 @@ typedef esp_interface_t wifi_interface_t;
|
|||
#define WIFI_IF_AP ESP_IF_WIFI_AP
|
||||
|
||||
typedef enum {
|
||||
WIFI_COUNTRY_CN = 0, /**< country China, channel range [1, 14] */
|
||||
WIFI_COUNTRY_JP, /**< country Japan, channel range [1, 14] */
|
||||
WIFI_COUNTRY_US, /**< country USA, channel range [1, 11] */
|
||||
WIFI_COUNTRY_EU, /**< country Europe, channel range [1, 13] */
|
||||
WIFI_COUNTRY_MAX
|
||||
WIFI_COUNTRY_POLICY_AUTO, /**< Country policy is auto, use the country info of AP to which the station is connected */
|
||||
WIFI_COUNTRY_POLICY_MANUAL, /**< Country policy is manual, always use the configured country info */
|
||||
} wifi_country_policy_t;
|
||||
|
||||
typedef struct {
|
||||
char cc[3]; /**< country code string */
|
||||
uint8_t schan; /**< start channel */
|
||||
uint8_t nchan; /**< total channel number */
|
||||
wifi_country_policy_t policy; /**< country policy */
|
||||
} wifi_country_t;
|
||||
|
||||
typedef enum {
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit c71367fb572b7710ce7950999ec5e67af57a105c
|
||||
Subproject commit 70e346552061b635d26079709348676446999cf9
|
Loading…
Reference in a new issue