fix: fresh node_uid on re-registration, remove duplicate ensure_registered call
This commit is contained in:
@@ -163,9 +163,11 @@ class IdentityIoT:
|
||||
return f.read().strip()
|
||||
except OSError:
|
||||
pass
|
||||
raw_uid = machine.unique_id()
|
||||
h = uhashlib.sha256(raw_uid)
|
||||
uid_hex = ubinascii.hexlify(h.digest()).decode()
|
||||
# Fresh UID — hardware ID + random entropy so each new registration is unique
|
||||
raw_uid = machine.unique_id()
|
||||
entropy = bytes([urandom.getrandbits(8) for _ in range(16)])
|
||||
h = uhashlib.sha256(raw_uid + entropy)
|
||||
uid_hex = ubinascii.hexlify(h.digest()).decode()
|
||||
with open(self._F_NODEID, 'w') as f:
|
||||
f.write(uid_hex)
|
||||
return uid_hex
|
||||
@@ -294,4 +296,4 @@ def _normalize_b64(s: str) -> str:
|
||||
|
||||
|
||||
class StateError(Exception):
|
||||
pass
|
||||
pass
|
||||
Reference in New Issue
Block a user