From: Márton Németh <nm...@freemail.hu>

When a system has more than one WiFi interface (not necessarily active at the
same time) the WiFi interface may not be called always /sys/class/net/wlan0 .
Check for all "wlan" strings in /sys/class/net/ directory and add
all of them one by one.

Signed-off-by: Márton Németh <nm...@freemail.hu>
---
diff --git a/tuning/wifi.cpp b/tuning/wifi.cpp
index 659ac9c..38d9be6 100644
--- a/tuning/wifi.cpp
+++ b/tuning/wifi.cpp
@@ -86,16 +86,27 @@ const char *wifi_tunable::toggle_script(void)

 void add_wifi_tunables(void)
 {
+       struct dirent *entry;
        DIR *dir;
+       char* wlan_name;
        class wifi_tunable *wifi;


-       dir = opendir("/sys/class/net/wlan0/");
+       dir = opendir("/sys/class/net/");
        if (!dir)
                return;
-       closedir(dir);
+       while (1) {
+               entry = readdir(dir);
+               if (!entry)
+                       break;
+               wlan_name = strstr(entry->d_name, "wlan");
+               if (wlan_name) {
+                       wifi = new class wifi_tunable(wlan_name);
+                       all_tunables.push_back(wifi);
+               }
+       
+       }

-       wifi = new class wifi_tunable("wlan0");
+       closedir(dir);

-       all_tunables.push_back(wifi);
 }

_______________________________________________
Power mailing list
Power@bughost.org
https://bughost.org/mailman/listinfo/power

Reply via email to