MCPcopy Create free account
hub / github.com/chirpstack/chirpstack / to_bytes

Method to_bytes

lrwn/src/relay.rs:27–48  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

25 }
26
27 pub fn to_bytes(&self) -> Result<[u8; 3]> {
28 if self.dr > 15 {
29 return Err(anyhow!("max dr value is 15"));
30 }
31
32 if self.wor_channel > 1 {
33 return Err(anyhow!("max wor_channel value is 1"));
34 }
35
36 let snr = self.snr.clamp(-20, 11);
37 let rssi = self.rssi.clamp(-142, -15);
38
39 // Encode values
40 let snr = (snr + 20) as u8;
41 let rssi = -(rssi + 15) as u8;
42
43 Ok([
44 self.dr | (snr << 4),
45 (snr >> 4) | (rssi << 1),
46 self.wor_channel,
47 ])
48 }
49}
50
51#[derive(Debug, PartialEq, Eq, Clone)]

Callers 15

unwrapFunction · 0.45
wrapFunction · 0.45
get_root_wor_s_keyFunction · 0.45
get_s_keyFunction · 0.45
get_js_keyFunction · 0.45
to_vecMethod · 0.45
to_vecMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected