Obtain MAC address

Post Reply
JanMulder
Posts: 15
Joined: Wed Jan 26, 2011 2:52 pm

Obtain MAC address

Post by JanMulder » Wed Jan 26, 2011 2:56 pm

Hey,
I'd like to get the MAC address of the DS. I think it is possible with readFirmware(), but that's for ARM7 only. It should also be possible with Wifi_GetData(), but that doesn't seem to work if you're not connected to the Wi-Fi... So how should I do this?

Thanks in advance,

Jan

zeromus
Posts: 212
Joined: Wed Mar 31, 2010 6:05 pm

Re: Obtain MAC address

Post by zeromus » Wed Jan 26, 2011 10:52 pm

why not use the arm7?

elhobbs
Posts: 358
Joined: Thu Jul 02, 2009 1:19 pm

Re: Obtain MAC address

Post by elhobbs » Thu Jan 27, 2011 12:39 am

Code: Select all

Wifi_InitDefault(false);
will cause dswifi to initialize but not connect to the default AP. after that the mac address should be in WifiData->MacAddr. however, WifiData is defined as

Code: Select all

volatile Wifi_MainStruct * WifiData;
but Wifi_MainStruct is only defined in wifi_shared.h which you would need to get from the the source for dswifi. the alternative is to do as zeromus suggested and read it from the firmware on the arm7 and request it via fifo on the arm9.

WinterMute
Site Admin
Posts: 1911
Joined: Tue Aug 09, 2005 3:21 am
Location: UK
Contact:

Re: Obtain MAC address

Post by WinterMute » Thu Jan 27, 2011 3:06 pm

zeromus wrote:why not use the arm7?
Because almost nobody should be using a custom arm7, 99% of the code out there using custom arm7 is *horrendous* and we'd really rather not encourage people to use it.

If there's a need to obtain the MAC address then there should be a means to do it in libnds.

Jan, what's this for?
Help keep devkitPro toolchains free, Donate today

Personal Blog

Copper
Posts: 7
Joined: Sun Dec 28, 2008 9:34 pm

Re: Obtain MAC address

Post by Copper » Thu Jan 27, 2011 10:07 pm

In my NIFI homebrews i use :

Code: Select all

	Wifi_InitDefault(false);

...

	u8 macAddress[6];
	Wifi_GetData(WIFIGETDATA_MACADDRESS, 6, macAddress);

JanMulder
Posts: 15
Joined: Wed Jan 26, 2011 2:52 pm

Re: Obtain MAC address

Post by JanMulder » Sun Jan 30, 2011 12:33 am

I need it because I don't want the user to be able to use another DS than the DS it has run on first. And the MAC address is the only unique number the DS has. And it isn't possible to change it I think. I found the way already:

Code: Select all

unsigned char mac_address[6];
char *GetMACAddress(void) {
	Wifi_EnableWifi();
	Wifi_InitDefault(false);
	Wifi_GetData(WIFIGETDATA_MACADDRESS,6,&mac_address[0]);
	Wifi_DisableWifi();
	return mac_address;
}
Thanks for the help anyway!
PS: the MAC Address isn't editable right?

WinterMute
Site Admin
Posts: 1911
Joined: Tue Aug 09, 2005 3:21 am
Location: UK
Contact:

Re: Obtain MAC address

Post by WinterMute » Sun Jan 30, 2011 2:56 am

The MAC address can be changed, yes. This sort of thing is easily patched out of homebrew though so it might be a bit of wasted effort.
Help keep devkitPro toolchains free, Donate today

Personal Blog

JanMulder
Posts: 15
Joined: Wed Jan 26, 2011 2:52 pm

Re: Obtain MAC address

Post by JanMulder » Sun Jan 30, 2011 4:09 pm

Isn't the whole point of a MAC address that it's unique?

WinterMute
Site Admin
Posts: 1911
Joined: Tue Aug 09, 2005 3:21 am
Location: UK
Contact:

Re: Obtain MAC address

Post by WinterMute » Sun Jan 30, 2011 9:38 pm

Well, yes but then people do silly things like lock software to a MAC address so provision is made to transfer a MAC address from an old machine being scrapped to a shiny new one and avoid being "taxed" for upgrading hardware.
Help keep devkitPro toolchains free, Donate today

Personal Blog

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest