Add function to retrieve unique ID (if present) (#780)
This commit is contained in:
+10
@@ -56,6 +56,9 @@ uint8_t hwReadConfig(int adr);
|
||||
* @param ms Time to sleep, in [ms].
|
||||
* @return Nonsense, please ignore.
|
||||
*/
|
||||
|
||||
typedef uint8_t unique_id_t[16];
|
||||
|
||||
int8_t hwSleep(unsigned long ms);
|
||||
|
||||
/**
|
||||
@@ -79,6 +82,13 @@ int8_t hwSleep(uint8_t interrupt, uint8_t mode, unsigned long ms);
|
||||
int8_t hwSleep(uint8_t interrupt1, uint8_t mode1, uint8_t interrupt2, uint8_t mode2,
|
||||
unsigned long ms);
|
||||
|
||||
/**
|
||||
* Retrieve unique ID
|
||||
* @param uniqueID uniqueID
|
||||
* @return True if unique ID successfully retrieved
|
||||
*/
|
||||
bool hwUniqueID(unique_id_t* uniqueID);
|
||||
|
||||
#if defined(MY_DEBUG) || defined(MY_SPECIAL_DEBUG)
|
||||
/**
|
||||
* CPU voltage
|
||||
|
||||
@@ -197,6 +197,13 @@ int8_t hwSleep(uint8_t interrupt1, uint8_t mode1, uint8_t interrupt2, uint8_t mo
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
bool hwUniqueID(unique_id_t* uniqueID)
|
||||
{
|
||||
// not implemented yet
|
||||
(void)uniqueID;
|
||||
return false;
|
||||
}
|
||||
#if defined(MY_DEBUG) || defined(MY_SPECIAL_DEBUG)
|
||||
uint16_t hwCPUVoltage()
|
||||
{
|
||||
|
||||
@@ -61,6 +61,17 @@ void hwWriteConfig(const int addr, uint8_t value)
|
||||
hwWriteConfigBlock(&value, reinterpret_cast<void*>(addr), 1);
|
||||
}
|
||||
|
||||
bool hwUniqueID(unique_id_t *uniqueID)
|
||||
{
|
||||
// padding
|
||||
memset((uint8_t*)uniqueID, 0x0A, sizeof(unique_id_t));
|
||||
uint32_t val = ESP.getChipId();
|
||||
(void)memcpy((uint8_t*)uniqueID, &val, 4);
|
||||
val = ESP.getFlashChipId();
|
||||
(void)memcpy((uint8_t*)uniqueID + 4, &val, 4);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
int8_t hwSleep(unsigned long ms)
|
||||
{
|
||||
|
||||
@@ -69,6 +69,13 @@ unsigned long hwMillis()
|
||||
return millis();
|
||||
}
|
||||
|
||||
bool hwUniqueID(unique_id_t *uniqueID)
|
||||
{
|
||||
// not implemented yet
|
||||
(void)uniqueID;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Not supported!
|
||||
int8_t hwSleep(unsigned long ms)
|
||||
{
|
||||
|
||||
@@ -116,6 +116,13 @@ int8_t hwSleep(uint8_t interrupt1, uint8_t mode1, uint8_t interrupt2, uint8_t mo
|
||||
return MY_SLEEP_NOT_POSSIBLE;
|
||||
}
|
||||
|
||||
bool hwUniqueID(unique_id_t *uniqueID)
|
||||
{
|
||||
(void)memcpy((uint8_t*)uniqueID, (uint32_t *)0x0080A00C, 4);
|
||||
(void)memcpy((uint8_t*)uniqueID + 4, (uint32_t *)0x0080A040, 12);
|
||||
return true;
|
||||
}
|
||||
|
||||
#if defined(MY_DEBUG) || defined(MY_SPECIAL_DEBUG)
|
||||
uint16_t hwCPUVoltage()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user