(&mut self)
| 2305 | } |
| 2306 | |
| 2307 | fn set_tx_info_for_rx2(&mut self) -> Result<()> { |
| 2308 | trace!("Setting tx-info for RX2"); |
| 2309 | let ds = self.device.get_device_session()?; |
| 2310 | |
| 2311 | let gw_down = self.downlink_gateway.as_ref().unwrap(); |
| 2312 | let mut tx_info = gw::DownlinkTxInfo { |
| 2313 | board: gw_down.board, |
| 2314 | antenna: gw_down.antenna, |
| 2315 | frequency: if ds.rx2_frequency == 0 { |
| 2316 | self.region_conf.get_defaults().rx2_frequency |
| 2317 | } else { |
| 2318 | ds.rx2_frequency |
| 2319 | }, |
| 2320 | context: gw_down.context.clone(), |
| 2321 | ..Default::default() |
| 2322 | }; |
| 2323 | |
| 2324 | // Set DR to tx-info. |
| 2325 | let rx2_dr = self.region_conf.get_data_rate(false, ds.rx2_dr as u8)?; |
| 2326 | helpers::set_tx_info_data_rate(&mut tx_info, &rx2_dr)?; |
| 2327 | |
| 2328 | // set tx power |
| 2329 | if self.network_conf.downlink_tx_power != -1 { |
| 2330 | tx_info.power = self.network_conf.downlink_tx_power; |
| 2331 | } else { |
| 2332 | tx_info.power = self |
| 2333 | .region_conf |
| 2334 | .get_downlink_tx_power_eirp(tx_info.frequency) as i32; |
| 2335 | } |
| 2336 | |
| 2337 | // set timestamp |
| 2338 | if !self.immediately { |
| 2339 | let delay = if ds.rx1_delay > 0 { |
| 2340 | Duration::from_secs(ds.rx1_delay as u64 + 1) |
| 2341 | } else { |
| 2342 | self.region_conf.get_defaults().rx2_delay |
| 2343 | }; |
| 2344 | |
| 2345 | tx_info.timing = Some(gw::Timing { |
| 2346 | parameters: Some(gw::timing::Parameters::Delay(gw::DelayTimingInfo { |
| 2347 | delay: Some(pbjson_types::Duration::from(delay)), |
| 2348 | })), |
| 2349 | }); |
| 2350 | } |
| 2351 | |
| 2352 | if self.immediately { |
| 2353 | tx_info.timing = Some(gw::Timing { |
| 2354 | parameters: Some(gw::timing::Parameters::Immediately( |
| 2355 | gw::ImmediatelyTimingInfo {}, |
| 2356 | )), |
| 2357 | }); |
| 2358 | } |
| 2359 | |
| 2360 | // get remaining payload size |
| 2361 | let max_pl_size = self.region_conf.get_max_dl_payload_size( |
| 2362 | ds.mac_version().from_proto(), |
| 2363 | self.device_profile.reg_params_revision, |
| 2364 | ds.rx2_dr as u8, |
no test coverage detected