developer | 3b7aaa7 | 2022-07-15 11:55:52 +0800 | [diff] [blame] | 1 | From 801018bbcf3427713997b1ead85fec6c9acaf2bb Mon Sep 17 00:00:00 2001 |
| 2 | From: "howard.hsu" <howard-yh.hsu@mediatek.com> |
| 3 | Date: Wed, 6 Apr 2022 09:20:37 +0800 |
| 4 | Subject: [PATCH] HAL: refactor wifi_getRadioEnable() |
| 5 | |
| 6 | --- |
| 7 | source/wifi/wifi_hal.c | 11 ++++++++--- |
| 8 | 1 file changed, 8 insertions(+), 3 deletions(-) |
| 9 | |
| 10 | diff --git a/source/wifi/wifi_hal.c b/source/wifi/wifi_hal.c |
| 11 | index 1d07d19..c753d99 100644 |
| 12 | --- a/source/wifi/wifi_hal.c |
| 13 | +++ b/source/wifi/wifi_hal.c |
| 14 | @@ -1025,13 +1025,18 @@ INT wifi_getRadioEnable(INT radioIndex, BOOL *output_bool) //RDKB |
| 15 | |
| 16 | snprintf(interface_path, sizeof(interface_path), "/sys/class/net/%s%d/address", RADIO_PREFIX, radioIndex); |
| 17 | fp = fopen(interface_path, "r"); |
| 18 | - if(fp) |
| 19 | + if(!fp) |
| 20 | { |
| 21 | - *output_bool = TRUE; |
| 22 | - fclose(fp); |
| 23 | + return RETURN_OK; |
| 24 | } |
| 25 | //TODO: check if hostapd with config is running |
| 26 | + char buf[MAX_BUF_SIZE] = {0}, cmd[MAX_CMD_SIZE] = {0}; |
| 27 | + sprintf(cmd, "hostapd_cli -i %s%d status | grep state | cut -d '=' -f2", AP_PREFIX, radioIndex); |
| 28 | + _syscmd(cmd, buf, sizeof(buf)); |
| 29 | |
| 30 | + if(!strncmp(buf, "ENABLED", 7)) |
| 31 | + *output_bool = TRUE; |
| 32 | + fclose(fp); |
| 33 | return RETURN_OK; |
| 34 | } |
| 35 | |
| 36 | -- |
| 37 | 2.18.0 |
| 38 | |