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

Method set_device_session

chirpstack/src/uplink/join.rs:777–856  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

775 }
776
777 async fn set_device_session(&mut self) -> Result<()> {
778 trace!("Setting device-session");
779
780 let region_conf = region::get(&self.uplink_frame_set.region_config_id)?;
781 let region_network = config::get_region_network(&self.uplink_frame_set.region_config_id)?;
782
783 let device = self.device.as_mut().unwrap();
784 let device_profile = self.device_profile.as_ref().unwrap();
785
786 let mut ds = internal::DeviceSession {
787 region_config_id: self.uplink_frame_set.region_config_id.clone(),
788 dev_addr: device.dev_addr.unwrap().to_be_bytes().to_vec(),
789 f_nwk_s_int_key: self.f_nwk_s_int_key.as_ref().unwrap().to_vec(),
790 s_nwk_s_int_key: self.s_nwk_s_int_key.as_ref().unwrap().to_vec(),
791 nwk_s_enc_key: self.nwk_s_enc_key.as_ref().unwrap().to_vec(),
792 app_s_key: self.app_s_key.clone(),
793 js_session_key_id: self.js_session_key_id.clone(),
794 rx1_delay: region_network.rx1_delay.into(),
795 rx1_dr_offset: region_network.rx1_dr_offset.into(),
796 rx2_dr: region_network.rx2_dr.into(),
797 rx2_frequency: region_conf.get_defaults().rx2_frequency,
798 enabled_uplink_channel_indices: region_conf
799 .get_default_uplink_channel_indices()
800 .iter()
801 .map(|i| *i as u32)
802 .collect(),
803 skip_f_cnt_check: device.skip_fcnt_check,
804 ..Default::default()
805 };
806
807 device_profile.reset_session_to_boot_params(&mut ds);
808
809 match region_conf.get_cf_list(device_profile.mac_version) {
810 Some(CFList::Channels(channels)) => {
811 for f in channels.iter().cloned() {
812 if f == 0 {
813 continue;
814 }
815
816 let i = region_conf
817 .get_uplink_channel_index(f, true)
818 .context("Unknown cf_list frequency")?;
819
820 ds.enabled_uplink_channel_indices.push(i as u32);
821
822 // add extra channel to extra uplink channels, so that we can
823 // keep track on frequency and data-rate changes
824 let c = region_conf
825 .get_uplink_channel(i)
826 .context("Get uplink channel error")?;
827
828 ds.extra_uplink_channels.insert(
829 i as u32,
830 internal::DeviceSessionChannel {
831 frequency: c.frequency,
832 data_rates: c.data_rates.into_iter().map(|v| v as u32).collect(),
833 ..Default::default()
834 },

Callers 2

_handleMethod · 0.45
_handle_relayedMethod · 0.45

Calls 15

get_region_networkFunction · 0.85
unwrapMethod · 0.80
as_refMethod · 0.80
iterMethod · 0.80
pushMethod · 0.80
insertMethod · 0.80
into_iterMethod · 0.80
getFunction · 0.50
to_vecMethod · 0.45
to_be_bytesMethod · 0.45
intoMethod · 0.45

Tested by

no test coverage detected