# Busfleet Hub

Registration endpoint for kit-connect devices. Runs on the VPS at `162.243.83.36:8080`.

## Files

- **register.sh** — Called per-device. Assigns a tunnel port from pool 2230-2299, records it in `port-registry.json`, returns JSON.
- **server.py** — Minimal Python HTTP server. Routes `GET /api/register/<DEVICE_ID>` → `register.sh`.
- **port-registry.json** — Persistent device→port mapping.

## Deploy

```bash
scp hub/register.sh hub/server.py root@162.243.83.36:/opt/busfleet-hub/
ssh root@162.243.83.36 systemctl restart busfleet-hub
```

## API

```
GET /api/register/<DEVICE_ID>
```

Response (existing device):
```json
{"device_id": "x5925", "tunnel_port": 2230, "tailscale_auth_key": "tskey-auth-...", "status": "existing"}
```

Response (new device):
```json
{"device_id": "x9999", "tunnel_port": 2231, "tailscale_auth_key": "tskey-auth-...", "status": "new"}
```

## Port Pool

Pool: 2230–2299 (plus grandfathered pre-pool ports 2225–2229).

| Device | Port | Location | Notes |
|--------|------|----------|-------|
| x4078  | 2226 | Bus (field) | Eyeride + Starlink, kit-connect installed (needs port fix) |
| x4324  | 2225 | Bus (field) | kit-connect ✅ stable |
| x4662  | 2229 | Bus (field) | MR2200ac mesh, old kittunnel ✅ stable |
| x5925  | 2230 | Office bench | kit-connect ✅ stable |
| x9002  | 2231 | Office bench | GL-XE3000, kit-connect/kit-mgmt ✅ stable |
