pub struct Xtime {
pub unit: u8,
pub session: u8,
pub micros: u64,
}Expand description
A station clock value taken apart: the radio it was read on, the run of the station it belongs to, and the microseconds that run had counted.
A station reports every uplink with an xtime, and a server hands the same value back
with the downlink that answers it, so the station knows which radio and which run the
answer is timed against. The reference station writes the microseconds in bits 0 to 47,
the run in bits 48 to 55, which it picks at random and never leaves at zero, and the
radio in bits 56 to 62 (src/ral.h in lorabasics/basicstation). A value with a run
past 31 is larger than a double holds exactly, which is why every reader here takes it as
an integer.
§Examples
use pamoja_gateway::station::Xtime;
// A frame heard 3512.348611 seconds into the station's first run, on its only radio.
let heard = Xtime::new(0, 1, 3_512_348_611).expect("in range");
let carried = heard.value();
assert_eq!(Xtime::of(carried), heard);
// A radio past 127, or a run longer than 48 bits of microseconds, has no value.
assert_eq!(Xtime::new(128, 1, 0), None);
assert_eq!(Xtime::new(0, 1, 1 << 48), None);Fields§
§unit: u8The radio unit the time was read on, 0 to 127.
session: u8The run of the station the time belongs to.
micros: u64The microseconds the run had counted, below 2^48.