gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > DSWifi: the perfect connection

#100320 - Lick - Sun Aug 27, 2006 10:56 am

I wonder if there's a way to always be sure that dswifi connects.. If this is a internal hanging bug, then there's little we can do about it. But I've found that the following function does the job pretty good, but still hangs quite often.

Code:
bool NDSX_DSWifi_ConnectAP()
{
    Wifi_EnableWifi();
    Wifi_AutoConnect();
    while(1)
    {
        scanKeys();
        if(keysDown() & KEY_B)
            return false;

       int stat = Wifi_AssocStatus();

       if(stat == ASSOCSTATUS_ASSOCIATED)
        {
          return (ConnectedToAP=true);
        }

       if(stat == ASSOCSTATUS_CANNOTCONNECT)
        {
            ConnectedToAP = false;
            swiWaitForVBlank();
            Wifi_AutoConnect();
        }
    }
}


I'm guessing that it's internal to DsWifi though.
_________________
http://licklick.wordpress.com

#100335 - kevinc - Sun Aug 27, 2006 12:22 pm

From my experience, Wifi_AssocStatus() can spontaneously return ASSOCSTATUS_CANNOTCONNECT in the middle of authentication; so even a value of 6 doesn't immediately imply that the association failed.
_________________
http://akzeac.blogspot.com

#100410 - sgstair - Sun Aug 27, 2006 7:26 pm

Lick: That code will not return at all if the wifi lib is unable to connect; so it's not possible to tell if it's the wifi lib "hanging" - what is possible is that the lib might be desyncing from the packet buffer (because of malformed packets in your area - but I can't be sure of this yet. - I'll look into it further.

kevinc: I've never seen that happen, and don't really see how it could happen...
if it does happen to you though, would you be willing to help me track down the problem?

-Stephen
_________________
http://blog.akkit.org/ - http://www.akkit.org/dswifi/

#100415 - kevinc - Sun Aug 27, 2006 7:57 pm

sgstair wrote:
kevinc: I've never seen that happen, and don't really see how it could happen...
if it does happen to you though, would you be willing to help me track down the problem?

-Stephen


You're right, it doesn't :). I'm sorry, I was confusing ASSOCSTATUS_CANNOTCONNECT and ASSOCSTATUS_DISCONNECTED.
_________________
http://akzeac.blogspot.com

#100417 - Lick - Sun Aug 27, 2006 8:15 pm

Sgstair and I figured that it's prolly swiWaitVBlank() that's stalling. But without it, the LED goes weird. Strange..
_________________
http://licklick.wordpress.com