forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Wlan.useConnectionConfig(1)

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development
View previous topic :: View next topic  
Author Message
AkumaATR



Joined: 30 Oct 2005
Posts: 11

PostPosted: Tue Jan 10, 2006 6:42 am    Post subject: Wlan.useConnectionConfig(1) Reply with quote

My app. seems to hang sometimes during this call... any ideas as to why? I have to hard reset when it happens. It only happens like 1/5. Thanks.
Back to top
View user's profile Send private message
AkumaATR



Joined: 30 Oct 2005
Posts: 11

PostPosted: Tue Jan 10, 2006 6:49 am    Post subject: Reply with quote

After searching I see that it's advised to have power save off for WiFi for WiFi homebrew. I'll use this setting for today to see if I have any improvements... although it's worth noting that if it didn't freeze at useConnectionConfig(1) it did work for the rest of my app's duration (and it continues to make connections). Perhaps Wlan.useConnectionConfig() doesn't wait long enough for something to come out of power save mode?
Back to top
View user's profile Send private message
wombot



Joined: 10 Jan 2006
Posts: 5

PostPosted: Tue Jan 10, 2006 10:41 am    Post subject: Reply with quote

I've been having the same problem with 0.16. 0.15 still seems to work fine for me though... maybe something broke in the update (even the 0.16 demo locks up, and I have powersave off)
Back to top
View user's profile Send private message
modsyn



Joined: 27 Sep 2005
Posts: 28

PostPosted: Tue Jan 10, 2006 2:13 pm    Post subject: Reply with quote

i had a similar issue with 0.16 and it seems that the function Wlan.useConnectionConfig() behaves differently for the 2 versions. it's mentioned in the changes. i just added one to the index value i wanted to use and it worked fine after that. like so:

Code:
function chooseNetwork()
  Wlan.init()
  configs = Wlan.getConnectionConfigs()
  local name,nstate = choose("Select a Network Connection",configs)
  if not quit then
    nstate=nstate+1
    gprintln("Using network connection " .. nstate)
    Wlan.useConnectionConfig(tonumber(nstate))
  end
end
Back to top
View user's profile Send private message
wombot



Joined: 10 Jan 2006
Posts: 5

PostPosted: Tue Jan 10, 2006 2:43 pm    Post subject: Reply with quote

Well will you look at that. Obviously I didn't read the changenotes cloesly enough. Thanks!

Strangely enough the WLAN example script still seems to lock up (my own code works though...)
Back to top
View user's profile Send private message
Elxx



Joined: 07 Dec 2005
Posts: 16

PostPosted: Tue Jan 10, 2006 4:23 pm    Post subject: Reply with quote

Yes, it appears that scripts completely freeze if they are unable to connect to the wireless network, and you have to restart LuaPlayer.

There needs to be a way to have a check of whether the connection succeeded or not, allowing us to try again if not.
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
AkumaATR



Joined: 30 Oct 2005
Posts: 11

PostPosted: Tue Jan 10, 2006 6:08 pm    Post subject: Reply with quote

Agreed. I had already modified it to use connection+1.
Back to top
View user's profile Send private message
Elxx



Joined: 07 Dec 2005
Posts: 16

PostPosted: Wed Jan 11, 2006 2:43 pm    Post subject: Reply with quote

Okay, I modified the LuaPlayer source code so it doesn't lock up when it's unable to connect. No idea how to do the fancy SVN submission thingee though, if I figure that out later I'll submit it as a patch.
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Oobles
Site Admin


Joined: 17 Jan 2004
Posts: 362
Location: Melbourne, Australia

PostPosted: Wed Jan 11, 2006 3:13 pm    Post subject: Reply with quote

If your patch is simple then paste it into a message here and someone with commit access with put it into svn.

David. aka Oobles.
www.livemedia.com.au/Blog
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
Elxx



Joined: 07 Dec 2005
Posts: 16

PostPosted: Thu Jan 12, 2006 11:05 am    Post subject: Reply with quote

Here's the fixed useConnectionConfig function. It will return nil if it was unable to connect to the network. Otherwise, if it succeeds, it will return 1.

So yeah, somebody please commit this into SVN, the current connection function is aggravating because you have to completely restart the app if it fails to connect. I've been testing my new function with PSP-HTTPD and it seems to work well, it hasn't frozen up at all yet.

I moved the sceKernelDelayThread to the top of the while{} just to give it at least a bit of time to initialize, otherwise it might return nil before the WLAN connection gets a chance to try connecting.

Code:
static int Wlan_useConnectionConfig(lua_State* L)
{
   if (!wlanInitialized) return luaL_error(L, wlanNotInitialized);
   int argc = lua_gettop(L);
   if (argc != 1) return luaL_error(L, "Argument error: index to connection config expected.");
   
   int connectionConfig = luaL_checkint(L, 1) - 1;
   int result = sceNetApctlConnect(connectionConfig);

   int state = 0;

   while (1)
   {
      sceKernelDelayThread(200*1000); // 200ms

      int err = sceNetApctlGetState(&state);
      if (err != 0)
         return 0;

      if (state == 0)
         return 0;

      if (state == 4) { //connection succeeded
         result = 1;
         break;
      }

   }

   lua_pushnumber(L, result);

   return 1;
}
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Shine



Joined: 03 Dec 2004
Posts: 728
Location: Germany

PostPosted: Sun Jan 15, 2006 4:18 am    Post subject: Reply with quote

Elxx wrote:
Here's the fixed useConnectionConfig function. It will return nil if it was unable to connect to the network. Otherwise, if it succeeds, it will return 1.


Thanks, I've committed it to the SVN repository.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group