-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a convenience function to return the board serial number
- Loading branch information
Showing
1 changed file
with
16 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#ifndef SENSESP_SRC_SENSESP_SYSTEM_SERIAL_NUMBER_H_ | ||
#define SENSESP_SRC_SENSESP_SYSTEM_SERIAL_NUMBER_H_ | ||
|
||
#include <esp_mac.h> | ||
|
||
#include <cstdint> | ||
|
||
uint64_t GetBoardSerialNumber() { | ||
uint8_t chipid[6]; | ||
esp_efuse_mac_get_default(chipid); | ||
return ((uint64_t)chipid[0] << 0) + ((uint64_t)chipid[1] << 8) + | ||
((uint64_t)chipid[2] << 16) + ((uint64_t)chipid[3] << 24) + | ||
((uint64_t)chipid[4] << 32) + ((uint64_t)chipid[5] << 40); | ||
} | ||
|
||
#endif // SENSESP_SRC_SENSESP_SYSTEM_SERIAL_NUMBER_H_ |