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 

using ADHOC

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



Joined: 05 Apr 2008
Posts: 30
Location: Germany -> Hessen -> Hanau

PostPosted: Sun Apr 20, 2008 4:53 am    Post subject: using ADHOC Reply with quote

Hi guys,

I need your help. I' m planing a new projetc needing ADHOC, the problem is, that I don' t know, how to use ADHOC. Kann someone post me a link to a Tut?? I want to know, how to build the connection, how to use it, mainly all. I now something about the C Programming but I' m not a pro, so give me the longest one you know xD

Great Whiches, Floorball92
_________________
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
pspZorba



Joined: 22 Sep 2007
Posts: 156
Location: NY

PostPosted: Sun Apr 20, 2008 5:48 am    Post subject: Reply with quote

read this thread:

http://forums.ps2dev.org/viewtopic.php?t=10165&highlight=adhoc
_________________
--pspZorba--
NO to K1.5 !
Back to top
View user's profile Send private message
floorball92



Joined: 05 Apr 2008
Posts: 30
Location: Germany -> Hessen -> Hanau

PostPosted: Sun Apr 20, 2008 9:14 pm    Post subject: Reply with quote

http://rafb.net/p/94oL8w72.html

This works not so really good
_________________
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
pspZorba



Joined: 22 Sep 2007
Posts: 156
Location: NY

PostPosted: Sun Apr 20, 2008 11:45 pm    Post subject: Reply with quote

Quote:

main.cpp:20:23: error: pspkernel.h: No such file or directory
main.cpp:21:22: error: pspdebug.h: No such file or directory
main.cpp:22:21: error: pspctrl.h: No such file or directory
main.cpp:23:20: error: pspsdk.h: No such file or directory
main.cpp:24:24: error: pspdisplay.h: No such file or directory


it means you miss the basic PSP headers, that's why you can't compile.
pb of path or sdk installation.[/quote]
_________________
--pspZorba--
NO to K1.5 !
Back to top
View user's profile Send private message
Pirata Nervo



Joined: 09 Oct 2007
Posts: 409

PostPosted: Mon Apr 21, 2008 2:53 am    Post subject: Reply with quote

I had the same problems when I tried your source and dont tell me I dont have the headers..

So I gave up and continued my 3.xx adhoc code instead of using yours
_________________

Upgrade your PSP
Back to top
View user's profile Send private message
pspZorba



Joined: 22 Sep 2007
Posts: 156
Location: NY

PostPosted: Mon Apr 21, 2008 4:04 am    Post subject: Reply with quote

Pirata Nervo

if you read the whole post (2 lines without the quote) you will have seen that i wrote :
Quote:
...pb of path ...


which is the case if floorball92's install is the same as mine, the headers or not under:

/cygwin/usr/local/pspdev/include
cf:
Quote:
psp-g++ -I. -IE:/cygwin/usr/local/pspdev/include


but under:
/cygwin/usr/local/pspdev/psp/sdk/include

which is certainly comming from the PSPSDK environment variable in the makefile.

solution : modify your makefile

I am sorry you gave up for something probably that simple.



floorball92:
I don't know if you are familliar with make/makefile/psp-g++, if you are not, there is a command which is very usefull: man

in a shell do man psp-g++ or man gcc (should be the same options) and man make. You will have a better comprehension of these tools options, and the basics to be able to compile.
_________________
--pspZorba--
NO to K1.5 !
Back to top
View user's profile Send private message
Pirata Nervo



Joined: 09 Oct 2007
Posts: 409

PostPosted: Mon Apr 21, 2008 5:39 am    Post subject: Reply with quote

what does "pb" mean? lol
I already changed -L/usr/local/pspdev/lib
to -L/usr/local/pspdev/psp/sdk/lib
and still getting errors
I did modify the makefile.
_________________

Upgrade your PSP
Back to top
View user's profile Send private message
pspZorba



Joined: 22 Sep 2007
Posts: 156
Location: NY

PostPosted: Mon Apr 21, 2008 6:42 am    Post subject: Reply with quote

pb means : problem

-L is the gcc option for setting the path to librairies when linking

