Leading Zeroes on Arduino Ethernet MAC Address How can I pass the MAC address to Ethernet shield with leading zeroes?
I change the default MAC address from DEADBEEFFEED to something like DEADBEEFFE01. So I only change the last number from 0xED to 0x01. My board is communicating to a separate server and when I look at the MAC in that server, my board is listed as DEADBEEFFE1.
It's not as simple as printing the MAC address with padded zeroes as the board is actually removing it.
I've looked at the Ethernet library and I saw that the mac is passed as an array of uint8_t. I think that's why, the last number is read as 1 (which is correct) but passed as just that.
Is there a way for the MAC to pass leading zeroes?
Writing this in case someone in the future might be interested.
The values passed in the Ethernet library is correct. The last value, 0x01 must be 1 and is written correctly, 0x01 in the registers of the W5500 inside the Ethernet shield.
Where I've got it wrong is how I pass the MAC address to the server. I'm basically creating a string for a json message. In there, I've put %02x to make sure that zeroes are padded.