Skip to content

Commit bb48dbb

Browse files
dbieberclaude
andcommitted
Add detailed debugging for WiFi settings
- Add extensive debug logging to wifi.get_networks() - Add debug logging to wifi.save_networks() - Add wifi-debug command to diagnose WiFi settings in Redis - Test network creation and retrieval with the debug command 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 93ab98f commit bb48dbb

File tree

2 files changed

+63
-3
lines changed

2 files changed

+63
-3
lines changed

gonotego/command_center/wifi_commands.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,3 +125,35 @@ def remove_wifi_network(ssid):
125125
@register_command('wifi-reconfigure')
126126
def reconfigure_wifi():
127127
wifi.reconfigure_wifi()
128+
129+
130+
@register_command('wifi-debug')
131+
def debug_wifi_settings():
132+
"""Debug command to check WiFi settings in Redis."""
133+
from gonotego.common import interprocess
134+
r = interprocess.get_redis_client()
135+
136+
# Check Redis directly
137+
key = 'GoNoteGo:settings:WIFI_NETWORKS'
138+
raw_value = r.get(key)
139+
140+
say(f"WIFI_NETWORKS in Redis: {raw_value}")
141+
142+
# Check via settings module
143+
from gonotego.settings import settings
144+
settings_value = settings.get('WIFI_NETWORKS')
145+
say(f"WIFI_NETWORKS via settings: {settings_value}")
146+
147+
# Check via wifi module
148+
networks = wifi.get_networks()
149+
say(f"Networks via wifi.get_networks(): {networks}")
150+
151+
# Test adding a network
152+
if not networks:
153+
test_network = {'ssid': 'test_network', 'psk': 'test_password'}
154+
wifi.save_networks([test_network])
155+
say(f"Added test network: {test_network}")
156+
157+
# Verify it was added
158+
new_networks = wifi.get_networks()
159+
say(f"Networks after adding test: {new_networks}")

gonotego/settings/wifi.py

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,42 @@
1212
def get_networks():
1313
"""Get the list of WiFi networks from Redis settings."""
1414
try:
15-
return json.loads(settings.get('WIFI_NETWORKS') or '[]')
16-
except (json.JSONDecodeError, TypeError):
15+
raw_value = settings.get('WIFI_NETWORKS')
16+
print(f"DEBUG wifi.get_networks() - raw value: {raw_value!r}, type: {type(raw_value)}")
17+
18+
if raw_value is None or raw_value == []:
19+
print("DEBUG wifi.get_networks() - returning empty list")
20+
return []
21+
22+
if isinstance(raw_value, list):
23+
print(f"DEBUG wifi.get_networks() - value is already a list: {raw_value}")
24+
return raw_value
25+
26+
parsed_value = json.loads(raw_value) if isinstance(raw_value, str) else raw_value
27+
print(f"DEBUG wifi.get_networks() - parsed value: {parsed_value}")
28+
return parsed_value
29+
except (json.JSONDecodeError, TypeError) as e:
30+
print(f"DEBUG wifi.get_networks() - error parsing value: {e}")
1731
return []
1832

1933

2034
def save_networks(networks):
2135
"""Save the list of WiFi networks to Redis settings."""
22-
settings.set('WIFI_NETWORKS', json.dumps(networks))
36+
print(f"DEBUG wifi.save_networks() - saving networks: {networks}")
37+
38+
if not isinstance(networks, list):
39+
print(f"DEBUG wifi.save_networks() - WARNING: networks is not a list: {type(networks)}")
40+
if isinstance(networks, str):
41+
try:
42+
networks = json.loads(networks)
43+
print(f"DEBUG wifi.save_networks() - parsed string to list: {networks}")
44+
except json.JSONDecodeError as e:
45+
print(f"DEBUG wifi.save_networks() - error parsing string: {e}")
46+
networks = []
47+
48+
json_str = json.dumps(networks)
49+
print(f"DEBUG wifi.save_networks() - JSON string: {json_str}")
50+
settings.set('WIFI_NETWORKS', json_str)
2351

2452

2553
def update_wpa_supplicant_config():

0 commit comments

Comments
 (0)