From cab7034526f8e57d2ce94bb6b1f6fbb593fce97e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Labrosse?= Date: Thu, 19 Nov 2026 16:58:36 +0100 Subject: [PATCH 1/2] chore: drop the unread SENSOR_TYPE and OREGON_MODE_0 flags from native_debug SENSOR_ID and SENSOR_CHANNEL were already gone; no source reads these two. native_debug: 80/80 tests pass before and after. AVR environments untouched. Closes #57 Co-Authored-By: Claude Opus 5.5 --- emitter/platformio.ini | 2 -- 1 file changed, 2 deletions(-) diff --git a/emitter/platformio.ini b/emitter/platformio.ini index 58aaccd2..6a5052d4 100644 --- a/emitter/platformio.ini +++ b/emitter/platformio.ini @@ -43,8 +43,6 @@ build_type = debug debug_test = test_analogFiltering debug_build_flags = -O0 -ggdb3 -g3 build_flags = - -DSENSOR_TYPE="{0xEA, 0x4C}" - -DOREGON_MODE_0=1 -DSLEEP_TIME_IN_SECONDS=32 -DNATIVE -DBATTERY_VOLTAGE_X10_ID=0xA From e111bef0c943ea10860fd2c09953a2662db7b90a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Labrosse?= Date: Thu, 19 Nov 2026 17:00:08 +0100 Subject: [PATCH 2/2] test(FUNC-BATTERY-003): low-battery cycle sends only the environment frame, with the Oregon battery-low flag Runs on every native_cycle_* env (5/5 pass). Behaviour already in place (runCycle): this backfills the cycle-level test; a mutation with a nominal battery makes it fail (4 frames instead of 2). FUNC-X10-006/007 were already covered by the cycle sequence test. Closes #53 Co-Authored-By: Claude Opus 5.5 --- .../test/test_main_cycle/mainCycleTest.cpp | 33 +++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/emitter/test/test_main_cycle/mainCycleTest.cpp b/emitter/test/test_main_cycle/mainCycleTest.cpp index d84334d6..33e37c63 100644 --- a/emitter/test/test_main_cycle/mainCycleTest.cpp +++ b/emitter/test/test_main_cycle/mainCycleTest.cpp @@ -150,7 +150,8 @@ static int CountTransmissions(const std::vector &orders) { #if defined(EXPECT_ENVIRONMENT_FRAME) // Orders of one environment encoder Send(), without the LED/delay wrapper. -static std::vector EnvironmentFrameOrders() { +static std::vector EnvironmentFrameOrders( + bool lowBattery = false) { CycleSpyHal ref; Measurements m; m.SetTemperature(0); // native BMx280 stub values @@ -162,7 +163,7 @@ static std::vector EnvironmentFrameOrders() { #endif EnvironmentEncoder environment(&ref); ConfigureEncoder(environment); - ApplyMeasurements(environment, m, false); + ApplyMeasurements(environment, m, lowBattery); environment.Send(); return ref.Orders; } @@ -408,6 +409,32 @@ void Expect_i2c_derived_when_an_i2c_sensor_is_selected() { TEST_ASSERT_TRUE(!needsI2c || hasI2c); } +// @req FUNC-BATTERY-003 +void Expect_low_battery_cycle_sends_only_the_environment_frame_with_its_flag() { + // Given: VCC ~1.1 V and no battery reading, below LOW_BATTERY_VOLTAGE on + // every variant (battery = VCC or divided PA1 reading) + CycleSpyHal spy; + spy.rawInternal11ref = 1023; + spy.rawBattery = 0; + + // When + runCycle(&spy); + + // Then: no X10 meter frame, no luminosity frame, only the environment + // frame (with the battery-low flag on Oregon; Lacrosse has none) +#if defined(EXPECT_ENVIRONMENT_FRAME) + TEST_ASSERT_EQUAL_INT(ENVIRONMENT_FRAMES, CountTransmissions(spy.Orders)); + std::vector frame = EnvironmentFrameOrders(true); + TEST_ASSERT_TRUE(std::search(spy.Orders.begin(), spy.Orders.end(), + frame.begin(), frame.end()) != spy.Orders.end()); +#if defined(USE_OREGON) + TEST_ASSERT_FALSE(frame == EnvironmentFrameOrders(false)); +#endif +#else + TEST_ASSERT_EQUAL_INT(0, CountTransmissions(spy.Orders)); +#endif +} + void setUp() {} void tearDown() {} @@ -424,6 +451,8 @@ int main(int, char **) { RUN_TEST(Expect_environment_frame_sent_twice_with_a_silence_one_frame_long); #endif RUN_TEST(Expect_i2c_derived_when_an_i2c_sensor_is_selected); + RUN_TEST( + Expect_low_battery_cycle_sends_only_the_environment_frame_with_its_flag); return UNITY_END(); }