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

Method _request_device_status

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

Source from the content-addressed store, hash-verified

1405 }
1406
1407 fn _request_device_status(&mut self) -> Result<()> {
1408 trace!("Requesting device-status");
1409
1410 if self.device_profile.device_status_req_interval == 0 {
1411 return Ok(());
1412 }
1413
1414 let ds = self.device.get_device_session_mut()?;
1415
1416 match &ds.last_device_status_request {
1417 None => {
1418 self.mac_commands.push(lrwn::MACCommandSet::new(vec![
1419 lrwn::MACCommand::DevStatusReq,
1420 ]));
1421
1422 ds.last_device_status_request = Some(Utc::now().into());
1423 }
1424 Some(ts) => {
1425 let ts: DateTime<Utc> = (*ts).try_into().map_err(anyhow::Error::msg)?;
1426 let req_interval = Duration::from_secs(60 * 60 * 24)
1427 / self.device_profile.device_status_req_interval as u32;
1428
1429 let cur_interval: Duration = (Utc::now() - ts).to_std()?;
1430
1431 if cur_interval >= req_interval {
1432 self.mac_commands.push(lrwn::MACCommandSet::new(vec![
1433 lrwn::MACCommand::DevStatusReq,
1434 ]));
1435
1436 ds.last_device_status_request = Some(Utc::now().into());
1437 }
1438 }
1439 }
1440
1441 Ok(())
1442 }
1443
1444 async fn _request_rejoin_param_setup(&mut self) -> Result<()> {
1445 trace!("Requesting rejoin param setup");

Callers 1

set_mac_commandsMethod · 0.80

Calls 3

pushMethod · 0.80
intoMethod · 0.45

Tested by

no test coverage detected