I am looking into printing out the MAC address of an ESP32 board. The Arduino Examples define it by the following:
uint64_t chipid=ESP.getEfuseMac();//The chip ID is essentially its MAC address(length: 6 bytes).
Serial.printf("ESP32 Chip ID = %04X",(uint16_t)(chipid>>32));//print High 2 bytes
Serial.printf("%08X\n",(uint32_t)chipid);//print Low 4bytes.
However, I found the following way to do it:
uint64_t chipId = ESP.getEfuseMac();
Serial.printf("%" PRIx64 "\n", chipId);
The second way is obviously more verbose, however, while looking online, I never found such an example with the Arduino boards. Is there a memory issue that way and if so - what?
64-bit printf() support was added end of 2016 (I think) and the example seems to predate that. The PRIx64
is the correct way to print a 64-bit number.