How tristanedu/litime-esp32-gateway works
LiTime ESP32 Gateway is a read-only battery-monitoring gateway. The main workflow discovers a LiTime battery over BLE, obtains live telemetry, exposes it through local APIs and the browser dashboard, and buffers bounded history and remote-sync data in LittleFS. Setup users can scan for and save Wi-Fi networks while retaining the setup access point. Optional branches push queued batches to a configured HTTPS endpoint or relay live status through a Cloudflare-hosted dashboard. The README documents these capabilities; the available firmware excerpts do not include the main API and BLE orchestration source, so those links use the existing firmware source directory and are limited to documented behavior.
Main entry points: src Gateway runtime · StorageManager.cpp Telemetry buffer · app.js Remote dashboard · NimBLEClient.cpp NimBLE central
Components 14
Gateway firmware
- Gateway runtime
firmware/src - Wi-Fi management
firmware/src/NetworkManager.cpp - Telemetry buffer
firmware/src/StorageManager.cpp - LittleFS
BLE transport
- NimBLE central
firmware/libraries/NimBLE-Arduino/src/NimBLEClient.cpp - NimBLE host
firmware/libraries/NimBLE-Arduino/src/nimble/nimble/host/src
Local dashboard
- Local web UI
firmware/data/app.js
Remote access
- Remote dashboard
cloudflare/remote-dashboard/public/app.js - Runtime estimator
cloudflare/remote-dashboard/public/runtime-estimate.mjs - WebSocket relay
cloudflare/remote-dashboard/src/index.js
Other components
- Gateway owner
- LiTime battery
- Local browser
- User HTTPS endpoint
Connections 18
- Gateway owner → Local browser: opens dashboard
- LiTime battery → NimBLE central: BLE telemetry
- Gateway runtime → NimBLE central: scans and connects
- NimBLE central → NimBLE host: uses host stack
- Gateway runtime → Telemetry buffer: records telemetry
- Telemetry buffer → LittleFS: reads and writes
- Gateway runtime → Wi-Fi management: manages Wi-Fi
- Local browser → Local web UI: loads UI
- Local web UI → Gateway runtime: requests local APIs
- Wi-Fi management → Gateway runtime: provides network status
- Gateway runtime → Telemetry buffer: serves history and events
- Gateway runtime → User HTTPS endpoint: posts queued batches
- Telemetry buffer → Gateway runtime: provides remote batches
- Local browser → Remote dashboard: opens dashboard
- Remote dashboard → WebSocket relay: requests status
- WebSocket relay → Gateway runtime: relays authenticated status
- Gateway runtime → WebSocket relay: sends battery snapshot
- Remote dashboard → Runtime estimator: estimates runtime