|
|
@@ -158,19 +158,42 @@ Host: 192.168.5.244
|
|
|
```json
|
|
|
{
|
|
|
"mode": "cloud",
|
|
|
- "api_base": "http://server:8000/api/v1",
|
|
|
+ "api_base": "http://192.168.5.4:8000/api/v1",
|
|
|
+ "cfg_polling_timeout": 30,
|
|
|
"ble": {
|
|
|
"enabled": true,
|
|
|
- "batch_interval_ms": 2500
|
|
|
+ "batch_interval_ms": 2500,
|
|
|
+ "upload_endpoint": ""
|
|
|
},
|
|
|
"wifi": {
|
|
|
"monitor_enabled": true,
|
|
|
"client_enabled": false,
|
|
|
- "ssid": "",
|
|
|
- "batch_interval_ms": 10000
|
|
|
+ "ssid": "MyNetwork",
|
|
|
+ "psk": "",
|
|
|
+ "batch_interval_ms": 10000,
|
|
|
+ "upload_endpoint": ""
|
|
|
+ },
|
|
|
+ "ssh_tunnel": {
|
|
|
+ "enabled": false,
|
|
|
+ "server": "",
|
|
|
+ "port": 22,
|
|
|
+ "user": "",
|
|
|
+ "key_path": "",
|
|
|
+ "remote_port": 0,
|
|
|
+ "keepalive_interval": 30,
|
|
|
+ "reconnect_delay": 5
|
|
|
+ },
|
|
|
+ "dashboard_tunnel": {
|
|
|
+ "enabled": false,
|
|
|
+ "server": "",
|
|
|
+ "port": 22,
|
|
|
+ "user": "",
|
|
|
+ "remote_port": 0,
|
|
|
+ "keepalive_interval": 30,
|
|
|
+ "reconnect_delay": 5
|
|
|
},
|
|
|
"network": {
|
|
|
- "ntp_servers": ["pool.ntp.org"],
|
|
|
+ "ntp_servers": ["pool.ntp.org", "time.google.com"],
|
|
|
"eth0": {
|
|
|
"static": false,
|
|
|
"address": "",
|
|
|
@@ -178,20 +201,21 @@ Host: 192.168.5.244
|
|
|
"dns": ""
|
|
|
}
|
|
|
},
|
|
|
+ "ap_fallback": {
|
|
|
+ "password": "mybeacon"
|
|
|
+ },
|
|
|
"dashboard": {
|
|
|
"enabled": true
|
|
|
},
|
|
|
- "ssh_tunnel": {
|
|
|
- "enabled": false,
|
|
|
- "server": "",
|
|
|
- "port": 22,
|
|
|
- "user": "tunnel",
|
|
|
- "remote_port": 0
|
|
|
- }
|
|
|
+ "zmq_addr_ble": "tcp://127.0.0.1:5555",
|
|
|
+ "zmq_addr_wifi": "tcp://127.0.0.1:5556",
|
|
|
+ "spool_dir": "/var/spool/mybeacon",
|
|
|
+ "wifi_iface": "wlan0",
|
|
|
+ "debug": false
|
|
|
}
|
|
|
```
|
|
|
|
|
|
-**Note:** Sensitive fields (passwords, keys) are omitted from response.
|
|
|
+**Note:** Sensitive fields (`wifi.psk`, `ssh_tunnel.key_path`) are returned as empty strings. Device ID and token are omitted.
|
|
|
|
|
|
---
|
|
|
|
|
|
@@ -350,11 +374,16 @@ Content-Type: application/json
|
|
|
{
|
|
|
"password": "82680499",
|
|
|
"settings": {
|
|
|
- "mode": "cloud",
|
|
|
+ "mode": "lan",
|
|
|
"wifi_client_enabled": true,
|
|
|
"wifi_ssid": "MyNetwork",
|
|
|
"wifi_psk": "password123",
|
|
|
- "wifi_monitor_enabled": false,
|
|
|
+ "wifi_monitor_enabled": true,
|
|
|
+ "wifi_monitor_endpoint": "http://192.168.1.100:8080/wifi",
|
|
|
+ "wifi_monitor_batch_interval_ms": 10000,
|
|
|
+ "ble_enabled": true,
|
|
|
+ "ble_batch_interval_ms": 2500,
|
|
|
+ "ble_endpoint": "http://192.168.1.100:8080/ble",
|
|
|
"eth0_mode": "dhcp",
|
|
|
"ntp_servers": "pool.ntp.org,time.google.com"
|
|
|
}
|
|
|
@@ -362,19 +391,33 @@ Content-Type: application/json
|
|
|
```
|
|
|
|
|
|
**Settings Fields:**
|
|
|
-- `mode`: `"cloud"` or `"lan"`
|
|
|
-- `wifi_client_enabled`: Enable WiFi client
|
|
|
-- `wifi_ssid`: WiFi network name
|
|
|
-- `wifi_psk`: WiFi password
|
|
|
-- `wifi_monitor_enabled`: Enable WiFi scanner (LAN mode only)
|
|
|
-- `eth0_mode`: `"dhcp"` or `"static"`
|
|
|
-- `eth0_ip`: Static IP (when `eth0_mode="static"`)
|
|
|
-- `eth0_gateway`: Gateway (static mode)
|
|
|
-- `eth0_dns`: DNS server (static mode)
|
|
|
-- `ntp_servers`: Comma-separated NTP servers
|
|
|
-- `ble_enabled`: Enable BLE scanner (LAN mode only)
|
|
|
-- `ble_batch_interval_ms`: BLE batch interval
|
|
|
-- `wifi_monitor_batch_interval_ms`: WiFi batch interval
|
|
|
+
|
|
|
+**Mode:**
|
|
|
+- `mode` (string): `"cloud"` or `"lan"`. In Cloud mode, server config has priority. In LAN mode, local settings have priority.
|
|
|
+
|
|
|
+**BLE Scanner (LAN mode only):**
|
|
|
+- `ble_enabled` (bool): Enable BLE scanner
|
|
|
+- `ble_batch_interval_ms` (int): BLE batch upload interval in milliseconds
|
|
|
+- `ble_endpoint` (string, optional): Custom BLE upload endpoint URL (full URL, e.g., "http://192.168.1.100:8080/ble")
|
|
|
+
|
|
|
+**WiFi Scanner (LAN mode only):**
|
|
|
+- `wifi_monitor_enabled` (bool): Enable WiFi monitor/scanner mode
|
|
|
+- `wifi_monitor_batch_interval_ms` (int): WiFi batch upload interval in milliseconds
|
|
|
+- `wifi_monitor_endpoint` (string, optional): Custom WiFi upload endpoint URL (full URL, e.g., "http://192.168.1.100:8080/wifi")
|
|
|
+
|
|
|
+**WiFi Client (both modes):**
|
|
|
+- `wifi_client_enabled` (bool): Enable WiFi client mode (connect to AP)
|
|
|
+- `wifi_ssid` (string): WiFi network SSID
|
|
|
+- `wifi_psk` (string): WiFi password (WPA/WPA2 pre-shared key)
|
|
|
+
|
|
|
+**Ethernet (always local):**
|
|
|
+- `eth0_mode` (string): `"dhcp"` or `"static"`
|
|
|
+- `eth0_ip` (string): Static IP address with CIDR (e.g., "192.168.1.100/24") when `eth0_mode="static"`
|
|
|
+- `eth0_gateway` (string): Gateway IP when `eth0_mode="static"`
|
|
|
+- `eth0_dns` (string): DNS server IP when `eth0_mode="static"`
|
|
|
+
|
|
|
+**NTP:**
|
|
|
+- `ntp_servers` (string): Comma-separated list of NTP server addresses (e.g., "pool.ntp.org,time.google.com")
|
|
|
|
|
|
**Response:** `200 OK`
|
|
|
```json
|
|
|
@@ -483,7 +526,7 @@ Content-Type: application/json
|
|
|
|
|
|
### GET /api/v1/config
|
|
|
|
|
|
-Fetches device configuration from server (Cloud mode only, polled every 30 seconds).
|
|
|
+Fetches device configuration from server. Device polls this endpoint at interval specified by `cfg_polling_timeout` (default: 30 seconds).
|
|
|
|
|
|
**Request:**
|
|
|
```http
|
|
|
@@ -496,17 +539,20 @@ Authorization: Bearer gRMRUKnqO9KXikBzoKhs0aE3uDYUvTxHYuU4/uatyrc=
|
|
|
```json
|
|
|
{
|
|
|
"force_cloud": false,
|
|
|
+ "cfg_polling_timeout": 30,
|
|
|
"ble": {
|
|
|
"enabled": true,
|
|
|
"batch_interval_ms": 2500,
|
|
|
- "uuid_filter_hex": ""
|
|
|
+ "uuid_filter_hex": "f7826da64fa24e988024bc5b71e0893e",
|
|
|
+ "upload_endpoint": "http://custom.example.com:8080/ble"
|
|
|
},
|
|
|
"wifi": {
|
|
|
- "client_enabled": false,
|
|
|
- "ssid": "",
|
|
|
- "psk": "",
|
|
|
"monitor_enabled": true,
|
|
|
- "batch_interval_ms": 10000
|
|
|
+ "client_enabled": true,
|
|
|
+ "ssid": "MyNetwork",
|
|
|
+ "psk": "mypassword123",
|
|
|
+ "batch_interval_ms": 10000,
|
|
|
+ "upload_endpoint": "http://custom.example.com:8080/wifi"
|
|
|
},
|
|
|
"ssh_tunnel": {
|
|
|
"enabled": true,
|
|
|
@@ -542,6 +588,58 @@ Authorization: Bearer gRMRUKnqO9KXikBzoKhs0aE3uDYUvTxHYuU4/uatyrc=
|
|
|
- **Always from server:** SSH tunnel, Dashboard tunnel, Dashboard enable/disable
|
|
|
- **Always local:** eth0 network settings
|
|
|
|
|
|
+**Configuration Fields:**
|
|
|
+
|
|
|
+**Top-Level:**
|
|
|
+- `force_cloud` (bool): Override local mode setting to force Cloud mode. Used for remote support/management. When true, device switches from LAN to Cloud mode even if locally configured otherwise.
|
|
|
+- `cfg_polling_timeout` (int): Configuration polling interval in seconds (default: 30). Device fetches configuration from server at this interval. Minimum: 5 seconds, recommended: 30-300 seconds.
|
|
|
+- `debug` (bool): Enable debug logging
|
|
|
+
|
|
|
+**BLE Settings (`ble`):**
|
|
|
+- `enabled` (bool): Enable/disable BLE scanner
|
|
|
+- `batch_interval_ms` (int): Batch upload interval in milliseconds (default: 2500)
|
|
|
+- `uuid_filter_hex` (string, optional): Filter beacons by specific UUID. Only beacons matching this UUID will be reported. Format: 32 hex characters without dashes (e.g., "f7826da64fa24e988024bc5b71e0893e")
|
|
|
+- `upload_endpoint` (string, optional): Custom upload endpoint URL. If set, BLE events will be sent to this URL instead of `{api_base}/ble`. Must be full URL (e.g., "http://custom.example.com:8080/ble")
|
|
|
+
|
|
|
+**WiFi Settings (`wifi`):**
|
|
|
+- `monitor_enabled` (bool): Enable WiFi scanner (AP detection/monitor mode)
|
|
|
+- `client_enabled` (bool): Enable WiFi client mode (connect to AP)
|
|
|
+- `ssid` (string): WiFi network SSID to connect to (when client_enabled=true)
|
|
|
+- `psk` (string): WiFi password (WPA/WPA2 pre-shared key)
|
|
|
+- `batch_interval_ms` (int): Batch upload interval in milliseconds (default: 10000)
|
|
|
+- `upload_endpoint` (string, optional): Custom upload endpoint URL. If set, WiFi events will be sent to this URL instead of `{api_base}/wifi`. Must be full URL (e.g., "http://custom.example.com:8080/wifi")
|
|
|
+
|
|
|
+**SSH Tunnel (`ssh_tunnel`):**
|
|
|
+- `enabled` (bool): Enable SSH reverse tunnel for remote terminal access
|
|
|
+- `server` (string): SSH server hostname/IP
|
|
|
+- `port` (int): SSH server port (default: 22)
|
|
|
+- `user` (string): SSH username
|
|
|
+- `remote_port` (int): Remote port assigned for this device's tunnel
|
|
|
+- `keepalive_interval` (int): SSH keepalive interval in seconds (default: 30)
|
|
|
+
|
|
|
+**Dashboard Tunnel (`dashboard_tunnel`):**
|
|
|
+- `enabled` (bool): Enable SSH reverse tunnel for remote dashboard access
|
|
|
+- `server` (string): SSH server hostname/IP
|
|
|
+- `port` (int): SSH server port (default: 22)
|
|
|
+- `user` (string): SSH username
|
|
|
+- `remote_port` (int): Remote port assigned for dashboard tunnel
|
|
|
+- `keepalive_interval` (int): SSH keepalive interval in seconds (default: 30)
|
|
|
+
|
|
|
+**Dashboard (`dashboard`):**
|
|
|
+- `enabled` (bool): Enable/disable HTTP dashboard on port 80
|
|
|
+
|
|
|
+**Network (`net`):**
|
|
|
+- `ntp.servers` ([]string): NTP server addresses (e.g., ["pool.ntp.org", "time.google.com"])
|
|
|
+
|
|
|
+**Custom Upload Endpoints:**
|
|
|
+When `upload_endpoint` is set for BLE or WiFi, the device will send event batches to the specified URL instead of the default API base URL. This allows:
|
|
|
+- Directing data to different collection servers per device
|
|
|
+- Using separate data pipelines for BLE and WiFi
|
|
|
+- Custom data processing without modifying the main API
|
|
|
+- Multi-tenant setups where each client has their own endpoint
|
|
|
+
|
|
|
+The custom endpoint receives the same gzip-compressed JSON payload format as described in `/api/v1/ble` and `/api/v1/wifi` endpoints below.
|
|
|
+
|
|
|
**Error Response:** `401 Unauthorized`
|
|
|
```
|
|
|
Invalid or missing token
|