M5Paper unique device identifier?
-
This post is deleted! -
Hello, does the getEfuseMac return you the same value? you can try to generate a value one time and keep it inside the device for use later.
-
Actually, my bad, I ran the same code again on 3 different M5Paper and it is indeed working...
So yes, getMACString is returning a unique id.
`
[global_setting.cpp:70] getMACString(): MAC = 0000CC240805613C
[main.cpp:261] run(): getEfuseMac: 0805613C[global_setting.cpp:70] getMACString(): MAC = 0000CC370805613C
[main.cpp:261] run(): getEfuseMac: 0805613C[global_setting.cpp:70] getMACString(): MAC = 000084170905613C
[main.cpp:261] run(): getEfuseMac: 0905613C
`Thanks
-
Here is a solution to create an unique identifier that is based on the device's MAC address (but is not easy to guess and is not the MAC address itself):
/** Returns a hashed uint64_t */ uint64_t getHashedInt64(uint64_t u) { uint64_t v = u * 3935559000370003845 + 2691343689449507681; v ^= v >> 21; v ^= v << 37; v ^= v >> 4; v *= 4768777513237032717; v ^= v << 20; v ^= v >> 41; v ^= v << 5; return v; } /** Return a device unique identifier based on device's mac address, eg. 6C4080B51A5D3659 */ String getUniqueId() { uint64_t mac = ESP.getEfuseMac(); uint64_t hash = getHashedInt64(mac); uint32_t msb = hash >> 32; uint32_t lsb = hash & 0xFFFFFFFF; char unique_id[20]; sprintf(unique_id, "%08X%08X", msb, lsb); return String(unique_id); }Calling:
getUniqueId() returns something like 6C4080B51A5D3659
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login