blob: 8156eb36f188174b9e47a478685fbae553fc4b67 [file] [log] [blame]
From c47c87b8412a219286e6f80cd8234aa506465be3 Mon Sep 17 00:00:00 2001
From: "Allen.Ye" <allen.ye@mediatek.com>
Date: Thu, 28 Jul 2022 10:52:36 +0800
Subject: [PATCH] HAL: refactor set and get Beacon Rate function
---
source/wifi/wifi_hal.c | 52 ++++++++++++++++++++++++++++++++++++++++--
1 file changed, 50 insertions(+), 2 deletions(-)
diff --git a/source/wifi/wifi_hal.c b/source/wifi/wifi_hal.c
index 6596cfc..0e047fc 100644
--- a/source/wifi/wifi_hal.c
+++ b/source/wifi/wifi_hal.c
@@ -618,14 +618,62 @@ static int readBandWidth(int radioIndex,char *bw_value)
return RETURN_OK;
}
+// Input must be "1Mbps"; "5.5Mbps"; "6Mbps"; "2Mbps"; "11Mbps"; "12Mbps"; "24Mbps"
INT wifi_setApBeaconRate(INT radioIndex,CHAR *beaconRate)
{
- return 0;
+ struct params params={'\0'};
+ char config_file[MAX_BUF_SIZE] = {0};
+ char buf[MAX_BUF_SIZE] = {'\0'};
+
+ WIFI_ENTRY_EXIT_DEBUG("Inside %s:%d\n",__func__, __LINE__);
+ if (strlen (beaconRate) < 5)
+ return RETURN_ERR;
+ // Copy the numeric value
+ strncpy(buf, beaconRate, strlen(beaconRate) - 4);
+ buf[strlen(beaconRate) - 4] = '\0';
+
+ params.name = "beacon_rate";
+ // hostapd config unit is 100 kbps. To convert Mbps to 100kbps, the value need to multiply 10.
+ if (strncmp(buf, "5.5", 3) == 0) {
+ snprintf(buf, sizeof(buf), "55");
+ params.value = buf;
+ } else {
+ strcat(buf, "0");
+ params.value = buf;
+ }
+
+ sprintf(config_file, "%s%d.conf", CONFIG_PREFIX, radioIndex);
+ wifi_hostapdWrite(config_file, &params, 1);
+ wifi_hostapdProcessUpdate(radioIndex, &params, 1);
+ WIFI_ENTRY_EXIT_DEBUG("Exiting %s:%d\n",__func__, __LINE__);
+
+ return RETURN_OK;
}
INT wifi_getApBeaconRate(INT radioIndex, CHAR *beaconRate)
{
- return 0;
+ char config_file[MAX_BUF_SIZE] = {'\0'};
+ char temp_output[MAX_BUF_SIZE] = {'\0'};
+ char buf[MAX_BUF_SIZE] = {'\0'};
+ float rate = 0;
+
+ WIFI_ENTRY_EXIT_DEBUG("Inside %s:%d\n",__func__, __LINE__);
+ if (NULL == beaconRate)
+ return RETURN_ERR;
+
+ sprintf(config_file, "%s%d.conf", CONFIG_PREFIX, radioIndex);
+ wifi_hostapdRead(config_file, "beacon_rate", buf, sizeof(buf));
+ // Hostapd unit is 100kbps. To convert to 100kbps to Mbps, the value need to divide 10.
+ if(strlen(buf) > 0) {
+ rate = atof(buf)/10;
+ snprintf(temp_output, sizeof(temp_output), "%.1fMbps", rate);
+ } else {
+ snprintf(temp_output, sizeof(temp_output), "1Mbps"); // default value
+ }
+ strncpy(beaconRate, temp_output, sizeof(temp_output));
+ WIFI_ENTRY_EXIT_DEBUG("Exiting %s:%d\n",__func__, __LINE__);
+
+ return RETURN_OK;
}
INT wifi_setLED(INT radioIndex, BOOL enable)
--
2.18.0