Skip to content

Commit

Permalink
locate and dump support for threshold reports
Browse files Browse the repository at this point in the history
  • Loading branch information
andymck committed Mar 26, 2024
1 parent 0f5718f commit 5389735
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
24 changes: 24 additions & 0 deletions file_store/src/cli/bucket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ use crate::{
iot_beacon_report::IotBeaconIngestReport,
iot_valid_poc::IotPoc,
iot_witness_report::IotWitnessIngestReport,
mobile_radio_invalidated_threshold::VerifiedInvalidatedRadioThresholdIngestReport,
mobile_radio_threshold::VerifiedRadioThresholdIngestReport,
speedtest::{cli::SpeedtestAverage, CellSpeedtest},
traits::MsgDecode,
Error, FileInfoStream, FileStore, FileType, Result, Settings,
Expand Down Expand Up @@ -154,6 +156,7 @@ impl Get {
fs::OpenOptions::new()
.write(true)
.create(true)
.truncate(true)
.open(&self.dest.join(Path::new(&info.key)))
.map_err(Error::from)
.and_then(|mut file| {
Expand Down Expand Up @@ -226,6 +229,15 @@ fn locate(prefix: &str, gateway: &PublicKey, buf: &[u8]) -> Result<Option<serde_
FileType::IotWitnessIngestReport => {
IotWitnessIngestReport::decode(buf).and_then(|event| event.to_value_if(pub_key))
}
FileType::VerifiedRadioThresholdIngestReport => {
VerifiedRadioThresholdIngestReport::decode(buf)
.and_then(|event| event.to_value_if(pub_key))
}
FileType::VerifiedInvalidatedRadioThresholdIngestReport => {
VerifiedInvalidatedRadioThresholdIngestReport::decode(buf)
.and_then(|event| event.to_value_if(pub_key))
}

FileType::IotPoc => IotPoc::decode(buf).and_then(|event| event.to_value_if(pub_key)),
_ => Ok(None),
}
Expand Down Expand Up @@ -305,3 +317,15 @@ impl Gateway for SpeedtestAverage {
self.pub_key.as_ref() == pub_key
}
}

impl Gateway for VerifiedRadioThresholdIngestReport {
fn has_pubkey(&self, pub_key: &[u8]) -> bool {
self.report.report.hotspot_pubkey.as_ref() == pub_key
}
}

impl Gateway for VerifiedInvalidatedRadioThresholdIngestReport {
fn has_pubkey(&self, pub_key: &[u8]) -> bool {
self.report.report.hotspot_pubkey.as_ref() == pub_key
}
}
13 changes: 13 additions & 0 deletions file_store/src/cli/dump.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ use crate::{
file_source,
heartbeat::{CbrsHeartbeat, CbrsHeartbeatIngestReport},
iot_packet::IotValidPacket,
mobile_radio_invalidated_threshold::VerifiedInvalidatedRadioThresholdIngestReport,
mobile_radio_threshold::VerifiedRadioThresholdIngestReport,
mobile_session::{DataTransferSessionIngestReport, InvalidDataTransferIngestReport},
mobile_subscriber::{SubscriberLocationIngestReport, VerifiedSubscriberLocationIngestReport},
speedtest::{CellSpeedtest, CellSpeedtestIngestReport},
Expand All @@ -25,6 +27,7 @@ use helium_proto::{
mobile_reward_share::Reward, CellHeartbeatIngestReportV1, CellHeartbeatReqV1,
Heartbeat, InvalidDataTransferIngestReportV1, MobileRewardShare, RadioRewardShare,
SpeedtestAvg, SpeedtestIngestReportV1, SpeedtestReqV1,
VerifiedInvalidatedRadioThresholdIngestReportV1, VerifiedRadioThresholdIngestReportV1,
},
router::PacketRouterPacketReportV1,
},
Expand Down Expand Up @@ -52,6 +55,16 @@ impl Cmd {
while let Some(result) = file_stream.next().await {
let msg = result?;
match self.file_type {
FileType::VerifiedRadioThresholdIngestReport => {
let dec_msg = VerifiedRadioThresholdIngestReportV1::decode(msg)?;
let report = VerifiedRadioThresholdIngestReport::try_from(dec_msg)?;
print_json(&report)?;
}
FileType::VerifiedInvalidatedRadioThresholdIngestReport => {
let dec_msg = VerifiedInvalidatedRadioThresholdIngestReportV1::decode(msg)?;
let report = VerifiedInvalidatedRadioThresholdIngestReport::try_from(dec_msg)?;
print_json(&report)?;
}
FileType::BoostedHexUpdate => {
let dec_msg = BoostedHexUpdateProto::decode(msg)?;
let update = dec_msg.update.unwrap();
Expand Down
1 change: 1 addition & 0 deletions file_store/src/file_sink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ impl FileSink {
OpenOptions::new()
.write(true)
.create(true)
.truncate(true)
.open(&new_path)
.await?,
));
Expand Down

0 comments on commit 5389735

Please sign in to comment.