# Pioneer Bus Router — Device Identity & Provisioning (Synology SRM)

**Last updated:** 2026-07-21
**Target hardware:** Synology RT2600ac, SRM 1.3.1+

---

## 1. Fleet-wide constants

| Parameter | Value |
|-----------|-------|
| WiFi SSID (2.4 + 5 GHz) | `<DEVICE_ID>` — SSID = device ID (e.g. `B0042`) |
| WiFi password | `Pioneer123` |
| Admin SSH user | `root` (enabled via SRM Control Panel → Terminal & SNMP) |
| Admin password | `Pioneer321!` |
| Timezone | `UTC` |
| Cellular modem | Eyeride Eyenet (OpenWrt) at `192.168.10.1:8080` |
| WAN balancer | aiwanbal (SPK package), environment=**mobile** |
| VPN transport | **Tailscale** (not WireGuard) |
| Fleet hub Tailscale IP | `100.76.128.1` (the hub's Tailscale address) |
| Telemetry endpoint | `http://<HUB_TAILSCALE_IP>:8080/api/telemetry` |
| Telemetry interval | 60 s (via cron) |
| Telemetry buffer dir | `/tmp/busrouter/telemetry-buf/` (60-file cap) |
| SSH jump key | `busfleet-hub-jump` (ed25519) |

**Platform identifier:** `"platform":"synology"` in telemetry JSON payloads.

---

## 2. Per-device parameters

| DEVICE_ID | Tailscale IP | Eyeride IP | Notes |
|-----------|-------------|------------|-------|
| `bus02`   | *(auto)*    | `192.168.10.1` | bench unit |
| `B0002`   | *(auto)*    | `192.168.10.1` | first production Synology unit |

Tailscale IPs are auto-assigned by the coordination server (100.x.y.z range).

---

## 3. Provisioning procedure

### Prerequisites
- SRM 1.3.1+ with SSH enabled (Control Panel → Terminal & SNMP → Enable SSH)
- SD card inserted
- LAN access at `192.168.1.1`
- `aiwanbal-latest.spk` at `/tmp/` on the router
- Tailscale SPK installed
- Tailscale auth key generated
- Eyeride Eyenet reachable at `192.168.10.1`

### Steps

```sh
# 1. Build + copy files
cd /home/node/workspace/aiwanbal && bash build.sh
scp -O scripts/provision-synology.sh \
    package/kit-busrouter/files/usr/lib/busrouter/telemetry-synology.sh \
    kitadmin@192.168.1.1:/tmp/
scp -O aiwanbal-*.spk kitadmin@192.168.1.1:/tmp/aiwanbal-latest.spk

# 2. SSH in and run
ssh kitadmin@192.168.1.1
sudo -i
chmod +x /tmp/provision-synology.sh /tmp/telemetry-synology.sh
/tmp/provision-synology.sh B0042 "tskey-auth-xxxx"
# Reboots after 5 s.
```

### Verification

```sh
ssh root@<router-ip>
cat /etc/busrouter/device-id         # B0042
synopkg status aiwanbal              # "started"
tailscale status                     # "active"
grep telemetry /etc/crontab          # cron job present
/usr/lib/busrouter/telemetry-synology.sh  # dry-run
```

---

## 4. Architecture differences: GL vs Synology

| Component | GL-XE3000 (OpenWrt) | Synology RT2600ac (SRM) |
|-----------|--------------------|--------------------------|
| WAN balancer | kit-busrouter + mwan3 | aiwanbal + SRM SmartWAN |
| State dir | `/tmp/busrouter/` | `/tmp/aiwanbal/` |
| VPN tunnel | WireGuard (`wgclient1`) | Tailscale (`tailscale0`) |
| Hub IP | `10.88.0.1` (WG) | `100.76.128.1` (Tailscale) |
| Telemetry trigger | daemon loop (30s) | cron (60s) |
| GPS source | Quectel AT commands | Eyeride ubus JSON-RPC |
| Modem signal | Quectel ubus | aiwanbal-modem.sh drivers |
| Starlink | gRPC to dish | aiwanbal-starlink.sh |
| Package mgmt | opkg | synopkg |
| Init system | procd | start-stop-status |
| Identity file | `/etc/busrouter/device-id` | `/etc/busrouter/device-id` *(same)* |

---

## 5. Telemetry JSON schema

```json
{
  "device_id": "B0042",
  "timestamp": 1737500000,
  "uptime": 86400,
  "version": "1.0",
  "platform": "synology",
  "sel_primary": "wan1",
  "gps": {"lat": 40.7128, "lon": -74.0060, "fix": 2},
  "wan": {
    "wan1": {"score": 85, "latency_ms": 15, "dl_mbps": 50.0, "ul_mbps": 10.0,
             "jitter_ms": 2, "loss_pct": 0, "rsrp_dbm": -80, "rsrq_db": -12,
             "sinr_db": 8, "technology": "5G-NR", "carrier": "Eyeride"},
    "wan2": {"score": 70, "latency_ms": 25, "dl_mbps": 30.0, "ul_mbps": 5.0,
             "jitter_ms": 5, "loss_pct": 1, "rsrp_dbm": -90, "rsrq_db": -15,
             "sinr_db": 3, "technology": "LTE", "carrier": "Peplink"}
  },
  "starlink": {"quality": 0, "latency_ms": null, "obstructed": 0, "outage": 0}
}
```

### Field mapping: aiwanbal state → telemetry JSON

| Telemetry field | aiwanbal state file | Notes |
|----------------|--------------------|-------|
| `wan.*.score` | `wanN_score_avg` | 3-sample rolling average |
| `wan.*.dl_mbps` | `wanN_throughput` | B/s → Mbps |
| `wan.*.ul_mbps` | `wanN_upload` | B/s → Mbps |
| `wan.*.latency_ms` | `wanN_latency` | ping probe result |
| `wan.*.jitter_ms` | `wanN_jitter` | ping jitter |
| `wan.*.loss_pct` | `wanN_packet_loss` | % |
| `wan.*.rsrp_dbm` | `wanN_rsrp` | cellular signal |
| `wan.*.technology` | `wanN_technology` | "5G-NR", "LTE", etc. |
| `wan.*.carrier` | `wanN_modem_type` | mapped to name |
| `sel_primary` | `wan0_mode` + states | "wan1" or "wan2" |
| `gps.*` | Eyeride ubus | null if unavailable |
| `starlink.*` | `wan0_starlink_*` | null if no dish |

### Hub-side: GL vs Synology payloads

| Field | GL value | Synology value |
|-------|---------|---------------|
| `platform` | absent or `"openwrt"` | `"synology"` |
| `wan` keys | `modem_0001`, `wan` | `wan1`, `wan2` |
| `sim_slot` | present (1 or 2) | absent |

The hub should handle both schemas.

---

## 6. Checklist — new Synology device before field deployment

- [ ] Device ID assigned and recorded in fleet registry
- [ ] SD card inserted and mounted
- [ ] SRM updated to latest 1.3.1+
- [ ] SSH enabled
- [ ] Tailscale SPK installed and authenticated
- [ ] aiwanbal SPK built and installed
- [ ] aiwanbal configured: ENVIRONMENT=mobile, SPEEDTEST_AUTO=0
- [ ] Eyeride Eyenet reachable at `192.168.10.1:8080`
- [ ] `provision-synology.sh` run end-to-end; device rebooted cleanly
- [ ] WiFi visible as `<DEVICE_ID>`, pw `Pioneer123`
- [ ] SSH to `root@<router-ip>` succeeds
- [ ] `synopkg status aiwanbal` shows "started"
- [ ] `tailscale status` shows "active"
- [ ] `/etc/busrouter/device-id` correct
- [ ] Telemetry cron job present
- [ ] Telemetry dry-run produces valid JSON
- [ ] Hub receiving telemetry payloads with `"platform":"synology"`
