$ show CamM2325/microlink
MicroLink v2 is a production-ready Tailscale VPN client for ESP32-S3 devices that establishes secure WireGuard tunnels through Tailscale's control plane. It implements the full Tailscale protocol stack including Noise protocol for control plane encryption, HTTP/2 framing, DISCO peer discovery, STUN for NAT traversal, DERP relay fallback, and WireGuard encryption via wireguard-lwip integration. The architecture uses a multi-task FreeRTOS design with separate tasks for coordination, WireGuard management, DERP transmission, network I/O, and application logic, communicating via message queues and event groups. Key features include WiFi/cellular network failover with health monitoring, zero-copy WireGuard receive option for high-throughput scenarios, NVS-based peer caching with LRU eviction, and an HTTP configuration server for runtime management. The code demonstrates strong protocol fidelity through direct reference to Tailscale's Go source files while adapting to embedded constraints.
The LLM identified 3 files worth highlighting for reuse:
Implements a WiFi/cellular network failover state machine with health monitoring and automatic failback. Uses event groups and timers to manage network switching, providing seamless connectivity for IoT devices in unstable network environments.
Provides a socket abstraction layer that routes data through AT commands when cellular connectivity is active. Enables standard lwIP socket APIs to work over cellular modems in data mode, isolating the cellular modem specifics from the networking stack.
Implements a peer cache stored in NVS with LRU eviction mechanism to handle large Tailscale tailnets. Stores peer information as blobs in NVS, allowing quick recovery of peer state after reboot without repeated DISCO probing.