I'm developing an OpenThread Sleepy End Device (SED) that periodically sends a payload to a CoAP server, including its own MAC address as one of the values. However, I noticed that the MAC address changes every time I build and flash the firmware. How to keep the MAC address persistent across firmware flashes?
My code for retrieving the MAC address:
void get_my_mac_address(char* buf, size_t buf_size) {
otInstance* myInstance = openthread_get_default_instance();
const otExtAddress* ext_addr = otLinkGetExtendedAddress(myInstance);
snprintf(buf, buf_size, "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X", ext_addr->m8[0], ext_addr->m8[1], ext_addr->m8[2], ext_addr->m8[3],
ext_addr->m8[4], ext_addr->m8[5], ext_addr->m8[6], ext_addr->m8[7]);
LOG_INF("My MAC: %s. (line %i)\n", buf, __LINE__);
}