In a project I am developing, I need to get the MAC address associated to a certain IP, but I cannot see any way go get it. I thought about doing an ARP request, but I see no interface to do it. I also could ping the IP and then check the ARP table, but I also see no way to do this.
Will this one give me the mac from the IP after connecting? There is no comments in the code and I am kind of lost with it. To me it seems that there are only methods to get the local MAC address...
This is a function I use to debug the w5100 sketches I have. It displays the mac address of any connected devices.
#include <utility/w5100.h>
byte socketStat[MAX_SOCK_NUM];
byte destMac[6];
void ShowSockStatus()
{
for (int i = 0; i < MAX_SOCK_NUM; i++) {
Serial.print(F("Socket#"));
Serial.print(i);
uint8_t s = W5100.readSnSR(i);
socketStat[i] = s;
Serial.print(F(":0x"));
Serial.print(s,16);
Serial.print(F(" "));
Serial.print(W5100.readSnPORT(i));
Serial.print(F(" D:"));
uint8_t dip[4];
W5100.readSnDIPR(i, dip);
for (int j=0; j<4; j++) {
Serial.print(dip[j],10);
if (j<3) Serial.print(".");
}
Serial.print(F("("));
Serial.print(W5100.readSnDPORT(i));
Serial.print(F(") "));
// this is the remote device mac address
W5100.readSnDHAR(i,destMac);
for (int j=0; j<6; j++) {
if(destMac[j] < 16) Serial.print(F("0"));
Serial.print(destMac[j],HEX);
if (j<5) Serial.print(":");
}
Serial.println();
}
}
Connect to the device, then modify the above code to check for a socket that has a status of 0x17. That is the status of a socket that is connected to another device.