feat: wifi hotspot provisioning + config integrations block
This commit is contained in:
@@ -14,6 +14,22 @@
|
|||||||
"node_label": "node-01",
|
"node_label": "node-01",
|
||||||
"identity_iot_url": "https://api.yourhost.com/API/V1/identity_layer/identity_iot/",
|
"identity_iot_url": "https://api.yourhost.com/API/V1/identity_layer/identity_iot/",
|
||||||
"data_destination_url": "https://api.parta.app/API/V1/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": {
|
"pinout": {
|
||||||
"i2c0_sda": 4,
|
"i2c0_sda": 4,
|
||||||
"i2c0_scl": 5,
|
"i2c0_scl": 5,
|
||||||
|
|||||||
@@ -168,9 +168,16 @@ def run_provisioning():
|
|||||||
print('[provisioning] connection from', addr)
|
print('[provisioning] connection from', addr)
|
||||||
method, path, body = _parse_http_request(conn)
|
method, path, body = _parse_http_request(conn)
|
||||||
|
|
||||||
if method == 'GET' and path == '/':
|
if method == 'GET' and (path == '/' or path == '/info'):
|
||||||
info = ujson.dumps({'sn': sn, 'ip': ip, 'status': 'awaiting_provision'})
|
info = ujson.dumps({
|
||||||
|
'sn': sn,
|
||||||
|
'ip': ip,
|
||||||
|
'status': 'awaiting_provision',
|
||||||
|
'type': 'identity-iot',
|
||||||
|
'port': HTTP_PORT,
|
||||||
|
})
|
||||||
_http_response(conn, '200 OK', info)
|
_http_response(conn, '200 OK', info)
|
||||||
|
conn.close()
|
||||||
|
|
||||||
elif method == 'POST' and path == '/provision':
|
elif method == 'POST' and path == '/provision':
|
||||||
try:
|
try:
|
||||||
@@ -184,7 +191,7 @@ def run_provisioning():
|
|||||||
|
|
||||||
# Basic validation
|
# Basic validation
|
||||||
required = ['wifi_ssid', 'wifi_pass', 'comm_key', 'comm_iv',
|
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:
|
for k in required:
|
||||||
if k not in cfg:
|
if k not in cfg:
|
||||||
raise Exception('missing field: ' + k)
|
raise Exception('missing field: ' + k)
|
||||||
|
|||||||
Reference in New Issue
Block a user