Wlan.useConnectionConfig(1)
Moderators: Shine, Insert_witty_name
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.
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?
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: Select all
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
-
- Site Admin
- Posts: 347
- Joined: Sat Jan 17, 2004 9:49 am
- Location: Melbourne, Australia
- Contact:
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
David. aka Oobles.
www.livemedia.com.au/Blog
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.
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: Select all
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;
}