| View previous topic :: View next topic |
| Author |
Message |
AkumaATR
Joined: 30 Oct 2005 Posts: 11
|
Posted: Tue Jan 10, 2006 6:42 am Post subject: Wlan.useConnectionConfig(1) |
|
|
| 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 |
|
 |
AkumaATR
Joined: 30 Oct 2005 Posts: 11
|
Posted: Tue Jan 10, 2006 6:49 am Post subject: |
|
|
| 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 |
|
 |
wombot
Joined: 10 Jan 2006 Posts: 5
|
Posted: Tue Jan 10, 2006 10:41 am Post subject: |
|
|
| 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 |
|
 |
modsyn
Joined: 27 Sep 2005 Posts: 28
|
Posted: Tue Jan 10, 2006 2:13 pm Post subject: |
|
|
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 |
|
 |
wombot
Joined: 10 Jan 2006 Posts: 5
|
Posted: Tue Jan 10, 2006 2:43 pm Post subject: |
|
|
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 |
|
 |
Elxx
Joined: 07 Dec 2005 Posts: 16
|
Posted: Tue Jan 10, 2006 4:23 pm Post subject: |
|
|
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 |
|
 |
AkumaATR
Joined: 30 Oct 2005 Posts: 11
|
Posted: Tue Jan 10, 2006 6:08 pm Post subject: |
|
|
| Agreed. I had already modified it to use connection+1. |
|
| Back to top |
|
 |
Elxx
Joined: 07 Dec 2005 Posts: 16
|
Posted: Wed Jan 11, 2006 2:43 pm Post subject: |
|
|
| 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 |
|
 |
Oobles Site Admin
Joined: 17 Jan 2004 Posts: 362 Location: Melbourne, Australia
|
Posted: Wed Jan 11, 2006 3:13 pm Post subject: |
|
|
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 |
|
 |
Elxx
Joined: 07 Dec 2005 Posts: 16
|
Posted: Thu Jan 12, 2006 11:05 am Post subject: |
|
|
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 |
|
 |
Shine
Joined: 03 Dec 2004 Posts: 728 Location: Germany
|
Posted: Sun Jan 15, 2006 4:18 am Post subject: |
|
|
| 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 |
|
 |
|