and the problem is a problem of path to headers (as the log shows it) when gcc is compiling.

The gcc option for setting the path to headers is -I

so you should have something like -IthePathToYourHeaders in your compile options of your makefile. you can set the path you want, even several -I.

It's often in a variable called INCDIR.


you should do a "man gcc " everything is explained even if not always easy to read
_________________
--pspZorba--
NO to K1.5 !
Back to top
View user's profile Send private message
Pirata Nervo



Joined: 09 Oct 2007
Posts: 409

PostPosted: Mon Apr 21, 2008 7:47 am    Post subject: Reply with quote

I got it to work before by removing a few lines and replacing some.
This is what I get:
Code:

ZBadhoc.cpp: In member function ‘int ZBadhoc::requestConnection(ZBremotePsp*)’:
ZBadhoc.cpp:351: error: invalid conversion from ‘char*’ to ‘unsigned char*’
ZBadhoc.cpp:351: error:   initializing argument 2 of ‘int sceNetAdhocMatchingSelectTarget(int, unsigned char*, int, int)’
ZBadhoc.cpp: In member function ‘void ZBadhoc::createMatching()’:
ZBadhoc.cpp:699: error: invalid conversion from ‘void (*)(int, int, char*, int, char*)’ to ‘void (*)(int, int, unsigned char*, int, void*)’
ZBadhoc.cpp:699: error:   initializing argument 9 of ‘int sceNetAdhocMatchingCreate(int, int, int, int, int, int, int, int, void (*)(int, int, unsigned char*, int, void*))’
ZBadhoc.cpp: In member function ‘ZBremotePsp* ZBadhoc::waitForConnection()’:
ZBadhoc.cpp:1002: error: invalid conversion from ‘char*’ to ‘unsigned char*’
ZBadhoc.cpp:1002: error:   initializing argument 2 of ‘int sceNetAdhocMatchingCancelTarget(int, unsigned char*)’
ZBadhoc.cpp:1010: error: invalid conversion from ‘char*’ to ‘unsigned char*’
ZBadhoc.cpp:1010: error:   initializing argument 2 of ‘int sceNetAdhocMatchingSelectTarget(int, unsigned char*, int, int)’
make: *** [ZBadhoc.o] Error 1



the errors appear where you do something like (char *)variable

Edit:

I changed the char* to unsigned char* and the only errors I get now are:
Code:
ZBadhoc.cpp: In member function ‘void ZBadhoc::createMatching()’:
ZBadhoc.cpp:699: error: invalid conversion from ‘void (*)(int, int, char*, int, char*)’ to ‘void (*)(int, int, unsigned char*, int, void*)’
ZBadhoc.cpp:699: error:   initializing argument 9 of ‘int sceNetAdhocMatchingCreate(int, int, int, int, int, int, int, int, void (*)(int, int, unsigned char*, int, void*))’
make: *** [ZBadhoc.o] Error 1


Edit2:

Changed this line:

void matchingCB(int unk1, int event, char *macSource, int size, char *data)
to:
void matchingCB(int unk1, int event, unsigned char *macSource, int size, void *data)

fixes the problem.
Now I got this error:
/usr/local/pspdev/lib/gcc/psp/4.1.0/../../../../psp/bin/ld: cannot find -lpspnet_adhocmatching

