[rdk-b][mt7986][wifi-hal][Add getRadioPossibleChannels]
[Description]
Add getRadioPossibleChannels
1. Use iw instead of iwlist
2. Add a check of dfs enable. If dfs is disable, the function should ignore dfs channels.
[Release-log]
N/A
diff --git a/src/wifi/wifi_hal.c b/src/wifi/wifi_hal.c
index 8457122..da84f6d 100644
--- a/src/wifi/wifi_hal.c
+++ b/src/wifi/wifi_hal.c
@@ -1568,10 +1568,24 @@
//The output_string is a max length 64 octet string that is allocated by the RDKB code. Implementations must ensure that strings are not longer than this.
INT wifi_getRadioPossibleChannels(INT radioIndex, CHAR *output_string) //RDKB
{
+ WIFI_ENTRY_EXIT_DEBUG("Inside %s:%d\n",__func__, __LINE__);
if (NULL == output_string)
return RETURN_ERR;
- //TODO:read this from iw phy phyX info |grep MHz
- snprintf(output_string, 64, (radioIndex == 0)?"1,2,3,4,5,6,7,8,9,10,11":"36,40,44,48,52,56,60,64,100,104,108,112,116,120,124,128,132,136,140");
+ char cmd[256] = {0};
+ char buf[128] = {0};
+ BOOL dfs_enable = false;
+ // Parse possible channel number and separate them with commas.
+ wifi_getRadioDfsEnable(radioIndex, &dfs_enable);
+ if (dfs_enable)
+ snprintf(cmd, sizeof(cmd), "iw phy phy%d info | grep -e '\\*.*MHz .*dBm' | cut -d '[' -f2 | cut -d ']' -f1 | tr '\\n' ',' | sed 's/.$//'", radioIndex);
+ else
+ snprintf(cmd, sizeof(cmd), "iw phy phy%d info | grep -e '\\*.*MHz .*dBm' | grep -v 'radar' | cut -d '[' -f2 | cut -d ']' -f1 | tr '\\n' ',' | sed 's/.$//'", radioIndex);
+
+ _syscmd(cmd,buf,sizeof(buf));
+ strncpy(output_string, buf, sizeof(buf));
+
+ WIFI_ENTRY_EXIT_DEBUG("Exiting %s:%d\n",__func__, __LINE__);
+ return RETURN_OK;
#if 0
char IFName[50] ={0};
char buf[MAX_BUF_SIZE] = {0};