Common error when enumerating Wifi connections

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
danzel
Posts: 182
Joined: Fri Nov 04, 2005 11:03 pm

Common error when enumerating Wifi connections

Post by danzel »

I've recently discovered a small bug that was in PSPPets wifi examples in the way it enumerates wifi connections.

Code: Select all

        for &#40;iNetIndex = 1; iNetIndex < 100; iNetIndex++&#41; // skip the 0th connection
        &#123;
            //variable declarations go here
            if &#40;sceUtilityCheckNetParam&#40;iNetIndex&#41; != 0&#41;
                break;  // no more
            .......... // <- at this point you have a good connection, add it to your picks list
        &#125;
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: Select all

        for &#40;iNetIndex = 1; iNetIndex < 100; iNetIndex++&#41; // skip the 0th connection
        &#123;
            //variable declarations go here
            if &#40;sceUtilityCheckNetParam&#40;iNetIndex&#41; != 0&#41;
                continue;  // no connection here
            .......... // <- at this point you have a good connection, add it to your picks list
        &#125;
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.
User avatar
dot_blank
Posts: 498
Joined: Wed Sep 28, 2005 8:47 am
Location: Brasil

Post by dot_blank »

thanx
10011011 00101010 11010111 10001001 10111010
raf
Posts: 57
Joined: Thu Oct 13, 2005 7:38 am

Re: Common error when enumerating Wifi connections

Post by raf »

Interesting... This may explain reports from various PSPRadio users.. I'll update my code to this..

Thanks!,

Raf.
Post Reply