How can I ask for the wifi status ?
(perfect, good, okay, bad no wifi)
Asking for wifi status
-
- Posts: 4
- Joined: Mon Aug 16, 2010 8:48 pm
Re: Asking for wifi status
you can get the signal strength in the rssi field of an ap Wifi_AccessPoint struct (in dswifi9.h).
the % of connection will be (ap.rssi * 100) / 0xD;
Here is a sample of code that tries connecting, among many access point called ssid, to the ssid access point with the best signal
the % of connection will be (ap.rssi * 100) / 0xD;
Here is a sample of code that tries connecting, among many access point called ssid, to the ssid access point with the best signal
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);
-
- Posts: 85
- Joined: Mon Sep 27, 2010 5:26 pm
Re: Asking for wifi status
Sorry, but when I use this code, it says me over 30 errors with "expected declaration specifers or '...' " and "data defination has no type or storange class"
and much more
and much more
-
- Posts: 85
- Joined: Mon Sep 27, 2010 5:26 pm
Re: Asking for wifi status
These are the errors:
- Attachments
-
- errors.jpg
- errors
- (118.15 KiB) Not downloaded yet
-
- Posts: 29
- Joined: Sun Mar 29, 2009 9:23 pm
Re: Asking for wifi status
@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.
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.
-
- Posts: 85
- Joined: Mon Sep 27, 2010 5:26 pm
Re: Asking for wifi status
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.
nintendods/devkitpro/examples/nds/template/arm9/source --> main.c
Okay, but I still have errors:
- Attachments
-
- errors2.jpg
- errors
- (210.54 KiB) Not downloaded yet
Re: Asking for wifi status
you overwrote the template. he told you not to do that.
heres a tip about programming in C which you normally learn on the first day but you seem to have skipped.
when you get an error like "X undeclared" then search the header files for X and #include the file which contains that symbol
heres a tip about programming in C which you normally learn on the first day but you seem to have skipped.
when you get an error like "X undeclared" then search the header files for X and #include the file which contains that symbol
Who is online
Users browsing this forum: No registered users and 0 guests