Skip to content

Commit 410e138

Browse files
author
Jiang Jiang Jian
committed
Merge branch 'feature/wifi_support_regdomain' into 'master'
feat(wifi):wifi support regdomain See merge request espressif/esp-idf!31441
2 parents 4f3e643 + cceb2c4 commit 410e138

File tree

9 files changed

+4393
-1
lines changed

9 files changed

+4393
-1
lines changed

components/esp_wifi/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ if(CONFIG_ESP_WIFI_ENABLED OR CONFIG_ESP_HOST_WIFI_ENABLED)
4040
"src/wifi_default_ap.c"
4141
"${idf_target}/esp_adapter.c")
4242

43+
44+
list(APPEND srcs "regulatory/esp_wifi_regulatory.c")
45+
4346
if(CONFIG_ESP_NETIF_USES_TCPIP_WITH_BSD_API AND CONFIG_LWIP_IPV4)
4447
list(APPEND srcs
4548
"src/smartconfig_ack.c")

components/esp_wifi/include/esp_wifi_types_generic.h

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1446,6 +1446,35 @@ typedef struct {
14461446
bool dcm; /**< Using dcm rate to send frame */
14471447
} wifi_tx_rate_config_t;
14481448

1449+
#define WIFI_MAX_SUPPORT_COUNTRY_NUM 175 /**< max number of supported countries */
1450+
#ifdef CONFIG_SOC_WIFI_SUPPORT_5G
1451+
#define WIFI_MAX_REGULATORY_RULE_NUM 7 /**< max number of regulatory rules */
1452+
#else
1453+
#define WIFI_MAX_REGULATORY_RULE_NUM 2 /**< max number of regulatory rules */
1454+
#endif
1455+
1456+
/** Argument structure for regulatory rule */
1457+
typedef struct {
1458+
uint8_t start_channel; /**< start channel of regulatory rule */
1459+
uint8_t end_channel; /**< end channel of regulatory rule */
1460+
uint16_t max_bandwidth : 3; /**< max bandwidth(MHz) of regulatory rule, 1:20M, 2:40M, 3:80M, 4:160M */
1461+
uint16_t max_eirp : 6; /**< indicates the maximum Equivalent Isotropically Radiated Power (EIRP), typically measured in dBm */
1462+
uint16_t is_dfs : 1; /**< flag to identify dfs channel */
1463+
uint16_t reserved : 6; /**< reserved */
1464+
} wifi_reg_rule_t;
1465+
1466+
/** Argument structure for regdomain */
1467+
typedef struct {
1468+
uint8_t n_reg_rules; /**< number of regulatory rules */
1469+
wifi_reg_rule_t reg_rules[WIFI_MAX_REGULATORY_RULE_NUM]; /**< array of regulatory rules*/
1470+
} wifi_regulatory_t;
1471+
1472+
/** Argument structure for regdomain */
1473+
typedef struct {
1474+
char cn[2]; /**< country code string */
1475+
uint8_t regulatory_type; /**< regulatory type of country */
1476+
} wifi_regdomain_t;
1477+
14491478
#ifdef __cplusplus
14501479
}
14511480
#endif
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# REGULATORY
2+
3+
## Introduction
4+
`esp_wifi_regulatory.txt` and `esp_wifi_regulatory.c` defines wireless communication regulations for different countries and regions to ensure that the device operates in compliance with local regulations.
5+
6+
`esp_wifi_regulatory.c` is generated from `esp_wifi_regulatory.txt` by using the `reg2fw.py` script.
7+
8+
The num of all suppported countries in `esp_wifi_regulatory.txt` is `WIFI_MAX_SUPPORT_COUNTRY_NUM` that is defined in `esp_wifi_types_generic.h`
9+
10+
- Generate `esp_wifi_regulatory.c`
11+
- `cd ~/esp-idf/components/esp_wifi/regulatory`
12+
- `python reg2fw.py`

0 commit comments

Comments
 (0)