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

Method get

chirpstack/src/api/device_profile.rs:180–300  ·  view source on GitHub ↗
(
        &self,
        request: Request<api::GetDeviceProfileRequest>,
    )

Source from the content-addressed store, hash-verified

178 }
179
180 async fn get(
181 &self,
182 request: Request<api::GetDeviceProfileRequest>,
183 ) -> Result<Response<api::GetDeviceProfileResponse>, Status> {
184 let req = request.get_ref();
185 let dp_id = Uuid::from_str(&req.id).map_err(|e| e.status())?;
186
187 self.validator
188 .validate(
189 request.extensions(),
190 validator::ValidateDeviceProfileAccess::new(validator::Flag::Read, dp_id),
191 )
192 .await?;
193
194 let dp = device_profile::get(&dp_id).await.map_err(|e| e.status())?;
195 let abp_params = dp.abp_params.clone().unwrap_or_default();
196 let class_b_params = dp.class_b_params.clone().unwrap_or_default();
197 let class_c_params = dp.class_c_params.clone().unwrap_or_default();
198 let relay_params = dp.relay_params.clone().unwrap_or_default();
199
200 let mut resp = Response::new(api::GetDeviceProfileResponse {
201 device_profile: Some(api::DeviceProfile {
202 id: dp.id.to_string(),
203 tenant_id: dp.tenant_id.map(|v| v.to_string()).unwrap_or_default(),
204 name: dp.name,
205 description: dp.description,
206 region: dp.region.to_proto().into(),
207 mac_version: dp.mac_version.to_proto().into(),
208 reg_params_revision: dp.reg_params_revision.to_proto().into(),
209 adr_algorithm_id: dp.adr_algorithm_id,
210 payload_codec_runtime: dp.payload_codec_runtime.to_proto().into(),
211 payload_codec_script: dp.payload_codec_script,
212 flush_queue_on_activate: dp.flush_queue_on_activate,
213 uplink_interval: dp.uplink_interval as u32,
214 device_status_req_interval: dp.device_status_req_interval as u32,
215 supports_otaa: dp.supports_otaa,
216 supports_class_b: dp.supports_class_b,
217 supports_class_c: dp.supports_class_c,
218 class_b_timeout: class_b_params.timeout as u32,
219 class_b_ping_slot_periodicity: class_b_params.ping_slot_periodicity as u32,
220 class_b_ping_slot_dr: class_b_params.ping_slot_dr as u32,
221 class_b_ping_slot_freq: class_b_params.ping_slot_freq as u32,
222 class_b_downlink_only: class_b_params.class_b_downlink_only,
223 class_c_timeout: class_c_params.timeout as u32,
224 abp_rx1_delay: abp_params.rx1_delay as u32,
225 abp_rx1_dr_offset: abp_params.rx1_dr_offset as u32,
226 abp_rx2_dr: abp_params.rx2_dr as u32,
227 abp_rx2_freq: abp_params.rx2_freq as u32,
228 tags: dp.tags.into_hashmap(),
229 measurements: dp
230 .measurements
231 .into_hashmap()
232 .iter()
233 .map(|(k, v)| {
234 (
235 k.to_string(),
236 api::Measurement {
237 name: v.name.clone(),

Callers 1

test_device_profileFunction · 0.45

Calls 11

statusMethod · 0.80
to_stringMethod · 0.80
to_protoMethod · 0.80
iterMethod · 0.80
insertMethod · 0.80
unwrapMethod · 0.80
getFunction · 0.50
validateMethod · 0.45
intoMethod · 0.45
into_hashmapMethod · 0.45

Tested by 1

test_device_profileFunction · 0.36