(&mut self)
| 796 | } |
| 797 | |
| 798 | async fn fragmentation_status(&mut self) -> Result<Option<(FuotaJob, DateTime<Utc>)>> { |
| 799 | let fuota_devices = fuota::get_devices(self.job.fuota_deployment_id.into(), -1, 0).await?; |
| 800 | let fuota_devices_completed_mc_session_count = fuota_devices |
| 801 | .iter() |
| 802 | .filter(|d| d.mc_session_completed_at.is_some()) |
| 803 | .count(); |
| 804 | |
| 805 | // Filter on devices that have completed the multicast-session setup but |
| 806 | // not yet responded to the FragSessionStatusReq. |
| 807 | let fuota_devices: Vec<fuota::FuotaDeploymentDevice> = fuota_devices |
| 808 | .into_iter() |
| 809 | .filter(|d| d.mc_session_completed_at.is_some() && d.frag_status_completed_at.is_none()) |
| 810 | .collect(); |
| 811 | |
| 812 | // Proceed with next step after reaching the max attempts. |
| 813 | if self.job.attempt_count > self.job.max_retry_count { |
| 814 | info!("Set timeout error to devices that did not respond to FragSessionStatusReq"); |
| 815 | fuota::set_device_timeout_error( |
| 816 | self.fuota_deployment.id.into(), |
| 817 | false, |
| 818 | false, |
| 819 | false, |
| 820 | true, |
| 821 | ) |
| 822 | .await?; |
| 823 | |
| 824 | if !fuota_devices.is_empty() { |
| 825 | self.job.warning_msg = format!( |
| 826 | "{} devices did not complete the fragmentation status", |
| 827 | fuota_devices.len() |
| 828 | ); |
| 829 | } |
| 830 | |
| 831 | return Ok(Some((FuotaJob::DeleteMcGroup, Utc::now()))); |
| 832 | } |
| 833 | |
| 834 | info!("Enqueue FragSessionStatusReq"); |
| 835 | self.job.attempt_count += 1; |
| 836 | |
| 837 | if fuota_devices_completed_mc_session_count == 0 { |
| 838 | self.job.error_msg = "There are no devices available to complete this step".into(); |
| 839 | return Ok(Some((FuotaJob::DeleteMcGroup, Utc::now()))); |
| 840 | } |
| 841 | |
| 842 | for fuota_dev in &fuota_devices { |
| 843 | let pl = match self.device_profile.app_layer_params.ts004_version { |
| 844 | Some(Ts004Version::V100) => fragmentation::v1::Payload::FragSessionStatusReq( |
| 845 | fragmentation::v1::FragSessionStatusReqPayload { |
| 846 | participants: true, |
| 847 | frag_index: 0, |
| 848 | }, |
| 849 | ) |
| 850 | .to_vec()?, |
| 851 | Some(Ts004Version::V200) => fragmentation::v2::Payload::FragSessionStatusReq( |
| 852 | fragmentation::v2::FragSessionStatusReqPayload { |
| 853 | participants: true, |
| 854 | frag_index: 0, |
| 855 | }, |
no test coverage detected