Files
wadamesh/web/mesh/BackendSelect.h
T
Kaj SchittecatandClaude Opus 5.5 a986c79cfc web: merge web-companion: the companion backend in both front ends
Backend selection moves into the shared boot: a WadaBackendChoice
(web/mesh/BackendSelect.h) that host_main.cpp fills from --serial / --tcp /
--read-only and web_main.cpp from the page (Module.wadaBackend, with its own
data dir), and board.cpp creates the backend from it. The demo position is
only set for the demo. The companion link reports its state through
g_wada_link_hook (web_main.cpp passes it to Module.wadaLink). The browser
transports' JS joins the Emscripten link as --pre-js. WEB_BUILD.md keeps both
phases' sections. build.sh: "$0" relative to the caller's directory no longer
breaks smoke / serve / webtest.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 13:06:51 +02:00

23 lines
1.1 KiB
C++

// SPDX-License-Identifier: GPL-3.0-or-later
#pragma once
// Which mesh the web board drives. The front ends fill a choice (host_main.cpp from
// --serial / --tcp / --read-only, web_main.cpp from the page's Connect chooser) and
// board.cpp's shared boot creates the backend from it.
#include <string>
class MeshBackend;
struct WadaBackendChoice {
// "demo" | "serial" | "tcp" (native) | "web-serial" | "ble" | "ws" (browser)
std::string kind = "demo";
std::string arg; // the device path, host[:port] or ws:// URL
bool read_only = false; // never change the node's settings, contacts, channels or clock
};
// The backend for a choice; the demo when the choice cannot be served by this build.
MeshBackend* wadaCreateBackend(const WadaBackendChoice& choice);
// The companion link's state, for a front end that shows it (the page's status bar).
// state 0 = connecting / reconnecting, 1 = up; node_name / via / key_hex (the node's
// public key, first 4 bytes as hex) are set when up. Called on the UI thread.
extern void (*g_wada_link_hook)(int state, const char* node_name, const char* via, const char* key_hex);