OTA-DroneNet Unified API v1

  • ✅ Same API format across internet + local networks
  • ✅ Works for drones, phones, Pi, laptops, etc.
  • ✅ Supports:
    • CID logging
    • OTAwallet sync
    • Device pairing
    • Defender alerts
    • Offline queuing → retry when reconnected

Deployment Models:

ModeDescription
localRuns on local network (e.g., Pi, phone hotspot)
relayDrone → Local Relay → IPFS/OTAwallet queue
onlineConnects directly to OTAwallet cloud node
meshUses LoRa, Bluetooth, or Wi-Fi Direct fallback layers

Example API Structure

POST /cid

Push a CID to OTAwallet (or queue if offline)

json{
"cid": "bafybeidabc123...",
"tag": "drone-footage",
"device_id": "pi-drone-01",
"wallet": "ota1xyz...",
"timestamp": 1723601836
}

Response (online):

json{ "status": "broadcasted", "relay": "ota-wallet", "tx_id": "abc123" }

Response (offline fallback):

json{ "status": "queued", "relay": "offline-buffer" }

POST /pair

Pair device with wallet or relay node

json{
"device_id": "drone-alpha",
"public_key": "-----BEGIN PUBLIC KEY----- ...",
"wallet": "ota1xyz..."
}

POST /defender/alert

Report intrusion or zone violation

json{
"device_id": "pi-drone-02",
"zone": "no-fly-zone-1",
"severity": "critical",
"details": "Entered restricted airspace"
}

Offline Queue Handling

When offline, data is saved to:

pgsqlqueue/
└── pending/
├── cid_001.json
├── alert_001.json

A sync_loop.py periodically tries to POST them when internet or OTAwallet node is reachable.


Implementation :

  • api/local_server.py: Flask-based API for Pi, drone, mobile
  • queue/sync_loop.py: Sync queued data to OTAwallet
  • broadcast/relay.py: Modular for IPFS, OTAwallet, mesh
  • Optional: use SQLite or flat JSON queue