developer | 65c1a0c | 2022-08-30 21:07:20 +0800 | [diff] [blame] | 1 | From 404109f913afc751127ccba752b7dbba98e5ba8b Mon Sep 17 00:00:00 2001 |
developer | 0d67a39 | 2022-07-15 11:55:52 +0800 | [diff] [blame] | 2 | From: "Allen.Ye" <allen.ye@mediatek.com> |
developer | 65c1a0c | 2022-08-30 21:07:20 +0800 | [diff] [blame] | 3 | Date: Tue, 30 Aug 2022 18:34:17 +0800 |
| 4 | Subject: [PATCH 1/2] HAL: refactor wifi_getRadioPossibleChannels |
developer | 0d67a39 | 2022-07-15 11:55:52 +0800 | [diff] [blame] | 5 | |
| 6 | --- |
developer | 65c1a0c | 2022-08-30 21:07:20 +0800 | [diff] [blame] | 7 | source/wifi/wifi_hal.c | 18 ++++++++++++++++-- |
| 8 | 1 file changed, 16 insertions(+), 2 deletions(-) |
developer | 0d67a39 | 2022-07-15 11:55:52 +0800 | [diff] [blame] | 9 | |
| 10 | diff --git a/source/wifi/wifi_hal.c b/source/wifi/wifi_hal.c |
developer | 65c1a0c | 2022-08-30 21:07:20 +0800 | [diff] [blame] | 11 | index d2f0c3b..d44eab0 100644 |
developer | 0d67a39 | 2022-07-15 11:55:52 +0800 | [diff] [blame] | 12 | --- a/source/wifi/wifi_hal.c |
| 13 | +++ b/source/wifi/wifi_hal.c |
developer | 65c1a0c | 2022-08-30 21:07:20 +0800 | [diff] [blame] | 14 | @@ -1925,10 +1925,24 @@ INT wifi_setRadioMode(INT radioIndex, CHAR *channelMode, UINT pureMode) |
developer | 0d67a39 | 2022-07-15 11:55:52 +0800 | [diff] [blame] | 15 | //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. |
| 16 | INT wifi_getRadioPossibleChannels(INT radioIndex, CHAR *output_string) //RDKB |
| 17 | { |
| 18 | + WIFI_ENTRY_EXIT_DEBUG("Inside %s:%d\n",__func__, __LINE__); |
| 19 | if (NULL == output_string) |
| 20 | return RETURN_ERR; |
| 21 | - //TODO:read this from iw phy phyX info |grep MHz |
| 22 | - 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"); |
developer | 65c1a0c | 2022-08-30 21:07:20 +0800 | [diff] [blame] | 23 | + char cmd[256] = {0}; |
| 24 | + char buf[128] = {0}; |
| 25 | + BOOL dfs_enable = false; |
developer | 0d67a39 | 2022-07-15 11:55:52 +0800 | [diff] [blame] | 26 | + // Parse possible channel number and separate them with commas. |
developer | 65c1a0c | 2022-08-30 21:07:20 +0800 | [diff] [blame] | 27 | + wifi_getRadioDfsEnable(radioIndex, &dfs_enable); |
| 28 | + if (dfs_enable) |
| 29 | + snprintf(cmd, sizeof(cmd), "iw phy phy%d info | grep -e '\\*.*MHz .*dBm' | cut -d '[' -f2 | cut -d ']' -f1 | tr '\\n' ',' | sed 's/.$//'", radioIndex); |
| 30 | + else |
| 31 | + 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); |
| 32 | + |
developer | 0d67a39 | 2022-07-15 11:55:52 +0800 | [diff] [blame] | 33 | + _syscmd(cmd,buf,sizeof(buf)); |
developer | 65c1a0c | 2022-08-30 21:07:20 +0800 | [diff] [blame] | 34 | + strncpy(output_string, buf, sizeof(buf)); |
developer | 0d67a39 | 2022-07-15 11:55:52 +0800 | [diff] [blame] | 35 | + |
| 36 | + WIFI_ENTRY_EXIT_DEBUG("Exiting %s:%d\n",__func__, __LINE__); |
| 37 | + return RETURN_OK; |
| 38 | #if 0 |
| 39 | char IFName[50] ={0}; |
| 40 | char buf[MAX_BUF_SIZE] = {0}; |
| 41 | -- |
| 42 | 2.18.0 |
| 43 | |