@@ -65,20 +65,6 @@ def check_wifi_power_save(self):
65
65
except :
66
66
pass
67
67
68
- # Check iwconfig power management
69
- try :
70
- result = subprocess .run (f"iwconfig { self .interface } " ,
71
- shell = True , capture_output = True , text = True , timeout = 5 )
72
- if "Power Management:on" in result .stdout :
73
- issues .append ({
74
- 'severity' : 'high' ,
75
- 'issue' : 'iwconfig shows Power Management ON' ,
76
- 'impact' : 'Causes disconnects every 1-5 minutes' ,
77
- 'fix' : f'sudo iwconfig { self .interface } power off'
78
- })
79
- except :
80
- pass
81
-
82
68
return issues
83
69
84
70
def check_usb_autosuspend (self ):
@@ -150,12 +136,13 @@ def check_pcie_aspm(self):
150
136
if os .path .exists (aspm_path ): # FIXED: was "asmp_path"
151
137
with open (aspm_path , 'r' ) as f : # FIXED: was "asmp_path"
152
138
policy = f .read ().strip ()
153
- if "powersave" in policy or " powersupersave" in policy :
139
+ if policy [ policy . find ( '[' ) + 1 : policy . find ( ']' )] in [ 'default' , 'powersave' , ' powersupersave' ] :
154
140
issues .append ({
155
141
'severity' : 'medium' ,
156
142
'issue' : f'PCIe ASPM set to: { policy } ' ,
157
143
'impact' : 'Can cause latency and brief disconnects' ,
158
- 'fix' : 'Add pcie_aspm=off to kernel boot parameters'
144
+ 'fix' : 'Add pcie_aspm=off to kernel boot parameters' ,
145
+ 'manual_only' : True
159
146
})
160
147
except :
161
148
pass
@@ -168,16 +155,13 @@ def check_network_manager_power(self):
168
155
169
156
try :
170
157
# Check if NetworkManager is managing power
171
- nm_conf_paths = [
172
- "/etc/NetworkManager/conf.d/default-wifi-powersave-on.conf" ,
173
- "/etc/NetworkManager/conf.d/wifi-powersave.conf"
174
- ]
158
+ nm_conf_paths = [f for f in glob .glob ("/etc/NetworkManager/conf.d/*.conf" ) if os .path .isfile (f )]
175
159
176
160
for conf_path in nm_conf_paths :
177
161
if os .path .exists (conf_path ):
178
162
with open (conf_path , 'r' ) as f :
179
163
content = f .read ()
180
- if "wifi.powersave = 3" in content or "wifi.powersave = 2 " in content :
164
+ if "wifi.powersave = 3" in content or "wifi.powersave = 1" in content or "wifi.powersave = 0 " in content :
181
165
issues .append ({
182
166
'severity' : 'high' ,
183
167
'issue' : 'NetworkManager WiFi power saving enabled' ,
@@ -600,29 +584,21 @@ def _generate_report(self, issues):
600
584
def _generate_fix_script (self , issues ):
601
585
"""Generate a script to fix all issues"""
602
586
fixes = []
587
+ manual_fixes = []
603
588
604
589
for category_issues in issues .values ():
605
590
for issue in category_issues :
606
591
if 'fix' in issue and issue .get ('severity' ) in ['high' , 'medium' ]:
607
- fixes .append (issue ['fix' ])
608
-
609
- if fixes :
610
- print ("\n 📝 Generated fix script: /tmp/fix_wifi_power.sh" )
611
- with open ("/tmp/fix_wifi_power.sh" , "w" ) as f :
612
- f .write ("#!/bin/bash\n " )
613
- f .write ("# WiFi Power Management Fixes\n " )
614
- f .write ("# Generated by mesh_power_detective.py\n \n " )
615
-
616
- f .write ("echo 'Applying WiFi power management fixes...'\n \n " )
617
-
618
- for fix in fixes :
619
- f .write (f"echo 'Running: { fix } '\n " )
620
- f .write (f"{ fix } \n \n " )
621
-
622
- f .write ("echo 'Fixes applied! Restart WiFi or reboot to ensure all changes take effect.'\n " )
623
-
624
- os .chmod ("/tmp/fix_wifi_power.sh" , 0o755 )
625
- print ("Run with: sudo /tmp/fix_wifi_power.sh" )
592
+ if issue .get ('manual_only' , False ):
593
+ manual_fixes .append (issue ['fix' ])
594
+ else :
595
+ fixes .append (issue ['fix' ])
596
+
597
+ if manual_fixes :
598
+ print ("\n ⚠️ Manual fixes required (cannot be automated):" )
599
+ for fix in manual_fixes :
600
+ print (f" • { fix } " )
601
+ print (" 💡 These require editing boot parameters or configuration files" )
626
602
627
603
628
604
# Usage example and testing
0 commit comments