Use Wifi with Oslib!

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
spyk
Posts: 14
Joined: Wed Mar 22, 2006 9:50 pm

Use Wifi with Oslib!

Post by spyk »

Hi all!
Hmm. I have a small problem...
I can't use wifi with Oslib.
look :

Code: Select all

//La librairie principale OSLib
#include <oslib/oslib.h>
//wifi
#include <pspnet.h>
#include <pspnet_inet.h>
#include <pspnet_apctl.h>
#include <pspnet_resolver.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/select.h>
//
#include <sys/socket.h>
#include <sys/types.h>
#include <netdb.h>
//

//les callbacks
PSP_MODULE_INFO&#40;"MyPSPGamePad", 0x1000, 1, 1&#41;;
PSP_MAIN_THREAD_ATTR&#40;0&#41;;

int main&#40;&#41;
&#123;
    //Initialisation de la librairie
    oslInit&#40;0&#41;;

    //Initialisation du mode graphique
    oslInitGfx&#40;OSL_PF_8888, 0&#41;;

    //Initialisation de la console texte
    oslInitConsole&#40;&#41;;

    //affiche sur l'écran du texte
    oslPrintf&#40;"pspSdkLoadInetModules&#40;&#41;"&#41;;
    pspSdkLoadInetModules&#40;&#41;;
    oslPrintf&#40;"pspSdkInetInit&#40;&#41;"&#41;;
    pspSdkInetInit&#40;&#41;;
    //attend l'appui sur une touche
    oslWaitKey&#40;&#41;;
    
    //on quitte l'application
    oslEndGfx&#40;&#41;;
    oslQuit&#40;&#41;;
    return 0;
&#125; 
I have made a lot of test, and in a homebrew with OSL, when we type
pspSdkLoadInetModules(), the screen of the psp stay black...

Can Anyone help me?

Has anyone made a Wifi homebrew with Old school librairie?

Thank You!
swaine
Posts: 1
Joined: Thu Feb 15, 2007 1:03 pm

Post by swaine »

I am currently making a using OSLib with wifi capability.

Since OSLib doesn't like to load stuff in the user mode created for wifi (like in all the examples everywhere) you have to load everything before going into the user thread ("needed for DHCP").

Just to give an example...

Code: Select all

int user_main&#40;SceSize args, void* argp&#41;;

int main&#40;void&#41;
&#123;
    // Kernel mode thread
	oslInit&#40;0&#41;;
	oslInitGfx&#40;OSL_PF_8888, 0&#41;;
	oslInitConsole&#40;&#41;;
    
	oslStartDrawing&#40;&#41;;


	oslPrintf&#40;"Loading images..."&#41;;
	back = oslLoadImageFile&#40;"blah.png", OSL_IN_RAM, OSL_PF_8888&#41;;
	if&#40;!back&#41;
	&#123;
		oslPrintf&#40;"ERROR"&#41;;
		for&#40;int i=0;i<100;i++&#41;
			sceDisplayWaitVblankStart&#40;&#41;;
		sceKernelExitGame&#40;&#41;;
		return 0;
	&#125;
	oslPrintf&#40;"Done\n\n"&#41;;

	oslPrintf&#40;"Loading Network drivers..."&#41;;
	if &#40;nlhLoadDrivers&#40;&module_info&#41; != 0&#41;
    &#123;
        printf&#40;"Driver load error\n"&#41;;
		for&#40;int i=0;i<100;i++&#41;
			sceDisplayWaitVblankStart&#40;&#41;;
		sceKernelExitGame&#40;&#41;;
        return 0;
    &#125;
	oslPrintf&#40;"Done\n\n"&#41;;

    
	oslEndDrawing&#40;&#41;;
	for&#40;int i=0;i<100;i++&#41;
		sceDisplayWaitVblankStart&#40;&#41;;
	oslEndGfx&#40;&#41;;


    // create user thread, tweek stack size here if necessary
    SceUID thid = sceKernelCreateThread&#40;"User Mode Thread", user_main,
            0x11, // default priority
            256 * 1024, // stack size &#40;256KB is regular default&#41;
            PSP_THREAD_ATTR_USER, NULL&#41;;

    // start user thread, then wait for it to do everything else
    sceKernelStartThread&#40;thid, 0, NULL&#41;;
    sceKernelWaitThreadEnd&#40;thid, NULL&#41;;

    sceKernelExitGame&#40;&#41;;
    return 0;
&#125;
Then, in your user_main you can do your nlhInit()
and you can also do a:

oslInitGfx(OSL_PF_8888, 1);

(note: in my main I only used a single buffer cause I was using console)

and start drawing, and using the network stuff.
goebish
Posts: 29
Joined: Sat Oct 14, 2006 11:59 pm

Post by goebish »

This is very interesting wraine !
I'm currently implementing networking in my game using OSLib, sure it will help :)
Post Reply