The MAC address is 64 bits, which is 8 bytes (64 bits / (8 bits/byte)). ATSH
and ATSL
both respond with a 4-byte value. So you should define my address
as 8 bytes, and copy ATSL
to myaddress[i+4]
.
Note that you can use memcpy()
instead of looping through the bytes:
memcpy( &myaddress[i+4], atResponse.getValue(), 4);
I'm not familiar with the Arudino's Serial.print()
, but if it doesn't support printing a hex byte with leading zero, you can print the MAC with:
for (int i = 0; i < 8; i++) {
if (myaddress[i] < 0x10) Serial.print( "0");
Serial.print( myaddress[i], HEX);
}