gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > Help with dswifi and general connectivity for the xtrem noob

#168974 - Emmanuel - Sun Jun 07, 2009 3:29 pm

Here's my issue:
Add multiplayer to my game.

Over Internet and local if possible. But, first I'd prefer local so it's easier to test. DS connect to DS.

I need to be able to at least send and receive one simple byte per frame. *well, in fact, 3 u16 per frame, but if not possible, 1 byte would keep me happy, what I plan on sending is the Key presses per frame to the server DS, and then it sends the missing presses back to the other DSs and have each calculate the game with no synchronization on hp or positions, but, they would likely be the same. I think.*

I am COMPLETELY clueless for the most part on all this network stuff. So, I don't expect a complete answer but at least some stuff to take me on the right path.

If someone has an example of DS-DS connectivity, it would be nice. *Without liblobby, cuz I've read it's buggy or something*

#168975 - DarkShadow44 - Sun Jun 07, 2009 4:28 pm

Hello,
look here for a example.

Liblobby doesn't work with the latest libnds/devkitARM, but this should work.

Use that sample code for sending/receiving a string:

Code:


#include <nds.h>
#include <stdio.h>
#include <dswifi9.h>
#include <string.h>


char SendData[300];

char RecvData[300];




void Handler(int packetID, int readlength)
{
    unsigned short* data=malloc(1000);
   static int bytesRead;

   bytesRead = Wifi_RxRawReadPacket(packetID, readlength, (unsigned short *)data);
   
   sprintf(RecvData,"%s", (char*)data+32);
}



int main()
{
   Wifi_InitDefault(false);
   Wifi_SetPromiscuousMode(1);
   Wifi_EnableWifi();
   Wifi_RawSetPacketHandler(Handler);
   Wifi_SetChannel(10);

   while(1)
   {
       //some stuff
     


     //sending:
    Wifi_RawTxFrameAdHoc(strlen((char *)SendData) , 0x0014, (unsigned short*)SendData) ;
     swiWaitForVBlank();
   }
return 0;
}


SendData is the string to send, RecvData the received string...

But attention! You receive ALL packets, also those from access points. You have to add a test for checking if it is your packet !

Wifi_RawTxFrameAdHoc is the renamed Wifi_RawTxFrame function from the other thread, you MUST add it to the the wifi lib and re-compile or it wouldn't work!

Hope I could help you. ;-)

#168982 - Emmanuel - Mon Jun 08, 2009 3:11 am

Didn't work...

Most recent dswifi from libnds at sourceforge had some errors with some critical point or something functions or something.

Then, I downloaded the 3392 revision, which did compile and gave no compiling errors.

I added the function by copy pasting it above the original one, and renamed to the same name +AdHoc. Copy pasted the generated files onto libnds's folder.

On the example from the other thread, it didn't work. It just said it sent packages but neither DS received them. They froze at the package 200 something.

On yours, nothing happened, so I added the default console, and an if that would only send the package on a KEY_A press, and would print "Sent" to screen. The "Sent's were printed, but nothing happened on the other end. *tried from both DSs*

I don't know what I'm doing wrong S: Any further help is welcomed.

EDIT: IT WORKED! I had forgotten to set the SendData to something instead of a Null array!