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

Method get_region

chirpstack/src/api/internal.rs:942–988  ·  view source on GitHub ↗
(
        &self,
        request: Request<api::GetRegionRequest>,
    )

Source from the content-addressed store, hash-verified

940 }
941
942 async fn get_region(
943 &self,
944 request: Request<api::GetRegionRequest>,
945 ) -> Result<Response<api::GetRegionResponse>, Status> {
946 let req = request.get_ref();
947 self.validator
948 .validate(request.extensions(), validator::ValidateActiveUser::new())
949 .await?;
950
951 let conf = config::get();
952 let reg = region::get(&req.id).map_err(|e| e.status())?;
953
954 let mut out = api::GetRegionResponse {
955 ..Default::default()
956 };
957
958 for region_conf in &conf.regions {
959 if req.id == region_conf.id {
960 out.id.clone_from(&region_conf.id);
961 out.description = if region_conf.description.is_empty() {
962 region_conf.id.clone()
963 } else {
964 region_conf.description.clone()
965 };
966 out.region = region_conf.common_name.to_proto().into();
967 out.user_info.clone_from(&region_conf.user_info);
968 out.rx1_delay = region_conf.network.rx1_delay as u32;
969 out.rx1_dr_offset = region_conf.network.rx1_dr_offset as u32;
970 out.rx2_dr = region_conf.network.rx2_dr as u32;
971 out.rx2_frequency = region_conf.network.rx2_frequency;
972 out.class_b_ping_slot_dr = region_conf.network.class_b.ping_slot_dr as u32;
973 out.class_b_ping_slot_frequency = region_conf.network.class_b.ping_slot_frequency;
974 }
975 }
976
977 let enabled_channels = reg.get_enabled_uplink_channel_indices();
978
979 for i in enabled_channels {
980 let ch = reg.get_uplink_channel(i).map_err(|e| e.status())?;
981 out.uplink_channels.push(api::RegionChannel {
982 frequency: ch.frequency,
983 data_rates: ch.data_rates.into_iter().map(|v| v as u32).collect(),
984 });
985 }
986
987 Ok(Response::new(out))
988 }
989
990 async fn get_version(
991 &self,

Callers

nothing calls this directly

Calls 9

statusMethod · 0.80
to_protoMethod · 0.80
pushMethod · 0.80
into_iterMethod · 0.80
getFunction · 0.50
validateMethod · 0.45
intoMethod · 0.45
get_uplink_channelMethod · 0.45

Tested by

no test coverage detected