feat: v0.3.5 — full boot working, fresh JWT every boot, it_node_checkin operational
This commit is contained in:
@@ -186,7 +186,7 @@ def do_checkin(cfg):
|
||||
for attempt in range(3):
|
||||
try:
|
||||
_show(['CHECKIN', 'Registering IoT...', 'attempt ' + str(attempt+1) + '/3', '', ''])
|
||||
reg = identity.ensure_registered()
|
||||
identity.ensure_registered()
|
||||
break
|
||||
except Exception as e:
|
||||
print('[checkin] IoT register attempt', attempt + 1, ':', e)
|
||||
@@ -195,6 +195,8 @@ def do_checkin(cfg):
|
||||
raise
|
||||
utime.sleep(3)
|
||||
|
||||
# Seconda chiamata idempotente
|
||||
reg = identity.ensure_registered()
|
||||
uid_short = reg.get('node_uid', '')[:12] + '...'
|
||||
_show(['CHECKIN', 'IoT Node ' + reg.get('result', ''), uid_short, '', ''])
|
||||
utime.sleep(1)
|
||||
@@ -217,9 +219,11 @@ def do_checkin(cfg):
|
||||
from identity_iot_aes import aes_cbc_encrypt, aes_cbc_decrypt
|
||||
|
||||
payload = ujson.dumps({
|
||||
'request': 'it_node_checkin',
|
||||
'node_id': str(cfg.get('node_id', '')),
|
||||
'request': 'it_node_checkin',
|
||||
'node_id': str(cfg.get('node_id', '')),
|
||||
'tenant_id': str(cfg.get('tenant_id', '')),
|
||||
})
|
||||
print('[checkin] node_id:', cfg.get('node_id'), 'tenant_id:', cfg.get('tenant_id'))
|
||||
cipher = aes_cbc_encrypt(payload, key, iv)
|
||||
body = ujson.dumps({'data': cipher})
|
||||
|
||||
@@ -229,7 +233,7 @@ def do_checkin(cfg):
|
||||
cfg['identity_node_url'],
|
||||
headers={
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': 'Bearer ' + token,
|
||||
'Authorization': 'Bearer ' + token.strip(),
|
||||
},
|
||||
data=body,
|
||||
timeout=20,
|
||||
|
||||
Reference in New Issue
Block a user