diff --git a/file_store/src/cli/dump.rs b/file_store/src/cli/dump.rs index ffd595632..6f896167c 100644 --- a/file_store/src/cli/dump.rs +++ b/file_store/src/cli/dump.rs @@ -5,7 +5,10 @@ use crate::{ iot_packet::IotValidPacket, mobile_radio_invalidated_threshold::VerifiedInvalidatedRadioThresholdIngestReport, mobile_radio_threshold::VerifiedRadioThresholdIngestReport, - mobile_session::{DataTransferSessionIngestReport, InvalidDataTransferIngestReport}, + mobile_session::{ + DataTransferSessionIngestReport, InvalidDataTransferIngestReport, + VerifiedDataTransferIngestReport, + }, mobile_subscriber::{SubscriberLocationIngestReport, VerifiedSubscriberLocationIngestReport}, reward_manifest::RewardManifest, speedtest::{CellSpeedtest, CellSpeedtestIngestReport}, @@ -32,8 +35,8 @@ use helium_proto::{ HexUsageStatsIngestReportV1, InvalidDataTransferIngestReportV1, MobileRewardShare, OracleBoostingReportV1, RadioRewardShare, RadioUsageStatsIngestReportV1, SpeedtestAvg, SpeedtestIngestReportV1, SpeedtestReqV1, UniqueConnectionsIngestReportV1, - VerifiedInvalidatedRadioThresholdIngestReportV1, VerifiedRadioThresholdIngestReportV1, - VerifiedUniqueConnectionsIngestReportV1, + VerifiedDataTransferIngestReportV1, VerifiedInvalidatedRadioThresholdIngestReportV1, + VerifiedRadioThresholdIngestReportV1, VerifiedUniqueConnectionsIngestReportV1, }, router::PacketRouterPacketReportV1, }, @@ -162,6 +165,27 @@ impl Cmd { "last_timestamp": msg.last_timestamp, }))?; } + FileType::VerifiedDataTransferSession => { + let report: VerifiedDataTransferIngestReport = + VerifiedDataTransferIngestReportV1::decode(msg)?.try_into()?; + let report = report.report; + let req = report.report; + let data_transfer_usage = json!({ + "pub_key": PublicKey::try_from(req.data_transfer_usage.pub_key)?, + "upload_bytes": req.data_transfer_usage.upload_bytes, + "download_bytes": req.data_transfer_usage.download_bytes, + "radio_access_technology": req.data_transfer_usage.radio_access_technology, + "event_id": req.data_transfer_usage.event_id, + "payer": req.data_transfer_usage.payer, + "timestamp": req.data_transfer_usage.timestamp, + }); + print_json(&json!({ + "rewardable_bytes": req.rewardable_bytes, + "pub_key": PublicKey::try_from(req.pub_key)?, + "received_timestamp": report.received_timestamp, + "data_transfer_usage": data_transfer_usage, + }))?; + } FileType::IotBeaconIngestReport => { let dec_msg = LoraBeaconIngestReportV1::decode(msg)?; let json = json!({ diff --git a/file_store/src/file_info.rs b/file_store/src/file_info.rs index a9b59d2d5..854a0e281 100644 --- a/file_store/src/file_info.rs +++ b/file_store/src/file_info.rs @@ -437,6 +437,7 @@ impl FromStr for FileType { } MOBILE_BAN_REPORT => Self::MobileBanReport, VERIFIED_MOBILE_BAN_REPORT => Self::VerifiedMobileBanReport, + VERIFIED_DATA_TRANSFER_SESSION => Self::VerifiedDataTransferSession, _ => return Err(Error::from(io::Error::from(io::ErrorKind::InvalidInput))), }; Ok(result) diff --git a/file_store/src/mobile_session.rs b/file_store/src/mobile_session.rs index e5b70e773..0260a805b 100644 --- a/file_store/src/mobile_session.rs +++ b/file_store/src/mobile_session.rs @@ -126,6 +126,26 @@ impl MsgTimestamp for VerifiedDataTransferIngestReport { } } +impl MsgTimestamp>> for VerifiedDataTransferIngestReportV1 { + fn timestamp(&self) -> Result> { + self.timestamp.to_timestamp_millis() + } +} + +impl TryFrom for VerifiedDataTransferIngestReport { + type Error = Error; + fn try_from(v: VerifiedDataTransferIngestReportV1) -> Result { + Ok(Self { + status: v.status(), + timestamp: v.timestamp()?, + report: v + .report + .ok_or_else(|| Error::not_found("data transfer session ingest report"))? + .try_into()?, + }) + } +} + impl From for VerifiedDataTransferIngestReportV1 { fn from(v: VerifiedDataTransferIngestReport) -> Self { let timestamp = v.timestamp();