Make RXPS preamble adaptive for fast radio settings
This commit is contained in:
1 parent
444df2969d
commit
e7433abb80
31 files changed
+1393
-242
No files matched your search
+1
-1
@@ -63,7 +63,7 @@ does not reflect the GoogleTest count -- run the built binary directly
|
||||
| `test_packet_manager` | `src/Packet.cpp`, `src/Dispatcher.cpp`, `src/helpers/StaticPoolPacketManager.cpp` | truncated-packet rejection, unavailable-radio behavior, scoped RX-delay replacement, queue/CAD scheduling, and staged radio/TX recovery |
|
||||
| `test_persistent_store_format` | `src/helpers/PersistentStoreFormat.h` | contact-page headers and CRCs, dirty-page state, stable slot allocation, and bounded resumable legacy migration across power loss |
|
||||
| `test_power_management` | `src/helpers/PowerManagementUtils.h` | median filtering of a brownout outlier and valid-reading requirements for the boot lock |
|
||||
| `test_rx_power_saving` | `src/helpers/radiolib/RXPowerSaving.h` | level-derived timing, automatic level/preamble selection, equivalent SF7/BW500, SF6/BW250, and SF5/BW125 profiles, SF5/BW62.5 with preamble 16, normal-preamble SF5/BW250/BW500 continuous-RX fallback, opt-in 64-symbol SF5/BW250 level-8 timing, automatic duty-cycle resume, and SX1262 TCXO timing thresholds |
|
||||
| `test_rx_power_saving` | `src/helpers/radiolib/RXPowerSaving.h` | level-derived timing, tuple-selected 32/64/128-symbol wire preambles, equivalent SF7/BW500, SF6/BW250, and SF5/BW125 profiles, SF5/BW250 and SF6/BW500 level-8/64 timing, SF5/BW500 level-8/128 timing, SF5/BW62.5 with a 16-symbol timing assumption, automatic retuning, and SX1262 TCXO timing thresholds |
|
||||
| `test_region_names` | `src/helpers/RegionNameUtils.h` | canonical public-region markers while preserving distinct private and differently named regions |
|
||||
| `test_routing_policy` | `src/helpers/RoutingPolicy.h` | scoped/unscoped flood hop limits and selection of direct, path-return, mirrored-scope, default-scope, or unscoped replies |
|
||||
| `test_rs232_uart` | `src/helpers/bridges/RS232UartUtils.h` | stopping the active UART peripheral before reassigning its pins |
|
||||
|
||||
@@ -12,29 +12,41 @@ TEST(RxPowerSaving, BalancedNormalProfileKeepsDerivedDutyCycle) {
|
||||
EXPECT_FALSE(rxPowerSavingUsesContinuousFallback(rx_us, sleep_us));
|
||||
}
|
||||
|
||||
TEST(RxPowerSaving, Sf5Bw500FallsBackToContinuousReceive) {
|
||||
TEST(RxPowerSaving, Sf5Bw500UsesPreamble128) {
|
||||
uint32_t rx_us = 0;
|
||||
uint32_t sleep_us = 0;
|
||||
uint8_t effective_level = 0;
|
||||
uint8_t effective_preamble = 0;
|
||||
|
||||
ASSERT_TRUE(recalcRxPowerSavingFromLevel(5, 5, 500.0f, 16,
|
||||
&rx_us, &sleep_us));
|
||||
EXPECT_EQ(RX_POWERSAVING_CONTINUOUS_FALLBACK_US, rx_us);
|
||||
EXPECT_EQ(RX_POWERSAVING_CONTINUOUS_FALLBACK_US, sleep_us);
|
||||
EXPECT_TRUE(rxPowerSavingUsesContinuousFallback(rx_us, sleep_us));
|
||||
&rx_us, &sleep_us,
|
||||
&effective_level,
|
||||
&effective_preamble));
|
||||
EXPECT_EQ(5U, effective_level);
|
||||
EXPECT_EQ(128U, effective_preamble);
|
||||
EXPECT_FALSE(rxPowerSavingUsesContinuousFallback(rx_us, sleep_us));
|
||||
}
|
||||
|
||||
TEST(RxPowerSaving, ReturningToSlowerProfileResumesDutyCycle) {
|
||||
TEST(RxPowerSaving, ReturningToSlowerProfileRestoresSmallerPreambleTiming) {
|
||||
uint32_t rx_us = 0;
|
||||
uint32_t sleep_us = 0;
|
||||
uint8_t effective_level = 0;
|
||||
uint8_t effective_preamble = 0;
|
||||
|
||||
ASSERT_TRUE(recalcRxPowerSavingFromLevel(5, 5, 500.0f, 16,
|
||||
&rx_us, &sleep_us));
|
||||
ASSERT_TRUE(rxPowerSavingUsesContinuousFallback(rx_us, sleep_us));
|
||||
&rx_us, &sleep_us,
|
||||
&effective_level,
|
||||
&effective_preamble));
|
||||
ASSERT_EQ(128U, effective_preamble);
|
||||
|
||||
ASSERT_TRUE(recalcRxPowerSavingFromLevel(5, 9, 500.0f, 16,
|
||||
&rx_us, &sleep_us));
|
||||
&rx_us, &sleep_us,
|
||||
&effective_level,
|
||||
&effective_preamble));
|
||||
EXPECT_EQ(10468U, rx_us);
|
||||
EXPECT_EQ(6712U, sleep_us);
|
||||
EXPECT_EQ(5U, effective_level);
|
||||
EXPECT_EQ(16U, effective_preamble);
|
||||
EXPECT_FALSE(rxPowerSavingUsesContinuousFallback(rx_us, sleep_us));
|
||||
}
|
||||
|
||||
@@ -54,6 +66,19 @@ TEST(RxPowerSaving, TcxoThresholdSeparatesFastestUsableProfiles) {
|
||||
rx_us, sleep_us, sx1262_tcxo_transition_us));
|
||||
}
|
||||
|
||||
TEST(RxPowerSaving, WirePreambleUses64OnlyWhen32CannotEnableRxps) {
|
||||
EXPECT_EQ(32U, rxPowerSavingPreambleForParams(7, 500.0f));
|
||||
EXPECT_EQ(32U, rxPowerSavingPreambleForParams(6, 250.0f));
|
||||
EXPECT_EQ(32U, rxPowerSavingPreambleForParams(5, 125.0f));
|
||||
EXPECT_EQ(32U, rxPowerSavingPreambleForParams(5, 62.5f));
|
||||
|
||||
EXPECT_EQ(64U, rxPowerSavingPreambleForParams(5, 250.0f));
|
||||
EXPECT_EQ(64U, rxPowerSavingPreambleForParams(6, 500.0f));
|
||||
|
||||
EXPECT_EQ(128U, rxPowerSavingPreambleForParams(5, 500.0f));
|
||||
EXPECT_EQ(16U, rxPowerSavingPreambleForParams(9, 500.0f));
|
||||
}
|
||||
|
||||
TEST(RxPowerSaving, RequestedLevelIsRaisedOnlyToRequiredMinimum) {
|
||||
constexpr uint32_t sx1262_tcxo_transition_us = 6000;
|
||||
uint32_t rx_us = 0;
|
||||
@@ -64,8 +89,8 @@ TEST(RxPowerSaving, RequestedLevelIsRaisedOnlyToRequiredMinimum) {
|
||||
ASSERT_TRUE(calcRxPowerSavingLevelAtOrAbove(
|
||||
1, 7, 500.0f, 16, sx1262_tcxo_transition_us,
|
||||
&rx_us, &sleep_us, &effective_level, &effective_preamble));
|
||||
EXPECT_EQ(LORA_FAST_PREAMBLE == 64 ? 3U : 7U, effective_level);
|
||||
EXPECT_EQ((uint8_t)LORA_FAST_PREAMBLE, effective_preamble);
|
||||
EXPECT_EQ(7U, effective_level);
|
||||
EXPECT_EQ(32U, effective_preamble);
|
||||
EXPECT_TRUE(canStartRxPowerSavingDutyCycle(
|
||||
rx_us, sleep_us, sx1262_tcxo_transition_us));
|
||||
|
||||
@@ -73,12 +98,12 @@ TEST(RxPowerSaving, RequestedLevelIsRaisedOnlyToRequiredMinimum) {
|
||||
8, 7, 500.0f, 16, sx1262_tcxo_transition_us,
|
||||
&rx_us, &sleep_us, &effective_level, &effective_preamble));
|
||||
EXPECT_EQ(8U, effective_level);
|
||||
EXPECT_EQ((uint8_t)LORA_FAST_PREAMBLE, effective_preamble);
|
||||
EXPECT_EQ(32U, effective_preamble);
|
||||
EXPECT_TRUE(canStartRxPowerSavingDutyCycle(
|
||||
rx_us, sleep_us, sx1262_tcxo_transition_us));
|
||||
}
|
||||
|
||||
TEST(RxPowerSaving, Sf5Bw500StillFallsBackWithPreamble32) {
|
||||
TEST(RxPowerSaving, Sf5Bw500UsesPreamble128AtEffectiveLevel8) {
|
||||
constexpr uint32_t sx1262_tcxo_transition_us = 6000;
|
||||
uint32_t rx_us = 0;
|
||||
uint32_t sleep_us = 0;
|
||||
@@ -88,9 +113,13 @@ TEST(RxPowerSaving, Sf5Bw500StillFallsBackWithPreamble32) {
|
||||
ASSERT_TRUE(calcRxPowerSavingLevelAtOrAbove(
|
||||
1, 5, 500.0f, 16, sx1262_tcxo_transition_us,
|
||||
&rx_us, &sleep_us, &effective_level, &effective_preamble));
|
||||
EXPECT_EQ(0U, effective_level);
|
||||
EXPECT_EQ(0U, effective_preamble);
|
||||
EXPECT_TRUE(rxPowerSavingUsesContinuousFallback(rx_us, sleep_us));
|
||||
EXPECT_EQ(8U, effective_level);
|
||||
EXPECT_EQ(128U, effective_preamble);
|
||||
EXPECT_EQ(626U, rx_us);
|
||||
EXPECT_EQ(6398U, sleep_us);
|
||||
EXPECT_TRUE(canStartRxPowerSavingDutyCycle(
|
||||
rx_us, sleep_us, sx1262_tcxo_transition_us));
|
||||
EXPECT_FALSE(rxPowerSavingUsesContinuousFallback(rx_us, sleep_us));
|
||||
}
|
||||
|
||||
TEST(RxPowerSaving, Sf5Bw250NeedsLongerTransmittedPreambleOnTcxoRadio) {
|
||||
@@ -110,19 +139,13 @@ TEST(RxPowerSaving, Sf5Bw250NeedsLongerTransmittedPreambleOnTcxoRadio) {
|
||||
rx_us, sleep_us, sx1262_tcxo_transition_us));
|
||||
|
||||
ASSERT_TRUE(calcRxPowerSavingLevelAtOrAbove(
|
||||
1, 5, 250.0f, 16, sx1262_tcxo_transition_us,
|
||||
8, 5, 250.0f, 32, sx1262_tcxo_transition_us,
|
||||
&rx_us, &sleep_us, &effective_level, &effective_preamble));
|
||||
#if LORA_FAST_PREAMBLE == 64
|
||||
EXPECT_EQ(8U, effective_level);
|
||||
EXPECT_EQ(64U, effective_preamble);
|
||||
EXPECT_EQ(1252U, rx_us);
|
||||
EXPECT_EQ(6424U, sleep_us);
|
||||
EXPECT_FALSE(rxPowerSavingUsesContinuousFallback(rx_us, sleep_us));
|
||||
#else
|
||||
EXPECT_EQ(0U, effective_level);
|
||||
EXPECT_EQ(0U, effective_preamble);
|
||||
EXPECT_TRUE(rxPowerSavingUsesContinuousFallback(rx_us, sleep_us));
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST(RxPowerSaving, Sf5Bw250UsesPreamble64AtEffectiveLevel8) {
|
||||
@@ -143,8 +166,7 @@ TEST(RxPowerSaving, Sf5Bw250UsesPreamble64AtEffectiveLevel8) {
|
||||
rx_us, sleep_us, sx1262_tcxo_transition_us));
|
||||
}
|
||||
|
||||
#if LORA_FAST_PREAMBLE == 64
|
||||
TEST(RxPowerSaving, FastPreamble64BuildSelectsItAutomatically) {
|
||||
TEST(RxPowerSaving, Sf5Bw250SelectorUsesPreamble64Automatically) {
|
||||
constexpr uint32_t sx1262_tcxo_transition_us = 6000;
|
||||
uint32_t rx_us = 0;
|
||||
uint32_t sleep_us = 0;
|
||||
@@ -159,9 +181,8 @@ TEST(RxPowerSaving, FastPreamble64BuildSelectsItAutomatically) {
|
||||
EXPECT_EQ(1252U, rx_us);
|
||||
EXPECT_EQ(6424U, sleep_us);
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST(RxPowerSaving, Sf5Bw125UsesPreamble32AtEffectiveLevel7) {
|
||||
TEST(RxPowerSaving, Sf5Bw125KeepsPreamble32) {
|
||||
constexpr uint32_t sx1262_tcxo_transition_us = 6000;
|
||||
uint32_t rx_us = 0;
|
||||
uint32_t sleep_us = 0;
|
||||
@@ -171,20 +192,43 @@ TEST(RxPowerSaving, Sf5Bw125UsesPreamble32AtEffectiveLevel7) {
|
||||
ASSERT_TRUE(calcRxPowerSavingLevelAtOrAbove(
|
||||
1, 5, 125.0f, 16, sx1262_tcxo_transition_us,
|
||||
&rx_us, &sleep_us, &effective_level, &effective_preamble));
|
||||
EXPECT_EQ(LORA_FAST_PREAMBLE == 64 ? 3U : 7U, effective_level);
|
||||
EXPECT_EQ((uint8_t)LORA_FAST_PREAMBLE, effective_preamble);
|
||||
#if LORA_FAST_PREAMBLE == 64
|
||||
EXPECT_EQ(3641U, rx_us);
|
||||
EXPECT_EQ(6414U, sleep_us);
|
||||
#else
|
||||
EXPECT_EQ(7U, effective_level);
|
||||
EXPECT_EQ(32U, effective_preamble);
|
||||
EXPECT_EQ(2731U, rx_us);
|
||||
EXPECT_EQ(6101U, sleep_us);
|
||||
#endif
|
||||
EXPECT_TRUE(canStartRxPowerSavingDutyCycle(
|
||||
rx_us, sleep_us, sx1262_tcxo_transition_us));
|
||||
}
|
||||
|
||||
TEST(RxPowerSaving, Sf6Bw250UsesPreamble32AtEffectiveLevel7) {
|
||||
TEST(RxPowerSaving, EquivalentFastProfilesSupportExplicitPreamble32Level7) {
|
||||
constexpr uint32_t sx1262_tcxo_transition_us = 6000;
|
||||
uint32_t rx_us = 0;
|
||||
uint32_t sleep_us = 0;
|
||||
uint8_t effective_level = 0;
|
||||
uint8_t effective_preamble = 0;
|
||||
|
||||
ASSERT_TRUE(calcRxPowerSavingLevelAtOrAbove(
|
||||
7, 7, 500.0f, 32, sx1262_tcxo_transition_us,
|
||||
&rx_us, &sleep_us, &effective_level, &effective_preamble));
|
||||
EXPECT_EQ(7U, effective_level);
|
||||
EXPECT_EQ(32U, effective_preamble);
|
||||
EXPECT_EQ(2731U, rx_us);
|
||||
EXPECT_EQ(6101U, sleep_us);
|
||||
|
||||
ASSERT_TRUE(calcRxPowerSavingLevelAtOrAbove(
|
||||
7, 6, 250.0f, 32, sx1262_tcxo_transition_us,
|
||||
&rx_us, &sleep_us, &effective_level, &effective_preamble));
|
||||
EXPECT_EQ(7U, effective_level);
|
||||
EXPECT_EQ(32U, effective_preamble);
|
||||
|
||||
ASSERT_TRUE(calcRxPowerSavingLevelAtOrAbove(
|
||||
7, 5, 125.0f, 32, sx1262_tcxo_transition_us,
|
||||
&rx_us, &sleep_us, &effective_level, &effective_preamble));
|
||||
EXPECT_EQ(7U, effective_level);
|
||||
EXPECT_EQ(32U, effective_preamble);
|
||||
}
|
||||
|
||||
TEST(RxPowerSaving, Sf6Bw250KeepsPreamble32) {
|
||||
constexpr uint32_t sx1262_tcxo_transition_us = 6000;
|
||||
uint32_t rx_us = 0;
|
||||
uint32_t sleep_us = 0;
|
||||
@@ -194,15 +238,42 @@ TEST(RxPowerSaving, Sf6Bw250UsesPreamble32AtEffectiveLevel7) {
|
||||
ASSERT_TRUE(calcRxPowerSavingLevelAtOrAbove(
|
||||
1, 6, 250.0f, 16, sx1262_tcxo_transition_us,
|
||||
&rx_us, &sleep_us, &effective_level, &effective_preamble));
|
||||
EXPECT_EQ(LORA_FAST_PREAMBLE == 64 ? 3U : 7U, effective_level);
|
||||
EXPECT_EQ((uint8_t)LORA_FAST_PREAMBLE, effective_preamble);
|
||||
#if LORA_FAST_PREAMBLE == 64
|
||||
EXPECT_EQ(3641U, rx_us);
|
||||
EXPECT_EQ(6414U, sleep_us);
|
||||
#else
|
||||
EXPECT_EQ(7U, effective_level);
|
||||
EXPECT_EQ(32U, effective_preamble);
|
||||
EXPECT_EQ(2731U, rx_us);
|
||||
EXPECT_EQ(6101U, sleep_us);
|
||||
}
|
||||
|
||||
TEST(RxPowerSaving, Sf6Bw500UsesPreamble64WhenRequired) {
|
||||
constexpr uint32_t sx1262_tcxo_transition_us = 6000;
|
||||
uint32_t rx_us = 0;
|
||||
uint32_t sleep_us = 0;
|
||||
uint8_t effective_level = 0;
|
||||
uint8_t effective_preamble = 0;
|
||||
|
||||
ASSERT_TRUE(calcRxPowerSavingLevelAtOrAbove(
|
||||
1, 6, 500.0f, 16, sx1262_tcxo_transition_us,
|
||||
&rx_us, &sleep_us, &effective_level, &effective_preamble));
|
||||
EXPECT_EQ(8U, effective_level);
|
||||
EXPECT_EQ(64U, effective_preamble);
|
||||
EXPECT_EQ(1252U, rx_us);
|
||||
EXPECT_EQ(6424U, sleep_us);
|
||||
}
|
||||
|
||||
TEST(RxPowerSaving, TimingAssumptionCannotExceedWirePreamble) {
|
||||
constexpr uint32_t sx1262_tcxo_transition_us = 6000;
|
||||
uint32_t rx_us = 0;
|
||||
uint32_t sleep_us = 0;
|
||||
uint8_t effective_level = 0;
|
||||
uint8_t effective_preamble = 0;
|
||||
|
||||
ASSERT_TRUE(calcRxPowerSavingLevelAtOrAbove(
|
||||
1, 7, 500.0f, 64, sx1262_tcxo_transition_us,
|
||||
&rx_us, &sleep_us, &effective_level, &effective_preamble));
|
||||
EXPECT_EQ(7U, effective_level);
|
||||
EXPECT_EQ(32U, effective_preamble);
|
||||
EXPECT_EQ(2731U, rx_us);
|
||||
EXPECT_EQ(6101U, sleep_us);
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST(RxPowerSaving, Sf5Bw62Point5UsesPreamble16AtEffectiveLevel10) {
|
||||
|
||||
Reference in new issue
Block a user