feat: wifi hotspot provisioning + config integrations block
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user