[rdkb][common][hal][Fix Colgin harrier cann't distinguish 2g band]
[Description]
Fix Colgin harrier cann't distinguish 2g band.
If hal detect a harrier, hal will read hostapd config not phy info.
[Release-log]
N/A
Change-Id: I6cfb54f9659d6c63ff0e83c7b1c467b21ba248ea
diff --git a/src/wifi/wifi_hal.c b/src/wifi/wifi_hal.c
index a51a444..07f1069 100644
--- a/src/wifi/wifi_hal.c
+++ b/src/wifi/wifi_hal.c
@@ -479,10 +479,46 @@
return RETURN_OK;
}
+static int wifi_hostapdRead(char *conf_file, char *param, char *output, int output_size)
+{
+ char cmd[MAX_CMD_SIZE]={'\0'};
+ char buf[MAX_BUF_SIZE]={'\0'};
+ int ret = 0;
+
+ sprintf(cmd, "cat %s 2> /dev/null | grep \"^%s=\" | cut -d \"=\" -f 2 | head -n1 | tr -d \"\\n\"", conf_file, param);
+ ret = _syscmd(cmd, buf, sizeof(buf));
+ if ((ret != 0) && (strlen(buf) == 0))
+ return -1;
+ snprintf(output, output_size, "%s", buf);
+
+ return 0;
+}
+
+static int wifi_hostapdWrite(char *conf_file, struct params *list, int item_count)
+{
+ char cmd[MAX_CMD_SIZE]={'\0'};
+ char buf[MAX_BUF_SIZE]={'\0'};
+
+ for(int i=0;i<item_count;i++)
+ {
+ wifi_hostapdRead(conf_file, list[i].name, buf, sizeof(buf));
+ if (strlen(buf) == 0) //Insert
+ snprintf(cmd, sizeof(cmd), "echo \"%s=%s\" >> %s", list[i].name, list[i].value, conf_file);
+ else //Update
+ snprintf(cmd, sizeof(cmd), "sed -i \"s/^%s=.*/%s=%s/\" %s", list[i].name, list[i].name, list[i].value, conf_file);
+
+ if(_syscmd(cmd, buf, sizeof(buf)))
+ return -1;
+ }
+
+ return 0;
+}
+
wifi_band wifi_index_to_band(int apIndex)
{
char cmd[128] = {0};
char buf[64] = {0};
+ char config_file[128] = {0};
int nl80211_band = 0;
int i = 0;
int phyIndex = 0;
@@ -495,8 +531,18 @@
wifi_getMaxRadioNumber(&max_radio_num);
radioIndex = apIndex % max_radio_num;
phyIndex = radio_index_to_phy(radioIndex);
+ snprintf(cmd, sizeof(cmd), "cat /sys/class/ieee80211/phy%d/device/device 2> /dev/null", phyIndex);
+ _syscmd(cmd, buf, sizeof(buf));
+ if (strncmp(buf, "0x7915", 6) == 0) { // harrier have two bands, consider as a special case.
+ snprintf(config_file, sizeof(config_file), "%s%d.conf", CONFIG_PREFIX, apIndex);
+ wifi_hostapdRead(config_file, "hw_mode", buf, sizeof(buf));
+ if (strncmp(buf, "a", 1) == 0)
+ return band_5;
+ else
+ return band_2_4;
+ }
while(i < 10){
- snprintf(cmd, sizeof(cmd), "iw phy%d info | grep 'Band .:' | tail -n 1 | tr -d ':\\n' | awk '{print $2}'", phyIndex);
+ snprintf(cmd, sizeof(cmd), "iw phy%d info | grep 'Band .:' | tr -d ':\\n' | awk '{print $2}'", phyIndex);
_syscmd(cmd, buf, sizeof(buf));
nl80211_band = strtol(buf, NULL, 10);
if (nl80211_band == 1)
@@ -517,41 +563,6 @@
return band;
}
-static int wifi_hostapdRead(char *conf_file, char *param, char *output, int output_size)
-{
- char cmd[MAX_CMD_SIZE]={'\0'};
- char buf[MAX_BUF_SIZE]={'\0'};
- int ret = 0;
-
- sprintf(cmd, "cat %s 2> /dev/null | grep \"^%s=\" | cut -d \"=\" -f 2 | head -n1 | tr -d \"\\n\"", conf_file, param);
- ret = _syscmd(cmd, buf, sizeof(buf));
- if ((ret != 0) && (strlen(buf) == 0))
- return -1;
- snprintf(output, output_size, "%s", buf);
-
- return 0;
-}
-
-static int wifi_hostapdWrite(char *conf_file, struct params *list, int item_count)
-{
- char cmd[MAX_CMD_SIZE]={'\0'};
- char buf[MAX_BUF_SIZE]={'\0'};
-
- for(int i=0;i<item_count;i++)
- {
- wifi_hostapdRead(conf_file, list[i].name, buf, sizeof(buf));
- if (strlen(buf) == 0) //Insert
- snprintf(cmd, sizeof(cmd), "echo \"%s=%s\" >> %s", list[i].name, list[i].value, conf_file);
- else //Update
- snprintf(cmd, sizeof(cmd), "sed -i \"s/^%s=.*/%s=%s/\" %s", list[i].name, list[i].name, list[i].value, conf_file);
-
- if(_syscmd(cmd, buf, sizeof(buf)))
- return -1;
- }
-
- return 0;
-}
-
//For Getting Current Interface Name from corresponding hostapd configuration
static int wifi_GetInterfaceName(int apIndex, char *interface_name)
{
@@ -2130,8 +2141,6 @@
WIFI_ENTRY_EXIT_DEBUG("Inside %s:%d\n", __func__, __LINE__);
band = wifi_index_to_band(radioIndex);
- if (band != band_2_4)
- return RETURN_OK;
sprintf(config_file, "%s%d.conf", CONFIG_PREFIX, radioIndex);
params.name = "noscan";