![]() |
| Forums | Gaming News | Videos | Downloads | Today's Posts | Mark Forums Read | Chat | FAQ | Members List | Contact |
| ||||||
This is a discussion on WLAN in user mode within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; Hi there, I'm developing a game that uses WLAN and a GFX-Lib(I want to use OSLib). The problem is: WLAN ...
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 |
|
Hi there,
I'm developing a game that uses WLAN and a GFX-Lib(I want to use OSLib). The problem is: WLAN has to be initialized in kernel mode, and the gfx-libs don't want to work in kernel mode. I heard that you can use WLAN in user mode, but I didn't find a real example about this. Could someone _please_ post a complete example on how to use WLAN in user mode (source+makefile)? If it's possible, without threading. I have read some other threads about this, but the examples were not complete or didn't work. This makes me really crazy, because I spent a lot of time in trying many things before I noticed that my gfx-libs don't work in kernel mode... Cya, Zwergengraf |
|
|
|
|
|
|
#4 |
![]() ![]() OMFG
|
I forgot to mention you have to be running in the 3.xx kernel
Code:
// Load modules
sceUtilityLoadNetModule(PSP_NET_MODULE_COMMON);
sceUtilityLoadNetModule(PSP_NET_MODULE_INET);
// Get connections
// Connect
int connectTo(int connectNum)
{
int err;
int stateLast = -1;
// WLAN
err = pspSdkInetInit();
if (err != 0)
{
printf("Error pspSdkInetInit() \n");
sceKernelDelayThread(2000*1000);
}
err = sceNetApctlConnect(connectNum);
if (err != 0)
{
printf("Error sceNetApctlConnect() \n");
sceKernelDelayThread(2000*1000);
}
sceNetResolverCreate(&resolverId, resolverBuffer, sizeof(resolverBuffer));
while (1)
{
int state;
int err = sceNetApctlGetState(&state);
if (err != 0)
{
printf("Error at state %i \n", state);
sceKernelDelayThread(2000*1000);
return 0; // connection failed
}
if (state > stateLast)
{
printf("State %i \n", state);
stateLast = state;
}
if (state == 4)
break; // connected with static IP
// wait a little before polling again
sceKernelDelayThread(200*1000); // 200 ms
}
return 1;
}
|
|
|
|
|
|
#5 |
|
Okay thanks, I tried this code:
---------- Code:
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspsdk.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <psputility_netmodules.h>
#include <psputility_netparam.h>
#include <pspwlan.h>
#include <pspnet.h>
#include <pspnet_apctl.h>
#define printf pspDebugScreenPrintf
PSP_MODULE_INFO("test", 0, 1, 1);
/* Exit callback */
int exit_callback(int arg1, int arg2, void *common)
{
sceKernelExitGame();
return 0;
}
/* Callback thread */
int CallbackThread(SceSize args, void *argp)
{
int cbid;
cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
sceKernelRegisterExitCallback(cbid);
sceKernelSleepThreadCB();
return 0;
}
/* Sets up the callback thread and returns its thread id */
int SetupCallbacks(void)
{
int thid = 0;
thid = sceKernelCreateThread("update_thread", CallbackThread,
0x11, 0xFA0, PSP_THREAD_ATTR_USER, 0);
if(thid >= 0)
{
sceKernelStartThread(thid, 0, 0);
}
return thid;
}
int connectTo(int connectNum)
{
int err;
int stateLast = -1;
// WLAN
err = pspSdkInetInit();
if (err != 0)
{
printf("Error pspSdkInetInit() \n");
sceKernelDelayThread(2000*1000);
}
err = sceNetApctlConnect(connectNum);
if (err != 0)
{
printf("Error sceNetApctlConnect() \n");
sceKernelDelayThread(2000*1000);
}
//sceNetResolverCreate(&resolverId, resolverBuffer, sizeof(resolverBuffer));
while (1)
{
int state;
int err = sceNetApctlGetState(&state);
if (err != 0)
{
printf("Error at state %i \n", state);
sceKernelDelayThread(2000*1000);
return 0; // connection failed
}
if (state > stateLast)
{
printf("State %i \n", state);
stateLast = state;
}
if (state == 4)
break; // connected with static IP
// wait a little before polling again
sceKernelDelayThread(200*1000); // 200 ms
}
return 1;
}
int main(){
SetupCallbacks();
pspDebugScreenInit();
// Load modules
if (sceUtilityLoadNetModule(PSP_NET_MODULE_COMMON) < 0)
{
printf("Error, could not load PSP_NET_MODULE_COMMON\n");
sceKernelSleepThread();
}
if (sceUtilityLoadNetModule(PSP_NET_MODULE_INET) < 0)
{
printf("Error, could not load PSP_NET_MODULE_INET\n");
sceKernelSleepThread();
}
printf("Connecting...");
connectTo(1);
sceKernelSleepThread();
return 0;
}
and this makefile: ---------- Code:
TARGET = netsample OBJS = main.o INCDIR = CFLAGS = -O0 -G0 -Wall -g CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti ASFLAGS = $(CFLAGS) PSP_FW_VERSION = 380 LIBDIR = EXTRA_TARGETS = EBOOT.PBP PSPSDK=$(shell psp-config --pspsdk-path) include $(PSPSDK)/lib/build.mak compiled it with "make kxploit", then I put it into GAME and the program displayed: Connecting...Error pspSdkInetInit() Error sceNetApctlConnect() Error at state -2012413952 At least it loads the modules, thats good! But what is wrong now? I hope you (or someone else ) can help me.Thanks, Zwergengraf |
|
|
|
|
|
|
#6 | |
![]() ![]() Developer
|
Hi.
Add BUILD_PRX=1 to your Makefile. Compile with make only. Place the EBOOT in a directory on GAME3XX. Run.
__________________
![]() Check out my homebrew & C tutorials at http://insomniac.0x89.org/ Coder formerly known as Insomniac197 Quote:
|
|
|
|
|
|
|
#7 |
|
OMFG, IT WORKS!
Ouh, I can't say how much you have helped me with this! I want to thank you two very much! Edit: Well, it doesn't work 100%: everytime I try to draw an image with blitAlphaImageToScreen, it crashes. It doesn't fail at loading the image. What's wrong? Zwergengraf Last edited by Zwergengraf; 03-29-2008 at 04:33 PM.. |
|
|
|
|
![]() |
| Tags |
| mode , user , wlan |
| Thread Tools | |
|
|