Asking for wifi status
Posted: Sat Oct 16, 2010 10:56 am
How can I ask for the wifi status ?
(perfect, good, okay, bad no wifi)
(perfect, good, okay, bad no wifi)
Code: Select all
Wifi_AccessPoint ap;
memset(&ap, 0, sizeof(ap));
Wifi_AccessPoint bestAp;
memset(&bestAp, 0, sizeof(bestAp));
int oldMaxRssi = -2;
int maxRssi = -1;
int maxTries = 120; // will try for a few seconds
while ((maxRssi < 60 || oldMaxRssi < maxRssi) || maxTries > 0) {
swiWaitForVBlank();
// scans the surroundings for wifi Access point -> puts the info in an intern list
Wifi_ScanMode();
oldMaxRssi = maxRssi;
for (int i = 0; i < Wifi_GetNumAP(); ++i) {
if ((Wifi_GetAPData(i, &ap) == WIFI_RETURN_OK) && (ap.rssi > maxRssi) &&
(!strcmp(ap.ssid, ssid))) {
maxRssi = ap.rssi;
bestAp = ap;
}
}
maxTries -= 1;
}
if (maxRssi < 0) {
fprintf("Can't find any %s access point", ssid);
return;
}
fprintf("Connecting to %s (%2i%%): ", bestAp.ssid, (bestAp.rssi * 100) / 0xD0);
// Setting the DS's IP address and other IP configuration information through DHCP.
Wifi_SetIP(0, 0, 0, 0, 0);
Wifi_ConnectAP(&bestAp, wepmode, wepkeyid, wepkey);
So I replaced the two "fprintf " by "iprintf" and write the code it in this path:@Lakedaemon:
fprintf is used incorrectly. Replace it by iprintf.
@lazyprogrammer:
use the arm9 template from the libnds examples. Also, create a copy of the template and don't just overwrite it.