I've tried to make a PSP program which use wifi to connect on the Internet but it's don't work.
I can compile it perfectly but when I run the program sceNetApctlConnect return an error 1106... something like that.
Here is the code (very dirty sorry) :
Code: Select all
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <zlib.h>
#include <unistd.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/select.h>
#include <errno.h>
/* PSP includes */
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspsdk.h>
#include <pspwlan.h>
#include <pspdisplay.h>
#include <pspnet.h>
#include <pspnet_inet.h>
#include <pspnet_apctl.h>
#include <pspnet_resolver.h>
#include <psputility_netmodules.h>
#include <netinet/in.h>
/* Define printf, just to make typing easier */
#define printf pspDebugScreenPrintf
/// If defined, can be executed on linux
/* #define LINUX_MODE */
#define PSP_MODULES_NAME "Onix"
#ifndef PSPFW30X
PSP_MODULE_INFO(PSP_MODULE_NAME, 0x0000, 1, 1);
#else
PSP_MODULE_INFO(PSP_MODULE_NAME, 0x0, 1, 1);
PSP_HEAP_SIZE_KB(16*1024);
#endif
PSP_MAIN_THREAD_ATTR(0); // kernel app
PSP_MAIN_THREAD_STACK_SIZE_KB(64);
/// Connect to an access point
int connect_to_apctl(int config)
{
int err;
int stateLast = -1;
// Connect using the first profile
err = sceNetApctlConnect(config);
if (err != 0)
{
printf("[-] sceNetApctlConnect returns %08X\n", err);
return 1;
}
printf("[*] Connecting...\n");
while (1)
{
int state;
err = sceNetApctlGetState(&state);
if (err != 0)
{
printf("[-] sceNetApctlGetState returns $%x\n", err);
break;
}
if (state > stateLast)
{
printf("[*] connection state %d of 4\n", state);
stateLast = state;
}
if (state == 4)
break; // connected with static IP
// wait a little before polling again
sceKernelDelayThread(50*1000); // 50ms
}
printf("[+] Connected!\n");
if(err != 0)
{
return 1;
}
return 0;
}
int UserInetInit(){
if(sceNetInit(0x20000, 0x20, 0x1000, 0x20, 0x1000)){
printf("[-] Error when sceNetInit()\n");
return 1;
}
if(sceNetInetInit()){
printf("[-] Error when sceNetInetInit()\n");
return 1;
}
if(sceNetApctlInit(0x1400, 0x42)){ // increase stack size
printf("[-] Error when sceNetApctlInit()\n");
return 1;
}
return 0;
}
int main(int argc, char *argv[]){
pspDebugScreenInit();
atexit(sceKernelExitGame);
printf("[*] PspDebugScreen initialized\n");
if(sceUtilityLoadNetModule(PSP_NET_MODULE_COMMON)){ // load common
printf("[-] Unable to load common net module\n");
}
if(sceUtilityLoadNetModule(PSP_NET_MODULE_INET)){ // load inet
printf("[-] Unable to load inet module\n");
}
if(UserInetInit() == 0){
connect_to_apctl(1);
}
sceKernelSleepThread();
return 0;
}
Thanks.