Ken Van Hoeylandt 56ddd4b355
Mesh Chat apps, ESP-NOW mesh radio, and shared Wi-Fi radio ownership (#698)
Mesh gets contacts, channels, delivery receipts, QR sharing and an ESP-NOW radio. Mesh Chat is split into Mesh Contacts and Mesh Channels, `mesh inspect` replaces the Mesh Inspect app, and ESP-NOW and Wi-Fi now share the Wi-Fi radio safely.
2026-10-17 18:56:27 +02:00

33 lines
1.1 KiB
C++

#include "doctest.h"
#include <mesh/mesh_airtime.h>
TEST_CASE("LoRa airtime matches the Semtech calculator") {
// SF11, 250 kHz, CR 4/5, preamble 16, 32 byte payload: 477.2 ms
const MeshRadioProfile profile = {
.modulation = RADIO_MODULATION_LORA,
.frequency = 869525000,
.bandwidth = 250000,
.spreading_factor = 11,
.coding_rate = 5,
.sync_word = 0x2B,
.preamble_length = 16,
.power = 14,
};
const uint32_t airtime = mesh_airtime_estimate_ms(profile, 32);
CHECK_EQ(airtime, 478);
}
TEST_CASE("Duty cycle depends on region and sub-band") {
CHECK_EQ(mesh_airtime_duty_cycle_percent(RADIO_REGION_EU_868, 869525000), 10);
CHECK_EQ(mesh_airtime_duty_cycle_percent(RADIO_REGION_EU_868, 868100000), 1);
CHECK_EQ(mesh_airtime_duty_cycle_percent(RADIO_REGION_US_915, 906875000), 100);
}
TEST_CASE("ESP-NOW frames take milliseconds") {
MeshRadioProfile profile {};
profile.modulation = RADIO_MODULATION_ESPNOW;
// 100 bytes of headers and 100 bytes of payload at 0.5 Mbit/s
CHECK_EQ(mesh_airtime_estimate_ms(profile, 100), 4);
}