26// Enable OTA support. Define PAINLESSMESH_DISABLE_OTA to compile the OTA
27// plugin out entirely (SECURITY.md, "OTA: integrity checked, not
28// authenticated").
29//
30// It must be a *build flag* -- `-DPAINLESSMESH_DISABLE_OTA`, or platformio.ini
31// `build_flags` -- so that every translation unit sees it. A `#define` above
32// the sketch's `#include <painlessMesh.h>` is not a narrower version of the
33// same thing, it is a bug: src/wifi.cpp and src/painlessMeshSTA.cpp compile
34// separately without it and would reach painlessmesh::Mesh with the OTA
35// members present, while the sketch sees the same class without them. That is
36// an ODR violation, and the standard requires no diagnostic for it.
37//
38// `#undef PAINLESSMESH_ENABLE_OTA` does not work either: it runs before
39// painlessMesh.h includes this header, which then defines the macro straight
40// back.
41#ifdef PAINLESSMESH_DISABLE_OTA
42// Opting out is not the same as declining to define. If the build already
43// supplies PAINLESSMESH_ENABLE_OTA -- redundantly, since it is the default --
44// then merely skipping the definition below leaves that one standing and every
45// #ifdef downstream still compiles OTA in, on a build that looks like it opted
46// out. That is a security control failing open and saying nothing, which is
47// the failure mode this opt-out exists to remove. Refuse the contradiction
48// rather than guessing which flag was meant.
49#ifdef PAINLESSMESH_ENABLE_OTA
50#error \
51 "PAINLESSMESH_DISABLE_OTA and PAINLESSMESH_ENABLE_OTA are both defined. Remove -DPAINLESSMESH_ENABLE_OTA from your build flags: OTA is on by default, so the disable flag alone is what you want."
57// NOTE: there is deliberately no PAINLESSMESH_OTA_REQUIRE_SIGNATURE flag.
58// OTA acceptance (painlessmesh/ota.hpp, OTA_OP_CODES::DATA) authenticates
59// nothing -- it matches the sender-supplied md5/role/hardware tuple -- so a
60// flag that did not gate that path would read as a security control while
61// enforcing nothing. Defining it fails the build rather than passing
62// silently, so no fleet can ship believing its OTA images are verified.
63// Compiling OTA out is the only mitigation the library offers today.
64#ifdef PAINLESSMESH_OTA_REQUIRE_SIGNATURE
65#error \
66 "PAINLESSMESH_OTA_REQUIRE_SIGNATURE is not implemented: painlessMesh does not verify OTA image signatures. Use -DPAINLESSMESH_DISABLE_OTA to compile OTA out, or drop this define."
67#endif
68
69// NOTE: there is likewise no PAINLESSMESH_DISABLE_ACK flag. The one this
70// branch briefly carried gated only the (since-deleted, #386) dead
71// painlessmesh/message_tracker.hpp include, so the flag reclaimed nothing
72// and its advertised RAM saving was not real.
73//
74// That is NOT a claim that acknowledgment is free. The delivery-ack subsystem
75// (painlessmesh/ack.hpp) is a different thing and is genuinely allocated:
76// Mesh holds an ack::AckTracker member whose std::map grows with each
77// in-flight tracked message. Nothing compiles that out today. If a
78// memory-constrained target needs it gone, that is a design question for the
79// ack feature (#379), not a flag to reinstate here.
80
81// NOTE: `MIN_FREE_MEMORY` and `MAX_MESSAGE_QUEUE` are kept as deprecated
82// no-op compatibility macros. The library does not read either macro:
83// the auto-flushing message queue they were meant to tune never landed
84// (see #385, PR #383 review). `MessageQueue`
85// (`painlessmesh/message_queue.hpp`) is a manual priority buffer with
86// its own per-instance `maxSize` argument. Their historical default
87// values are preserved so downstream code that referenced them keeps