I edited the LIBS in the makefile and I was getting this error:
cp eboot.pbp F:/PSP/GAME/test
cp: cannot stat `eboot.pbp': No such file or directory

removed the copy file part and the debug and compiled everything right.
Tested and run fine although something are not working like when I press [], it crashes if I press /\ on my other psp
_________________

Upgrade your PSP
Back to top
View user's profile Send private message
pspZorba



Joined: 22 Sep 2007
Posts: 156
Location: NY

PostPosted: Mon Apr 21, 2008 8:34 am    Post subject: Reply with quote

That's strange you had to change the char * to unsigned char *


could you have a look at pspnet_adhocmatching.h

about line 110 do you have for sceNetAdhocMatchingSelectTarget :

int sceNetAdhocMatchingSelectTarget(int matchingId, char *mac, int unk3, int unk4);


and line 47 for MatchingCallback :

typedef void (*MatchingCallback)(int unk1, int event, char *mac2, int optLen, char *optData);


It looks like we don't have the same header may be one of us has a more recent version.


concerning the crash, I ve just re-run the sample, I ve no problem. could you see where it crashs?
_________________
--pspZorba--
NO to K1.5 !
Back to top
View user's profile Send private message
Pirata Nervo



Joined: 09 Oct 2007
Posts: 409

PostPosted: Mon Apr 21, 2008 8:40 am    Post subject: Reply with quote

I updated the sdk 3 or 4 weeks ago.
pspnet_adhocmatching.h
$Id: pspnet_adhocmatching.h 2356 2008-01-15 23:50:17Z iwn $

int sceNetAdhocMatchingSelectTarget(int matchingId, unsigned char *mac, int unk3, int unk4);

MatchingCallBack:
typedef void (*MatchingCallback)(int unk1, int event, unsigned char *mac2, int optLen, void *optData);

What's your revicion number?

Edit: Im updating the sdk in case you have a more recent version

Edit 2: The functions are the same as the ones I said above so you need to rewrite your source (because it is crashing) or I need to edit my file lol.

Edit 3 (wow): I edited my pspnet_adhocmatching.h so it is the same as yours but still shuts down when sending/receiving..
_________________

Upgrade your PSP


Last edited by Pirata Nervo on Mon Apr 21, 2008 8:55 am; edited 1 time in total
Back to top
View user's profile Send private message
pspZorba



Joined: 22 Sep 2007
Posts: 156
Location: NY

PostPosted: Mon Apr 21, 2008 8:53 am    Post subject: Reply with quote

Mine is older than yours that's why you had to change the char * to unsigned char *.

I think I'll have to update mine.

Concerning the crash did you see where it happens ?
_________________
--pspZorba--
NO to K1.5 !
Back to top
View user's profile Send private message
Pirata Nervo



Joined: 09 Oct 2007
Posts: 409

PostPosted: Mon Apr 21, 2008 8:57 am    Post subject: Reply with quote

Example:
First PSP -> Press [] or /\
Second PSP -> Press [] or /\
one of them crashes and shuts down
_________________

Upgrade your PSP
Back to top
View user's profile Send private message
pspZorba



Joined: 22 Sep 2007
Posts: 156
Location: NY

PostPosted: Mon Apr 21, 2008 9:08 am    Post subject: Reply with quote

I update my sdk, and I'll check.
_________________
--pspZorba--
NO to K1.5 !
Back to top
View user's profile Send private message
Pirata Nervo



Joined: 09 Oct 2007
Posts: 409

PostPosted: Mon Apr 21, 2008 5:46 pm    Post subject: Reply with quote

OK, thanks, post a working sample when you are done please.
_________________

Upgrade your PSP
Back to top
View user's profile Send private message
floorball92



Joined: 05 Apr 2008
Posts: 30
Location: Germany -> Hessen -> Hanau

PostPosted: Tue Apr 22, 2008 12:55 am    Post subject: Reply with quote

I changed the path and get this:

Code:
**** Build of configuration Default for project adhoc ****

make all
make: *** No rule to make target `all'.  Stop.

_________________
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
pspZorba



Joined: 22 Sep 2007
Posts: 156
Location: NY

PostPosted: Wed Apr 23, 2008 1:49 am    Post subject: Reply with quote

floorball92

just do "make" not "make all"
or add the target "all" in the makefile.

---------------------
Pirata Nervo,

I updated my sdk. the signature of some functions have changed from char * to unsigned char *. But nothing very important.

You just have to remove the casts (as the macAdresse is already an u8).
And adapt the signature of the matching callback.

You recompile and it works : if it still doesn't work, try the this eboot

if this eboot is working => you may have changed too many thing in the sample

if not ....what is your firmware? can you do game sharing with games such lumines ?
_________________
--pspZorba--
NO to K1.5 !
Back to top
View user's profile Send private message
Pirata Nervo



Joined: 09 Oct 2007
Posts: 409

