Refactor LoRa airtime tests and add new functionality

- Updated LoRa airtime calculations in `lora_airtime_test.dart` to reflect new reference values.
- Introduced new tests for LDRO behavior and preamble symbol calculations.
- Added `contact_path_width_test.dart` to validate path hash width handling in contacts.
- Enhanced `model_changes_test.dart` to ensure legacy data migration works correctly.
- Created `remote_node_stats_test.dart` to decode and validate remote node statistics.
- Implemented `map_marker_parse_test.dart` for parsing marker text with coordinate validation.
- Developed `map_tile_cache_key_test.dart` to ensure API keys are excluded from cache keys.
- Added `message_retry_failure_test.dart` to test message retry service behavior on failures.
- Extended `path_history_service_test.dart` to preserve learned state across path attempts.
- Enhanced `received_image_store_test.dart` to handle concurrent writes and review fixes.
- Implemented `repeater_command_service_test.dart` to validate command response handling.
- Created `store_tolerant_parsing_test.dart` to ensure stores skip malformed records gracefully.
- Cleared untranslated JSON file for localization updates.
This commit is contained in:
Zach committed 2026-09-25 10:01:18 -07:00
1 parent d5f54dfa11
commit d74587c167
105 files changed
+6419 -2072

No files matched your search

+14 -7
View File
@@ -55,11 +55,12 @@ const int kMeshCoreMaxTransUnit = 255;
/// (it would compute CR 4/9..4/12), and passing a 1..4 value to
/// [loraTimeOnAir] trips its assert in debug and understates airtime in
/// release. Always normalise at the boundary.
/// * **Low-data-rate optimise.** `calculateLoRaAirtime()` takes `DE` as a
/// parameter and its one caller passes the `sf >= 11` shortcut, which is
/// wrong for SF11/BW250 and SF12/BW500 (Tsym is 8.192 ms there, below the
/// 16 ms threshold). This file derives `DE` from `Tsym > 16 ms`, per the
/// datasheet. See the LDRO tests in `test/lora_airtime_test.dart`.
/// * **Low-data-rate optimise.** `DE` is derived from `Tsym > 16 ms` (the
/// RadioLib rule), not the `sf >= 11` shortcut, which is wrong for
/// SF11/BW250 and SF12/BW500 (Tsym is 8.192 ms there). See the LDRO tests
/// in `test/lora_airtime_test.dart`.
/// * **Preamble.** Defaults to the firmware's per-SF length, see
/// [meshCorePreambleSymbols].
/// * **Precision and guards.** `calculateLoRaAirtime()` returns whole
/// milliseconds and will throw `Unsupported operation: Infinity or NaN
/// toInt` on `sf == 0` / `bw == 0`, which a half-initialised device does
@@ -88,7 +89,7 @@ Duration loraTimeOnAir({
required int spreadingFactor,
required int bandwidthHz,
required int codingRate,
int preambleSymbols = 8,
int? preambleSymbols,
bool crc = true,
bool explicitHeader = true,
}) {
@@ -114,12 +115,18 @@ Duration loraTimeOnAir({
0,
);
final preambleMs = (preambleSymbols + 4.25) * tsymMs;
final preamble = preambleSymbols ?? meshCorePreambleSymbols(sf);
final preambleMs = (preamble + 4.25) * tsymMs;
final payloadMs = (8 + payloadSymbols) * tsymMs;
return Duration(microseconds: ((preambleMs + payloadMs) * 1000).round());
}
/// Preamble length MeshCore firmware configures for [spreadingFactor]
/// (`RadioLibWrapper::preambleLengthForSF`): 32 symbols up to SF8, 16 above.
int meshCorePreambleSymbols(int spreadingFactor) =>
spreadingFactor <= 8 ? 32 : 16;
/// Normalises a raw firmware coding rate into the 5..8 domain used by
/// [loraTimeOnAir] and [LoRaCodingRate.value]. Some firmwares report 1..4.
int normalizeCodingRate(int deviceCodingRate) =>