| From b9c9912e64f040ce214679925a434ec54685f1b0 Mon Sep 17 00:00:00 2001 |
| From: "howard.hsu" <howard-yh.hsu@mediatek.com> |
| Date: Tue, 22 Feb 2022 17:02:42 +0800 |
| Subject: [PATCH 01/18] [patch] HAL: implement wifi_setRadioCountryCode() & |
| wifi_getRadioCountryCode() |
| |
| Change-Id: I32f948112e924379da5e1f8a5300257171841589 |
| --- |
| source/wifi/wifi_hal.c | 37 +++++++++++++++++++++++++++++++++++-- |
| 1 file changed, 35 insertions(+), 2 deletions(-) |
| |
| diff --git a/source/wifi/wifi_hal.c b/source/wifi/wifi_hal.c |
| index 6a11b049..14452dd4 100644 |
| --- a/source/wifi/wifi_hal.c |
| +++ b/source/wifi/wifi_hal.c |
| @@ -907,9 +907,16 @@ INT wifi_createInitialConfigFiles() |
| // outputs the country code to a max 64 character string |
| INT wifi_getRadioCountryCode(INT radioIndex, CHAR *output_string) |
| { |
| - if (NULL == output_string) |
| + char buf[MAX_BUF_SIZE] = {0}, cmd[MAX_CMD_SIZE] = {0}, *value; |
| + if(!output_string || !(radioIndex==0 || radioIndex==1)) |
| + return RETURN_ERR; |
| + |
| + sprintf(cmd,"hostapd_cli -i %s%d status driver | grep country | cut -d '=' -f2", AP_PREFIX, radioIndex); |
| + _syscmd(cmd, buf, sizeof(buf)); |
| + if(strlen(buf) > 0) |
| + snprintf(output_string, 64, "%s", buf); |
| + else |
| return RETURN_ERR; |
| - snprintf(output_string, 64, "841"); |
| |
| return RETURN_OK; |
| } |
| @@ -917,6 +924,32 @@ INT wifi_getRadioCountryCode(INT radioIndex, CHAR *output_string) |
| INT wifi_setRadioCountryCode(INT radioIndex, CHAR *CountryCode) |
| { |
| //Set wifi config. Wait for wifi reset to apply |
| + char str[MAX_BUF_SIZE]={'\0'}; |
| + char cmd[MAX_CMD_SIZE]={'\0'}; |
| + struct params params; |
| + char config_file[MAX_BUF_SIZE] = {0}; |
| + |
| + WIFI_ENTRY_EXIT_DEBUG("Inside %s:%d\n",__func__, __LINE__); |
| + if(NULL == CountryCode || strlen(CountryCode) >= 32 ) |
| + return RETURN_ERR; |
| + |
| + params.name = "country_code"; |
| + params.value = CountryCode; |
| + sprintf(config_file,"%s%d.conf",CONFIG_PREFIX, radioIndex); |
| + int ret = wifi_hostapdWrite(config_file, ¶ms, 1); |
| + if (ret) { |
| + WIFI_ENTRY_EXIT_DEBUG("Inside %s: wifi_hostapdWrite() return %d\n" |
| + ,__func__, ret); |
| + } |
| + |
| + ret = wifi_hostapdProcessUpdate(radioIndex, ¶ms, 1); |
| + if (ret) { |
| + WIFI_ENTRY_EXIT_DEBUG("Inside %s: wifi_hostapdProcessUpdate() return %d\n" |
| + ,__func__, ret); |
| + } |
| + wifi_reloadAp(radioIndex); |
| + WIFI_ENTRY_EXIT_DEBUG("Exiting %s:%d\n",__func__, __LINE__); |
| + |
| return RETURN_OK; |
| } |
| |
| -- |
| 2.29.2 |
| |