PostPosted: Wed Apr 23, 2008 4:44 am    Post subject: Reply with quote

What do you mean by casts?
the (u8*) and (unsigned char*) or only the (u8*) ?
_________________

Upgrade your PSP
Back to top
View user's profile Send private message
pspZorba



Joined: 22 Sep 2007
Posts: 156
Location: NY

PostPosted: Wed Apr 23, 2008 8:16 am    Post subject: Reply with quote

a cast is an explicit transformation of a type A in type B.

eg:

the old signatures of sceNetAdhocMatchingSelectTarget is:

int sceNetAdhocMatchingSelectTarget(int, char*, int, int) (<= see the 2nd arg)

But as my variable was an (u8 * ) which is the same as (unsigned char *). I had to cast it in (char *).

so the code is something like:

sceNetAdhocMatchingSelectTarget( .., (char*) myVariable , .., ..)


But you have the newer header, where the signature is

int sceNetAdhocMatchingSelectTarget(int, unsigned char*, int, int) (<= see the 2nd arg)

And the code is still :
sceNetAdhocMatchingSelectTarget( .., (char*) myVariable , .., ..)

so now you just have to remove the cast (char*) and it will compile like a charm.

that was the error line 351,1002,1010.

for the error line 699 it's similar and simpler, it's only the signature of the matching callback that has changed, so just change the signature of the function matchingCB, the second function in the source if I remember well.


If you want to use the code and adapt it to your own homebrew, you really have to read some books like thinking in C++ it's free and very good.
_________________
--pspZorba--
NO to K1.5 !
Back to top
View user's profile Send private message
Pirata Nervo



Joined: 09 Oct 2007
Posts: 409

PostPosted: Wed Apr 23, 2008 8:44 am    Post subject: Reply with quote

>.< I know what a cast is, I think I did not explain it right, sorry.
I just wanted to know what to change, if the char * only or the u8 * too.

I have got 3 C++ books and 2 C books ;)
I know how C++ works although I have not learned a lot of it as I don't have enough time to continue learning one of the books (I started learning one of the books but did not end it)

Edit:
Removed the (char *) from those lines
and changed in the callbacks function I changed the 1st char* to unsigned char* and the 2nd char* to void*

still crashes.
the eboot you give in your post works but not mine.
damn, lol
_________________

Upgrade your PSP
Back to top
View user's profile Send private message
pspZorba



Joined: 22 Sep 2007
Posts: 156
Location: NY

PostPosted: Wed Apr 23, 2008 12:20 pm    Post subject: Reply with quote

ok your question made me think you had problems with casts.

So if the eboot I sent you is working and the one you compile doesn't, it means :
It's not a problem of context on you PSP, so nothing block the homebrew such as a pluggin or I don't not what, it means that all the prx etc are started correctly.

If you don't have even a warning during the compile phase (which should be the case).

There is only one possibility : the link.

could you show the compile option and libs you used ?
_________________
--pspZorba--
NO to K1.5 !
Back to top
View user's profile Send private message
Pirata Nervo



Joined: 09 Oct 2007
Posts: 409

PostPosted: Wed Apr 23, 2008 6:15 pm    Post subject: Reply with quote

No warnings, no nothing lool.

Here's my makefile:
Code:
##########################################################################

# This file is part of pspZorba samples.

#

#   pspZorba samples are free softwares: you can redistribute it and/or modify

#   it under the terms of the GNU General Public License as published by

#   the Free Software Foundation, either version 3 of the License, or

#   (at your option) any later version.

#

#   pspZorba samples is distributed in the hope that it will be useful,

#   but WITHOUT ANY WARRANTY; without even the implied warranty of

#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

#   GNU General Public License for more details.

#

#   You should have received a copy of the GNU General Public License

#   along with pspZorba samples.  If not, see <http://www.gnu.org/licenses/>.

#

#########################################################################



#########################################################

#

#              pspZorba : PSPlorer

#            www.pspzorba.com

#########################################################



# name displayed by the XMB

PSP_EBOOT_TITLE = pspZorba-ex028



# fisrt icon displayed (*.PNG)  by the XMB

