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

Method create_deployment

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

Source from the content-addressed store, hash-verified

28#[tonic::async_trait]
29impl FuotaService for Fuota {
30 async fn create_deployment(
31 &self,
32 request: Request<api::CreateFuotaDeploymentRequest>,
33 ) -> Result<Response<api::CreateFuotaDeploymentResponse>, Status> {
34 let req_dp = match &request.get_ref().deployment {
35 Some(v) => v,
36 None => {
37 return Err(Status::invalid_argument("deployment is missing"));
38 }
39 };
40
41 let app_id = Uuid::from_str(&req_dp.application_id).map_err(|e| e.status())?;
42 let dp_id = Uuid::from_str(&req_dp.device_profile_id).map_err(|e| e.status())?;
43
44 self.validator
45 .validate(
46 request.extensions(),
47 validator::ValidateFuotaDeploymentsAccess::new(
48 validator::Flag::Create,
49 None,
50 Some(app_id),
51 ),
52 )
53 .await?;
54
55 let t = tenant::get_for_application_id(app_id)
56 .await
57 .map_err(|e| e.status())?;
58
59 let mut dp = fuota::FuotaDeployment {
60 name: req_dp.name.clone(),
61 application_id: app_id.into(),
62 device_profile_id: dp_id.into(),
63 multicast_addr: get_random_dev_addr(&t.get_dev_addr_prefixes()),
64 multicast_key: get_random_aes_key(),
65 multicast_group_type: match req_dp.multicast_group_type() {
66 api::MulticastGroupType::ClassB => "B",
67 api::MulticastGroupType::ClassC => "C",
68 }
69 .to_string(),
70 multicast_class_c_scheduling_type: req_dp
71 .multicast_class_c_scheduling_type()
72 .from_proto(),
73 multicast_dr: req_dp.multicast_dr as i16,
74 multicast_class_b_ping_slot_periodicity: req_dp.multicast_class_b_ping_slot_periodicity
75 as i16,
76 multicast_frequency: req_dp.multicast_frequency as i64,
77 multicast_timeout: req_dp.multicast_timeout as i16,
78 unicast_max_retry_count: req_dp.unicast_max_retry_count as i16,
79 fragmentation_fragment_size: req_dp.fragmentation_fragment_size as i16,
80 fragmentation_redundancy_percentage: req_dp.fragmentation_redundancy_percentage as i16,
81 fragmentation_session_index: req_dp.fragmentation_session_index as i16,
82 fragmentation_matrix: req_dp.fragmentation_matrix as i16,
83 fragmentation_block_ack_delay: req_dp.fragmentation_block_ack_delay as i16,
84 fragmentation_descriptor: req_dp.fragmentation_descriptor.clone(),
85 request_fragmentation_session_status: req_dp
86 .request_fragmentation_session_status()
87 .from_proto(),

Callers 1

test_fuotaFunction · 0.80

Calls 14

get_for_application_idFunction · 0.85
get_random_dev_addrFunction · 0.85
get_random_aes_keyFunction · 0.85
get_max_fragment_sizeFunction · 0.85
get_multicast_timeoutFunction · 0.85
create_deploymentFunction · 0.85
statusMethod · 0.80
to_stringMethod · 0.80
from_protoMethod · 0.80
insertMethod · 0.80
unwrapMethod · 0.80
validateMethod · 0.45

Tested by 1

test_fuotaFunction · 0.64