Files
MeshCore/examples/companion_radio/CompanionFeatures.h
mikecarper 3e8c637866 Add Companion lost-status replies and repair room mailbox test adapters
Save an opt-in off/no/yes answer to private Am I lost questions from known
chat contacts. Keep reply traffic and ACK state bounded, preserve pending
user delivery, and expose the setting through local CLI and ESP32 WebConfig.

Retain compact STM32 application/filesystem boundaries, qualify the Tag BLE
queue allowance, and exercise saved-image compatibility and browser controls.
Fix stale room mailbox protocol dependencies in the ACL/route test fixtures.

Validation: ten Companion builds, sanitized production-path regressions,
preference fault/compatibility tests, browser tests, and 86 capacity/build
recipe checks passed. No live radio was flashed for this feature.
2026-10-10 19:24:42 -07:00

138 lines
4.9 KiB
C

#pragma once
#include <helpers/CompanionReaderConfig.h>
#include <helpers/ota/OtaMemoryPolicy.h>
// Compact STM32 Companion images retain their existing application/filesystem
// boundary. The persistent preference stays in the shared wire image even
// when the optional private responder is excluded from an image.
#ifndef MESH_ENABLE_LOST_REPLY
#if defined(STM32_PLATFORM)
#define MESH_ENABLE_LOST_REPLY 0
#else
#define MESH_ENABLE_LOST_REPLY 1
#endif
#endif
// STM32WL has only 224 KiB of application flash. Keep its established image
// within that boundary; larger targets provide the programmable alert engine.
#ifndef COMPANION_FEATURE_NOTIFICATIONS
#if defined(STM32_PLATFORM)
#define COMPANION_FEATURE_NOTIFICATIONS 0
#else
#define COMPANION_FEATURE_NOTIFICATIONS 1
#endif
#endif
// The role terminal is also used by WebConfig on WiFi-only Companions. Its
// parser and reply tracking do not require a physical USB transport.
#if defined(ENABLE_USB_INTERFACE) \
|| (defined(ESP32_PLATFORM) && defined(WIFI_SSID) && !defined(WEBCONFIG_DISABLED))
#define COMPANION_FEATURE_TEXT_TERMINAL 1
#else
#define COMPANION_FEATURE_TEXT_TERMINAL 0
#endif
// Features are selected independently so adding a transport or changing an
// image-size profile cannot accidentally remove unrelated Companion behavior.
// Keep the legacy umbrella as a compatibility input for existing target files;
// application code must use the capability macros below.
#if defined(COMPANION_RADIO_FULL)
#ifndef COMPANION_FEATURE_TEMP_RADIO
#define COMPANION_FEATURE_TEMP_RADIO 1
#endif
#ifndef COMPANION_FEATURE_OTA_CLI
#define COMPANION_FEATURE_OTA_CLI 1
#endif
#if defined(ESP32_PLATFORM)
#ifndef COMPANION_FEATURE_NETWORK_TERMINAL
#define COMPANION_FEATURE_NETWORK_TERMINAL 1
#endif
#ifndef COMPANION_FEATURE_MEMORY_DIAGNOSTICS
#define COMPANION_FEATURE_MEMORY_DIAGNOSTICS 1
#endif
#endif
#if defined(MESH_DUAL_CDC_LOGGING)
#ifndef COMPANION_FEATURE_DEDICATED_USB_LOGGING
#define COMPANION_FEATURE_DEDICATED_USB_LOGGING 1
#endif
#endif
// A Full Companion cannot leave its line-oriented terminal active while the
// serial folder source exchanges binary request/reply frames on that same
// stream. Both nRF52 CDC and ESP32's inherited OTA_FOLDER_SERIAL transport
// therefore use the exclusive USB mOTA owner state in main.cpp.
#if defined(OTA_FOLDER_SERIAL) \
&& (defined(NRF52_PLATFORM) || defined(ESP32_PLATFORM))
#ifndef COMPANION_FEATURE_USB_MOTA_SOURCE
#define COMPANION_FEATURE_USB_MOTA_SOURCE 1
#endif
#endif
#endif
#ifndef COMPANION_FEATURE_TEMP_RADIO
#define COMPANION_FEATURE_TEMP_RADIO 0
#endif
#ifndef COMPANION_FEATURE_OTA_CLI
#define COMPANION_FEATURE_OTA_CLI 0
#endif
#ifndef COMPANION_FEATURE_NETWORK_TERMINAL
#define COMPANION_FEATURE_NETWORK_TERMINAL 0
#endif
#ifndef COMPANION_FEATURE_MEMORY_DIAGNOSTICS
#define COMPANION_FEATURE_MEMORY_DIAGNOSTICS 0
#endif
#ifndef COMPANION_FEATURE_USB_MOTA_SOURCE
#define COMPANION_FEATURE_USB_MOTA_SOURCE 0
#endif
#ifndef COMPANION_FEATURE_BLE_MOTA_SOURCE
#define COMPANION_FEATURE_BLE_MOTA_SOURCE 0
#endif
#ifndef COMPANION_FEATURE_DEDICATED_USB_LOGGING
#define COMPANION_FEATURE_DEDICATED_USB_LOGGING 0
#endif
#if COMPANION_FEATURE_OTA_CLI && !defined(ENABLE_OTA)
#error "COMPANION_FEATURE_OTA_CLI requires ENABLE_OTA"
#endif
#if COMPANION_FEATURE_NETWORK_TERMINAL && !defined(ENABLE_USB_INTERFACE)
#error "COMPANION_FEATURE_NETWORK_TERMINAL requires ENABLE_USB_INTERFACE"
#endif
#if COMPANION_FEATURE_NETWORK_TERMINAL \
&& !(defined(ESP32_PLATFORM) && defined(WIFI_SSID) \
&& defined(ENABLE_OTA))
#error "COMPANION_FEATURE_NETWORK_TERMINAL requires ESP32 WiFi and the OTA source overlay"
#endif
#if COMPANION_FEATURE_USB_MOTA_SOURCE \
&& !((defined(NRF52_PLATFORM) || defined(ESP32_PLATFORM)) \
&& defined(OTA_FOLDER_SERIAL) && defined(ENABLE_USB_INTERFACE) \
&& defined(ENABLE_OTA))
#error "COMPANION_FEATURE_USB_MOTA_SOURCE requires a USB serial folder source"
#endif
#if COMPANION_FEATURE_BLE_MOTA_SOURCE \
&& !(defined(COMPANION_RADIO_FULL) && defined(NRF52_PLATFORM) \
&& defined(BLE_PIN_CODE) && defined(ENABLE_OTA))
#error "COMPANION_FEATURE_BLE_MOTA_SOURCE requires an nRF52 Full Companion with BLE and OTA"
#endif
#if COMPANION_FEATURE_MEMORY_DIAGNOSTICS && !defined(ESP32_PLATFORM)
#error "COMPANION_FEATURE_MEMORY_DIAGNOSTICS requires ESP32"
#endif
#if COMPANION_FEATURE_DEDICATED_USB_LOGGING \
&& !(defined(MESH_DUAL_CDC_LOGGING) \
&& defined(ENABLE_USB_INTERFACE))
#error "COMPANION_FEATURE_DEDICATED_USB_LOGGING requires nRF52 dual-CDC USB"
#endif
#if defined(MESHCORE_REQUIRES_COMPANION_RADIO_FULL) \
&& !defined(COMPANION_RADIO_FULL)
#error "This target requires build.sh to apply the Full Companion profile"
#endif
#if defined(COMPANION_RADIO_FULL) && !defined(BLE_PIN_CODE)
#error "COMPANION_RADIO_FULL requires the Bluetooth Companion transport"
#endif