diff --git a/README.md b/README.md
index 8cf3791b0c..481c40e028 100644
--- a/README.md
+++ b/README.md
@@ -117,7 +117,7 @@ Following table summarizes this entire discussion.
Chipsets supported |
- ESP32, ESP32-C2/C3/C6/S2/S3 |
+ ESP32, ESP32-C2/C3/C5/C6/S2/S3 |
ESP32, ESP32-C2/C3/C6/S2/S3 |
diff --git a/esp_hosted_fg/README.md b/esp_hosted_fg/README.md
index 0e99fda84e..0b1b056517 100644
--- a/esp_hosted_fg/README.md
+++ b/esp_hosted_fg/README.md
@@ -49,9 +49,8 @@ ESP-Hosted-FG solution provides following WLAN and BT/BLE features to the host:
ESP-Hosted-FG solution is supported on following ESP boards:
-| Supported Targets | ESP32 | ESP32-S2 | ESP32-S3 | ESP32-C2 | ESP32-C3 | ESP32-C6 |
-| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- |
-
+| Supported Targets | ESP32 | ESP32-S2 | ESP32-S3 | ESP32-C2 | ESP32-C3 | ESP32-C5 | ESP32-C6 |
+| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- |
### 1.3 Supported Hosts
diff --git a/esp_hosted_fg/common/esp_hosted_config.pb-c.c b/esp_hosted_fg/common/esp_hosted_config.pb-c.c
index 1970b211fd..717f7303f8 100644
--- a/esp_hosted_fg/common/esp_hosted_config.pb-c.c
+++ b/esp_hosted_fg/common/esp_hosted_config.pb-c.c
@@ -2795,7 +2795,7 @@ const ProtobufCMessageDescriptor ctrl_msg__req__get_apconfig__descriptor =
(ProtobufCMessageInit) ctrl_msg__req__get_apconfig__init,
NULL,NULL,NULL /* reserved[123] */
};
-static const ProtobufCFieldDescriptor ctrl_msg__resp__get_apconfig__field_descriptors[6] =
+static const ProtobufCFieldDescriptor ctrl_msg__resp__get_apconfig__field_descriptors[7] =
{
{
"ssid",
@@ -2869,8 +2869,21 @@ static const ProtobufCFieldDescriptor ctrl_msg__resp__get_apconfig__field_descri
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
+ {
+ "band_mode",
+ 7,
+ PROTOBUF_C_LABEL_NONE,
+ PROTOBUF_C_TYPE_INT32,
+ 0, /* quantifier_offset */
+ offsetof(CtrlMsgRespGetAPConfig, band_mode),
+ NULL,
+ NULL,
+ 0, /* flags */
+ 0,NULL,NULL /* reserved1,reserved2, etc */
+ },
};
static const unsigned ctrl_msg__resp__get_apconfig__field_indices_by_name[] = {
+ 6, /* field[6] = band_mode */
1, /* field[1] = bssid */
3, /* field[3] = chnl */
5, /* field[5] = resp */
@@ -2881,7 +2894,7 @@ static const unsigned ctrl_msg__resp__get_apconfig__field_indices_by_name[] = {
static const ProtobufCIntRange ctrl_msg__resp__get_apconfig__number_ranges[1 + 1] =
{
{ 1, 0 },
- { 0, 6 }
+ { 0, 7 }
};
const ProtobufCMessageDescriptor ctrl_msg__resp__get_apconfig__descriptor =
{
@@ -2891,14 +2904,14 @@ const ProtobufCMessageDescriptor ctrl_msg__resp__get_apconfig__descriptor =
"CtrlMsgRespGetAPConfig",
"",
sizeof(CtrlMsgRespGetAPConfig),
- 6,
+ 7,
ctrl_msg__resp__get_apconfig__field_descriptors,
ctrl_msg__resp__get_apconfig__field_indices_by_name,
1, ctrl_msg__resp__get_apconfig__number_ranges,
(ProtobufCMessageInit) ctrl_msg__resp__get_apconfig__init,
NULL,NULL,NULL /* reserved[123] */
};
-static const ProtobufCFieldDescriptor ctrl_msg__req__connect_ap__field_descriptors[5] =
+static const ProtobufCFieldDescriptor ctrl_msg__req__connect_ap__field_descriptors[6] =
{
{
"ssid",
@@ -2960,8 +2973,21 @@ static const ProtobufCFieldDescriptor ctrl_msg__req__connect_ap__field_descripto
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
+ {
+ "band_mode",
+ 6,
+ PROTOBUF_C_LABEL_NONE,
+ PROTOBUF_C_TYPE_INT32,
+ 0, /* quantifier_offset */
+ offsetof(CtrlMsgReqConnectAP, band_mode),
+ NULL,
+ NULL,
+ 0, /* flags */
+ 0,NULL,NULL /* reserved1,reserved2, etc */
+ },
};
static const unsigned ctrl_msg__req__connect_ap__field_indices_by_name[] = {
+ 5, /* field[5] = band_mode */
2, /* field[2] = bssid */
3, /* field[3] = is_wpa3_supported */
4, /* field[4] = listen_interval */
@@ -2971,7 +2997,7 @@ static const unsigned ctrl_msg__req__connect_ap__field_indices_by_name[] = {
static const ProtobufCIntRange ctrl_msg__req__connect_ap__number_ranges[1 + 1] =
{
{ 1, 0 },
- { 0, 5 }
+ { 0, 6 }
};
const ProtobufCMessageDescriptor ctrl_msg__req__connect_ap__descriptor =
{
@@ -2981,14 +3007,14 @@ const ProtobufCMessageDescriptor ctrl_msg__req__connect_ap__descriptor =
"CtrlMsgReqConnectAP",
"",
sizeof(CtrlMsgReqConnectAP),
- 5,
+ 6,
ctrl_msg__req__connect_ap__field_descriptors,
ctrl_msg__req__connect_ap__field_indices_by_name,
1, ctrl_msg__req__connect_ap__number_ranges,
(ProtobufCMessageInit) ctrl_msg__req__connect_ap__init,
NULL,NULL,NULL /* reserved[123] */
};
-static const ProtobufCFieldDescriptor ctrl_msg__resp__connect_ap__field_descriptors[2] =
+static const ProtobufCFieldDescriptor ctrl_msg__resp__connect_ap__field_descriptors[3] =
{
{
"resp",
@@ -3014,15 +3040,28 @@ static const ProtobufCFieldDescriptor ctrl_msg__resp__connect_ap__field_descript
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
+ {
+ "band_mode",
+ 3,
+ PROTOBUF_C_LABEL_NONE,
+ PROTOBUF_C_TYPE_INT32,
+ 0, /* quantifier_offset */
+ offsetof(CtrlMsgRespConnectAP, band_mode),
+ NULL,
+ NULL,
+ 0, /* flags */
+ 0,NULL,NULL /* reserved1,reserved2, etc */
+ },
};
static const unsigned ctrl_msg__resp__connect_ap__field_indices_by_name[] = {
+ 2, /* field[2] = band_mode */
1, /* field[1] = mac */
0, /* field[0] = resp */
};
static const ProtobufCIntRange ctrl_msg__resp__connect_ap__number_ranges[1 + 1] =
{
{ 1, 0 },
- { 0, 2 }
+ { 0, 3 }
};
const ProtobufCMessageDescriptor ctrl_msg__resp__connect_ap__descriptor =
{
@@ -3032,7 +3071,7 @@ const ProtobufCMessageDescriptor ctrl_msg__resp__connect_ap__descriptor =
"CtrlMsgRespConnectAP",
"",
sizeof(CtrlMsgRespConnectAP),
- 2,
+ 3,
ctrl_msg__resp__connect_ap__field_descriptors,
ctrl_msg__resp__connect_ap__field_indices_by_name,
1, ctrl_msg__resp__connect_ap__number_ranges,
@@ -3057,7 +3096,7 @@ const ProtobufCMessageDescriptor ctrl_msg__req__get_soft_apconfig__descriptor =
(ProtobufCMessageInit) ctrl_msg__req__get_soft_apconfig__init,
NULL,NULL,NULL /* reserved[123] */
};
-static const ProtobufCFieldDescriptor ctrl_msg__resp__get_soft_apconfig__field_descriptors[8] =
+static const ProtobufCFieldDescriptor ctrl_msg__resp__get_soft_apconfig__field_descriptors[9] =
{
{
"ssid",
@@ -3155,8 +3194,21 @@ static const ProtobufCFieldDescriptor ctrl_msg__resp__get_soft_apconfig__field_d
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
+ {
+ "band_mode",
+ 9,
+ PROTOBUF_C_LABEL_NONE,
+ PROTOBUF_C_TYPE_INT32,
+ 0, /* quantifier_offset */
+ offsetof(CtrlMsgRespGetSoftAPConfig, band_mode),
+ NULL,
+ NULL,
+ 0, /* flags */
+ 0,NULL,NULL /* reserved1,reserved2, etc */
+ },
};
static const unsigned ctrl_msg__resp__get_soft_apconfig__field_indices_by_name[] = {
+ 8, /* field[8] = band_mode */
6, /* field[6] = bw */
2, /* field[2] = chnl */
4, /* field[4] = max_conn */
@@ -3169,7 +3221,7 @@ static const unsigned ctrl_msg__resp__get_soft_apconfig__field_indices_by_name[]
static const ProtobufCIntRange ctrl_msg__resp__get_soft_apconfig__number_ranges[1 + 1] =
{
{ 1, 0 },
- { 0, 8 }
+ { 0, 9 }
};
const ProtobufCMessageDescriptor ctrl_msg__resp__get_soft_apconfig__descriptor =
{
@@ -3179,14 +3231,14 @@ const ProtobufCMessageDescriptor ctrl_msg__resp__get_soft_apconfig__descriptor =
"CtrlMsgRespGetSoftAPConfig",
"",
sizeof(CtrlMsgRespGetSoftAPConfig),
- 8,
+ 9,
ctrl_msg__resp__get_soft_apconfig__field_descriptors,
ctrl_msg__resp__get_soft_apconfig__field_indices_by_name,
1, ctrl_msg__resp__get_soft_apconfig__number_ranges,
(ProtobufCMessageInit) ctrl_msg__resp__get_soft_apconfig__init,
NULL,NULL,NULL /* reserved[123] */
};
-static const ProtobufCFieldDescriptor ctrl_msg__req__start_soft_ap__field_descriptors[7] =
+static const ProtobufCFieldDescriptor ctrl_msg__req__start_soft_ap__field_descriptors[8] =
{
{
"ssid",
@@ -3272,8 +3324,21 @@ static const ProtobufCFieldDescriptor ctrl_msg__req__start_soft_ap__field_descri
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
+ {
+ "band_mode",
+ 8,
+ PROTOBUF_C_LABEL_NONE,
+ PROTOBUF_C_TYPE_INT32,
+ 0, /* quantifier_offset */
+ offsetof(CtrlMsgReqStartSoftAP, band_mode),
+ NULL,
+ NULL,
+ 0, /* flags */
+ 0,NULL,NULL /* reserved1,reserved2, etc */
+ },
};
static const unsigned ctrl_msg__req__start_soft_ap__field_indices_by_name[] = {
+ 7, /* field[7] = band_mode */
6, /* field[6] = bw */
2, /* field[2] = chnl */
4, /* field[4] = max_conn */
@@ -3285,7 +3350,7 @@ static const unsigned ctrl_msg__req__start_soft_ap__field_indices_by_name[] = {
static const ProtobufCIntRange ctrl_msg__req__start_soft_ap__number_ranges[1 + 1] =
{
{ 1, 0 },
- { 0, 7 }
+ { 0, 8 }
};
const ProtobufCMessageDescriptor ctrl_msg__req__start_soft_ap__descriptor =
{
@@ -3295,14 +3360,14 @@ const ProtobufCMessageDescriptor ctrl_msg__req__start_soft_ap__descriptor =
"CtrlMsgReqStartSoftAP",
"",
sizeof(CtrlMsgReqStartSoftAP),
- 7,
+ 8,
ctrl_msg__req__start_soft_ap__field_descriptors,
ctrl_msg__req__start_soft_ap__field_indices_by_name,
1, ctrl_msg__req__start_soft_ap__number_ranges,
(ProtobufCMessageInit) ctrl_msg__req__start_soft_ap__init,
NULL,NULL,NULL /* reserved[123] */
};
-static const ProtobufCFieldDescriptor ctrl_msg__resp__start_soft_ap__field_descriptors[2] =
+static const ProtobufCFieldDescriptor ctrl_msg__resp__start_soft_ap__field_descriptors[3] =
{
{
"resp",
@@ -3328,15 +3393,28 @@ static const ProtobufCFieldDescriptor ctrl_msg__resp__start_soft_ap__field_descr
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
+ {
+ "band_mode",
+ 3,
+ PROTOBUF_C_LABEL_NONE,
+ PROTOBUF_C_TYPE_INT32,
+ 0, /* quantifier_offset */
+ offsetof(CtrlMsgRespStartSoftAP, band_mode),
+ NULL,
+ NULL,
+ 0, /* flags */
+ 0,NULL,NULL /* reserved1,reserved2, etc */
+ },
};
static const unsigned ctrl_msg__resp__start_soft_ap__field_indices_by_name[] = {
+ 2, /* field[2] = band_mode */
1, /* field[1] = mac */
0, /* field[0] = resp */
};
static const ProtobufCIntRange ctrl_msg__resp__start_soft_ap__number_ranges[1 + 1] =
{
{ 1, 0 },
- { 0, 2 }
+ { 0, 3 }
};
const ProtobufCMessageDescriptor ctrl_msg__resp__start_soft_ap__descriptor =
{
@@ -3346,7 +3424,7 @@ const ProtobufCMessageDescriptor ctrl_msg__resp__start_soft_ap__descriptor =
"CtrlMsgRespStartSoftAP",
"",
sizeof(CtrlMsgRespStartSoftAP),
- 2,
+ 3,
ctrl_msg__resp__start_soft_ap__field_descriptors,
ctrl_msg__resp__start_soft_ap__field_indices_by_name,
1, ctrl_msg__resp__start_soft_ap__number_ranges,
diff --git a/esp_hosted_fg/common/include/esp_hosted_config.pb-c.h b/esp_hosted_fg/common/include/esp_hosted_config.pb-c.h
index 093ab0d0bf..932bfcac92 100644
--- a/esp_hosted_fg/common/include/esp_hosted_config.pb-c.h
+++ b/esp_hosted_fg/common/include/esp_hosted_config.pb-c.h
@@ -377,10 +377,11 @@ struct CtrlMsgRespGetAPConfig
int32_t chnl;
CtrlWifiSecProt sec_prot;
int32_t resp;
+ int32_t band_mode;
};
#define CTRL_MSG__RESP__GET_APCONFIG__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&ctrl_msg__resp__get_apconfig__descriptor) \
- , {0,NULL}, {0,NULL}, 0, 0, CTRL__WIFI_SEC_PROT__Open, 0 }
+ , {0,NULL}, {0,NULL}, 0, 0, CTRL__WIFI_SEC_PROT__Open, 0, 0 }
struct CtrlMsgReqConnectAP
@@ -391,10 +392,11 @@ struct CtrlMsgReqConnectAP
char *bssid;
protobuf_c_boolean is_wpa3_supported;
int32_t listen_interval;
+ int32_t band_mode;
};
#define CTRL_MSG__REQ__CONNECT_AP__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&ctrl_msg__req__connect_ap__descriptor) \
- , (char *)protobuf_c_empty_string, (char *)protobuf_c_empty_string, (char *)protobuf_c_empty_string, 0, 0 }
+ , (char *)protobuf_c_empty_string, (char *)protobuf_c_empty_string, (char *)protobuf_c_empty_string, 0, 0, 0 }
struct CtrlMsgRespConnectAP
@@ -402,10 +404,11 @@ struct CtrlMsgRespConnectAP
ProtobufCMessage base;
int32_t resp;
ProtobufCBinaryData mac;
+ int32_t band_mode;
};
#define CTRL_MSG__RESP__CONNECT_AP__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&ctrl_msg__resp__connect_ap__descriptor) \
- , 0, {0,NULL} }
+ , 0, {0,NULL}, 0 }
struct CtrlMsgReqGetSoftAPConfig
@@ -428,10 +431,11 @@ struct CtrlMsgRespGetSoftAPConfig
protobuf_c_boolean ssid_hidden;
int32_t bw;
int32_t resp;
+ int32_t band_mode;
};
#define CTRL_MSG__RESP__GET_SOFT_APCONFIG__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&ctrl_msg__resp__get_soft_apconfig__descriptor) \
- , {0,NULL}, {0,NULL}, 0, CTRL__WIFI_SEC_PROT__Open, 0, 0, 0, 0 }
+ , {0,NULL}, {0,NULL}, 0, CTRL__WIFI_SEC_PROT__Open, 0, 0, 0, 0, 0 }
struct CtrlMsgReqStartSoftAP
@@ -444,10 +448,11 @@ struct CtrlMsgReqStartSoftAP
int32_t max_conn;
protobuf_c_boolean ssid_hidden;
int32_t bw;
+ int32_t band_mode;
};
#define CTRL_MSG__REQ__START_SOFT_AP__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&ctrl_msg__req__start_soft_ap__descriptor) \
- , (char *)protobuf_c_empty_string, (char *)protobuf_c_empty_string, 0, CTRL__WIFI_SEC_PROT__Open, 0, 0, 0 }
+ , (char *)protobuf_c_empty_string, (char *)protobuf_c_empty_string, 0, CTRL__WIFI_SEC_PROT__Open, 0, 0, 0, 0 }
struct CtrlMsgRespStartSoftAP
@@ -455,10 +460,11 @@ struct CtrlMsgRespStartSoftAP
ProtobufCMessage base;
int32_t resp;
ProtobufCBinaryData mac;
+ int32_t band_mode;
};
#define CTRL_MSG__RESP__START_SOFT_AP__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&ctrl_msg__resp__start_soft_ap__descriptor) \
- , 0, {0,NULL} }
+ , 0, {0,NULL}, 0 }
struct CtrlMsgReqScanResult
diff --git a/esp_hosted_fg/common/proto/esp_hosted_config.proto b/esp_hosted_fg/common/proto/esp_hosted_config.proto
index 99f4eec790..6a0aa19ea0 100644
--- a/esp_hosted_fg/common/proto/esp_hosted_config.proto
+++ b/esp_hosted_fg/common/proto/esp_hosted_config.proto
@@ -1,4 +1,4 @@
-/* Copyright (C) 2015-2023 Espressif Systems (Shanghai) PTE LTD */
+/* Copyright (C) 2015-2024 Espressif Systems (Shanghai) PTE LTD */
/* SPDX-License-Identifier: GPL-2.0-only OR Apache-2.0 */
syntax = "proto3";
@@ -230,6 +230,7 @@ message CtrlMsg_Resp_GetAPConfig {
int32 chnl = 4;
Ctrl_WifiSecProt sec_prot = 5;
int32 resp = 6;
+ int32 band_mode = 7;
}
message CtrlMsg_Req_ConnectAP {
@@ -238,11 +239,13 @@ message CtrlMsg_Req_ConnectAP {
string bssid = 3;
bool is_wpa3_supported = 4;
int32 listen_interval = 5;
+ int32 band_mode = 6;
}
message CtrlMsg_Resp_ConnectAP {
int32 resp = 1;
bytes mac = 2;
+ int32 band_mode = 3;
}
message CtrlMsg_Req_GetSoftAPConfig {
@@ -257,6 +260,7 @@ message CtrlMsg_Resp_GetSoftAPConfig {
bool ssid_hidden = 6;
int32 bw = 7;
int32 resp = 8;
+ int32 band_mode = 9;
}
message CtrlMsg_Req_StartSoftAP {
@@ -267,11 +271,13 @@ message CtrlMsg_Req_StartSoftAP {
int32 max_conn = 5;
bool ssid_hidden = 6;
int32 bw = 7;
+ int32 band_mode = 8;
}
message CtrlMsg_Resp_StartSoftAP {
int32 resp = 1;
bytes mac = 2;
+ int32 band_mode = 3;
}
message CtrlMsg_Req_ScanResult {
diff --git a/esp_hosted_fg/docs/Linux_based_host/SPI_setup.md b/esp_hosted_fg/docs/Linux_based_host/SPI_setup.md
index 25558a6f87..5525c3360c 100644
--- a/esp_hosted_fg/docs/Linux_based_host/SPI_setup.md
+++ b/esp_hosted_fg/docs/Linux_based_host/SPI_setup.md
@@ -1,7 +1,7 @@
# Wi-Fi and BT/BLE connectivity Setup over SPI
-| Supported Targets | ESP32 | ESP32-S2 | ESP32-S3 | ESP32-C2 | ESP32-C3 | ESP32-C6 |
-| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- |
+| Supported Targets | ESP32 | ESP32-S2 | ESP32-S3 | ESP32-C2 | ESP32-C3 | ESP32-C5 | ESP32-C6 |
+| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- |
## 1. Setup
### 1.1 Hardware Setup
@@ -13,7 +13,7 @@ ESP can be powered through PC using micro-USB/USB-C cable.
Raspberry-Pi pinout can be found [here!](https://pinout.xyz/pinout/spi)
#### 1.1.1 Pin connections
-| Raspberry-Pi Pin | ESP32 | ESP32-S2/S3 | ESP32-C2/C3/C6 | Function |
+| Raspberry-Pi Pin | ESP32 | ESP32-S2/S3 | ESP32-C2/C3/C5/C6 | Function |
|:-------:|:---------:|:--------:|:--------:|:--------:|
| 24 | IO15 | IO10 | IO10 | CS0 |
| 23 | IO14 | IO12 | IO6 | SCLK |
diff --git a/esp_hosted_fg/esp/esp_driver/esp-idf b/esp_hosted_fg/esp/esp_driver/esp-idf
index cbce221e88..81f4ef73c3 160000
--- a/esp_hosted_fg/esp/esp_driver/esp-idf
+++ b/esp_hosted_fg/esp/esp_driver/esp-idf
@@ -1 +1 @@
-Subproject commit cbce221e88d52665523093b2b6dd0ebe3f1243f1
+Subproject commit 81f4ef73c358e924e1e34bed0e51b5989dcfefa3
diff --git a/esp_hosted_fg/esp/esp_driver/network_adapter/main/Kconfig.projbuild b/esp_hosted_fg/esp/esp_driver/network_adapter/main/Kconfig.projbuild
index aac8846ddb..6cfe514249 100644
--- a/esp_hosted_fg/esp/esp_driver/network_adapter/main/Kconfig.projbuild
+++ b/esp_hosted_fg/esp/esp_driver/network_adapter/main/Kconfig.projbuild
@@ -7,6 +7,7 @@ menu "Example Configuration"
default ESP_SPI_HOST_INTERFACE if IDF_TARGET_ESP32S3
default ESP_SPI_HOST_INTERFACE if IDF_TARGET_ESP32C2
default ESP_SPI_HOST_INTERFACE if IDF_TARGET_ESP32C3
+ default ESP_SPI_HOST_INTERFACE if IDF_TARGET_ESP32C5
default ESP_SPI_HOST_INTERFACE if IDF_TARGET_ESP32C6
help
Bus interface to be used for communication with the host
@@ -38,6 +39,7 @@ menu "Example Configuration"
int "GPIO pin for handshake"
default 3 if IDF_TARGET_ESP32C2
default 3 if IDF_TARGET_ESP32C3
+ default 3 if IDF_TARGET_ESP32C5
default 3 if IDF_TARGET_ESP32C6
default 2
help
diff --git a/esp_hosted_fg/esp/esp_driver/network_adapter/main/mempool.c b/esp_hosted_fg/esp/esp_driver/network_adapter/main/mempool.c
index f885561787..d74056c92e 100644
--- a/esp_hosted_fg/esp/esp_driver/network_adapter/main/mempool.c
+++ b/esp_hosted_fg/esp/esp_driver/network_adapter/main/mempool.c
@@ -53,8 +53,8 @@ struct hosted_mempool * hosted_mempool_create(void *pre_allocated_mem,
}
}
- new = (struct hosted_mempool*)CALLOC(sizeof(struct hosted_mempool), 1);
- pool = (struct os_mempool *)CALLOC(sizeof(struct os_mempool), 1);
+ new = (struct hosted_mempool*)CALLOC(1, sizeof(struct hosted_mempool));
+ pool = (struct os_mempool *)CALLOC(1, sizeof(struct os_mempool));
if(!new || !pool) {
goto free_buffs;
diff --git a/esp_hosted_fg/esp/esp_driver/network_adapter/main/slave_control.c b/esp_hosted_fg/esp/esp_driver/network_adapter/main/slave_control.c
index 11f40176e2..fc33b2e547 100644
--- a/esp_hosted_fg/esp/esp_driver/network_adapter/main/slave_control.c
+++ b/esp_hosted_fg/esp/esp_driver/network_adapter/main/slave_control.c
@@ -43,7 +43,11 @@
#define TIMEOUT_IN_MIN (60*TIMEOUT_IN_SEC)
#define TIMEOUT_IN_HOUR (60*TIMEOUT_IN_MIN)
+#if WIFI_DUALBAND_SUPPORT
+#define STA_MODE_TIMEOUT (15*TIMEOUT_IN_SEC)
+#else
#define STA_MODE_TIMEOUT (5*TIMEOUT_IN_SEC)
+#endif
#define RESTART_TIMEOUT (5*TIMEOUT_IN_SEC)
#if CONFIG_ESP_OTA_WORKAROUND
@@ -425,6 +429,10 @@ static esp_err_t req_connect_ap_handler (CtrlMsg *req,
CtrlMsgRespConnectAP *resp_payload = NULL;
EventBits_t bits = {0};
int retry = 0;
+#if WIFI_DUALBAND_SUPPORT
+ wifi_band_mode_t band_mode = 0; // 0 is currently an invalid value
+ wifi_band_mode_t requested_band_mode = 0; // 0 is currently an invalid value
+#endif
if (!req || !resp || !req->req_connect_ap) {
ESP_LOGE(TAG, "Invalid parameters");
@@ -518,6 +526,32 @@ static esp_err_t req_connect_ap_handler (CtrlMsg *req,
if (req->req_connect_ap->listen_interval >= 0) {
wifi_cfg->sta.listen_interval = req->req_connect_ap->listen_interval;
}
+#if WIFI_DUALBAND_SUPPORT
+ // get current band_mode
+ ret = esp_wifi_get_band_mode(&band_mode);
+ if (ret != ESP_OK) {
+ ESP_LOGW(TAG, "failed to get band mode, defaulting to AUTO");
+ band_mode = WIFI_BAND_MODE_AUTO;
+ }
+
+ // get requested band mode
+ if (req->req_connect_ap->band_mode) {
+ requested_band_mode = req->req_connect_ap->band_mode;
+ } else {
+ // requested band mode not set: default to auto
+ requested_band_mode = WIFI_BAND_MODE_AUTO;
+ }
+
+ // compare and update current band mode, if needed
+ if (band_mode != requested_band_mode) {
+ ret = esp_wifi_set_band_mode(requested_band_mode);
+ if (ret) {
+ ESP_LOGE(TAG, "failed to set band mode");
+ goto err;
+ }
+ band_mode = requested_band_mode;
+ }
+#endif
/* Make sure that we connect to strongest signal, when multiple SSID with
* the same name. This should take a small extra time to search for all SSIDs,
@@ -613,6 +647,9 @@ static esp_err_t req_connect_ap_handler (CtrlMsg *req,
err:
if (station_connected) {
+#if WIFI_DUALBAND_SUPPORT
+ resp_payload->band_mode = band_mode;
+#endif
ESP_LOGI(TAG, "%s:%u Set resp to Success",__func__,__LINE__);
resp_payload->resp = SUCCESS;
} else {
@@ -637,6 +674,9 @@ static esp_err_t req_get_ap_config_handler (CtrlMsg *req,
credentials_t credentials = {0};
wifi_ap_record_t *ap_info = NULL;
CtrlMsgRespGetAPConfig *resp_payload = NULL;
+#if WIFI_DUALBAND_SUPPORT
+ wifi_band_mode_t band_mode = 0; // 0 is currently an invalid value
+#endif
if (!req || !resp) {
ESP_LOGE(TAG, "Invalid parameters");
return ESP_FAIL;
@@ -713,6 +753,15 @@ static esp_err_t req_get_ap_config_handler (CtrlMsg *req,
resp_payload->rssi = credentials.rssi;
resp_payload->chnl = credentials.chnl;
resp_payload->sec_prot = credentials.ecn;
+#if WIFI_DUALBAND_SUPPORT
+ // get current band_mode
+ ret = esp_wifi_get_band_mode(&band_mode);
+ if (ret != ESP_OK) {
+ ESP_LOGW(TAG, "failed to get band mode, defaulting to AUTO");
+ band_mode = WIFI_BAND_MODE_AUTO;
+ }
+ resp_payload->band_mode = band_mode;
+#endif
resp_payload->resp = SUCCESS;
err:
@@ -787,10 +836,15 @@ static esp_err_t req_get_softap_config_handler (CtrlMsg *req,
CtrlMsg *resp, void *priv_data)
{
esp_err_t ret = ESP_OK;
- wifi_bandwidth_t get_bw = 0;
credentials_t credentials = {0};
wifi_config_t get_conf = {0};
CtrlMsgRespGetSoftAPConfig *resp_payload = NULL;
+#if WIFI_DUALBAND_SUPPORT
+ wifi_bandwidths_t bandwidths = { 0 };
+ wifi_band_mode_t band_mode = 0; // 0 is currently an invalid value
+#else
+ wifi_bandwidth_t get_bw = 0;
+#endif
if (!req || !resp) {
ESP_LOGE(TAG, "Invalid parameters");
@@ -818,11 +872,19 @@ static esp_err_t req_get_softap_config_handler (CtrlMsg *req,
goto err;
}
+#if WIFI_DUALBAND_SUPPORT
+ ret = esp_wifi_get_bandwidths(ESP_IF_WIFI_AP,&bandwidths);
+ if (ret) {
+ ESP_LOGE(TAG,"Failed to get bandwidths");
+ goto err;
+ }
+#else
ret = esp_wifi_get_bandwidth(ESP_IF_WIFI_AP,&get_bw);
if (ret) {
ESP_LOGE(TAG,"Failed to get bandwidth");
goto err;
}
+#endif
if (strlen((char *)get_conf.ap.ssid)) {
strncpy((char *)credentials.ssid,(char *)&get_conf.ap.ssid,
@@ -869,7 +931,26 @@ static esp_err_t req_get_softap_config_handler (CtrlMsg *req,
resp_payload->sec_prot = credentials.ecn;
resp_payload->max_conn = credentials.max_conn;
resp_payload->ssid_hidden = credentials.ssid_hidden;
+#if WIFI_DUALBAND_SUPPORT
+ // return the 2.4/5G band bandwidth based on the channel we are on
+ // if channel > 14, assume we are on 5G band
+ if (credentials.chnl <= 14) {
+ resp_payload->bw = bandwidths.ghz_2g;
+ } else {
+ resp_payload->bw = bandwidths.ghz_5g;
+ }
+ // return band mode
+ ret = esp_wifi_get_band_mode(&band_mode);
+ if (ret) {
+ ESP_LOGE(TAG,"Failed to get current band_mode");
+ // force band mode value
+ band_mode = WIFI_BAND_MODE_AUTO;
+ }
+ resp_payload->band_mode = band_mode;
+#else
resp_payload->bw = get_bw;
+#endif
+
resp_payload->resp = SUCCESS;
return ESP_OK;
@@ -887,6 +968,10 @@ static esp_err_t req_start_softap_handler (CtrlMsg *req,
uint8_t mac[MAC_LEN] = {0};
wifi_config_t *wifi_config = NULL;
CtrlMsgRespStartSoftAP *resp_payload = NULL;
+#if WIFI_DUALBAND_SUPPORT
+ wifi_bandwidths_t bandwidths = { 0 };
+ wifi_band_mode_t band_mode = 0; // 0 is currently an invalid value
+#endif
if (!req || !resp || !req->req_start_softap) {
ESP_LOGE(TAG, "Invalid parameters");
@@ -974,11 +1059,47 @@ static esp_err_t req_start_softap_handler (CtrlMsg *req,
goto err;
}
+#if WIFI_DUALBAND_SUPPORT
+ // set band mode
+ band_mode = req->req_start_softap->band_mode;
+
+ if (!band_mode) {
+ // incoming band mode is 0: make it auto
+ band_mode = WIFI_BAND_MODE_AUTO;
+ }
+ ret = esp_wifi_set_band_mode(band_mode);
+ if (ret) {
+ ESP_LOGE(TAG, "failed to set band_mode");
+ goto err;
+ }
+
+ // set bandwidth, based on band mode
+ switch (band_mode) {
+ case WIFI_BAND_MODE_2G_ONLY:
+ bandwidths.ghz_2g = req->req_start_softap->bw;
+ break;
+ case WIFI_BAND_MODE_5G_ONLY:
+ bandwidths.ghz_5g = req->req_start_softap->bw;
+ break;
+ // auto and default have the same settings
+ case WIFI_BAND_MODE_AUTO:
+ default:
+ bandwidths.ghz_2g = req->req_start_softap->bw;
+ bandwidths.ghz_5g = req->req_start_softap->bw;
+ break;
+ }
+ ret = esp_wifi_set_bandwidths(ESP_IF_WIFI_AP, &bandwidths);
+ if (ret) {
+ ESP_LOGE(TAG,"Failed to set bandwidth");
+ goto err;
+ }
+#else
ret = esp_wifi_set_bandwidth(ESP_IF_WIFI_AP,req->req_start_softap->bw);
if (ret) {
ESP_LOGE(TAG,"Failed to set bandwidth");
goto err;
}
+#endif
ESP_LOGI(TAG, MACSTR, MAC2STR(mac));
@@ -1000,6 +1121,9 @@ static esp_err_t req_start_softap_handler (CtrlMsg *req,
wifi_config->ap.authmode, wifi_config->ap.ssid_hidden,
wifi_config->ap.max_connection,wifi_config->ap.channel);
ESP_LOGI(TAG,"ESP32 SoftAP is avaliable ");
+#if WIFI_DUALBAND_SUPPORT
+ resp_payload->band_mode = band_mode;
+#endif
resp_payload->resp = SUCCESS;
mem_free(wifi_config);
return ESP_OK;
@@ -1028,6 +1152,9 @@ static esp_err_t req_get_ap_scan_list_handler (CtrlMsg *req,
wifi_scan_config_t scanConf = {
.show_hidden = true
};
+#if WIFI_DUALBAND_SUPPORT
+ wifi_band_mode_t band_mode = 0; // 0 is currently an invalid value
+#endif
if (!req || !resp) {
ESP_LOGE(TAG, "Invalid parameters");
@@ -1061,6 +1188,22 @@ static esp_err_t req_get_ap_scan_list_handler (CtrlMsg *req,
ESP_LOGI(TAG,"Station mode set in scan handler");
}
+#if WIFI_DUALBAND_SUPPORT
+ // ensure wifi band is set to auto to get all scan results (2.4G and 5G bands)
+ ret = esp_wifi_get_band_mode(&band_mode);
+ if (ret == ESP_OK) {
+ if (band_mode != WIFI_BAND_MODE_AUTO) {
+ ESP_LOGI(TAG, "Setting band_mode to AUTO");
+ ret = esp_wifi_set_band_mode(WIFI_BAND_MODE_AUTO);
+ if (ret) {
+ ESP_LOGE(TAG, "Failed to set band_mode to AUTO");
+ }
+ }
+ } else {
+ ESP_LOGE(TAG,"Failed to get current band_mode");
+ }
+#endif
+
ret = esp_wifi_scan_start(&scanConf, true);
if (ret) {
ESP_LOGE(TAG,"Failed to start scan start command");
diff --git a/esp_hosted_fg/esp/esp_driver/network_adapter/main/slave_control.h b/esp_hosted_fg/esp/esp_driver/network_adapter/main/slave_control.h
index 7a311fe73d..1435aa26ea 100644
--- a/esp_hosted_fg/esp/esp_driver/network_adapter/main/slave_control.h
+++ b/esp_hosted_fg/esp/esp_driver/network_adapter/main/slave_control.h
@@ -24,6 +24,18 @@
#define TIMEOUT_IN_SEC (1000 / portTICK_RATE_MS)
#endif
+#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 4, 0)
+// 5G band support only available in ESP-IDF 5.4 or later
+
+#if CONFIG_SOC_WIFI_HE_SUPPORT_5G
+ #define WIFI_DUALBAND_SUPPORT 1
+#else
+ #define WIFI_DUALBAND_SUPPORT 0
+#endif // CONFIG_SOC_WIFI_HE_SUPPORT_5G
+
+#else
+ #define WIFI_DUALBAND_SUPPORT 0
+#endif
#define SSID_LENGTH 33
#define PASSWORD_LENGTH 64
diff --git a/esp_hosted_fg/esp/esp_driver/network_adapter/main/spi_slave_api.c b/esp_hosted_fg/esp/esp_driver/network_adapter/main/spi_slave_api.c
index 3e1e2be128..3b32ced546 100644
--- a/esp_hosted_fg/esp/esp_driver/network_adapter/main/spi_slave_api.c
+++ b/esp_hosted_fg/esp/esp_driver/network_adapter/main/spi_slave_api.c
@@ -103,6 +103,15 @@ static const char TAG[] = "SPI_DRIVER";
#define GPIO_CS 10
#define DMA_CHAN SPI_DMA_CH_AUTO
+#elif defined CONFIG_IDF_TARGET_ESP32C5
+
+ #define ESP_SPI_CONTROLLER 1
+ #define GPIO_MOSI 7
+ #define GPIO_MISO 2
+ #define GPIO_SCLK 6
+ #define GPIO_CS 10
+ #define DMA_CHAN SPI_DMA_CH_AUTO
+
#elif defined CONFIG_IDF_TARGET_ESP32C6
#define ESP_SPI_CONTROLLER 1
diff --git a/esp_hosted_fg/host/control_lib/include/ctrl_api.h b/esp_hosted_fg/host/control_lib/include/ctrl_api.h
index 6f87a099a8..37fc173286 100644
--- a/esp_hosted_fg/host/control_lib/include/ctrl_api.h
+++ b/esp_hosted_fg/host/control_lib/include/ctrl_api.h
@@ -35,6 +35,7 @@
#define WAIT_TIME_B2B_CTRL_REQ 5
#define DEFAULT_CTRL_RESP_TIMEOUT 30
#define DEFAULT_CTRL_RESP_AP_SCAN_TIMEOUT (60*3)
+#define DEFAULT_CTRL_RESP_CONNECT_AP_TIMEOUT (15*3)
#ifndef MAC2STR
#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
@@ -278,6 +279,7 @@ typedef struct {
uint16_t listen_interval;
char status[STATUS_LENGTH];
char out_mac[MAX_MAC_STR_SIZE];
+ int band_mode;
} wifi_ap_config_t;
typedef struct {
@@ -289,6 +291,7 @@ typedef struct {
bool ssid_hidden;
wifi_bandwidth_e bandwidth;
char out_mac[MAX_MAC_STR_SIZE];
+ int band_mode;
} softap_config_t;
typedef struct {
diff --git a/esp_hosted_fg/host/control_lib/src/ctrl_core.c b/esp_hosted_fg/host/control_lib/src/ctrl_core.c
index 7e79716b73..f2f8af2d59 100644
--- a/esp_hosted_fg/host/control_lib/src/ctrl_core.c
+++ b/esp_hosted_fg/host/control_lib/src/ctrl_core.c
@@ -468,6 +468,7 @@ static int ctrl_app_parse_resp(CtrlMsg *ctrl_msg, ctrl_cmd_t *app_resp)
p->channel = ctrl_msg->resp_get_ap_config->chnl;
p->rssi = ctrl_msg->resp_get_ap_config->rssi;
p->encryption_mode = ctrl_msg->resp_get_ap_config->sec_prot;
+ p->band_mode = ctrl_msg->resp_get_ap_config->band_mode;
break;
case FAILURE:
@@ -486,7 +487,9 @@ static int ctrl_app_parse_resp(CtrlMsg *ctrl_msg, ctrl_cmd_t *app_resp)
app_resp->resp_event_status = ctrl_msg->resp_connect_ap->resp;
- command_log("Connect AP failed, Reason[%d]\n", ctrl_msg->resp_connect_ap->resp);
+ if (ctrl_msg->resp_connect_ap->resp) {
+ command_log("Connect AP failed, Reason[%d]\n", ctrl_msg->resp_connect_ap->resp);
+ }
switch(ctrl_msg->resp_connect_ap->resp) {
case CTRL_ERR_INVALID_PASSWORD:
command_log("Invalid password for SSID\n");
@@ -497,6 +500,7 @@ static int ctrl_app_parse_resp(CtrlMsg *ctrl_msg, ctrl_cmd_t *app_resp)
goto fail_parse_ctrl_msg;
break;
case SUCCESS:
+ command_log("Info: Connect band_mode is %d\n", ctrl_msg->resp_connect_ap->band_mode);
CHECK_CTRL_MSG_NON_NULL(resp_connect_ap->mac.data);
CHECK_CTRL_MSG_FAILED(resp_connect_ap);
break;
@@ -548,6 +552,8 @@ static int ctrl_app_parse_resp(CtrlMsg *ctrl_msg, ctrl_cmd_t *app_resp)
ctrl_msg->resp_get_softap_config->ssid_hidden;
app_resp->u.wifi_softap_config.bandwidth =
ctrl_msg->resp_get_softap_config->bw;
+ app_resp->u.wifi_softap_config.band_mode =
+ ctrl_msg->resp_get_softap_config->band_mode;
break;
} case CTRL_RESP_SET_SOFTAP_VND_IE : {
@@ -564,6 +570,7 @@ static int ctrl_app_parse_resp(CtrlMsg *ctrl_msg, ctrl_cmd_t *app_resp)
strncpy(app_resp->u.wifi_softap_config.out_mac,
(char *)ctrl_msg->resp_connect_ap->mac.data, len_l);
app_resp->u.wifi_softap_config.out_mac[len_l] = '\0';
+ app_resp->u.wifi_softap_config.band_mode = ctrl_msg->resp_connect_ap->band_mode;
break;
} case CTRL_RESP_GET_SOFTAP_CONN_STA_LIST : {
CHECK_CTRL_MSG_NON_NULL(resp_softap_connected_stas_list);
@@ -1316,6 +1323,9 @@ int ctrl_app_send_req(ctrl_cmd_t *app_req)
req_payload->mode = p->mode;
break;
} case CTRL_REQ_CONNECT_AP: {
+ if (app_req->cmd_timeout_sec < DEFAULT_CTRL_RESP_CONNECT_AP_TIMEOUT)
+ app_req->cmd_timeout_sec = DEFAULT_CTRL_RESP_CONNECT_AP_TIMEOUT;
+
wifi_ap_config_t * p = &app_req->u.wifi_ap_config;
CTRL_ALLOC_ASSIGN(CtrlMsgReqConnectAP,req_connect_ap);
@@ -1344,6 +1354,7 @@ int ctrl_app_send_req(ctrl_cmd_t *app_req)
req_payload->bssid = (char *)&p->bssid;
req_payload->is_wpa3_supported = p->is_wpa3_supported;
req_payload->listen_interval = p->listen_interval;
+ req_payload->band_mode = p->band_mode;
break;
} case CTRL_REQ_SET_SOFTAP_VND_IE: {
wifi_softap_vendor_ie_t *p = &app_req->u.wifi_softap_vendor_ie;
@@ -1411,13 +1422,6 @@ int ctrl_app_send_req(ctrl_cmd_t *app_req)
goto fail_req;
}
- if ((p->channel < MIN_CHNL_NO) ||
- (p->channel > MAX_CHNL_NO)) {
- command_log("Invalid softap channel\n");
- failure_status = CTRL_ERR_INCORRECT_ARG;
- goto fail_req;
- }
-
if ((p->encryption_mode < WIFI_AUTH_OPEN) ||
(p->encryption_mode == WIFI_AUTH_WEP) ||
(p->encryption_mode > WIFI_AUTH_WPA_WPA2_PSK)) {
@@ -1449,6 +1453,7 @@ int ctrl_app_send_req(ctrl_cmd_t *app_req)
req_payload->max_conn = p->max_connections;
req_payload->ssid_hidden = p->ssid_hidden;
req_payload->bw = p->bandwidth;
+ req_payload->band_mode = p->band_mode;
break;
} case CTRL_REQ_SET_PS_MODE: {
wifi_power_save_t * p = &app_req->u.wifi_ps;
diff --git a/esp_hosted_fg/host/linux/host_control/c_support/ctrl_config.h b/esp_hosted_fg/host/linux/host_control/c_support/ctrl_config.h
index 227d182b4d..958f99413b 100644
--- a/esp_hosted_fg/host/linux/host_control/c_support/ctrl_config.h
+++ b/esp_hosted_fg/host/linux/host_control/c_support/ctrl_config.h
@@ -64,11 +64,21 @@
#endif
#define CHUNK_SIZE 4000
+/* sets the band used in Station Mode to connect to the SSID
+ * BAND_MODE_2G_ONLY - only look for SSID on 2.4GHz bands
+ * BAND_MODE_5G_ONLY - only look for SSID on 5GHz bands
+ * BAND_MODE_AUTO - look for SSID on 2.4GHz band, then 5GHz band
+ */
+#define BAND_MODE_2G_ONLY 1
+#define BAND_MODE_5G_ONLY 2
+#define BAND_MODE_AUTO 3
+
/* station mode */
#define STATION_MODE_MAC_ADDRESS "aa:bb:cc:dd:ee:ff"
#define STATION_MODE_SSID "MyWifi"
#define STATION_MODE_PWD "MyWifiPass@123"
#define STATION_MODE_BSSID ""
+#define STATION_BAND_MODE BAND_MODE_AUTO
#define STATION_MODE_IS_WPA3_SUPPORTED false
#define STATION_MODE_LISTEN_INTERVAL 3
@@ -81,6 +91,7 @@
#define SOFTAP_MODE_MAX_ALLOWED_CLIENTS 4
#define SOFTAP_MODE_SSID_HIDDEN false
#define SOFTAP_MODE_BANDWIDTH 2
+#define SOFTAP_BAND_MODE BAND_MODE_AUTO
#define INPUT_WIFI_TX_POWER 20
diff --git a/esp_hosted_fg/host/linux/host_control/c_support/test_utils.c b/esp_hosted_fg/host/linux/host_control/c_support/test_utils.c
index 9aed41d058..a12140202e 100644
--- a/esp_hosted_fg/host/linux/host_control/c_support/test_utils.c
+++ b/esp_hosted_fg/host/linux/host_control/c_support/test_utils.c
@@ -520,6 +520,7 @@ int ctrl_app_resp_callback(ctrl_cmd_t * app_resp)
printf("AP's channel number %d\n", p->channel);
printf("AP's rssi %d\n", p->rssi);
printf("AP's encryption mode %d\n", p->encryption_mode);
+ printf("AP's band mode %d\n", p->band_mode);
} else {
printf("Station mode status: %s\n",p->status);
}
@@ -543,13 +544,14 @@ int ctrl_app_resp_callback(ctrl_cmd_t * app_resp)
printf("softAP max connections %d \n", resp_p->max_connections);
printf("softAP ssid broadcast status %d \n", resp_p->ssid_hidden);
printf("softAP bandwidth mode %d \n", resp_p->bandwidth);
+ printf("softAP band mode %d \n", resp_p->band_mode);
break;
} case CTRL_RESP_SET_SOFTAP_VND_IE : {
printf("Success in set vendor specific ie\n");
break;
} case CTRL_RESP_START_SOFTAP : {
- printf("esp32 softAP started \n");
+ printf("esp32 softAP started with band_mode %d\n", app_resp->u.wifi_softap_config.band_mode);
if (up_softap_netdev(app_resp->u.wifi_softap_config.out_mac))
goto fail_resp;
break;
@@ -751,6 +753,7 @@ int test_station_mode_connect(void)
strcpy((char *)&req.u.wifi_ap_config.bssid, STATION_MODE_BSSID);
req.u.wifi_ap_config.is_wpa3_supported = STATION_MODE_IS_WPA3_SUPPORTED;
req.u.wifi_ap_config.listen_interval = STATION_MODE_LISTEN_INTERVAL;
+ req.u.wifi_ap_config.band_mode = STATION_BAND_MODE;
/* register callback for handling asynch reply */
req.ctrl_resp_cb = ctrl_app_resp_callback;
@@ -808,6 +811,7 @@ int test_softap_mode_start(void)
req.u.wifi_softap_config.max_connections = SOFTAP_MODE_MAX_ALLOWED_CLIENTS;
req.u.wifi_softap_config.ssid_hidden = SOFTAP_MODE_SSID_HIDDEN;
req.u.wifi_softap_config.bandwidth = SOFTAP_MODE_BANDWIDTH;
+ req.u.wifi_softap_config.band_mode = SOFTAP_BAND_MODE;
resp = wifi_start_softap(req);
diff --git a/esp_hosted_fg/host/linux/host_control/python_support/commands_lib.py b/esp_hosted_fg/host/linux/host_control/python_support/commands_lib.py
index d7c9fc41c9..bc97f23f1f 100644
--- a/esp_hosted_fg/host/linux/host_control/python_support/commands_lib.py
+++ b/esp_hosted_fg/host/linux/host_control/python_support/commands_lib.py
@@ -489,6 +489,7 @@ def ctrl_app_resp_callback(app_resp):
print("AP's channel number \""+str(ap_config_p.contents.channel)+"\"")
print("AP's rssi \""+str(ap_config_p.contents.rssi)+"\"")
print("AP's encryption mode \""+str(ap_config_p.contents.encryption_mode)+"\"")
+ print("AP's band mode \""+str(ap_config_p.contents.band_mode)+"\"")
else:
print("Station mode status: "+get_str(ap_config_p.contents.status))
@@ -499,7 +500,7 @@ def ctrl_app_resp_callback(app_resp):
return FAILURE
elif (app_resp.contents.msg_id == CTRL_MSGID.CTRL_RESP_START_SOFTAP.value) :
- print("esp32 softAP started")
+ print("esp32 softAP started with band_mode "+str(app_resp.contents.control_data.wifi_softap_config.band_mode))
if (process_resp_start_softap(app_resp)):
fail_resp(app_resp)
return FAILURE
@@ -514,6 +515,7 @@ def ctrl_app_resp_callback(app_resp):
print("softAP max connections \""+str(softap_config_p.contents.max_connections)+"\"")
print("softAP hide ssid \""+str(softap_config_p.contents.ssid_hidden)+"\"")
print("softAP bandwidth \""+str(softap_config_p.contents.bandwidth)+"\"")
+ print("softAP band mode \""+str(softap_config_p.contents.band_mode)+"\"")
elif (app_resp.contents.msg_id == CTRL_MSGID.CTRL_RESP_GET_SOFTAP_CONN_STA_LIST.value) :
count = app_resp.contents.control_data.wifi_softap_con_sta.count
@@ -822,7 +824,7 @@ def test_sync_get_available_wifi():
-def test_async_station_mode_connect(ssid,pwd,bssid,use_wpa3,listen_interval):
+def test_async_station_mode_connect(ssid,pwd,bssid,use_wpa3,listen_interval,band_mode):
req = CONTROL_COMMAND()
CTRL_CMD_DEFAULT_REQ(req)
@@ -831,6 +833,7 @@ def test_async_station_mode_connect(ssid,pwd,bssid,use_wpa3,listen_interval):
req.control_data.wifi_ap_config.bssid = set_str(bssid)
req.control_data.wifi_ap_config.is_wpa3_supported = use_wpa3
req.control_data.wifi_ap_config.listen_interval = listen_interval
+ req.control_data.wifi_ap_config.band_mode = band_mode
req.ctrl_resp_cb = ctrl_app_resp_cb
commands_map_py_to_c.wifi_connect_ap(req)
@@ -838,7 +841,7 @@ def test_async_station_mode_connect(ssid,pwd,bssid,use_wpa3,listen_interval):
-def test_sync_station_mode_connect(ssid,pwd,bssid,use_wpa3,listen_interval):
+def test_sync_station_mode_connect(ssid,pwd,bssid,use_wpa3,listen_interval,band_mode):
req = CONTROL_COMMAND()
CTRL_CMD_DEFAULT_REQ(req)
req.control_data.wifi_ap_config.ssid = set_str(str(ssid))
@@ -846,6 +849,7 @@ def test_sync_station_mode_connect(ssid,pwd,bssid,use_wpa3,listen_interval):
req.control_data.wifi_ap_config.bssid = set_str(bssid)
req.control_data.wifi_ap_config.is_wpa3_supported = use_wpa3
req.control_data.wifi_ap_config.listen_interval = listen_interval
+ req.control_data.wifi_ap_config.band_mode = band_mode
resp = POINTER(CONTROL_COMMAND)
resp = None
@@ -875,7 +879,7 @@ def test_sync_station_mode_disconnect():
-def test_sync_softap_mode_start(ssid, pwd, channel, sec_prot, max_conn, hide_ssid, bw):
+def test_sync_softap_mode_start(ssid, pwd, channel, sec_prot, max_conn, hide_ssid, bw, band_mode):
req = CONTROL_COMMAND()
CTRL_CMD_DEFAULT_REQ(req)
resp = POINTER(CONTROL_COMMAND)
@@ -887,6 +891,7 @@ def test_sync_softap_mode_start(ssid, pwd, channel, sec_prot, max_conn, hide_ssi
req.control_data.wifi_softap_config.max_connections = max_conn
req.control_data.wifi_softap_config.ssid_hidden = hide_ssid
req.control_data.wifi_softap_config.bandwidth = bw
+ req.control_data.wifi_softap_config.band_mode = band_mode
resp = commands_map_py_to_c.wifi_start_softap(req)
return ctrl_app_resp_callback(resp)
diff --git a/esp_hosted_fg/host/linux/host_control/python_support/hosted_py_header.py b/esp_hosted_fg/host/linux/host_control/python_support/hosted_py_header.py
index 3c217c96a5..7effb1eae3 100644
--- a/esp_hosted_fg/host/linux/host_control/python_support/hosted_py_header.py
+++ b/esp_hosted_fg/host/linux/host_control/python_support/hosted_py_header.py
@@ -48,6 +48,9 @@
CALLBACK_NOT_REGISTERED = -1
MSG_ID_OUT_OF_ORDER = -2
+WIFI_BAND_MODE_2G_ONLY = 1
+WIFI_BAND_MODE_5G_ONLY = 2
+WIFI_BAND_MODE_AUTO = 3
class WIFI_MODE_E(Enum):
WIFI_MODE_NONE = 0
@@ -195,7 +198,8 @@ class STA_CONFIG(Structure):
("encryption_mode", c_uint),
("listen_interval", c_ushort),
("status", c_char * STATUS_LENGTH),
- ("out_mac", c_char * MAX_MAC_STR_LEN)]
+ ("out_mac", c_char * MAX_MAC_STR_LEN),
+ ("band_mode", c_int)]
class SOFTAP_CONFIG(Structure):
@@ -206,7 +210,8 @@ class SOFTAP_CONFIG(Structure):
("max_connections", c_int),
("ssid_hidden", c_bool),
("bandwidth", c_uint),
- ("out_mac", c_char * MAX_MAC_STR_LEN)]
+ ("out_mac", c_char * MAX_MAC_STR_LEN),
+ ("band_mode", c_int)]
class CONTROL_CONFIG(Union):
diff --git a/esp_hosted_fg/host/linux/host_control/python_support/py_parse/cmds.py b/esp_hosted_fg/host/linux/host_control/python_support/py_parse/cmds.py
index 3d9167f2ff..698a7695a3 100644
--- a/esp_hosted_fg/host/linux/host_control/python_support/py_parse/cmds.py
+++ b/esp_hosted_fg/host/linux/host_control/python_support/py_parse/cmds.py
@@ -104,7 +104,7 @@ def get_available_ap(self):
return self
- def connect_ap(self, ssid : str = "", pwd : str = "", bssid : str = "", use_wpa3 : bool = False, listen_interval : int = 3, set_dhcp : bool = True):
+ def connect_ap(self, ssid : str = "", pwd : str = "", bssid : str = "", use_wpa3 : bool = False, listen_interval : int = 3, set_dhcp : bool = True, band_mode: int = WIFI_BAND_MODE_AUTO):
"""Connect to AP (Wi-Fi router or hotspot)
Args:
@@ -114,6 +114,7 @@ def connect_ap(self, ssid : str = "", pwd : str = "", bssid : str = "", use_wpa3
use_wpa3(bool, optional): O | Use wpa3 security protocol | Default: False
listen_interval(int, optional) : O | Number of AP beacons station will sleep | Default:3
set_dhcp(bool, optional): O | Request DHCP | Default: True
+ band_mode(int, optional): O | Connect on 2.4G (1) or 5G (2) band, or Auto select (3) | Default:3
Returns:
ctrl_cmd: ctrl_cmd object
@@ -123,7 +124,7 @@ def connect_ap(self, ssid : str = "", pwd : str = "", bssid : str = "", use_wpa3
self.out = "Missing param " + "--ssid"
return self
- self.out = process_connect_ap(ssid, pwd, bssid, use_wpa3, listen_interval, set_dhcp)
+ self.out = process_connect_ap(ssid, pwd, bssid, use_wpa3, listen_interval, set_dhcp, band_mode)
return self
@@ -173,7 +174,7 @@ def softap_vendor_ie(self, enable : bool = "True", data: str = ""):
return self
- def start_softap(self, ssid : str = "", pwd : str = "", channel : int = 1, sec_prot: str = "wpa_wpa2_psk", max_conn: int = 4, hide_ssid: bool = False, bw : int = 20, start_dhcp_server : bool = True):
+ def start_softap(self, ssid : str = "", pwd : str = "", channel : int = 1, sec_prot: str = "wpa_wpa2_psk", max_conn: int = 4, hide_ssid: bool = False, bw : int = 20, start_dhcp_server : bool = True, band_mode: int = WIFI_BAND_MODE_AUTO):
"""Connect to AP (Wi-Fi router or hotspot)
Args:
@@ -185,6 +186,7 @@ def start_softap(self, ssid : str = "", pwd : str = "", channel : int = 1, sec_p
hide_ssid(bool, optional): O | Hide SSID broadcasting [ True | False ] | Default: False
bw(int, optional): O | Wi-Fi Bandwidth [ 20 | 40 ] | Default: 20
start_dhcp_server(bool, optional): O | Start DHCP server | Default: True
+ band_mode(int, optional): O | Connect on 2.4G (1) or 5G (2) band, or Auto select (3) | Default:3
Returns:
ctrl_cmd: ctrl_cmd object
@@ -197,7 +199,7 @@ def start_softap(self, ssid : str = "", pwd : str = "", channel : int = 1, sec_p
self.out = "Missing param " + "--pwd"
return self
- self.out = process_start_softap(ssid, pwd, channel, sec_prot, max_conn, hide_ssid, bw, start_dhcp_server)
+ self.out = process_start_softap(ssid, pwd, channel, sec_prot, max_conn, hide_ssid, bw, start_dhcp_server, band_mode)
return self
diff --git a/esp_hosted_fg/host/linux/host_control/python_support/py_parse/process.py b/esp_hosted_fg/host/linux/host_control/python_support/py_parse/process.py
index 12a6cf98c2..60709c8fc6 100644
--- a/esp_hosted_fg/host/linux/host_control/python_support/py_parse/process.py
+++ b/esp_hosted_fg/host/linux/host_control/python_support/py_parse/process.py
@@ -153,10 +153,13 @@ def process_get_available_wifi():
return ""
-def process_connect_ap(ssid, pwd, bssid, use_wpa3, listen_interval, set_dhcp):
+def process_connect_ap(ssid, pwd, bssid, use_wpa3, listen_interval, set_dhcp, band_mode):
ret_str = ""
- if test_sync_station_mode_connect(ssid, pwd, bssid, use_wpa3, listen_interval) != SUCCESS:
+ if band_mode < WIFI_BAND_MODE_2G_ONLY or band_mode > WIFI_BAND_MODE_AUTO:
+ return "Invalid band_mode parameter " + get_str(band_mode)
+
+ if test_sync_station_mode_connect(ssid, pwd, bssid, use_wpa3, listen_interval, band_mode) != SUCCESS:
ret_str = "Failed to connect AP"
return ret_str
print("\n")
@@ -207,7 +210,7 @@ def process_softap_vendor_ie(enable, data):
return ""
-def process_start_softap(ssid, pwd, channel, sec_prot, max_conn, hide_ssid, bw, start_dhcp_server):
+def process_start_softap(ssid, pwd, channel, sec_prot, max_conn, hide_ssid, bw, start_dhcp_server, band_mode):
if sec_prot != "open" and pwd == "":
return "password mandatory for security protocol"
@@ -229,14 +232,13 @@ def process_start_softap(ssid, pwd, channel, sec_prot, max_conn, hide_ssid, bw,
else:
return "Unsupported bandwidth " + get_str(bw)
- if channel < 1 or channel > 11:
- return "Channel supported from 1 to 11"
-
-
if max_conn < 1 or max_conn > 10:
return "max connections should be 1 to 10(hardware_max)"
- if test_sync_softap_mode_start(ssid, pwd, channel, encr, max_conn, hide_ssid, bw_l) != SUCCESS:
+ if band_mode < WIFI_BAND_MODE_2G_ONLY or band_mode > WIFI_BAND_MODE_AUTO:
+ return "Invalid band_mode parameter " + str(band_mode) + ": value should be from " + str(WIFI_BAND_MODE_2G_ONLY) + " to " + str(WIFI_BAND_MODE_AUTO)
+
+ if test_sync_softap_mode_start(ssid, pwd, channel, encr, max_conn, hide_ssid, bw_l, band_mode) != SUCCESS:
ret_str = "Failed to start ESP softap"
return ret_str
print("\n")
diff --git a/esp_hosted_fg/host/linux/host_driver/esp32/esp.h b/esp_hosted_fg/host/linux/host_driver/esp32/esp.h
index b9f0a9b802..24805004e8 100644
--- a/esp_hosted_fg/host/linux/host_driver/esp32/esp.h
+++ b/esp_hosted_fg/host/linux/host_driver/esp32/esp.h
@@ -62,6 +62,7 @@ enum chipset_type_e {
ESP_FIRMWARE_CHIP_ESP32S2 = 0x2,
ESP_FIRMWARE_CHIP_ESP32C2 = 0xC,
ESP_FIRMWARE_CHIP_ESP32C3 = 0x5,
+ ESP_FIRMWARE_CHIP_ESP32C5 = 0x17,
ESP_FIRMWARE_CHIP_ESP32C6 = 0xD,
ESP_FIRMWARE_CHIP_ESP32S3 = 0x9,
};
diff --git a/esp_hosted_fg/host/linux/host_driver/esp32/spi/esp_spi.c b/esp_hosted_fg/host/linux/host_driver/esp32/spi/esp_spi.c
index 9eab7c2194..12113c33ed 100644
--- a/esp_hosted_fg/host/linux/host_driver/esp32/spi/esp_spi.c
+++ b/esp_hosted_fg/host/linux/host_driver/esp32/spi/esp_spi.c
@@ -45,6 +45,7 @@
#define ESP_PRIV_FIRMWARE_CHIP_ESP32C3 (0x5)
#define ESP_PRIV_FIRMWARE_CHIP_ESP32S3 (0x9)
#define ESP_PRIV_FIRMWARE_CHIP_ESP32C2 (0xC)
+#define ESP_PRIV_FIRMWARE_CHIP_ESP32C5 (0x17)
#define ESP_PRIV_FIRMWARE_CHIP_ESP32C6 (0xD)
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0))
@@ -226,11 +227,12 @@ int process_init_event(u8 *evt_buf, u8 len)
}
if ((hardware_type != ESP_PRIV_FIRMWARE_CHIP_ESP32) &&
- (hardware_type != ESP_PRIV_FIRMWARE_CHIP_ESP32S2) &&
- (hardware_type != ESP_PRIV_FIRMWARE_CHIP_ESP32C2) &&
- (hardware_type != ESP_PRIV_FIRMWARE_CHIP_ESP32C3) &&
- (hardware_type != ESP_PRIV_FIRMWARE_CHIP_ESP32C6) &&
- (hardware_type != ESP_PRIV_FIRMWARE_CHIP_ESP32S3)) {
+ (hardware_type != ESP_PRIV_FIRMWARE_CHIP_ESP32S2) &&
+ (hardware_type != ESP_PRIV_FIRMWARE_CHIP_ESP32C2) &&
+ (hardware_type != ESP_PRIV_FIRMWARE_CHIP_ESP32C3) &&
+ (hardware_type != ESP_PRIV_FIRMWARE_CHIP_ESP32C5) &&
+ (hardware_type != ESP_PRIV_FIRMWARE_CHIP_ESP32C6) &&
+ (hardware_type != ESP_PRIV_FIRMWARE_CHIP_ESP32S3)) {
esp_err("ESP board type [%d] is not recognized: aborting\n", hardware_type);
hardware_type = ESP_PRIV_FIRMWARE_CHIP_UNRECOGNIZED;
return -1;