Page 1 of 1

Obtain MAC address

Posted: Wed Jan 26, 2011 2:56 pm
by JanMulder
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

Re: Obtain MAC address

Posted: Wed Jan 26, 2011 10:52 pm
by zeromus
why not use the arm7?

Re: Obtain MAC address

Posted: Thu Jan 27, 2011 12:39 am
by elhobbs

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.

Re: Obtain MAC address

Posted: Thu Jan 27, 2011 3:06 pm
by WinterMute
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?

Re: Obtain MAC address

Posted: Thu Jan 27, 2011 10:07 pm
by Copper
In my NIFI homebrews i use :

Code: Select all

	Wifi_InitDefault(false);

...

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

Re: Obtain MAC address

Posted: Sun Jan 30, 2011 12:33 am
by JanMulder
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?

Re: Obtain MAC address

Posted: Sun Jan 30, 2011 2:56 am
by WinterMute
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.

Re: Obtain MAC address

Posted: Sun Jan 30, 2011 4:09 pm
by JanMulder
Isn't the whole point of a MAC address that it's unique?

Re: Obtain MAC address

Posted: Sun Jan 30, 2011 9:38 pm
by WinterMute
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.