| 707 | } |
| 708 | |
| 709 | async fn log_uplink_meta(&self) -> Result<()> { |
| 710 | trace!("Logging uplink meta"); |
| 711 | |
| 712 | if let lrwn::Payload::MACPayload(mac_pl) = &self.phy_payload.payload { |
| 713 | let um = stream_pb::UplinkMeta { |
| 714 | dev_eui: self.device.as_ref().unwrap().dev_eui.to_string(), |
| 715 | tx_info: Some(self.uplink_frame_set.tx_info.clone()), |
| 716 | rx_info: self.uplink_frame_set.rx_info_set.clone(), |
| 717 | phy_payload_byte_count: self.phy_payload.to_vec()?.len() as u32, |
| 718 | mac_command_byte_count: { |
| 719 | if mac_pl.f_port == Some(0) { |
| 720 | if let Some(lrwn::FRMPayload::MACCommandSet(v)) = &mac_pl.frm_payload { |
| 721 | v.size()? |
| 722 | } else { |
| 723 | 0 |
| 724 | } |
| 725 | } else { |
| 726 | mac_pl.fhdr.f_opts.size()? |
| 727 | } |
| 728 | } as u32, |
| 729 | application_payload_byte_count: { |
| 730 | if mac_pl.f_port.unwrap_or_default() > 0 { |
| 731 | if let Some(lrwn::FRMPayload::Raw(b)) = &mac_pl.frm_payload { |
| 732 | b.len() |
| 733 | } else { |
| 734 | 0 |
| 735 | } |
| 736 | } else { |
| 737 | 0 |
| 738 | } |
| 739 | } as u32, |
| 740 | frame_type: self.phy_payload.mhdr.f_type.to_proto().into(), |
| 741 | }; |
| 742 | |
| 743 | stream::meta::log_uplink(&um).await?; |
| 744 | } |
| 745 | |
| 746 | Ok(()) |
| 747 | } |
| 748 | |
| 749 | // This is needed as in case the device sets the ADRAckReq bit, we do not know if the device |
| 750 | // has reset its channels / channel-mask or not, as there is no explicit signalling in case |