Skip to content

Commit dab2ca6

Browse files
authored
Changes to deal with an invalid number of networks being returned fro… (#136)
* Changes to deal with an invalid number of networks being returned from wifi scan * Ifdefout locate command for non-coco builds
1 parent 42a80aa commit dab2ca6

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

src/set_wifi.c

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,30 +126,46 @@ void set_wifi_password(void)
126126
void set_wifi_scan(void)
127127
{
128128
char i;
129+
unsigned char valid_networks = 0;
130+
SSIDInfo *ssid_info;
129131
screen_set_wifi(io_get_adapter_config());
130132

131133

132134
numNetworks = io_scan_for_networks();
133135

134136
if (numNetworks > 16)
135-
numNetworks = 16;
137+
numNetworks = 16;
136138

137139
if (io_error())
140+
{
141+
screen_error("COULD NOT WS_SCAN NETWORKS");
142+
die(); // to do retry or something instead
143+
}
144+
145+
for (i = 0; i < numNetworks; i++)
146+
{
147+
ssid_info = io_get_scan_result(i);
148+
if (ssid_info != NULL && ssid_info->ssid != NULL & strlen(ssid_info->ssid) != 0)
138149
{
139-
screen_error("COULD NOT WS_SCAN NETWORKS");
140-
die(); // to do retry or something instead
150+
screen_set_wifi_display_ssid(i, ssid_info);
151+
valid_networks++;
141152
}
142-
143-
for (i=0;i<numNetworks;i++)
153+
else
144154
{
145-
screen_set_wifi_display_ssid(i,io_get_scan_result(i));
155+
break;
146156
}
157+
}
147158

148-
ws_subState=WS_SELECT;
159+
numNetworks = valid_networks;
160+
161+
ws_subState = WS_SELECT;
149162
}
150163

151164
void set_wifi_done(void)
152165
{
166+
#ifdef _CMOC_VERSION_
167+
locate(0,14);
168+
#endif
153169
int result = io_set_ssid(&nc);
154170
// always (good or bad) go to connect_wifi.
155171
// I had used result to only show this when we have good return, but

0 commit comments

Comments
 (0)