PSP_EBOOT_ICON = NULL



# animation (*.PMF) displayed by the XMB

PSP_EBOOT_ANIM = NULL



# it's a picture (*.PNG)displayed after some seconds rather  with transparency to allow us to see the first icon and the anim.

PSP_EBOOT_FOREGROUND = NULL



# background image (*.PNG) displayed

PSP_EBOOT_BACKGROUND = NULL



# music (*.AT3) rather a loop but not mandatory

PSP_EBOOT_SND0 = NULL



CXXFLAGS = -g -G0 -Wall -O3 -D_PSP_FW_VERSION=380 -fno-rtti -fno-exceptions

INCDIR = -I. -I/home/piratanervo/meus/380Projects/_380SDK/include -I/usr/local/pspdev/psp/sdk/include

LIBDIR = -L. -L/usr/local/pspdev/psp/sdk/lib -L/home/piratanervo/meus/380Projects/_380SDK/lib -specs=/usr/local/pspdev/psp/sdk/lib/prxspecs -Wl,-q,-T/usr/local/pspdev/psp/sdk/lib/linkfile.prx

LIBS =  /usr/local/pspdev/psp/sdk/lib/prxexports.o -lstdc++ -lpspnet_adhocmatching -lpspnet_adhoc -lpspnet_adhocctl -lpspwlan -lpspnet -lpspusb -lpspusbstor -lpsppower -lpspgum -lpspgu -lm  -lpspumd -lpspctrl -lpspdebug -lpspge -lpspdisplay -lpspsdk -lc -lpspuser -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_resolver -lpspnet_inet -lpsputility



OBJECTS = main.o ZBadhoc.o

#########################################################



EBOOT.PBP: PARAM.SFO a.prx $(PSP_EBOOT_ICON)  $(PSP_EBOOT_FOREGROUND) $(PSP_EBOOT_BACKGROUND) $(PSP_EBOOT_ANIM) $(PSP_EBOOT_SND0)

   pack-pbp $@ PARAM.SFO $(PSP_EBOOT_ICON) $(PSP_EBOOT_ANIM) $(PSP_EBOOT_FOREGROUND) $(PSP_EBOOT_BACKGROUND) $(PSP_EBOOT_SND0) a.prx NULL



PARAM.SFO: a.prx

   mksfo $(PSP_EBOOT_TITLE) $@



a.prx: a.elf

   psp-prxgen $< $@





a.elf: $(OBJECTS) Makefile

   psp-gcc $(CXXFLAGS) $(LIBDIR) $(OBJECTS) $(LIBS) -o $@

   psp-fixup-imports  $@







main.o: main.cpp ZBadhoc.h

   psp-g++ $(INCDIR)  $(CXXFLAGS) -c -o $@ $<





ZBadhoc.o: ZBadhoc.cpp ZBadhoc.h

   psp-g++ $(INCDIR)  $(CXXFLAGS) -c -o $@ $<







NULL:



cleanall: clean



clean:

   rm -f $(OBJECTS) a.elf a_strip.elf PARAM.SFO EBOOT.PBP





_________________

Upgrade your PSP
Back to top
View user's profile Send private message
pspZorba



Joined: 22 Sep 2007
Posts: 156
Location: NY

PostPosted: Thu Apr 24, 2008 10:39 am    Post subject: Reply with quote

I don't see anything wrong ...

last hypothesis :
- you may have remove/modify something in the code (not on purpose I mean)
or .... I don't know


so re-upload the sources here , use the makefile above, and recompile them (without any change at first), they are exactly the sources of the Eboot I sent you.

If it crashes ...then I am running out of idea
_________________
--pspZorba--
NO to K1.5 !
Back to top
View user's profile Send private message
Pirata Nervo



Joined: 09 Oct 2007
Posts: 409

PostPosted: Fri Apr 25, 2008 5:15 am    Post subject: Reply with quote

I was using your released source code :|
I used your new code and it still crashes..damn
I will try to figure out the problem, I changed the makefile again to test if it was working or not but no luck
_________________

Upgrade your PSP
Back to top
View user's profile Send private message
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