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

Method get_id

lrwn/src/netid.rs:62–80  ·  view source on GitHub ↗
(&self, bits: u8)

Source from the content-addressed store, hash-verified

60 }
61
62 fn get_id(&self, bits: u8) -> Vec<u8> {
63 // convert netid to u32
64 let mut b: [u8; 4] = [0; 4];
65 b[1..].clone_from_slice(self.0.as_ref());
66 let mut temp = u32::from_be_bytes(b);
67
68 // clear prefix
69 temp <<= 32 - bits;
70 temp >>= 32 - bits;
71
72 // back to bytes
73 let out = temp.to_be_bytes();
74 let mut blen: usize = (bits / 8) as usize;
75 if bits % 8 != 0 {
76 blen += 1;
77 }
78
79 out[4 - blen..].to_vec()
80 }
81
82 pub fn dev_addr_prefix(&self) -> DevAddrPrefix {
83 match self.netid_type() {

Callers 1

idMethod · 0.45

Calls 3

as_refMethod · 0.80
to_be_bytesMethod · 0.45
to_vecMethod · 0.45

Tested by

no test coverage detected