feat: add capability-aware firmware build profiles
This commit is contained in:
1 parent
9d57a3a4f8
commit
f01970058d
21 files changed
+1084
-101
No files matched your search
@@ -0,0 +1,59 @@
|
||||
#pragma once
|
||||
|
||||
// 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
|
||||
#ifndef COMPANION_FEATURE_NETWORK_TERMINAL
|
||||
#define COMPANION_FEATURE_NETWORK_TERMINAL 1
|
||||
#endif
|
||||
#ifndef COMPANION_FEATURE_MEMORY_DIAGNOSTICS
|
||||
#define COMPANION_FEATURE_MEMORY_DIAGNOSTICS 1
|
||||
#endif
|
||||
#if defined(MESH_DUAL_CDC_LOGGING)
|
||||
#ifndef COMPANION_FEATURE_DEDICATED_USB_LOGGING
|
||||
#define COMPANION_FEATURE_DEDICATED_USB_LOGGING 1
|
||||
#endif
|
||||
#endif
|
||||
#if defined(NRF52_PLATFORM) && defined(OTA_FOLDER_SERIAL)
|
||||
#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_DEDICATED_USB_LOGGING
|
||||
#define COMPANION_FEATURE_DEDICATED_USB_LOGGING 0
|
||||
#endif
|
||||
|
||||
#if COMPANION_FEATURE_NETWORK_TERMINAL && !defined(ENABLE_USB_INTERFACE)
|
||||
#error "COMPANION_FEATURE_NETWORK_TERMINAL requires ENABLE_USB_INTERFACE"
|
||||
#endif
|
||||
|
||||
#if COMPANION_FEATURE_USB_MOTA_SOURCE \
|
||||
&& !(defined(NRF52_PLATFORM) && defined(OTA_FOLDER_SERIAL) \
|
||||
&& defined(ENABLE_USB_INTERFACE))
|
||||
#error "COMPANION_FEATURE_USB_MOTA_SOURCE requires nRF52 USB folder seeding"
|
||||
#endif
|
||||
@@ -25,7 +25,7 @@
|
||||
#include <helpers/TracePathHelpers.h>
|
||||
#endif
|
||||
|
||||
#if defined(COMPANION_RADIO_FULL)
|
||||
#if COMPANION_FEATURE_OTA_CLI
|
||||
#include <helpers/ota/OtaCli.h>
|
||||
#endif
|
||||
|
||||
@@ -430,7 +430,7 @@ float MyMesh::getAirtimeBudgetFactor() const {
|
||||
// TempRadio is a short-lived, explicitly coordinated OTA channel. Let its
|
||||
// primary transfer use the full dispatcher budget; the persisted public
|
||||
// channel duty factor becomes authoritative again as soon as TempRadio ends.
|
||||
#if defined(COMPANION_RADIO_FULL)
|
||||
#if COMPANION_FEATURE_TEMP_RADIO
|
||||
if (isTempRadioActive()) return 0.0f;
|
||||
#endif
|
||||
return _prefs.airtime_factor;
|
||||
@@ -1413,7 +1413,7 @@ MyMesh::MyMesh(mesh::Radio &radio, mesh::RNG &rng, mesh::RTCClock &rtc, SimpleMe
|
||||
#if MESH_USB_LOGGING_AVAILABLE
|
||||
_usb_logging_reboot_at = 0;
|
||||
#endif
|
||||
#if defined(COMPANION_RADIO_FULL)
|
||||
#if COMPANION_FEATURE_TEMP_RADIO
|
||||
_temp_radio_set_at = 0;
|
||||
_temp_radio_revert_at = 0;
|
||||
_temp_radio_retry_at = 0;
|
||||
@@ -1474,7 +1474,7 @@ MyMesh::MyMesh(mesh::Radio &radio, mesh::RNG &rng, mesh::RTCClock &rtc, SimpleMe
|
||||
_prefs.powersaving_enabled = 1;
|
||||
_prefs.powersaving_policy_version = 0;
|
||||
_prefs.wifi_enabled = 1;
|
||||
#if defined(COMPANION_RADIO_FULL) && defined(MESH_DUAL_CDC_LOGGING)
|
||||
#if defined(MESH_DUAL_CDC_LOGGING)
|
||||
// Keep the primary CDC stream exclusively framed unless the owner opts in
|
||||
// to the separate plaintext logging interface and reboots.
|
||||
_prefs.usb_logging_enabled = 0;
|
||||
@@ -1800,7 +1800,7 @@ void MyMesh::servicePendingRadioParamApply() {
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(COMPANION_RADIO_FULL)
|
||||
#if COMPANION_FEATURE_TEMP_RADIO
|
||||
static bool isFullCompanionBandwidth(float bw) {
|
||||
static const float supported[] = {
|
||||
7.8f, 10.4f, 15.6f, 20.8f, 31.25f, 41.7f,
|
||||
@@ -2005,7 +2005,8 @@ bool MyMesh::handleLocalControlCommand(const char* command, char* reply,
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(COMPANION_RADIO_FULL)
|
||||
#if COMPANION_FEATURE_TEMP_RADIO || COMPANION_FEATURE_OTA_CLI
|
||||
#if COMPANION_FEATURE_TEMP_RADIO
|
||||
if (strcmp(command, "tempradio") == 0) {
|
||||
if (_temp_radio_set_at) {
|
||||
snprintf(reply, reply_size, "TempRadio pending: %.3f,%.2f,%u,%u",
|
||||
@@ -2048,7 +2049,9 @@ bool MyMesh::handleLocalControlCommand(const char* command, char* reply,
|
||||
scheduleNormalRadio(reply, reply_size);
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if COMPANION_FEATURE_OTA_CLI
|
||||
if (strncmp(command, "ota", 3) == 0
|
||||
&& (command[3] == 0 || command[3] == ' ')) {
|
||||
char ota_reply[160] = {0};
|
||||
@@ -2056,12 +2059,13 @@ bool MyMesh::handleLocalControlCommand(const char* command, char* reply,
|
||||
snprintf(reply, reply_size, "%s", ota_reply);
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#if defined(COMPANION_RADIO_FULL)
|
||||
#if COMPANION_FEATURE_TEMP_RADIO
|
||||
void MyMesh::serviceTempRadio() {
|
||||
const unsigned long now = _ms->getMillis();
|
||||
const bool retry_ready = !_temp_radio_retry_at
|
||||
@@ -3149,7 +3153,7 @@ void MyMesh::handleCmdFrame(size_t len) {
|
||||
writeErrFrame(ERR_CODE_ILLEGAL_ARG);
|
||||
return;
|
||||
}
|
||||
#if defined(COMPANION_RADIO_FULL)
|
||||
#if COMPANION_FEATURE_TEMP_RADIO
|
||||
if (isTempRadioActive() || _temp_radio_set_at != 0
|
||||
|| _temp_radio_revert_at != 0) {
|
||||
writeErrFrame(ERR_CODE_BAD_STATE);
|
||||
@@ -4217,7 +4221,7 @@ void MyMesh::resetTerminalSession() {
|
||||
|
||||
void MyMesh::printTerminalBanner(bool show_binary_stop) {
|
||||
Stream& output = terminalOutput();
|
||||
#if defined(COMPANION_RADIO_FULL)
|
||||
#if COMPANION_FEATURE_TEMP_RADIO || COMPANION_FEATURE_NETWORK_TERMINAL
|
||||
output.print("\r\n===== MeshCore Full Companion Terminal =====\r\n\r\n");
|
||||
#else
|
||||
output.print("\r\n===== MeshCore Companion Terminal =====\r\n\r\n");
|
||||
@@ -4247,7 +4251,7 @@ void MyMesh::exitTerminalMode() {
|
||||
if (_terminal_output == &Serial) _terminal_output = NULL;
|
||||
}
|
||||
|
||||
#if defined(COMPANION_RADIO_FULL)
|
||||
#if COMPANION_FEATURE_NETWORK_TERMINAL
|
||||
bool MyMesh::enterNetworkTerminalMode(Stream& output) {
|
||||
if (_terminal_mode) return false;
|
||||
_terminal_output = &output;
|
||||
@@ -5059,7 +5063,7 @@ void MyMesh::handleTerminalCommand(char* command) {
|
||||
uint32_t effective_sleep_us = _prefs.rx_ps_sleep_us;
|
||||
uint8_t active_sf = _prefs.sf;
|
||||
float active_bw = _prefs.bw;
|
||||
#if defined(COMPANION_RADIO_FULL)
|
||||
#if COMPANION_FEATURE_TEMP_RADIO
|
||||
if (isTempRadioActive()) {
|
||||
active_sf = _temp_radio_sf;
|
||||
active_bw = _temp_radio_bw;
|
||||
@@ -5318,10 +5322,14 @@ void MyMesh::handleTerminalCommand(char* command) {
|
||||
terminalOutput().print(" public <text>\r\n");
|
||||
terminalOutput().print(" channels\r\n");
|
||||
terminalOutput().print(" channel <name-or-slot> <text>\r\n");
|
||||
#if defined(COMPANION_RADIO_FULL)
|
||||
#if COMPANION_FEATURE_TEMP_RADIO || COMPANION_FEATURE_OTA_CLI
|
||||
#if COMPANION_FEATURE_TEMP_RADIO
|
||||
terminalOutput().print(" tempradio [freq,bw,sf,cr,minutes]\r\n");
|
||||
terminalOutput().print(" normalradio\r\n");
|
||||
#endif
|
||||
#if COMPANION_FEATURE_OTA_CLI
|
||||
terminalOutput().print(" ota {status|ls|announce|folder|config|...}\r\n");
|
||||
#endif
|
||||
#endif
|
||||
terminalOutput().print(" ver\r\n");
|
||||
if (_terminal_mode) {
|
||||
@@ -5555,7 +5563,7 @@ void MyMesh::loop() {
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
#if defined(COMPANION_RADIO_FULL)
|
||||
#if COMPANION_FEATURE_TEMP_RADIO
|
||||
serviceTempRadio();
|
||||
#endif
|
||||
BaseChatMesh::loop();
|
||||
@@ -5568,7 +5576,7 @@ void MyMesh::loop() {
|
||||
serviceTerminalTrace();
|
||||
#endif
|
||||
if (!command_radio_apply_pending && saved_radio_apply_pending && !hasOutbound()
|
||||
#if defined(COMPANION_RADIO_FULL)
|
||||
#if COMPANION_FEATURE_TEMP_RADIO
|
||||
&& !_temp_radio_applied && _temp_radio_set_at == 0
|
||||
&& _temp_radio_revert_at == 0
|
||||
#endif
|
||||
@@ -5647,7 +5655,7 @@ bool MyMesh::hasPendingWork() const {
|
||||
|| (dirty_contacts_expiry != 0 && millisHasNowPassed(dirty_contacts_expiry))
|
||||
|| (emergency_client_repeat_packet != NULL
|
||||
&& millisHasNowPassed(emergency_client_repeat_send_at))
|
||||
#if defined(COMPANION_RADIO_FULL)
|
||||
#if COMPANION_FEATURE_TEMP_RADIO
|
||||
|| (_temp_radio_set_at != 0 && millisHasNowPassed(_temp_radio_set_at))
|
||||
|| (_temp_radio_revert_at != 0 && millisHasNowPassed(_temp_radio_revert_at))
|
||||
|| (_temp_radio_retry_at != 0 && millisHasNowPassed(_temp_radio_retry_at))
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <Arduino.h>
|
||||
#include <Mesh.h>
|
||||
#include "AbstractUITask.h"
|
||||
#include "CompanionFeatures.h"
|
||||
|
||||
/*------------ Frame Protocol --------------*/
|
||||
#define FIRMWARE_VER_CODE 13
|
||||
@@ -80,8 +81,8 @@
|
||||
#ifndef OFFLINE_QUEUE_SIZE
|
||||
#if defined(ESP32_PLATFORM) && defined(BOARD_HAS_PSRAM)
|
||||
#define OFFLINE_QUEUE_SIZE 512
|
||||
#elif defined(COMPANION_RADIO_FULL) || defined(ESP32_PLATFORM) \
|
||||
|| defined(NRF52_PLATFORM) || defined(RP2040_PLATFORM)
|
||||
#elif defined(ESP32_PLATFORM) || defined(NRF52_PLATFORM) \
|
||||
|| defined(RP2040_PLATFORM)
|
||||
#define OFFLINE_QUEUE_SIZE 256
|
||||
#else
|
||||
#define OFFLINE_QUEUE_SIZE 16
|
||||
@@ -169,7 +170,7 @@ public:
|
||||
void exitTerminalMode();
|
||||
bool isTerminalMode() const { return _terminal_mode; }
|
||||
void handleTerminalCommand(char* command);
|
||||
#if defined(COMPANION_RADIO_FULL)
|
||||
#if COMPANION_FEATURE_NETWORK_TERMINAL
|
||||
bool enterNetworkTerminalMode(Stream& output);
|
||||
void exitNetworkTerminalMode(Stream& output);
|
||||
bool isNetworkTerminalMode(const Stream& output) const;
|
||||
@@ -184,7 +185,7 @@ public:
|
||||
int getRecentlyHeard(AdvertPath dest[], int max_num);
|
||||
|
||||
protected:
|
||||
#if defined(COMPANION_RADIO_FULL)
|
||||
#if COMPANION_FEATURE_TEMP_RADIO
|
||||
bool isTempRadioActive() const override {
|
||||
return _temp_radio_applied && _temp_radio_revert_at != 0
|
||||
&& !millisHasNowPassed(_temp_radio_revert_at);
|
||||
@@ -357,7 +358,7 @@ private:
|
||||
void finishRadioParamApply(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t repeat);
|
||||
void cancelPendingRadioParamApply();
|
||||
void servicePendingRadioParamApply();
|
||||
#if defined(COMPANION_RADIO_FULL)
|
||||
#if COMPANION_FEATURE_TEMP_RADIO
|
||||
bool scheduleTempRadio(float freq, float bw, uint8_t sf, uint8_t cr,
|
||||
uint32_t timeout_mins, char* reply, size_t reply_size);
|
||||
void scheduleNormalRadio(char* reply, size_t reply_size);
|
||||
@@ -435,7 +436,7 @@ private:
|
||||
#if MESH_USB_LOGGING_AVAILABLE
|
||||
unsigned long _usb_logging_reboot_at;
|
||||
#endif
|
||||
#if defined(COMPANION_RADIO_FULL)
|
||||
#if COMPANION_FEATURE_TEMP_RADIO
|
||||
unsigned long _temp_radio_set_at;
|
||||
unsigned long _temp_radio_revert_at;
|
||||
unsigned long _temp_radio_retry_at;
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#else
|
||||
#define COMPANION_BT_MODEM_SLEEP_AVAILABLE 0
|
||||
#endif
|
||||
#if defined(COMPANION_RADIO_FULL)
|
||||
#if COMPANION_FEATURE_MEMORY_DIAGNOSTICS
|
||||
#include <esp_heap_caps.h>
|
||||
#endif
|
||||
#endif
|
||||
@@ -80,7 +80,7 @@ MultiSerialInterface interface_manager;
|
||||
#include <helpers/CLICommandUtils.h>
|
||||
static const char USB_TERMINAL_START_TOKEN[] = "+++MESHCORE-TERM-START";
|
||||
static const char USB_TERMINAL_STOP_TOKEN[] = "+++MESHCORE-TERM-STOP";
|
||||
#if defined(NRF52_PLATFORM) && defined(COMPANION_RADIO_FULL) && defined(OTA_FOLDER_SERIAL)
|
||||
#if COMPANION_FEATURE_USB_MOTA_SOURCE
|
||||
// motatool sends this command automatically when `serve --serial` opens the
|
||||
// port. In Binary mode it is an exact, idle-parser control sequence that
|
||||
// hands USB ownership to the host-backed mOTA source.
|
||||
@@ -291,7 +291,7 @@ static char usb_terminal_line[MAX_TRANS_UNIT * 2 + 32];
|
||||
static size_t usb_terminal_line_len = 0;
|
||||
static bool usb_terminal_discard_line = false;
|
||||
static bool usb_terminal_disconnect_armed = false;
|
||||
#if defined(NRF52_PLATFORM) && defined(COMPANION_RADIO_FULL) && defined(OTA_FOLDER_SERIAL)
|
||||
#if COMPANION_FEATURE_USB_MOTA_SOURCE
|
||||
static bool usb_mota_mode = false;
|
||||
static char usb_mota_line[32];
|
||||
static size_t usb_mota_line_len = 0;
|
||||
@@ -359,7 +359,7 @@ static void leaveUsbTerminalMode(bool acknowledge) {
|
||||
usb_terminal_disconnect_armed = false;
|
||||
}
|
||||
|
||||
#if defined(NRF52_PLATFORM) && defined(COMPANION_RADIO_FULL) && defined(OTA_FOLDER_SERIAL)
|
||||
#if COMPANION_FEATURE_USB_MOTA_SOURCE
|
||||
static void resetUsbMotaMode() {
|
||||
usb_mota_mode = false;
|
||||
usb_mota_line_len = 0;
|
||||
@@ -440,7 +440,7 @@ static void serviceUsbMota() {
|
||||
#endif
|
||||
|
||||
static void serviceUsbTerminal() {
|
||||
#if defined(NRF52_PLATFORM) && defined(COMPANION_RADIO_FULL) && defined(OTA_FOLDER_SERIAL)
|
||||
#if COMPANION_FEATURE_USB_MOTA_SOURCE
|
||||
if (usb_mota_mode) {
|
||||
serviceUsbMota();
|
||||
return;
|
||||
@@ -449,7 +449,7 @@ static void serviceUsbTerminal() {
|
||||
if (!the_mesh.isTerminalMode()) {
|
||||
if (usb_serial_interface.takeControlSequence()) {
|
||||
enterUsbTerminalMode();
|
||||
#if defined(NRF52_PLATFORM) && defined(COMPANION_RADIO_FULL) && defined(OTA_FOLDER_SERIAL)
|
||||
#if COMPANION_FEATURE_USB_MOTA_SOURCE
|
||||
} else if (usb_serial_interface.takeSecondaryControlSequence()) {
|
||||
enterUsbMotaMode();
|
||||
#endif
|
||||
@@ -746,7 +746,7 @@ void halt() {
|
||||
|
||||
static void ota_console_start() {
|
||||
ota_console_server.begin();
|
||||
#if defined(COMPANION_RADIO_FULL) && defined(ENABLE_USB_INTERFACE)
|
||||
#if COMPANION_FEATURE_NETWORK_TERMINAL
|
||||
WIFI_DEBUG_PRINTLN("Full Companion terminal listening on :%d (nc <ip> %d)",
|
||||
OTA_CONSOLE_TCP_PORT, OTA_CONSOLE_TCP_PORT);
|
||||
#else
|
||||
@@ -756,7 +756,7 @@ void halt() {
|
||||
}
|
||||
|
||||
static void ota_console_stop() {
|
||||
#if defined(COMPANION_RADIO_FULL) && defined(ENABLE_USB_INTERFACE)
|
||||
#if COMPANION_FEATURE_NETWORK_TERMINAL
|
||||
the_mesh.exitNetworkTerminalMode(ota_console_client);
|
||||
#endif
|
||||
if (ota_console_client) ota_console_client.stop();
|
||||
@@ -767,7 +767,7 @@ void halt() {
|
||||
|
||||
static void ota_console_loop() {
|
||||
if (!ota_console_client || !ota_console_client.connected()) {
|
||||
#if defined(COMPANION_RADIO_FULL) && defined(ENABLE_USB_INTERFACE)
|
||||
#if COMPANION_FEATURE_NETWORK_TERMINAL
|
||||
the_mesh.exitNetworkTerminalMode(ota_console_client);
|
||||
#endif
|
||||
WiFiClient c = ota_console_server.available();
|
||||
@@ -775,7 +775,7 @@ void halt() {
|
||||
ota_console_client = c;
|
||||
ota_console_clear_line();
|
||||
ota_console_discard_line = false;
|
||||
#if defined(COMPANION_RADIO_FULL) && defined(ENABLE_USB_INTERFACE)
|
||||
#if COMPANION_FEATURE_NETWORK_TERMINAL
|
||||
if (!the_mesh.enterNetworkTerminalMode(ota_console_client)) {
|
||||
ota_console_client.print(
|
||||
"ERROR: USB currently owns the Full Companion terminal\r\n");
|
||||
@@ -787,7 +787,7 @@ void halt() {
|
||||
}
|
||||
return;
|
||||
}
|
||||
#if defined(COMPANION_RADIO_FULL) && defined(ENABLE_USB_INTERFACE)
|
||||
#if COMPANION_FEATURE_NETWORK_TERMINAL
|
||||
if (!the_mesh.isNetworkTerminalMode(ota_console_client)) {
|
||||
ota_console_client.print(
|
||||
"\r\nERROR: terminal ownership moved to USB; closing\r\n");
|
||||
@@ -809,7 +809,7 @@ void halt() {
|
||||
if (ch == '\r' || ch == '\n') {
|
||||
if (ota_console_len == 0) continue; // ignore blanks / the CRLF pair
|
||||
ota_console_line[ota_console_len] = 0;
|
||||
#if defined(COMPANION_RADIO_FULL) && defined(ENABLE_USB_INTERFACE)
|
||||
#if COMPANION_FEATURE_NETWORK_TERMINAL
|
||||
if (strcmp(ota_console_line, "disconnect") == 0) {
|
||||
ota_console_client.print(" OK - disconnecting\r\n");
|
||||
the_mesh.exitNetworkTerminalMode(ota_console_client);
|
||||
@@ -1007,7 +1007,7 @@ void halt() {
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(ESP32_PLATFORM) && defined(COMPANION_RADIO_FULL)
|
||||
#if defined(ESP32_PLATFORM) && COMPANION_FEATURE_MEMORY_DIAGNOSTICS
|
||||
static void logFullCompanionMemory(const char* stage) {
|
||||
mesh::usbLoggingPort().printf(
|
||||
"Full Companion memory %s: heap=%u largest_internal=%u psram_free=%u/%u offline_queue=%d\r\n",
|
||||
@@ -1152,15 +1152,14 @@ void setup() {
|
||||
loadCompanionWiFiCredentials();
|
||||
#endif
|
||||
|
||||
#if defined(ESP32_PLATFORM) && defined(COMPANION_RADIO_FULL)
|
||||
#if defined(ESP32_PLATFORM) && COMPANION_FEATURE_MEMORY_DIAGNOSTICS
|
||||
logFullCompanionMemory("before interfaces");
|
||||
#endif
|
||||
|
||||
// NimBLE must reserve its internal controller/host memory before WiFi starts
|
||||
// its AP and WebConfig services. Starting WiFi first can leave plenty of total
|
||||
// heap but no internal block large enough for nimble_port_init().
|
||||
#if defined(BLE_PIN_CODE) && defined(ESP32) \
|
||||
&& defined(COMPANION_RADIO_FULL) && defined(WIFI_SSID)
|
||||
#if defined(BLE_PIN_CODE) && defined(ESP32) && defined(WIFI_SSID)
|
||||
startCompanionBluetooth();
|
||||
#endif
|
||||
|
||||
@@ -1189,22 +1188,21 @@ void setup() {
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(ESP32_PLATFORM) && defined(COMPANION_RADIO_FULL)
|
||||
#if defined(ESP32_PLATFORM) && COMPANION_FEATURE_MEMORY_DIAGNOSTICS
|
||||
logFullCompanionMemory("after WiFi start");
|
||||
#endif
|
||||
|
||||
// Full ESP32 WiFi+BLE companions started BLE above so its controller memory
|
||||
// could not be fragmented by WiFi. Other BLE companions start here.
|
||||
// ESP32 WiFi+BLE companions started BLE above so its controller memory could
|
||||
// not be fragmented by WiFi. Other BLE companions start here.
|
||||
#if defined(BLE_PIN_CODE)
|
||||
#if !(defined(ESP32) && defined(COMPANION_RADIO_FULL) \
|
||||
&& defined(WIFI_SSID))
|
||||
#if !(defined(ESP32) && defined(WIFI_SSID))
|
||||
startCompanionBluetooth();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// add usb interface
|
||||
#if defined(ENABLE_USB_INTERFACE)
|
||||
#if defined(NRF52_PLATFORM) && defined(COMPANION_RADIO_FULL) && defined(OTA_FOLDER_SERIAL)
|
||||
#if COMPANION_FEATURE_USB_MOTA_SOURCE
|
||||
usb_serial_interface.begin(Serial, USB_TERMINAL_START_TOKEN, USB_MOTA_START_TOKEN);
|
||||
#else
|
||||
usb_serial_interface.begin(Serial, USB_TERMINAL_START_TOKEN);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "FloodRuleEngine.h"
|
||||
|
||||
#if defined(MESHCORE_ESP32_FULL_PROFILE)
|
||||
#if MESH_ENABLE_ROOM_FLOOD_RULE_ENGINE
|
||||
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#if defined(MESHCORE_ESP32_FULL_PROFILE)
|
||||
#include "RoomServerFeatures.h"
|
||||
|
||||
#if MESH_ENABLE_ROOM_FLOOD_RULE_ENGINE
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <Mesh.h>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "MyMesh.h"
|
||||
#include <helpers/radiolib/RxBoostedGainDefaults.h>
|
||||
#include <helpers/CLICommandUtils.h>
|
||||
#if defined(MESHCORE_ESP32_FULL_PROFILE)
|
||||
#if MESH_ENABLE_ROOM_FLOOD_RULE_ENGINE
|
||||
#include <helpers/FloodFilterPolicy.h>
|
||||
#endif
|
||||
#include <helpers/radiolib/RXPowerSaving.h>
|
||||
@@ -371,7 +371,7 @@ int MyMesh::calcRxDelay(float score, uint32_t air_time) const {
|
||||
return (int)((powf(_prefs.rx_delay_base, 0.85f - score) - 1.0f) * air_time);
|
||||
}
|
||||
|
||||
#if defined(MESHCORE_ESP32_FULL_PROFILE)
|
||||
#if MESH_ENABLE_ROOM_FLOOD_RULE_ENGINE
|
||||
bool MyMesh::evaluateFloodRuleTiming(const mesh::Packet* packet,
|
||||
bool& fast_track) {
|
||||
fast_track = false;
|
||||
@@ -530,14 +530,14 @@ bool MyMesh::allowPacketForward(const mesh::Packet *packet) {
|
||||
_prefs.flood_max_advert)) {
|
||||
return false;
|
||||
}
|
||||
#if defined(MESHCORE_ESP32_FULL_PROFILE)
|
||||
#if MESH_ENABLE_ROOM_FLOOD_RULE_ENGINE
|
||||
if (flood_rules.shouldBlock(packet, recv_pkt_rule_match_mask,
|
||||
_ms->getMillis())) {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#if defined(MESHCORE_ESP32_FULL_PROFILE)
|
||||
#if MESH_ENABLE_ROOM_FLOOD_RULE_ENGINE
|
||||
if (packet->isRouteFlood()) {
|
||||
if (recv_pkt_region == NULL && !recv_pkt_regionless_scope_set) {
|
||||
MESH_DEBUG_PRINTLN(
|
||||
@@ -564,7 +564,7 @@ bool MyMesh::allowPacketForward(const mesh::Packet *packet) {
|
||||
}
|
||||
|
||||
mesh::DispatcherAction MyMesh::onRecvPacket(mesh::Packet* pkt) {
|
||||
#if defined(MESHCORE_ESP32_FULL_PROFILE)
|
||||
#if MESH_ENABLE_ROOM_FLOOD_RULE_ENGINE
|
||||
bool scope_changed = false;
|
||||
bool fast_track_scope_change = false;
|
||||
recv_pkt_regionless_scope_set = false;
|
||||
@@ -599,7 +599,7 @@ mesh::DispatcherAction MyMesh::onRecvPacket(mesh::Packet* pkt) {
|
||||
recv_pkt_region = NULL;
|
||||
}
|
||||
mesh::DispatcherAction action = Mesh::onRecvPacket(pkt);
|
||||
#if defined(MESHCORE_ESP32_FULL_PROFILE)
|
||||
#if MESH_ENABLE_ROOM_FLOOD_RULE_ENGINE
|
||||
if (scope_changed && action != ACTION_RELEASE
|
||||
&& action != ACTION_MANUAL_HOLD) {
|
||||
if (fast_track_scope_change) {
|
||||
@@ -1155,7 +1155,7 @@ MyMesh::MyMesh(mesh::MainBoard &board, mesh::Radio &radio, mesh::MillisecondCloc
|
||||
radio_apply_retry_at = 0;
|
||||
radio_apply_failures = 0;
|
||||
recv_pkt_region = NULL;
|
||||
#if defined(MESHCORE_ESP32_FULL_PROFILE)
|
||||
#if MESH_ENABLE_ROOM_FLOOD_RULE_ENGINE
|
||||
recv_pkt_rule_match_mask = 0;
|
||||
recv_pkt_regionless_scope_set = false;
|
||||
#endif
|
||||
@@ -1261,7 +1261,7 @@ void MyMesh::begin(FILESYSTEM *fs) {
|
||||
acl.load(_fs, self_id);
|
||||
region_map.load(_fs);
|
||||
_clock_sync.begin(_fs);
|
||||
#if defined(MESHCORE_ESP32_FULL_PROFILE)
|
||||
#if MESH_ENABLE_ROOM_FLOOD_RULE_ENGINE
|
||||
flood_rules.begin(_fs, ®ion_map);
|
||||
#endif
|
||||
|
||||
@@ -2115,7 +2115,7 @@ void MyMesh::handleCommand(uint32_t sender_timestamp, char *command, char *reply
|
||||
snprintf(reply, MAX_POST_TEXT_LEN, "OK");
|
||||
}
|
||||
}
|
||||
#if defined(MESHCORE_ESP32_FULL_PROFILE)
|
||||
#if MESH_ENABLE_ROOM_FLOOD_RULE_ENGINE
|
||||
else if (flood_rules.handleCommand(command, reply)) {
|
||||
// handled by the FULL-profile persistent flood rule engine
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <Arduino.h> // needed for PlatformIO
|
||||
#include <Mesh.h>
|
||||
#include "RoomServerFeatures.h"
|
||||
|
||||
#if defined(NRF52_PLATFORM)
|
||||
#include <InternalFileSystem.h>
|
||||
@@ -139,7 +140,7 @@ class MyMesh : public mesh::Mesh, public CommonCLICallbacks,
|
||||
NodePrefs _prefs;
|
||||
TransportKeyStore key_store;
|
||||
RegionMap region_map, temp_map;
|
||||
#if defined(MESHCORE_ESP32_FULL_PROFILE)
|
||||
#if MESH_ENABLE_ROOM_FLOOD_RULE_ENGINE
|
||||
FloodRuleEngine flood_rules;
|
||||
uint32_t recv_pkt_rule_match_mask;
|
||||
bool recv_pkt_regionless_scope_set;
|
||||
@@ -255,7 +256,7 @@ class MyMesh : public mesh::Mesh, public CommonCLICallbacks,
|
||||
mesh::Packet* createSelfAdvert();
|
||||
File openAppend(const char* fname);
|
||||
int handleRequest(ClientInfo* sender, uint32_t sender_timestamp, uint8_t* payload, size_t payload_len);
|
||||
#if defined(MESHCORE_ESP32_FULL_PROFILE)
|
||||
#if MESH_ENABLE_ROOM_FLOOD_RULE_ENGINE
|
||||
bool evaluateFloodRuleTiming(const mesh::Packet* packet,
|
||||
bool& fast_track);
|
||||
bool isLooped(const mesh::Packet* packet,
|
||||
@@ -278,7 +279,7 @@ protected:
|
||||
void logTxFail(mesh::Packet* pkt, int len) override;
|
||||
|
||||
int calcRxDelay(float score, uint32_t air_time) const override;
|
||||
#if defined(MESHCORE_ESP32_FULL_PROFILE)
|
||||
#if MESH_ENABLE_ROOM_FLOOD_RULE_ENGINE
|
||||
int calcRxDelayForPacket(const mesh::Packet* packet, float score,
|
||||
uint32_t air_time) override;
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
// Keep role capabilities independent from partition/profile labels. Existing
|
||||
// FULL recipes remain compatible, while build tooling can now select this
|
||||
// feature directly and verify that its CLI survived the link.
|
||||
#ifndef MESH_ENABLE_ROOM_FLOOD_RULE_ENGINE
|
||||
#if defined(MESHCORE_ESP32_FULL_PROFILE)
|
||||
#define MESH_ENABLE_ROOM_FLOOD_RULE_ENGINE 1
|
||||
#else
|
||||
#define MESH_ENABLE_ROOM_FLOOD_RULE_ENGINE 0
|
||||
#endif
|
||||
#endif
|
||||
Reference in new issue
Block a user