From bedd99f06ca9fa2df1b6c3c8c4aa7ce27dc37080 Mon Sep 17 00:00:00 2001 From: nuttxs Date: Mon, 14 Oct 2024 09:51:05 +0800 Subject: [PATCH] xtensa/esp32s3: add wapi support for getting country code commands on ESP32-S3 --- arch/xtensa/src/esp32s3/esp32s3_wifi_adapter.c | 9 ++++++++- arch/xtensa/src/esp32s3/esp32s3_wlan.c | 4 ++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/arch/xtensa/src/esp32s3/esp32s3_wifi_adapter.c b/arch/xtensa/src/esp32s3/esp32s3_wifi_adapter.c index 071c251647915..f8d583308f9d3 100644 --- a/arch/xtensa/src/esp32s3/esp32s3_wifi_adapter.c +++ b/arch/xtensa/src/esp32s3/esp32s3_wifi_adapter.c @@ -5884,7 +5884,14 @@ int esp_wifi_sta_country(struct iwreq *iwr, bool set) } else { - return -ENOSYS; + memset(&country, 0x00, sizeof(wifi_country_t)); + ret = esp_wifi_get_country(&country); + if (ret) + { + wlerr("Failed to get country info ret=%d\n", ret); + return wifi_errno_trans(ret); + } + memcpy(iwr->u.data.pointer, country.cc, 2); } return OK; diff --git a/arch/xtensa/src/esp32s3/esp32s3_wlan.c b/arch/xtensa/src/esp32s3/esp32s3_wlan.c index 638d802a9a9ac..d7c0578d0b86c 100644 --- a/arch/xtensa/src/esp32s3/esp32s3_wlan.c +++ b/arch/xtensa/src/esp32s3/esp32s3_wlan.c @@ -1377,6 +1377,10 @@ static int wlan_ioctl(struct net_driver_s *dev, ret = ops->country(iwr, true); break; + case SIOCGIWCOUNTRY: /* Set country code */ + ret = ops->country(iwr, false); + break; + case SIOCGIWSENS: /* Get sensitivity (dBm) */ ret = ops->rssi(iwr, false); break;