| View previous topic :: View next topic |
| Author |
Message |
Freezez
Joined: 16 Feb 2008 Posts: 7
|
Posted: Sat Feb 16, 2008 2:18 am Post subject: sceNetApctlConnect() problem |
|
|
Hi.
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: |
#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;
}
|
I use 3.71 M33-2 firmware and pspsdk-1.0+beta2.
Thanks. |
|
| Back to top |
|
 |
Insert_witty_name
Joined: 10 May 2006 Posts: 376
|
Posted: Sat Feb 16, 2008 4:53 am Post subject: |
|
|
Remove the following line:
| Code: | | PSP_MAIN_THREAD_ATTR(0); // kernel app |
|
|
| Back to top |
|
 |
Freezez
Joined: 16 Feb 2008 Posts: 7
|
Posted: Sat Feb 16, 2008 11:02 am Post subject: |
|
|
Thanks for your answer. I've tried what you say but nothing happened.
I have always the 80110601 error. |
|
| Back to top |
|
 |
Insert_witty_name
Joined: 10 May 2006 Posts: 376
|
Posted: Sat Feb 16, 2008 11:14 am Post subject: |
|
|
80110601 is a bad netconf.
Delete your network settings and re-enter them. |
|
| Back to top |
|
 |
Freezez
Joined: 16 Feb 2008 Posts: 7
|
Posted: Sat Feb 16, 2008 9:32 pm Post subject: |
|
|
| I will try that but other apps using this netconf work perfectly. Why ? |
|
| Back to top |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Sun Feb 17, 2008 6:14 am Post subject: |
|
|
| Freezez wrote: | | I will try that but other apps using this netconf work perfectly. Why ? |
I ran into this with Doom. I think it has to do with trying to iterate through all connections versus just using the first one. It's all I could figure on it at the time. |
|
| Back to top |
|
 |
|