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

Method set_phy_payloads_relay

chirpstack/src/downlink/data.rs:920–966  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

918 }
919
920 fn set_phy_payloads_relay(&mut self) -> Result<()> {
921 trace!("Set relay PhyPayloads");
922
923 let relay_ctx = self.relay_context.as_ref().unwrap();
924 let relay_ds = relay_ctx.device.get_device_session()?;
925
926 for item in self.downlink_frame_items.iter_mut() {
927 let mut relay_phy = lrwn::PhyPayload {
928 mhdr: lrwn::MHDR {
929 f_type: lrwn::FType::UnconfirmedDataDown,
930 major: lrwn::Major::LoRaWANR1,
931 },
932 payload: lrwn::Payload::MACPayload(lrwn::MACPayload {
933 fhdr: lrwn::FHDR {
934 devaddr: relay_ctx.device.get_dev_addr()?,
935 f_cnt: relay_ds.get_a_f_cnt_down(),
936 f_ctrl: lrwn::FCtrl {
937 adr: !self.network_conf.adr_disabled,
938 ack: relay_ctx.must_ack,
939 ..Default::default()
940 },
941 f_opts: lrwn::MACCommandSet::new(vec![]),
942 },
943 f_port: None,
944 frm_payload: None,
945 }),
946 mic: None,
947 };
948
949 // Set MIC.
950 // If this is an ACK, then FCntUp has already been incremented by one. If
951 // this is not an ACK, then DownlinkDataMIC will zero out ConfFCnt.
952 relay_phy.set_downlink_data_mic(
953 relay_ds.mac_version().from_proto(),
954 (relay_ctx.device.f_cnt_up as u32) - 1,
955 &lrwn::AES128Key::from_slice(&relay_ds.s_nwk_s_int_key)?,
956 )?;
957
958 let relay_phy_b = relay_phy.to_vec()?;
959 item.downlink_frame_item.phy_payload = relay_phy_b;
960 self.downlink_frame
961 .items
962 .push(item.downlink_frame_item.clone());
963 }
964
965 Ok(())
966 }
967
968 async fn update_device_queue_item(&mut self) -> Result<()> {
969 trace!("Updating device queue-item");

Callers 1

Calls 10

MACPayloadClass · 0.85
unwrapMethod · 0.80
as_refMethod · 0.80
get_device_sessionMethod · 0.80
get_dev_addrMethod · 0.80
get_a_f_cnt_downMethod · 0.80
set_downlink_data_micMethod · 0.80
from_protoMethod · 0.80
pushMethod · 0.80
to_vecMethod · 0.45

Tested by

no test coverage detected