| View previous topic :: View next topic |
| Author |
Message |
danzel
Joined: 04 Nov 2005 Posts: 182
|
Posted: Tue Mar 28, 2006 12:46 pm Post subject: Common error when enumerating Wifi connections |
|
|
I've recently discovered a small bug that was in PSPPets wifi examples in the way it enumerates wifi connections.
| Code: | for (iNetIndex = 1; iNetIndex < 100; iNetIndex++) // skip the 0th connection
{
//variable declarations go here
if (sceUtilityCheckNetParam(iNetIndex) != 0)
break; // no more
.......... // <- at this point you have a good connection, add it to your picks list
}
|
This is incorrect as if a user has added 2 wifi connections and then deleted the first one (in their network settings), then when you call sceUtilityCheckNetParam(1); it will return a non zero value so you will stop looking for new connections, but if you called sceUtilityCheckNetParam(2); it would return zero as there is a connection set up there.
Alter the code to do continue; instead of break; when sceUtilityCheckNetParam(iNetIndex) returns a non-zero value, giving:
| Code: | for (iNetIndex = 1; iNetIndex < 100; iNetIndex++) // skip the 0th connection
{
//variable declarations go here
if (sceUtilityCheckNetParam(iNetIndex) != 0)
continue; // no connection here
.......... // <- at this point you have a good connection, add it to your picks list
}
|
So we check the first 100 network connections to see if there is a connection set up in any of them instead of stopping when we hit the first index where there is no network connection.
This finds connections where previously we would stop looking prematurely.
This probably isn't the best fix as that 100 value is just pulled out of nowhere (afaik), but it should be a big enough value that you won't have any problems.
Hope that helps everyone who is using wifi, as It took me a while to realize what was causing it!
I'll put the fix in the next versions of all my wifi apps. |
|
| Back to top |
|
 |
dot_blank

Joined: 28 Sep 2005 Posts: 498 Location: Brasil
|
Posted: Wed Mar 29, 2006 7:49 pm Post subject: |
|
|
thanx _________________ 10011011 00101010 11010111 10001001 10111010 |
|
| Back to top |
|
 |
raf
Joined: 13 Oct 2005 Posts: 57
|
Posted: Sun Apr 02, 2006 1:39 pm Post subject: Re: Common error when enumerating Wifi connections |
|
|
Interesting... This may explain reports from various PSPRadio users.. I'll update my code to this..
Thanks!,
Raf. |
|
| Back to top |
|
 |
|