From 0aaca3fb96ced9c5d9cd43e937ae43ee025dc2b5 Mon Sep 17 00:00:00 2001 From: Niko Date: Thu, 11 Jun 2026 11:03:42 +0200 Subject: [PATCH] feat: wifi hotspot provisioning + config integrations block --- config_example.json | 16 ++++++++++++++++ provisioning_server.py | 15 +++++++++++---- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/config_example.json b/config_example.json index fbb52f4..f04890b 100644 --- a/config_example.json +++ b/config_example.json @@ -14,6 +14,22 @@ "node_label": "node-01", "identity_iot_url": "https://api.yourhost.com/API/V1/identity_layer/identity_iot/", "data_destination_url": "https://api.parta.app/API/V1/identity_iot/", + "integrations": { + "openweather": { + "api_key": "abc123" + }, + "mqtt": { + "host": "broker.example.com", + "port": 1883, + "username": "user", + "password": "pass", + "topic": "sensors/node-01" + }, + "webhook": { + "url": "https://hooks.example.com/xyz", + "api_key": "secret" + } + }, "pinout": { "i2c0_sda": 4, "i2c0_scl": 5, diff --git a/provisioning_server.py b/provisioning_server.py index 44fd719..18346e0 100644 --- a/provisioning_server.py +++ b/provisioning_server.py @@ -168,9 +168,16 @@ def run_provisioning(): print('[provisioning] connection from', addr) method, path, body = _parse_http_request(conn) - if method == 'GET' and path == '/': - info = ujson.dumps({'sn': sn, 'ip': ip, 'status': 'awaiting_provision'}) + if method == 'GET' and (path == '/' or path == '/info'): + info = ujson.dumps({ + 'sn': sn, + 'ip': ip, + 'status': 'awaiting_provision', + 'type': 'identity-iot', + 'port': HTTP_PORT, + }) _http_response(conn, '200 OK', info) + conn.close() elif method == 'POST' and path == '/provision': try: @@ -184,7 +191,7 @@ def run_provisioning(): # Basic validation required = ['wifi_ssid', 'wifi_pass', 'comm_key', 'comm_iv', - 'base_url', 'tenant_id', 'node_type', 'node_id'] + 'identity_iot_url', 'tenant_id', 'node_type', 'node_id'] for k in required: if k not in cfg: raise Exception('missing field: ' + k) @@ -209,4 +216,4 @@ def run_provisioning(): udp.close() srv.close() - return received_cfg + return received_cfg \ No newline at end of file