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

Function update_gateway_metadata

chirpstack/src/uplink/mod.rs:370–417  ·  view source on GitHub ↗
(ufs: &mut UplinkFrameSet)

Source from the content-addressed store, hash-verified

368}
369
370async fn update_gateway_metadata(ufs: &mut UplinkFrameSet) -> Result<()> {
371 let conf = config::get();
372 for rx_info in &mut ufs.rx_info_set {
373 let gw_id = EUI64::from_str(&rx_info.gateway_id).context("Gateway ID")?;
374 let gw_meta = match gateway::get_meta(&gw_id).await {
375 Ok(v) => v,
376 Err(e) => {
377 if conf.gateway.allow_unknown_gateways
378 && let StorageError::NotFound(_) = e
379 {
380 ufs.gateway_private_up_map.insert(gw_id, false);
381 ufs.gateway_private_down_map.insert(gw_id, false);
382 continue;
383 }
384
385 error!(
386 gateway_id = %gw_id,
387 error = %e.full(),
388 "Getting gateway meta-data failed"
389 );
390 continue;
391 }
392 };
393
394 // Do not overwrite the location if it is already set. In case of a 'virtual' it is
395 // possible that the location is already set in the RxInfo. Overwriting this with the
396 // location of the 'virtual' gateway would mean we will get the wrong location.
397 if rx_info.location.is_none() {
398 rx_info.location = Some(common::Location {
399 latitude: gw_meta.latitude,
400 longitude: gw_meta.longitude,
401 altitude: gw_meta.altitude as f64,
402 ..Default::default()
403 });
404 }
405
406 ufs.gateway_private_up_map
407 .insert(gw_id, gw_meta.is_private_up);
408 ufs.gateway_private_down_map
409 .insert(gw_id, gw_meta.is_private_down);
410 ufs.gateway_tenant_id_map
411 .insert(gw_id, gw_meta.tenant_id.into());
412 ufs.gateway_downlink_priority_map
413 .insert(gw_id, gw_meta.downlink_priority as u32);
414 }
415
416 Ok(())
417}
418
419fn filter_rx_info_by_tenant_id(tenant_id: Uuid, uplink: &mut UplinkFrameSet) -> Result<()> {
420 let force_gws_private = config::get_force_gws_private(&uplink.region_config_id)?;

Callers 1

handle_uplinkFunction · 0.85

Calls 4

get_metaFunction · 0.85
insertMethod · 0.80
getFunction · 0.50
intoMethod · 0.45

Tested by

no test coverage detected