DeterministicESPAsyncWebServer v6.27.1
Zero-allocation, bounded-execution async HTTP server for ESP32
Loading...
Searching...
No Matches
ntrip_caster_listener.h
Go to the documentation of this file.
1// Copyright (C) 2026 Douglas Quigg (dstroy0) <dquigg123@gmail.com>
2// SPDX-License-Identifier: AGPL-3.0-or-later
3
4/**
5 * @file ntrip_caster_listener.h
6 * @brief Server-side NTRIP caster listener (DETWS_ENABLE_NTRIP_CASTER): the ConnProto::PROTO_NTRIP_CASTER
7 * handler that answers rover requests and streams RTCM to subscribers.
8 *
9 * The pure codec (ntrip_caster.h) parses requests and builds responses / the source table; this file owns
10 * the connection state: it reads each rover's request off its socket, replies (stream-accept, source
11 * table, error, or 401), and then fans RTCM correction bytes out to every rover subscribed to a mountpoint.
12 * Layered exactly like services/relay - the app opens the listener, adds one or more mountpoints, then
13 * pushes RTCM as its survey/receiver produces it:
14 *
15 * @code
16 * int32_t li = server.listen(2101, ConnProto::PROTO_NTRIP_CASTER); // 2101 = the IANA NTRIP port
17 * NtripMount m = {};
18 * m.mountpoint = "BASE1";
19 * m.identifier = "Lab roof";
20 * m.format_details = "1005(1)";
21 * m.lat_deg = 37.77; m.lon_deg = -122.42;
22 * det_ntrip_caster_add_mount((uint8_t)li, &m, nullptr); // null = open (no auth)
23 * ...
24 * uint8_t frame[64];
25 * size_t n = rtcm3_build_1005(frame, sizeof(frame), 2003, x01mm, y01mm, z01mm);
26 * det_ntrip_caster_broadcast("BASE1", frame, n); // -> every subscribed rover
27 * @endcode
28 *
29 * The @c NtripMount's string fields must remain valid for the caster's lifetime (they are referenced, not
30 * copied - configure them from static storage). Only the mountpoint name and optional credentials are
31 * copied internally.
32 *
33 * @author Douglas Quigg (dstroy0)
34 * @date 2026
35 */
36
37#ifndef DETERMINISTICESPASYNCWEBSERVER_NTRIP_CASTER_LISTENER_H
38#define DETERMINISTICESPASYNCWEBSERVER_NTRIP_CASTER_LISTENER_H
39
40#include "ServerConfig.h"
41
42#if DETWS_ENABLE_NTRIP_CASTER
43
45#include <stddef.h>
46#include <stdint.h>
47
48/**
49 * @brief Register a mountpoint the caster serves and install the handler (first call).
50 *
51 * @param listener_id the id from `server.listen(port, ConnProto::PROTO_NTRIP_CASTER)`.
52 * @param mount the source-table description; string fields are referenced (keep them alive).
53 * @param auth_b64 optional base64 of "user:pass" a rover must present via HTTP Basic, or null for open
54 * access. Referenced, not copied.
55 * @return true; false if @p mount / its mountpoint is null or too long, or the mount table is full.
56 */
57bool det_ntrip_caster_add_mount(uint8_t listener_id, const NtripMount *mount, const char *auth_b64);
58
59/**
60 * @brief Push RTCM bytes to every rover currently streaming @p mountpoint.
61 * @return the number of rovers the bytes were queued to.
62 */
63int det_ntrip_caster_broadcast(const char *mountpoint, const uint8_t *data, size_t len);
64
65/** @brief Number of rovers currently streaming @p mountpoint (observability). */
66int det_ntrip_caster_subscriber_count(const char *mountpoint);
67
68/** @brief Clear all mounts and drop all rover state (start from empty). */
69void det_ntrip_caster_reset(void);
70
71#endif // DETWS_ENABLE_NTRIP_CASTER
72
73#endif // DETERMINISTICESPASYNCWEBSERVER_NTRIP_CASTER_LISTENER_H
User-facing configuration for DeterministicESPAsyncWebServer.
NTRIP caster protocol codec (DETWS_ENABLE_NTRIP_CASTER) - the pure, host-tested core.