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

Function handle_uplink

chirpstack/src/uplink/mod.rs:305–368  ·  view source on GitHub ↗
(
    region_common_name: CommonName,
    region_config_id: &str,
    deduplication_id: Uuid,
    uplink: gw::UplinkFrameSet,
)

Source from the content-addressed store, hash-verified

303}
304
305pub async fn handle_uplink(
306 region_common_name: CommonName,
307 region_config_id: &str,
308 deduplication_id: Uuid,
309 uplink: gw::UplinkFrameSet,
310) -> Result<()> {
311 let mut uplink = UplinkFrameSet {
312 uplink_set_id: deduplication_id,
313 region_common_name,
314 region_config_id: region_config_id.to_string(),
315 dr: 0,
316 ch: 0,
317 phy_payload: PhyPayload::from_slice(&uplink.phy_payload)?,
318 tx_info: uplink.tx_info.context("tx_info must not be None")?,
319 rx_info_set: uplink.rx_info,
320 gateway_private_up_map: HashMap::new(),
321 gateway_private_down_map: HashMap::new(),
322 gateway_tenant_id_map: HashMap::new(),
323 gateway_downlink_priority_map: HashMap::new(),
324 roaming_meta_data: None,
325 };
326
327 UPLINK_COUNTER
328 .get_or_create(&UplinkLabels {
329 f_type: uplink.phy_payload.mhdr.f_type.to_string(),
330 })
331 .inc();
332
333 uplink.dr = helpers::get_uplink_dr(&uplink.region_config_id, &uplink.tx_info)?;
334 uplink.ch = helpers::get_uplink_ch(
335 &uplink.region_config_id,
336 uplink.tx_info.frequency,
337 uplink.dr,
338 )?;
339
340 info!(
341 f_type = %uplink.phy_payload.mhdr.f_type,
342 "Uplink received"
343 );
344
345 debug!("Updating gateway meta-data for uplink frame-set");
346 update_gateway_metadata(&mut uplink)
347 .await
348 .context("Update gateway meta-data")?;
349
350 debug!("Logging uplink frame to Redis Stream");
351 let ufl: stream_pb::UplinkFrameLog = (&uplink).try_into()?;
352 stream::frame::log_uplink_for_gateways(&ufl)
353 .await
354 .context("Log uplink for gateways")?;
355
356 match uplink.phy_payload.mhdr.f_type {
357 FType::JoinRequest => join::JoinRequest::handle(uplink).await,
358 FType::UnconfirmedDataUp | FType::ConfirmedDataUp => data::Data::handle(uplink).await,
359 _ => {
360 return Err(anyhow!(
361 "Unexpected f_type: {}",
362 uplink.phy_payload.mhdr.f_type

Callers 11

_deduplicate_uplinkFunction · 0.70
handle_mac_commandsMethod · 0.70
handle_applayerMethod · 0.70
run_testFunction · 0.50
test_fnsFunction · 0.50
run_testFunction · 0.50
test_fns_uplinkFunction · 0.50
run_uplink_testFunction · 0.50
run_testFunction · 0.50
test_lorawan_10Function · 0.50
run_testFunction · 0.50

Calls 6

get_uplink_drFunction · 0.85
get_uplink_chFunction · 0.85
update_gateway_metadataFunction · 0.85
log_uplink_for_gatewaysFunction · 0.85
to_stringMethod · 0.80
handleFunction · 0.50

Tested by 8

run_testFunction · 0.40
test_fnsFunction · 0.40
run_testFunction · 0.40
test_fns_uplinkFunction · 0.40
run_uplink_testFunction · 0.40
run_testFunction · 0.40
test_lorawan_10Function · 0.40
run_testFunction · 0.40