forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

sceNetApctlConnect() problem

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
Freezez



Joined: 16 Feb 2008
Posts: 7

PostPosted: Sat Feb 16, 2008 2:18 am    Post subject: sceNetApctlConnect() problem Reply with quote

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
View user's profile Send private message
Insert_witty_name



Joined: 10 May 2006
Posts: 376

PostPosted: Sat Feb 16, 2008 4:53 am    Post subject: Reply with quote

Remove the following line:

Code:
PSP_MAIN_THREAD_ATTR(0);   // kernel app
Back to top
View user's profile Send private message
Freezez



Joined: 16 Feb 2008
Posts: 7

PostPosted: Sat Feb 16, 2008 11:02 am    Post subject: Reply with quote

Thanks for your answer. I've tried what you say but nothing happened.
I have always the 80110601 error.
Back to top
View user's profile Send private message
Insert_witty_name



Joined: 10 May 2006
Posts: 376

PostPosted: Sat Feb 16, 2008 11:14 am    Post subject: Reply with quote

80110601 is a bad netconf.

Delete your network settings and re-enter them.
Back to top
View user's profile Send private message
Freezez



Joined: 16 Feb 2008
Posts: 7

PostPosted: Sat Feb 16, 2008 9:32 pm    Post subject: Reply with quote

I will try that but other apps using this netconf work perfectly. Why ?
Back to top
View user's profile Send private message
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Sun Feb 17, 2008 6:14 am    Post subject: Reply with quote

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
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group