Use precise T1000-E dual-profile timing
This commit is contained in:
1 parent
960936183c
commit
d66b9336a9
11 files changed
+142
-74
No files matched your search
+25
-12
@@ -11,7 +11,7 @@ int main() {
|
||||
assert(Profiles::MinListenSymbols==4.6);
|
||||
assert(Profiles::SlowListenSymbols==4.6);
|
||||
assert(Profiles::MinFastListenSymbols==4.6);
|
||||
assert(Profiles::LoopBudgetUs==300);
|
||||
assert(Profiles::LoopBudgetUs==0);
|
||||
auto a=params(10,125),b=params(10,125);
|
||||
auto t=Profiles::calculateChirpTiming(a,b,1,0,1000,4000);
|
||||
assert(t.valid && t.slow==0 && t.symbol_us[0]==8192);
|
||||
@@ -31,9 +31,9 @@ int main() {
|
||||
b=params(10,1e-30f);assert(Profiles::minimumListenUs(b)==0);
|
||||
a=params(7,62.5);b=params(8,500);
|
||||
t=Profiles::calculateChirpTiming(a,b);
|
||||
assert(t.preamble[1]==88); // Existing measured acquisition floor retained.
|
||||
assert(t.preamble[1]==40); // Derived from dwell and acquisition, not a pair-specific floor.
|
||||
auto swapped=Profiles::calculateChirpTiming(b,a);
|
||||
assert(swapped.slow==1 && swapped.preamble[0]==88);
|
||||
assert(swapped.slow==1 && swapped.preamble[0]==40);
|
||||
assert(swapped.preamble[1]==t.preamble[0]);
|
||||
for (float bw0: {7.8f,62.5f,125.0f,250.0f,500.0f})
|
||||
for (float bw1: {7.8f,62.5f,125.0f,250.0f,500.0f})
|
||||
@@ -76,8 +76,8 @@ int main() {
|
||||
for (unsigned n=0;n<Profiles::SwitchTestSamplesPerDirection;++n) {
|
||||
p.sampleSwitch(0,1,545);p.sampleSwitch(1,0,545);
|
||||
}
|
||||
assert(p.listenUs(0)==9421 && p.listenUs(1)==21847);
|
||||
assert(p.chirpTiming().switch_us==600 && p.chirpTiming().loop_us==300 && p.chirpTiming().preamble[1]==64);
|
||||
assert(p.listenUs(0)==9421 && p.listenUs(1)==22147);
|
||||
assert(p.chirpTiming().switch_us==600 && p.chirpTiming().loop_us==0 && p.chirpTiming().preamble[1]==64);
|
||||
auto before=p.chirpTiming();const auto wire0=p.preamble(0,32),wire1=p.preamble(1,32);
|
||||
p.sampleSwitch(0,1,8428);auto overrun=p.chirpTiming();
|
||||
assert(overrun.switch_us==9271 && overrun.preamble[1]>before.preamble[1]);
|
||||
@@ -97,23 +97,23 @@ int main() {
|
||||
p.primary=params(7,62.5);p.primary.preamble=32;
|
||||
p.secondary.params=params(8,500);p.secondary.params.preamble=32;
|
||||
p.secondary.mode=mesh::RadioProfileMode::Rx;
|
||||
assert(p.automaticPreambleFits() && p.listenUs(0)==9421 && p.listenUs(1)==21847);
|
||||
assert(p.automaticPreambleFits() && p.listenUs(0)==9421 && p.listenUs(1)==22147);
|
||||
assert(p.preamble(0,32)==32 && p.preamble(1,32)==32);
|
||||
assert(p.chirpTiming().preamble[1]==88);
|
||||
assert(p.chirpTiming().preamble[1]==40);
|
||||
std::swap(p.primary,p.secondary.params);
|
||||
assert(p.slowerProfile()==1 && p.listenUs(1)==9421 && p.listenUs(0)==21847);
|
||||
assert(p.slowerProfile()==1 && p.listenUs(1)==9421 && p.listenUs(0)==22147);
|
||||
p.secondary.params.preamble=8;
|
||||
assert(!p.automaticPreambleFits());
|
||||
// This formerly fit the 4.1 fast floor (1050 us), but not 4.6 (1178 us).
|
||||
// With no fixed loop reserve, 27 symbols cannot cover both 4.6-symbol visits.
|
||||
p.primary=params(7,500);p.secondary.params=params(7,500);
|
||||
p.primary.preamble=30;
|
||||
p.primary.preamble=27;
|
||||
assert(p.listenUs(0)==1178 && p.listenUs(1)>=1178);
|
||||
assert(!p.automaticPreambleFits());
|
||||
p.primary.preamble=32;
|
||||
assert(p.automaticPreambleFits() && p.listenUs(1)==1418);
|
||||
assert(p.automaticPreambleFits() && p.listenUs(1)==1718);
|
||||
// Long requested visits remain visible, not replaced by policy minima.
|
||||
t=Profiles::calculateChirpTiming(params(7,62.5),params(8,500),20000,30000);
|
||||
assert(t.listen_us[0]==20000 && t.listen_us[1]==30000 && t.cycle_us==50300);
|
||||
assert(t.listen_us[0]==20000 && t.listen_us[1]==30000 && t.cycle_us==50000);
|
||||
Profiles measured;
|
||||
measured.primary=params(7,500);
|
||||
measured.secondary.params=params(7,500);
|
||||
@@ -138,4 +138,17 @@ int main() {
|
||||
measured.setSecondary(replacement,true);
|
||||
assert(!measured.switchTestReady() && measured.switchBudgetUs()==0);
|
||||
assert(measured.preamble(0,32)==128 && measured.preamble(1,32)==88);
|
||||
|
||||
// A T1000-E-sized 977 us hop calibrates to 1075 us, yet SF8/500 no longer
|
||||
// inherits the historical 88-symbol floor or a fixed 300 us loop pad.
|
||||
Profiles t1000;
|
||||
t1000.primary=params(7,62.5);
|
||||
t1000.secondary.params=params(8,500);
|
||||
t1000.secondary.mode=mesh::RadioProfileMode::RxTx;
|
||||
for (unsigned n=0;n<Profiles::SwitchTestSamplesPerDirection;++n) {
|
||||
t1000.sampleSwitch(0,1,977);t1000.sampleSwitch(1,0,977);
|
||||
}
|
||||
assert(t1000.switchBudgetUs()==1075);
|
||||
assert(t1000.preamble(0,32)==32 && t1000.preamble(1,32)==40);
|
||||
assert(t1000.chirpTiming().loop_us==0 && t1000.chirpTiming().preamble[1]==40);
|
||||
}
|
||||
+7
-7
@@ -367,11 +367,11 @@ int main(int argc, char** argv) {
|
||||
assert(strstr(f.reply,"switch=600us"));
|
||||
assert(strstr(f.cmd("set radio2 910.5,500,7,5,rxtx"),"preamble=64;"));
|
||||
assert(strstr(f.reply,"switch=600us"));
|
||||
assert(strstr(f.cmd("get radio2.scan"),"slow=radio; listen_us=9421,21847"));
|
||||
assert(strstr(f.cmd("get radio2.timing"),"chirps=4.60,85.34; need=32,64"));
|
||||
assert(strstr(f.cmd("get radio2.scan"),"slow=radio; listen_us=9421,22147"));
|
||||
assert(strstr(f.cmd("get radio2.timing"),"chirps=4.60,86.51; need=32,64"));
|
||||
assert(strstr(f.reply,"switch=600us"));
|
||||
assert(strstr(f.reply,"loop=300us"));
|
||||
assert(strstr(f.reply,"estimate"));
|
||||
assert(strstr(f.reply,"loop=0us"));
|
||||
assert(!strstr(f.reply,"estimate"));
|
||||
assert(strstr(f.reply,"WARN recommended preamble: radio2=64"));
|
||||
char timing_reply[160]; strcpy(timing_reply, f.reply);
|
||||
assert(!strcmp(f.cmd("get radio.timing"),timing_reply));
|
||||
@@ -476,9 +476,9 @@ int main(int argc, char** argv) {
|
||||
f.advance(2000);
|
||||
f.finishTimingTest();
|
||||
assert(f.radio.p.secondary.params.preamble==32);
|
||||
assert(strstr(f.cmd("get radio2.scan"),"slow=radio; listen_us=9421,21847"));
|
||||
assert(strstr(f.cmd("get radio2.timing"),"chirps=4.60,42.67; need=32,88"));
|
||||
assert(strstr(f.reply,"loop=300us"));
|
||||
assert(strstr(f.cmd("get radio2.scan"),"slow=radio; listen_us=9421,22147"));
|
||||
assert(strstr(f.cmd("get radio2.timing"),"chirps=4.60,43.26; need=32,40"));
|
||||
assert(strstr(f.reply,"loop=0us"));
|
||||
}
|
||||
{
|
||||
Fixture f;
|
||||
|
||||
+5
-5
@@ -699,15 +699,15 @@ TEST(RadioProfiles, AutomaticPreamblesUseSelfTestedSwitchingMargin) {
|
||||
p.sampleSwitch(0, 1, 545); p.sampleSwitch(1, 0, 545);
|
||||
}
|
||||
EXPECT_EQ(600, p.switchBudgetUs());
|
||||
EXPECT_EQ(300, p.LoopBudgetUs);
|
||||
const uint16_t expected[] = {64, 88, 32};
|
||||
EXPECT_EQ(0, p.LoopBudgetUs);
|
||||
const uint16_t expected[] = {64, 40, 32};
|
||||
for (int sf = 7; sf <= 9; ++sf) {
|
||||
p.secondary.params.sf = sf;
|
||||
EXPECT_EQ(expected[sf-7], p.preamble(1, 32));
|
||||
EXPECT_EQ(32, p.preamble(0, 32));
|
||||
EXPECT_EQ(0, p.preamble(1, 32) % 8);
|
||||
EXPECT_EQ(9421, p.listenUs(0));
|
||||
EXPECT_EQ(21847, p.listenUs(1));
|
||||
EXPECT_EQ(22147, p.listenUs(1));
|
||||
EXPECT_LE(2 * (p.listenUs(0) + p.listenUs(1) + 2 * p.switchBudgetUs() + p.LoopBudgetUs),
|
||||
p.preamble(0, 32) * p.symbolUs(p.primary));
|
||||
EXPECT_LE(p.listenUs(1) + 2 * p.switchBudgetUs() + p.LoopBudgetUs
|
||||
@@ -729,9 +729,9 @@ TEST(RadioProfiles, SlowerProfileDeterminesOrderAndFasterReceiveWindow) {
|
||||
std::swap(p.primary, p.secondary.params);
|
||||
EXPECT_EQ(1, p.slowerProfile());
|
||||
EXPECT_EQ(9421, p.listenUs(1));
|
||||
EXPECT_EQ(21847, p.listenUs(0));
|
||||
EXPECT_EQ(22147, p.listenUs(0));
|
||||
p.secondary.params.preamble = 40;
|
||||
EXPECT_EQ(30039, p.listenUs(0));
|
||||
EXPECT_EQ(30339, p.listenUs(0));
|
||||
p.secondary.params.preamble = 8;
|
||||
EXPECT_FALSE(p.automaticPreambleFits()); // no safe time for the faster channel
|
||||
}
|
||||
|
||||
@@ -24,6 +24,8 @@ namespace mesh { enum class RadioParamApplyResult { APPLIED, BUSY, FAILED }; }
|
||||
static uint64_t elapsed_us;
|
||||
static uint8_t state;
|
||||
uint32_t micros() { return (uint32_t)elapsed_us; }
|
||||
uint32_t profileTimestamp() { return micros(); }
|
||||
uint32_t profileElapsedUs(uint32_t since, uint32_t now) { return now - since; }
|
||||
uint32_t millis() { return (uint32_t)(elapsed_us / 1000); }
|
||||
struct Chip { bool standbyXOSC=false; int standby() { return 0; } };
|
||||
using CustomSX1262 = Chip;
|
||||
@@ -45,7 +47,7 @@ struct RadioLibWrapper {
|
||||
}
|
||||
uint32_t _rx_ps_rx_us=50000, _rx_ps_sleep_us=50000;
|
||||
uint8_t _active_profile=0, _cur_sf=7, _cur_cr=5;
|
||||
uint32_t _profile_generation=1, _profile_visit_us=0, _profile_retry_at=0;
|
||||
uint32_t _profile_generation=1, _profile_visit_stamp=0, _profile_retry_at=0;
|
||||
uint32_t _profile_scan_generation[2]={};
|
||||
uint16_t _physical_preamble=32;
|
||||
float _cur_freq=909.5, _cur_bw=62.5;
|
||||
@@ -57,7 +59,7 @@ struct RadioLibWrapper {
|
||||
state=STATE_RX; elapsed_us=100000;
|
||||
auto& p=_profiles.primary;
|
||||
p.freq=_cur_freq; p.bw=_cur_bw; p.sf=_cur_sf; p.cr=_cur_cr;
|
||||
_profile_visit_us=micros();
|
||||
_profile_visit_stamp=profileTimestamp();
|
||||
}
|
||||
bool isChipBusy() { return busy; }
|
||||
bool isInRecvMode() const { return (state & ~STATE_INT_READY) == STATE_RX; }
|
||||
@@ -69,7 +71,7 @@ struct RadioLibWrapper {
|
||||
void startRecv() {
|
||||
if (failRxStarts) { --failRxStarts; state=STATE_IDLE; return; }
|
||||
if (_profile_rxps_suspended) assert(chip.standbyXOSC && !_rx_ps_enabled);
|
||||
state=STATE_RX; _profile_visit_us=micros(); _rx_ps_armed=_rx_ps_enabled;
|
||||
state=STATE_RX; _profile_visit_stamp=profileTimestamp(); _rx_ps_armed=_rx_ps_enabled;
|
||||
}
|
||||
void stopReceiveDutyCycle() { _rx_ps_armed=false; }
|
||||
bool applyParams(float f,float,uint8_t,uint8_t) { ++applies; elapsed_us+=switch_apply_us; return !fail || f==909.5f; }
|
||||
@@ -273,7 +275,7 @@ int main() {
|
||||
w.enable();
|
||||
w._floor_estimator.add(-100, millis());
|
||||
w._active_profile=0;
|
||||
w._profile_visit_us=micros();
|
||||
w._profile_visit_stamp=profileTimestamp();
|
||||
const auto primary_visit=w._profiles.listenUs(0);
|
||||
elapsed_us += primary_visit - 1; w.serviceProfileScan(); assert(w._active_profile==0);
|
||||
elapsed_us++; w.serviceProfileScan(); assert(w._active_profile==1);
|
||||
|
||||
Reference in new issue
Block a user