Skip to content

Commit

Permalink
Add a convenience function to return the board serial number
Browse files Browse the repository at this point in the history
  • Loading branch information
mairas committed Jun 3, 2024
1 parent 01d0db7 commit 62ee197
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/sensesp/system/serial_number.h
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_

0 comments on commit 62ee197

Please sign in to comment.