33 lines
1.1 KiB
Python
33 lines
1.1 KiB
Python
# ============================================================+
|
|
# Identity IoT — Provisioning via NFC
|
|
# (c) Copyright : ae Aeonian Engineering Limited - Hong Kong
|
|
# (c) Copyright : WIDE di D. Papa - Naples - Italy
|
|
# ============================================================+
|
|
# Used when has_nfc = True and no config.json found.
|
|
# Waits for writer badge tap, reads AES-encrypted config payload
|
|
# from NTAG424, decrypts with PROG_KEY/PROG_IV.
|
|
# ============================================================+
|
|
|
|
import utime
|
|
from provisioning_server import PROG_KEY, PROG_IV
|
|
from identity_iot_aes import aes_cbc_decrypt
|
|
import ujson
|
|
|
|
|
|
def run_provisioning_nfc():
|
|
"""
|
|
Block until writer badge is tapped.
|
|
Reads encrypted config from NTAG424, returns config dict.
|
|
"""
|
|
print('[provisioning_nfc] waiting for writer badge...')
|
|
|
|
# TODO: init PN532
|
|
# TODO: wait for NTAG424 tap
|
|
# TODO: read encrypted config payload from tag memory
|
|
# TODO: aes_cbc_decrypt(payload, PROG_KEY, PROG_IV)
|
|
# TODO: validate and return config dict
|
|
|
|
while True:
|
|
print('[provisioning_nfc] tap writer badge...')
|
|
utime.sleep(2)
|