developer | 4d0c6a5 | 2022-07-12 13:27:26 +0800 | [diff] [blame^] | 1 | From f804c8f10fc057308def2fb70c9c94922b03f161 Mon Sep 17 00:00:00 2001 |
| 2 | From: "Allen.Ye" <allen.ye@mediatek.com> |
| 3 | Date: Mon, 11 Jul 2022 17:47:56 +0800 |
| 4 | Subject: [PATCH] [patch] HAL: implement wifi_setRadioCountryCode() & |
developer | 15a4331 | 2022-04-12 11:23:23 +0800 | [diff] [blame] | 5 | wifi_getRadioCountryCode() |
| 6 | |
developer | 15a4331 | 2022-04-12 11:23:23 +0800 | [diff] [blame] | 7 | --- |
| 8 | source/wifi/wifi_hal.c | 37 +++++++++++++++++++++++++++++++++++-- |
| 9 | 1 file changed, 35 insertions(+), 2 deletions(-) |
| 10 | |
| 11 | diff --git a/source/wifi/wifi_hal.c b/source/wifi/wifi_hal.c |
developer | 4d0c6a5 | 2022-07-12 13:27:26 +0800 | [diff] [blame^] | 12 | index 51f25c6..23572ac 100644 |
developer | 15a4331 | 2022-04-12 11:23:23 +0800 | [diff] [blame] | 13 | --- a/source/wifi/wifi_hal.c |
| 14 | +++ b/source/wifi/wifi_hal.c |
developer | 4d0c6a5 | 2022-07-12 13:27:26 +0800 | [diff] [blame^] | 15 | @@ -929,9 +929,16 @@ INT wifi_createInitialConfigFiles() |
developer | 15a4331 | 2022-04-12 11:23:23 +0800 | [diff] [blame] | 16 | // 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; |
developer | 4d0c6a5 | 2022-07-12 13:27:26 +0800 | [diff] [blame^] | 30 | - snprintf(output_string, 64, "US"); |
developer | 15a4331 | 2022-04-12 11:23:23 +0800 | [diff] [blame] | 31 | |
| 32 | return RETURN_OK; |
| 33 | } |
developer | 4d0c6a5 | 2022-07-12 13:27:26 +0800 | [diff] [blame^] | 34 | @@ -939,6 +946,32 @@ INT wifi_getRadioCountryCode(INT radioIndex, CHAR *output_string) |
developer | 15a4331 | 2022-04-12 11:23:23 +0800 | [diff] [blame] | 35 | 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, ¶ms, 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, ¶ms, 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 | -- |
developer | 4d0c6a5 | 2022-07-12 13:27:26 +0800 | [diff] [blame^] | 68 | 2.18.0 |
developer | 15a4331 | 2022-04-12 11:23:23 +0800 | [diff] [blame] | 69 | |