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

Method _request_ctrl_uplink_list

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

Source from the content-addressed store, hash-verified

1715 }
1716
1717 async fn _request_ctrl_uplink_list(&mut self) -> Result<()> {
1718 trace!("Requesting CtrlUplinkList to sync WFCnt");
1719
1720 let dev_eui = self.device.dev_eui;
1721 let ds = self.device.get_device_session_mut()?;
1722
1723 if ds.relay.is_none() {
1724 ds.relay = Some(internal::Relay::default());
1725 }
1726
1727 // Get a copy of the current relay state.
1728 let mut relay = ds.relay.as_ref().unwrap().clone();
1729
1730 // Get devices that must be configured on the relay.
1731 let relay_devices = relay::list_devices(
1732 15,
1733 0,
1734 &relay::DeviceFilters {
1735 relay_dev_eui: Some(dev_eui),
1736 },
1737 )
1738 .await?;
1739
1740 // Get DevEUIs of Relay EDs.
1741 let relay_devices_dev_euis: Vec<Vec<u8>> =
1742 relay_devices.iter().map(|d| d.dev_eui.to_vec()).collect();
1743
1744 // Calculate removed slots.
1745 let removed_slots: Vec<u32> = relay
1746 .devices
1747 .iter()
1748 .filter(|d| !relay_devices_dev_euis.contains(&d.dev_eui))
1749 .map(|f| f.index)
1750 .collect();
1751
1752 let max_count = 3;
1753 let mut counter = 0;
1754 let mut commands: Vec<lrwn::MACCommand> = vec![];
1755
1756 // Delete end-device from trusted list.
1757 for slot in &removed_slots {
1758 if counter < max_count {
1759 counter += 1;
1760 commands.push(lrwn::MACCommand::CtrlUplinkListReq(
1761 lrwn::CtrlUplinkListReqPayload {
1762 ctrl_uplink_action: lrwn::CtrlUplinkActionPL {
1763 uplink_list_idx: *slot as u8,
1764 ctrl_uplink_action: 1,
1765 },
1766 },
1767 ));
1768 }
1769 }
1770
1771 // Sync WFCnt.
1772 for rd in &mut relay.devices {
1773 if removed_slots.contains(&rd.index) {
1774 continue;

Callers 2

set_mac_commandsMethod · 0.80

Calls 9

unwrapMethod · 0.80
as_refMethod · 0.80
iterMethod · 0.80
containsMethod · 0.80
pushMethod · 0.80
list_devicesFunction · 0.50
to_vecMethod · 0.45
intoMethod · 0.45

Tested by 1