From 3d29a1d811525e88f496518f6551d68bc4fe8d06 Mon Sep 17 00:00:00 2001 From: mikecarper Date: Thu, 22 Oct 2026 17:19:24 -0700 Subject: [PATCH] Keep noise history within small-board memory budgets --- examples/simple_repeater/MyMesh.h | 29 ++++---- examples/simple_room_server/MyMesh.h | 9 +-- src/Dispatcher.h | 7 +- src/helpers/FloodAdvertLimiter.h | 9 ++- src/helpers/TelemetryHistoryConfig.h | 20 +++++ src/helpers/radiolib/RadioLibWrappers.cpp | 14 ++++ src/helpers/radiolib/RadioLibWrappers.h | 5 ++ .../test_flood_advert_limiter.cpp | 40 +++++++++- test/test_noise_floor_readings.py | 74 +++++++++++++++++-- test/test_radio_receive_contract.py | 1 + .../test_repeater_radio_timing_integration.py | 52 ++++++++++--- test/test_solarxiao_room.py | 4 +- 12 files changed, 217 insertions(+), 47 deletions(-) create mode 100644 src/helpers/TelemetryHistoryConfig.h diff --git a/examples/simple_repeater/MyMesh.h b/examples/simple_repeater/MyMesh.h index 3631e7ac8..40921da3b 100644 --- a/examples/simple_repeater/MyMesh.h +++ b/examples/simple_repeater/MyMesh.h @@ -15,15 +15,7 @@ #include #include #include - -#ifndef MESH_ENABLE_TELEMETRY_HISTORY - // LoRa-E5-class STM32 repeater images have less than 3 KB of spare flash. - #if defined(STM32_PLATFORM) - #define MESH_ENABLE_TELEMETRY_HISTORY 0 - #else - #define MESH_ENABLE_TELEMETRY_HISTORY 1 - #endif -#endif +#include #ifndef MESH_ENABLE_TELEMETRY_GPS_HISTORY // Builds without a GPS provider only collect missing GPS positions. Omit @@ -299,18 +291,23 @@ class MyMesh : public mesh::Mesh, public CommonCLICallbacks #endif { struct ScheduledRadioSetting { + // RAM only: group aligned fields to keep each schedule within 32 bytes. + uint64_t hard_end_uptime_millis; + float freq; + float bw; + uint32_t start_time; + uint32_t end_time; uint16_t preamble = 0; + uint8_t sf; + uint8_t cr; bool active; bool temporary; bool started; - float freq; - float bw; - uint8_t sf; - uint8_t cr; - uint32_t start_time; - uint32_t end_time; - uint64_t hard_end_uptime_millis; }; + static_assert(sizeof(ScheduledRadioSetting) <= 32, + "Scheduled radio rows must retain their compact RAM layout"); + static_assert(alignof(ScheduledRadioSetting) >= alignof(uint64_t), + "Scheduled radio uptime deadlines must remain naturally aligned"); FILESYSTEM* _fs; #ifndef PORTABLE_MQTT_OBSERVER diff --git a/examples/simple_room_server/MyMesh.h b/examples/simple_room_server/MyMesh.h index f27821748..fa14bb6b1 100644 --- a/examples/simple_room_server/MyMesh.h +++ b/examples/simple_room_server/MyMesh.h @@ -46,14 +46,7 @@ namespace mesh { class RoomJsonWriter; } -#ifndef MESH_ENABLE_TELEMETRY_HISTORY - // LoRa-E5-class STM32 room images do not have enough flash for history. - #if defined(STM32_PLATFORM) - #define MESH_ENABLE_TELEMETRY_HISTORY 0 - #else - #define MESH_ENABLE_TELEMETRY_HISTORY 1 - #endif -#endif +#include #ifndef MESH_ENABLE_TELEMETRY_GPS_HISTORY #if ENV_INCLUDE_GPS == 1 diff --git a/src/Dispatcher.h b/src/Dispatcher.h index fcce7ad9b..dc18cb1b1 100644 --- a/src/Dispatcher.h +++ b/src/Dispatcher.h @@ -11,6 +11,7 @@ #include #include #include +#include #ifndef RADIO_LIVENESS_SOFT_ONLY #include #endif @@ -215,13 +216,13 @@ public: // Only successfully published estimates have a timestamp. Unsupported // transports and disabled/unmeasured profiles return false, not a zero dBm // reading. millis() may legitimately be zero or wrap between publications. - virtual bool getNoiseFloorReading(uint8_t profile, float& dbm, - uint32_t& published_at_ms) const { + MESH_TELEMETRY_HISTORY_VIRTUAL bool getNoiseFloorReading( + uint8_t profile, float& dbm, uint32_t& published_at_ms) const { (void)profile; (void)dbm; (void)published_at_ms; return false; } // Join a bounded idle-RX collection without discarding a valid estimate or // interrupting reception, transmission, or another owner of the radio. - virtual void requestNoiseFloorMeasurement() { } + MESH_TELEMETRY_HISTORY_VIRTUAL void requestNoiseFloorMeasurement() { } // A zero result means there is no active sampled calibration window (or // that this transport does not expose one). The estimate itself may remain diff --git a/src/helpers/FloodAdvertLimiter.h b/src/helpers/FloodAdvertLimiter.h index 2549c5580..c392853ef 100644 --- a/src/helpers/FloodAdvertLimiter.h +++ b/src/helpers/FloodAdvertLimiter.h @@ -24,6 +24,7 @@ public: static constexpr uint32_t BAD_INTERVAL_MS = 12UL * 60UL * 60UL * 1000UL; static constexpr uint32_t RECOVERY_MS = 7UL * 24UL * 60UL * 60UL * 1000UL; static constexpr uint8_t HASH_SLOTS = 11; // maximum normal allowance + evidence of excess + static_assert(HASH_SLOTS <= 15, "Advert hash count must fit its four-bit field"); static constexpr uint8_t PREFIX_BYTES = 6; // first 12 public-key hex characters enum class Decision : uint8_t { Allow, Duplicate, Quota, BadList, Capacity }; @@ -37,8 +38,10 @@ public: uint32_t last_heard; uint16_t forwarded; uint8_t min_hops; - uint8_t count; - uint8_t flags; + // RAM-only state: count is 0..11 and the four flags are independent. + // Sharing one byte also removes tail padding without shortening history. + uint8_t count : 4; + uint8_t flags : 4; }; enum LimitReason : uint8_t { WindowQuota = 1, ReceiveHistory = 2, BadListRule = 4 }; @@ -77,6 +80,8 @@ protected: private: enum : uint8_t { ACTIVE = 1, PREVIOUS_OVER = 2, BAD = 4, HAS_FORWARDED = 8 }; + static_assert((ACTIVE | PREVIOUS_OVER | BAD | HAS_FORWARDED) <= 15, + "Advert flags must fit their four-bit field"); Entry* _entries; size_t _capacity; uint32_t _last_sweep = 0; diff --git a/src/helpers/TelemetryHistoryConfig.h b/src/helpers/TelemetryHistoryConfig.h new file mode 100644 index 000000000..edc9f62a2 --- /dev/null +++ b/src/helpers/TelemetryHistoryConfig.h @@ -0,0 +1,20 @@ +#pragma once + +// STM32 images omit diagnostic history to preserve their existing flash limit. +// Share this default with radio wrappers so unused publication tracking is +// omitted too. A build may explicitly enable or disable the complete feature. +#ifndef MESH_ENABLE_TELEMETRY_HISTORY + #if defined(STM32_PLATFORM) + #define MESH_ENABLE_TELEMETRY_HISTORY 0 + #else + #define MESH_ENABLE_TELEMETRY_HISTORY 1 + #endif +#endif + +// Disabled builds retain callable unsupported defaults without enlarging each +// radio vtable or retaining unused publication/request implementations. +#if MESH_ENABLE_TELEMETRY_HISTORY + #define MESH_TELEMETRY_HISTORY_VIRTUAL virtual +#else + #define MESH_TELEMETRY_HISTORY_VIRTUAL +#endif diff --git a/src/helpers/radiolib/RadioLibWrappers.cpp b/src/helpers/radiolib/RadioLibWrappers.cpp index 174509771..d1cd24283 100644 --- a/src/helpers/radiolib/RadioLibWrappers.cpp +++ b/src/helpers/radiolib/RadioLibWrappers.cpp @@ -271,7 +271,9 @@ void RadioLibWrapper::begin() { _noise_floor_secondary_centi_dbm = 0; _noise_floor_valid = false; _noise_floor_secondary_valid = false; +#if MESH_ENABLE_TELEMETRY_HISTORY _nf_published_valid = 0; +#endif _threshold = 0; _cad_enabled = false; _rx_mode_checked_at = millis(); @@ -920,7 +922,9 @@ void RadioLibWrapper::serviceProfileScan() { // values from two frequencies are never blended into one estimate. _noise_floor_valid = false; _noise_floor_secondary_valid = false; +#if MESH_ENABLE_TELEMETRY_HISTORY _nf_published_valid = 0; +#endif _nf_refresh_requested = true; _nf_last_calib = 0; _nf_calib_deadline = 0; @@ -966,7 +970,9 @@ void RadioLibWrapper::serviceProfileScan() { // the first visit on the replacement tuples. _noise_floor_valid = false; _noise_floor_secondary_valid = false; +#if MESH_ENABLE_TELEMETRY_HISTORY _nf_published_valid = 0; +#endif _nf_refresh_requested = true; _nf_last_calib = 0; _nf_calib_deadline = 0; @@ -1265,7 +1271,9 @@ void RadioLibWrapper::recalibrateNoiseFloor() { // available while discarding the old samples and rise-hold history. _noise_floor_valid = false; _noise_floor_secondary_valid = false; +#if MESH_ENABLE_TELEMETRY_HISTORY _nf_published_valid = 0; +#endif _nf_refresh_requested = true; _nf_last_calib = 0; _nf_lazy_refresh = _nf_refresh_attempted = false; @@ -2083,17 +2091,21 @@ void RadioLibWrapper::loop() { && _secondary_floor_estimator.complete()) { if (_floor_estimator.publish(_noise_floor_centi_dbm, _noise_floor_valid)) { _noise_floor_valid = true; +#if MESH_ENABLE_TELEMETRY_HISTORY _nf_published_at[0] = static_cast(now); _nf_published_generation[0] = _profiles.generation[0]; _nf_published_valid |= 1U; +#endif _noise_floor = (_noise_floor_centi_dbm - 50) / 100; } if (_secondary_floor_estimator.publish(_noise_floor_secondary_centi_dbm, _noise_floor_secondary_valid)) { _noise_floor_secondary_valid = true; +#if MESH_ENABLE_TELEMETRY_HISTORY _nf_published_at[1] = static_cast(now); _nf_published_generation[1] = _profiles.generation[1]; _nf_published_valid |= 2U; +#endif } _nf_refresh_requested = false; _nf_last_calib = now; @@ -2153,9 +2165,11 @@ void RadioLibWrapper::loop() { _nf_lazy_refresh = _floor_estimator.publish(_noise_floor_centi_dbm, _noise_floor_valid); if (_nf_lazy_refresh) { _noise_floor_valid = true; +#if MESH_ENABLE_TELEMETRY_HISTORY _nf_published_at[0] = static_cast(now); _nf_published_generation[0] = _profiles.generation[0]; _nf_published_valid |= 1U; +#endif // Retain the whole-dB API/wire format and the fractional display value. _noise_floor = (_noise_floor_centi_dbm - 50) / 100; } diff --git a/src/helpers/radiolib/RadioLibWrappers.h b/src/helpers/radiolib/RadioLibWrappers.h index 5c9e2631e..d7fe89457 100644 --- a/src/helpers/radiolib/RadioLibWrappers.h +++ b/src/helpers/radiolib/RadioLibWrappers.h @@ -1,6 +1,7 @@ #pragma once #include "NoiseFloorEstimator.h" +#include "../TelemetryHistoryConfig.h" #include "../CarrierTools.h" #include @@ -56,9 +57,11 @@ protected: uint32_t _cad_scan_timeout_override_ms; bool _noise_floor_valid; bool _noise_floor_secondary_valid = false; +#if MESH_ENABLE_TELEMETRY_HISTORY uint32_t _nf_published_at[2] = {}; uint32_t _nf_published_generation[2] = {}; uint8_t _nf_published_valid = 0; +#endif bool _nf_refresh_requested; NoiseFloorEstimator _floor_estimator; NoiseFloorEstimator _secondary_floor_estimator; @@ -555,6 +558,7 @@ public: } return getNoiseFloorDbm(); } +#if MESH_ENABLE_TELEMETRY_HISTORY bool getNoiseFloorReading(uint8_t profile, float& dbm, uint32_t& published_at_ms) const override { if (profile > 1 || (profile == 1 && !_profiles.enabled()) @@ -566,6 +570,7 @@ public: return true; } void requestNoiseFloorMeasurement() override { requestNoiseFloorRefresh(); } +#endif float getNoiseFloorCalibrationSecondsRemaining() const override { const float primary = profileNoiseFloorSecondsRemaining(0); if (!_profiles.enabled()) return primary; diff --git a/test/test_flood_advert_limiter/test_flood_advert_limiter.cpp b/test/test_flood_advert_limiter/test_flood_advert_limiter.cpp index 9c8840b22..6506fb47c 100644 --- a/test/test_flood_advert_limiter/test_flood_advert_limiter.cpp +++ b/test/test_flood_advert_limiter/test_flood_advert_limiter.cpp @@ -45,7 +45,45 @@ TEST_F(FloodAdvertLimit, EveryHopAllowanceAndSaturation) { EXPECT_EQ(Decision::Quota, receive(expected[hops], hops, 0)); } EXPECT_EQ(2, Limiter::allowance(63)); - EXPECT_EQ(144U, sizeof(Limiter::Entry)); + EXPECT_EQ(140U, sizeof(Limiter::Entry)); +} + +TEST(FloodAdvertPacking, EveryFlagCombinationAndCountRetainsAllHistoryFields) { + Limiter::Entry entry{}; + memset(entry.key, 0xa5, sizeof(entry.key)); + memset(entry.hashes, 0x5a, sizeof(entry.hashes)); + entry.window_start = UINT32_MAX; + entry.last_violation = UINT32_MAX - 1; + entry.last_forwarded = UINT32_MAX - 2; + entry.last_heard = UINT32_MAX - 3; + entry.forwarded = uint16_t((1U << Limiter::HASH_SLOTS) - 1U); + entry.min_hops = 255; + for (uint8_t count = 0; count <= Limiter::HASH_SLOTS; ++count) { + for (uint8_t flags = 0; flags < 16; ++flags) { + entry.flags = flags; + entry.count = count; + EXPECT_EQ(flags, entry.flags); + EXPECT_EQ(count, entry.count); + entry.flags ^= 15; + EXPECT_EQ(uint8_t(flags ^ 15), entry.flags); + EXPECT_EQ(count, entry.count); + entry.flags &= ~8; + entry.flags |= 8; + EXPECT_EQ(uint8_t((flags ^ 15) | 8), entry.flags); + EXPECT_EQ(count, entry.count); + } + } + EXPECT_EQ(UINT32_MAX, entry.window_start); + EXPECT_EQ(UINT32_MAX - 1, entry.last_violation); + EXPECT_EQ(UINT32_MAX - 2, entry.last_forwarded); + EXPECT_EQ(UINT32_MAX - 3, entry.last_heard); + EXPECT_EQ(2047, entry.forwarded); + EXPECT_EQ(255, entry.min_hops); + for (uint8_t byte : entry.key) EXPECT_EQ(0xa5, byte); + for (const auto& hash : entry.hashes) for (uint8_t byte : hash) EXPECT_EQ(0x5a, byte); + EXPECT_EQ(4U, alignof(Limiter::Entry)); + EXPECT_EQ(140U * 128U, sizeof(Limiter::Entry[128])); + EXPECT_EQ(140U * 96U, sizeof(Limiter::Entry[96])); } TEST_F(FloodAdvertLimit, PrefixIsSixBytesAndCollisionsShareQuota) { diff --git a/test/test_noise_floor_readings.py b/test/test_noise_floor_readings.py index cb9189378..e2c881f11 100644 --- a/test/test_noise_floor_readings.py +++ b/test/test_noise_floor_readings.py @@ -2,6 +2,7 @@ from pathlib import Path import os +import re import subprocess import sys import tempfile @@ -183,6 +184,39 @@ int main(int argc, char** argv) { } ''' +DISABLED_FIXTURE = r''' +#include +template struct HasPublicationState:std::false_type {}; +template struct HasPublicationState>:std::true_type {}; +static_assert(!HasPublicationState::value, + "disabled history must not reserve publication timestamp RAM"); +static_assert(!std::is_polymorphic::value && sizeof(PublicRadio)==1, + "disabled defaults must not add radio vtable slots"); +static_assert(std::is_same::value, + "disabled history must inherit the unsupported reading API"); +static_assert(std::is_same::value, + "disabled history must inherit the no-op request API"); +int main() { + RadioLibWrapper w; + w._noise_floor_valid=false; + for (unsigned i=0;i", "#include \n#include ") harness = harness.replace("bool serviceCarrierWave() { return false; }", "bool _morse_owned = false, _morse_rx_owned = false, _beacon_owned = false;\n" @@ -206,22 +252,29 @@ class NoiseFloorReadingTests(unittest.TestCase): "#define MESH_ENABLE_TX_BEACONS 1\n#define MESH_ENABLE_CARRIER_TOOLS 1\n" + loop + "\n#undef MESH_ENABLE_TX_BEACONS\n#undef MESH_ENABLE_CARRIER_TOOLS\n") fixture = FIXTURE.replace("@DEFAULT_GETTER@", method(dispatcher, - "virtual bool getNoiseFloorReading(")).replace("@DEFAULT_REQUEST@", method(dispatcher, - "virtual void requestNoiseFloorMeasurement(")) + "MESH_TELEMETRY_HISTORY_VIRTUAL bool getNoiseFloorReading(")) + fixture = fixture.replace("@DEFAULT_REQUEST@", method(dispatcher, + "MESH_TELEMETRY_HISTORY_VIRTUAL void requestNoiseFloorMeasurement(")) cls.binaries = {} flags = [] if not sys.platform.startswith("linux") else [ "-fsanitize=address,undefined", "-fno-sanitize-recover=all", "-fno-pie", "-no-pie"] - for family in ("sx1262", "other"): + variants = (("sx1262", ["-DUSE_SX1262=1"]), ("other", []), + ("stm32_opt_in", ["-DSTM32_PLATFORM=1", "-DMESH_ENABLE_TELEMETRY_HISTORY=1"]), + ("stm32_default", ["-DSTM32_PLATFORM=1"]), + ("explicit_off", ["-DMESH_ENABLE_TELEMETRY_HISTORY=0"])) + cls.disabled_binaries = {} + for family, defines in variants: + disabled = family in ("stm32_default", "explicit_off") cpp, binary = work / (family + ".cpp"), work / family - cpp.write_text((harness + fixture).replace("\u2014", "-"), encoding="ascii") + cpp.write_text((harness + (DISABLED_FIXTURE if disabled else fixture)) + .replace("\u2014", "-"), encoding="ascii") built = subprocess.run([os.environ.get("CXX", "g++"), "-std=c++17", "-O1", "-g", - "-Wall", "-Wextra", "-Werror", *flags, - *(["-DUSE_SX1262=1"] if family == "sx1262" else []), + "-Wall", "-Wextra", "-Werror", *flags, *defines, "-I", str(ROOT / "src"), str(cpp), "-o", str(binary)], capture_output=True, text=True, timeout=60) if built.returncode: raise AssertionError(built.stdout + built.stderr) - cls.binaries[family] = binary + (cls.disabled_binaries if disabled else cls.binaries)[family] = binary def run_case(self, scenario): for family, binary in self.binaries.items(): @@ -249,6 +302,13 @@ class NoiseFloorReadingTests(unittest.TestCase): def test_requests_join_collection_without_interrupting_radio_owners(self): self.run_case("request") + def test_disabled_history_omits_tracking_and_keeps_ordinary_calibration(self): + for family, binary in self.disabled_binaries.items(): + with self.subTest(family=family): + result = subprocess.run([str(binary)], capture_output=True, text=True, timeout=20) + self.assertEqual(result.returncode, 0, result.stdout + result.stderr) + self.assertIn("PASS: disabled", result.stdout) + if __name__ == "__main__": unittest.main() diff --git a/test/test_radio_receive_contract.py b/test/test_radio_receive_contract.py index 50653bbd0..688a4ca9f 100644 --- a/test/test_radio_receive_contract.py +++ b/test/test_radio_receive_contract.py @@ -24,6 +24,7 @@ HARNESS = r''' #include #include #include +#include #define STATE_IDLE 0 #define STATE_RX 1 #define STATE_TX_WAIT 3 diff --git a/test/test_repeater_radio_timing_integration.py b/test/test_repeater_radio_timing_integration.py index deae5034d..5869fc4df 100644 --- a/test/test_repeater_radio_timing_integration.py +++ b/test/test_repeater_radio_timing_integration.py @@ -19,6 +19,11 @@ def method(text, signature): return text[start:end] +SCHEDULED_SETTING = method( + (ROOT / "examples/simple_repeater/MyMesh.h").read_text(encoding="utf-8"), + "struct ScheduledRadioSetting {") + ";" + + HARNESS = r''' #include #include @@ -106,14 +111,7 @@ struct Radio { uint32_t last_rx = 0; uint32_t getLastRecvMillis() { return last_ // separate Morse loop-policy suite executes the real ownership predicate. namespace mesh { bool morseTimingActive(const Radio*) { return false; } } struct Barrier { bool held = false; bool waiting() const { return held; } void clear() { held = false; } }; -struct ScheduledRadioSetting { - bool active = false, temporary = false, started = false; - float freq = 0, bw = 0; - uint8_t sf = 0, cr = 0; - uint16_t preamble = 0; - uint32_t start_time = 0, end_time = 0; - uint64_t hard_end_uptime_millis = 0; -}; +@SCHEDULED_SETTING@ class MyMesh { public: RadioPrefs _prefs; @@ -128,7 +126,7 @@ public: bool radio_reply_secondary = false; mesh::RxInactivityWatchdog rx_inactivity_watchdog; mesh::RepeaterRadioTiming radio_timing; - ScheduledRadioSetting scheduled_radio_settings[MAX_SCHEDULED_RADIO_SETTINGS]; + ScheduledRadioSetting scheduled_radio_settings[MAX_SCHEDULED_RADIO_SETTINGS]{}; uint64_t uptime_millis = 1; uint32_t last_millis = 1; uint32_t next_local_advert = 0, next_flood_advert = 0; @@ -456,6 +454,7 @@ int main() { puts("Production scheduler, storage-backoff, watchdog and advert scenarios passed"); } ''' +HARNESS = HARNESS.replace("@SCHEDULED_SETTING@", SCHEDULED_SETTING) CLI_HARNESS = r''' #include @@ -531,6 +530,41 @@ class RepeaterRadioTimingIntegrationTest(unittest.TestCase): str(cpp), "-o", str(exe)], check=True) subprocess.run([str(exe)], check=True) + def test_actual_schedule_rows_are_32_bytes_with_aligned_full_width_fields(self): + self.compile_and_run(r''' +#include +#include +#include +#include +@SETTING@ +static_assert(sizeof(ScheduledRadioSetting) == 32, "schedule padding increased"); +static_assert(alignof(ScheduledRadioSetting) >= alignof(uint64_t), "unaligned deadline"); +static_assert(offsetof(ScheduledRadioSetting, hard_end_uptime_millis) == 0, "deadline moved"); +static_assert(offsetof(ScheduledRadioSetting, freq) % alignof(float) == 0, "unaligned frequency"); +static_assert(offsetof(ScheduledRadioSetting, bw) % alignof(float) == 0, "unaligned bandwidth"); +static_assert(offsetof(ScheduledRadioSetting, start_time) % alignof(uint32_t) == 0, "unaligned start"); +static_assert(offsetof(ScheduledRadioSetting, end_time) % alignof(uint32_t) == 0, "unaligned end"); +static_assert(offsetof(ScheduledRadioSetting, preamble) % alignof(uint16_t) == 0, "unaligned preamble"); +static_assert(std::is_standard_layout::value, "schedule layout changed"); +static_assert(std::is_trivially_copyable::value, "schedule copies changed"); +int main() { + ScheduledRadioSetting rows[6]{}; + static_assert(sizeof(rows) == 192, "all six schedules must retain their capacity"); + assert(rows[0].preamble == 0 && !rows[0].active && !rows[0].temporary && !rows[0].started); + rows[0].hard_end_uptime_millis = 0xFEDCBA9876543210ULL; + rows[0].freq = 911.150f; rows[0].bw = 250; + rows[0].start_time = 0xFFFFFFFEUL; rows[0].end_time = 0xFFFFFFFFUL; + rows[0].preamble = 65535; rows[0].sf = 12; rows[0].cr = 8; + rows[0].active = rows[0].temporary = rows[0].started = true; + rows[5] = rows[0]; + assert(rows[5].hard_end_uptime_millis == 0xFEDCBA9876543210ULL); + assert(rows[5].freq == 911.150f && rows[5].bw == 250); + assert(rows[5].start_time == 0xFFFFFFFEUL && rows[5].end_time == 0xFFFFFFFFUL); + assert(rows[5].preamble == 65535 && rows[5].sf == 12 && rows[5].cr == 8); + assert(rows[5].active && rows[5].temporary && rows[5].started); +} +'''.replace("@SETTING@", SCHEDULED_SETTING)) + def test_production_scheduler_and_services(self): source = (ROOT / "examples/simple_repeater/MyMesh.cpp").read_text(encoding="utf-8") signatures = [ diff --git a/test/test_solarxiao_room.py b/test/test_solarxiao_room.py index 1dddc4e98..1d6ad0a4c 100644 --- a/test/test_solarxiao_room.py +++ b/test/test_solarxiao_room.py @@ -372,7 +372,9 @@ class SolarXiaoRoomTests(unittest.TestCase): settings = setup[start:setup.index("#ifdef DISPLAY_CLASS", start)] start = loop.index("mesh::power::serviceRegulatorSettings();") periodic = loop[start:loop.index("board.loop();", start) + len("board.loop();")] - history = conditional_block((ROOM / "MyMesh.h").read_text(), "#ifndef MESH_ENABLE_TELEMETRY_HISTORY") + self.assertIn("#include ", (ROOM / "MyMesh.h").read_text()) + history = conditional_block((ROOT / "src/helpers/TelemetryHistoryConfig.h").read_text(), + "#ifndef MESH_ENABLE_TELEMETRY_HISTORY") self.assertLess(setup.index("board.begin()"), setup.index("mesh::solar::beginSettings")) self.assertLess(setup.index("mesh::solar::beginSettings"), setup.index("sensors.begin()")) self.assertLess(setup.index("mesh::solar::beginSettings"), setup.index("radio_init()"))