The Husarnet embedded library is currently available only for ESP32 Wi-Fi microcontrollers. It allows a peer-to-peer connection of your ESP32 devices with other hosts running the Husarnet Client app.
Husarnet Library API
Husarnet on ESP32 (similar to no-embedded hosts) runs in the background and creates a virtual network interface on the Lwip layer. This is why there are only a few C++ methods:
// Sets up Husarnet to use self-hosted base server
void selfHostedSetup(const char *hostname);
// Starts the Husarnet
// Provides join code. Use before Husarnet.start().
void join(const char *joinCode, const char *hostname = "");
// Get list of peers' hostnames and addresses
std::vector<std::pair<IPv6Address, String>> listPeers();
// Get hostname you're currently known at
extern _Husarnet Husarnet;
For writing a UDP/TCP client or server code, use regular libraries for ESP32.
The current version of Husarnet for ESP32 works with a forked version of Arduino Core for ESP32. There are some modifications related to IPv6 support.
A project template
The Husarnet API for ESP32 is very short and self-describing, however to work in Husarnet you need to use a forked version of Arduino Core.
To make the environment configuration as straightforward as possible we recommend using Husarnet with PlatformIO.
The fastest way to start is making a new project based on this GitHub template.