[rdkb][common][hal][Fix wifi agent generate data model failed]
[Description]
Fix wifi agent generate data model failed.
We give wifi agent a fake interface name and index to generate datamodel successfully.
[Release-log]
N/A
Change-Id: I2347396cf057130322693b3a223e861f25930df5
diff --git a/src/wifi/wifi_hal.c b/src/wifi/wifi_hal.c
index fdb5817..6c462dd 100644
--- a/src/wifi/wifi_hal.c
+++ b/src/wifi/wifi_hal.c
@@ -4954,7 +4954,7 @@
return RETURN_ERR;
if (GetInterfaceName(apIndex, interface_name) != RETURN_OK)
- memset(output_string, 0, 16);
+ snprintf(output_string, 16, "%s%d", AP_PREFIX, apIndex); // For wifiagent generating data model.
else
snprintf(output_string, 16, "%s", interface_name);
return RETURN_OK;
@@ -4971,17 +4971,23 @@
snprintf(cmd, sizeof(cmd), "grep -rn ^interface=%s$ /nvram/hostapd*.conf | cut -d '.' -f1 | cut -d 'd' -f2 | tr -d '\\n'", inputSsidString);
_syscmd(cmd, buf, sizeof(buf));
- // May get multiple output, so we need to check which ap is enable.
+
apIndex_str = strtok(buf, "\n");
while (apIndex_str != NULL) {
apIndex = strtoul(apIndex_str, NULL, 10);
- wifi_getApEnable(apIndex, &enable);
if (enable == TRUE) {
*output_int = apIndex;
return RETURN_OK;
}
apIndex_str = strtok(NULL, "\n");
}
+
+ // If interface name is not in hostapd config, the caller maybe wifi agent to generate data model.
+ apIndex_str = strstr(inputSsidString, AP_PREFIX);
+ if (apIndex_str) {
+ sscanf(apIndex_str + strlen(AP_PREFIX), "%d", output_int);
+ return RETURN_OK;
+ }
*output_int = -1;
return RETURN_OK;
}