cancel
Showing results for 
Search instead for 
Did you mean: 

Get MacAddress Of Device

Former Member
0 Kudos

Hi,

How can i get the MacAddress of Device on Java?

Regards,

Bruno

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi

The Bluetooth address serves the same purpose of the MAC address on the network card of your computer; every Bluetooth device has a unique address.

Check out the link below..atleast you can have some idea to initiate.

<a href="http://today.java.net/pub/a/today/2004/07/27/bluetooth.html">http://today.java.net/pub/a/today/2004/07/27/bluetooth.html</a>

Hope this is useful..

Cheers,

kumarR

Former Member
0 Kudos

Hi Bruno Ambrozio,

<b>Do check the below link which contains some psedocode which include Mac address.</b>

<a href="http://www.tigoe.net/pcomp/code/archives/lantronix_devices/000315.shtml">Check the pseudocode - Mac Address in Java</a>

Cheers,

kumarR

Former Member
0 Kudos

Hi kumarR/Divya Sarraju,

I have been looked at this links and didn't get solving my problem... In Windows Desktop, I found a code that return me the MAC Address, but for device not yet. Do you have any more idea?

Thanks for help.

Regards,

Bruno

Former Member
0 Kudos

Hi Bruno Ambrozio ,

Check out the code below...May the logic helps u out

IP_ADAPTER_INFO AdapterInfo[16]; // Allocate information

// for up to 16 NICs

DWORD dwBufLen = sizeof(AdapterInfo); // Save memory size of buffer

DWORD dwStatus = GetAdaptersInfo( // Call GetAdapterInfo

AdapterInfo, // [out] buffer to receive data

&dwBufLen); // [in] size of receive data buffer

if (dwStatus != ERROR_SUCCESS)

{

return oa.newString(&java_string("00:00:00:00:00", -1), 0);

} // Verify return value is

// valid, no buffer overflow

PIP_ADAPTER_INFO pAdapterInfo = AdapterInfo; // Contains pointer to

// current adapter info

char buffer[200]="";

if (pAdapterInfo) {

unsigned char MACData[8]={pAdapterInfo->Address[0], pAdapterInfo->Address[1], pAdapterInfo->Address[2], pAdapterInfo->Address[3], pAdapterInfo->Address[4], pAdapterInfo->Address[5], pAdapterInfo->Address[6], pAdapterInfo->Address[7]}; // Print MAC address

sprintf(buffer, "%02X:%02X:%02X:%02X:%02X:%02X", MACData[0], MACData[1], MACData[2], MACData[3], MACData[4], MACData[5]);

}

..for more Check out the link below

<a href="http://www.pdastreet.com/forums/showthread.php?t=30413">http://www.pdastreet.com/forums/showthread.php?t=30413</a>

Cheers,

kumarR

Former Member
0 Kudos

Hey Bruno,

If you could tell us what is the environment setup, it would be easy to give specific answer.

Is it WLAN or Bluetooth or IR, .

Also what is the platform on which you have to write the code J2ME, WinCE or Symbian.

Divya

Former Member
0 Kudos

Hi Divya Sarraju,

We're using Windows Mobile 2003/5.0, WLAN, CrEmE (Java) ...

We want the MACAddress to identify in that device the user is working, to generate reports in the future.

Thanks for help Divya and Kumar.

Bruno.

Former Member
0 Kudos

Hi

Check this URL /thread/245711 [original link is broken]

-

Ps: You get 1 point when you reward points to the replies of your queries.

Cheers,

kumarR

Former Member
0 Kudos

Hi Bruno Ambrozio,

hope this code helps you...

<i>This code will only work in Windows 2000/XP since Microsoft replaced UuidCreate in Windows 2000/XP with one that doesn't use the PC's MAC address.</i>

// Fetches the MAC address and prints it

static void GetMACaddress(void)

{

unsigned char MACData[6];

UUID uuid;

UuidCreateSequential( &uuid ); // Ask OS to create UUID

for (int i=2; i<8; i++) // Bytes 2 through 7 inclusive

// are MAC address

MACData[i - 2] = uuid.Data4<i>;

PrintMACaddress(MACData); // Print MAC address

}

<b>If this is not enough...try out this</b> <a href="http://www.codeguru.com/Cpp/I-N/network/networkinformation/article.php/c5451#more">Link</a>

Cheers,

kumarR

Former Member
0 Kudos

Hi Bruno,

Are you working on any wireless application?

1. I succeded in doing this in VC++. You can create a UUID and pull the MAC from there.or can import NDIS miniport driver itself. you open this API documentation you will find the relevant methods for acces in MAC adress.

2. for JAVA you can find this link enumerating all APIs and new enhancements.

http://java.sun.com/j2se/1.4.2/docs/guide/net/enhancements14.html

3. Also, you can look for DHCP.

The Dynamic Host Configuration Protocol (DHCP) is an Internet protocol for automating the configuration of computers that use TCP/IP. DHCP can be used to automatically assign IP addresses, to deliver TCP/IP stack configuration parameters such as the subnet mask and default router, and to provide other configuration information such as the addresses for printer, time and news servers.

http://www.dhcp.org/

http://developers.sun.com/solaris/articles/dhcp-wp.pdf

4. Check this too, if you need in j2ME.

http://articles.techrepublic.com.com/5100-3513_11-6171367.html

Hope this helps. Please feel free to ask for more help.

Regards

Divya