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

Method add_devices

chirpstack/src/api/fuota.rs:402–438  ·  view source on GitHub ↗
(
        &self,
        request: Request<api::AddDevicesToFuotaDeploymentRequest>,
    )

Source from the content-addressed store, hash-verified

400 }
401
402 async fn add_devices(
403 &self,
404 request: Request<api::AddDevicesToFuotaDeploymentRequest>,
405 ) -> Result<Response<()>, Status> {
406 let req = request.get_ref();
407 let dp_id = Uuid::from_str(&req.fuota_deployment_id).map_err(|e| e.status())?;
408
409 self.validator
410 .validate(
411 request.extensions(),
412 validator::ValidateFuotaDeploymentAccess::new(validator::Flag::Update, dp_id),
413 )
414 .await?;
415
416 let d = fuota::get_deployment(dp_id).await.map_err(|e| e.status())?;
417 if d.started_at.is_some() {
418 return Err(Status::failed_precondition(
419 "FUOTA deployment has already started",
420 ));
421 }
422
423 let mut dev_euis = Vec::with_capacity(req.dev_euis.len());
424 for dev_eui in &req.dev_euis {
425 dev_euis.push(EUI64::from_str(dev_eui).map_err(|e| e.status())?);
426 }
427
428 fuota::add_devices(dp_id, dev_euis)
429 .await
430 .map_err(|e| e.status())?;
431
432 let mut resp = Response::new(());
433 resp.metadata_mut().insert(
434 "x-log-fuota_deployment_id",
435 req.fuota_deployment_id.parse().unwrap(),
436 );
437 Ok(resp)
438 }
439
440 async fn remove_devices(
441 &self,

Callers 1

test_fuotaFunction · 0.80

Calls 7

get_deploymentFunction · 0.85
add_devicesFunction · 0.85
statusMethod · 0.80
pushMethod · 0.80
insertMethod · 0.80
unwrapMethod · 0.80
validateMethod · 0.45

Tested by 1

test_fuotaFunction · 0.64