blob: 9fc54a129e472f16c5c44aff29614c1336b565fb [file] [log] [blame]
developer4d0c6a52022-07-12 13:27:26 +08001From f804c8f10fc057308def2fb70c9c94922b03f161 Mon Sep 17 00:00:00 2001
2From: "Allen.Ye" <allen.ye@mediatek.com>
3Date: Mon, 11 Jul 2022 17:47:56 +0800
4Subject: [PATCH] [patch] HAL: implement wifi_setRadioCountryCode() &
developer15a43312022-04-12 11:23:23 +08005 wifi_getRadioCountryCode()
6
developer15a43312022-04-12 11:23:23 +08007---
8 source/wifi/wifi_hal.c | 37 +++++++++++++++++++++++++++++++++++--
9 1 file changed, 35 insertions(+), 2 deletions(-)
10
11diff --git a/source/wifi/wifi_hal.c b/source/wifi/wifi_hal.c
developer4d0c6a52022-07-12 13:27:26 +080012index 51f25c6..23572ac 100644
developer15a43312022-04-12 11:23:23 +080013--- a/source/wifi/wifi_hal.c
14+++ b/source/wifi/wifi_hal.c
developer4d0c6a52022-07-12 13:27:26 +080015@@ -929,9 +929,16 @@ INT wifi_createInitialConfigFiles()
developer15a43312022-04-12 11:23:23 +080016 // outputs the country code to a max 64 character string
17 INT wifi_getRadioCountryCode(INT radioIndex, CHAR *output_string)
18 {
19- if (NULL == output_string)
20+ char buf[MAX_BUF_SIZE] = {0}, cmd[MAX_CMD_SIZE] = {0}, *value;
21+ if(!output_string || !(radioIndex==0 || radioIndex==1))
22+ return RETURN_ERR;
23+
24+ sprintf(cmd,"hostapd_cli -i %s%d status driver | grep country | cut -d '=' -f2", AP_PREFIX, radioIndex);
25+ _syscmd(cmd, buf, sizeof(buf));
26+ if(strlen(buf) > 0)
27+ snprintf(output_string, 64, "%s", buf);
28+ else
29 return RETURN_ERR;
developer4d0c6a52022-07-12 13:27:26 +080030- snprintf(output_string, 64, "US");
developer15a43312022-04-12 11:23:23 +080031
32 return RETURN_OK;
33 }
developer4d0c6a52022-07-12 13:27:26 +080034@@ -939,6 +946,32 @@ INT wifi_getRadioCountryCode(INT radioIndex, CHAR *output_string)
developer15a43312022-04-12 11:23:23 +080035 INT wifi_setRadioCountryCode(INT radioIndex, CHAR *CountryCode)
36 {
37 //Set wifi config. Wait for wifi reset to apply
38+ char str[MAX_BUF_SIZE]={'\0'};
39+ char cmd[MAX_CMD_SIZE]={'\0'};
40+ struct params params;
41+ char config_file[MAX_BUF_SIZE] = {0};
42+
43+ WIFI_ENTRY_EXIT_DEBUG("Inside %s:%d\n",__func__, __LINE__);
44+ if(NULL == CountryCode || strlen(CountryCode) >= 32 )
45+ return RETURN_ERR;
46+
47+ params.name = "country_code";
48+ params.value = CountryCode;
49+ sprintf(config_file,"%s%d.conf",CONFIG_PREFIX, radioIndex);
50+ int ret = wifi_hostapdWrite(config_file, &params, 1);
51+ if (ret) {
52+ WIFI_ENTRY_EXIT_DEBUG("Inside %s: wifi_hostapdWrite() return %d\n"
53+ ,__func__, ret);
54+ }
55+
56+ ret = wifi_hostapdProcessUpdate(radioIndex, &params, 1);
57+ if (ret) {
58+ WIFI_ENTRY_EXIT_DEBUG("Inside %s: wifi_hostapdProcessUpdate() return %d\n"
59+ ,__func__, ret);
60+ }
61+ wifi_reloadAp(radioIndex);
62+ WIFI_ENTRY_EXIT_DEBUG("Exiting %s:%d\n",__func__, __LINE__);
63+
64 return RETURN_OK;
65 }
66
67--
developer4d0c6a52022-07-12 13:27:26 +0800682.18.0
developer15a43312022-04-12 11:23:23 +080069