Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support wifi heartbeats originating from indoor wifi hotspots #623

Merged
merged 1 commit into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions file_store/src/cli/bucket.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{
heartbeat::CellHeartbeat, iot_beacon_report::IotBeaconIngestReport, iot_valid_poc::IotPoc,
heartbeat::CbrsHeartbeat, iot_beacon_report::IotBeaconIngestReport, iot_valid_poc::IotPoc,
iot_witness_report::IotWitnessIngestReport, speedtest::CellSpeedtest, traits::MsgDecode, Error,
FileInfoStream, FileStore, FileType, Result, Settings,
};
Expand Down Expand Up @@ -204,8 +204,8 @@ impl Locate {
fn locate(prefix: &str, gateway: &PublicKey, buf: &[u8]) -> Result<Option<serde_json::Value>> {
let pub_key = gateway.to_vec();
match FileType::from_str(prefix)? {
FileType::CellHeartbeat => {
CellHeartbeat::decode(buf).and_then(|event| event.to_value_if(pub_key))
FileType::CbrsHeartbeat => {
CbrsHeartbeat::decode(buf).and_then(|event| event.to_value_if(pub_key))
}
FileType::CellSpeedtest => {
CellSpeedtest::decode(buf).and_then(|event| event.to_value_if(pub_key))
Expand Down Expand Up @@ -254,7 +254,7 @@ where
}
}

impl Gateway for CellHeartbeat {
impl Gateway for CbrsHeartbeat {
fn has_pubkey(&self, pub_key: &[u8]) -> bool {
self.pubkey.as_ref() == pub_key
}
Expand Down
22 changes: 17 additions & 5 deletions file_store/src/cli/dump.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
use crate::{
cli::print_json,
file_source,
heartbeat::{CellHeartbeat, CellHeartbeatIngestReport},
heartbeat::{CbrsHeartbeat, CbrsHeartbeatIngestReport},
iot_packet::IotValidPacket,
mobile_session::{DataTransferSessionIngestReport, InvalidDataTransferIngestReport},
mobile_subscriber::{SubscriberLocationIngestReport, VerifiedSubscriberLocationIngestReport},
speedtest::{CellSpeedtest, CellSpeedtestIngestReport},
traits::MsgDecode,
wifi_heartbeat::WifiHeartbeatIngestReport,
FileType, Result, Settings,
};
use base64::Engine;
Expand Down Expand Up @@ -50,17 +51,27 @@ impl Cmd {
while let Some(result) = file_stream.next().await {
let msg = result?;
match self.file_type {
FileType::CellHeartbeat => {
FileType::CbrsHeartbeat => {
let dec_msg = CellHeartbeatReqV1::decode(msg)?;
wtr.serialize(CellHeartbeat::try_from(dec_msg)?)?;
wtr.serialize(CbrsHeartbeat::try_from(dec_msg)?)?;
}
FileType::WifiHeartbeatIngestReport => {
let msg = WifiHeartbeatIngestReport::decode(msg)?;
andymck marked this conversation as resolved.
Show resolved Hide resolved
let json = json!({
"received_timestamp": msg.received_timestamp,
"pubkey": msg.report.pubkey,
"operation_mode": msg.report.operation_mode,
"location_validation_timestamp": msg.report.location_validation_timestamp,
});
print_json(&json)?;
}
FileType::CellSpeedtest => {
let dec_msg = SpeedtestReqV1::decode(msg)?;
wtr.serialize(CellSpeedtest::try_from(dec_msg)?)?;
}
FileType::CellHeartbeatIngestReport => {
FileType::CbrsHeartbeatIngestReport => {
let dec_msg = CellHeartbeatIngestReportV1::decode(msg)?;
let ingest_report = CellHeartbeatIngestReport::try_from(dec_msg)?;
let ingest_report = CbrsHeartbeatIngestReport::try_from(dec_msg)?;
print_json(&ingest_report)?;
}
FileType::CellSpeedtestIngestReport => {
Expand Down Expand Up @@ -207,6 +218,7 @@ impl Cmd {
"dc_transfer_reward": reward.dc_transfer_reward,
}))?,
Some(Reward::RadioReward(reward)) => print_json(&json!({
"hotspot_key": PublicKey::try_from(reward.hotspot_key)?,
"cbsd_id": reward.cbsd_id,
"poc_reward": reward.poc_reward,
}))?,
Expand Down
4 changes: 2 additions & 2 deletions file_store/src/cli/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ impl MsgTimestamp<Result<DateTime<Utc>>> for PriceReportV1 {

fn get_timestamp(file_type: &str, buf: &[u8]) -> Result<DateTime<Utc>> {
let result = match FileType::from_str(file_type)? {
FileType::CellHeartbeat => CellHeartbeatReqV1::decode(buf)
FileType::CbrsHeartbeat => CellHeartbeatReqV1::decode(buf)
.map_err(Error::from)
.and_then(|entry| entry.timestamp())?,
FileType::CellSpeedtest => SpeedtestReqV1::decode(buf)
.map_err(Error::from)
.and_then(|entry| entry.timestamp())?,
FileType::CellHeartbeatIngestReport => CellHeartbeatIngestReportV1::decode(buf)
FileType::CbrsHeartbeatIngestReport => CellHeartbeatIngestReportV1::decode(buf)
.map_err(Error::from)
.and_then(|ingest_report| {
ingest_report.report.ok_or_else(|| {
Expand Down
28 changes: 19 additions & 9 deletions file_store/src/file_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,12 @@ impl FileInfo {
pub const SUBSCRIBER_LOCATION_REQ: &str = "subscriber_location_req";
pub const SUBSCRIBER_LOCATION_INGEST_REPORT: &str = "subscriber_location_report";
pub const VERIFIED_SUBSCRIBER_LOCATION_INGEST_REPORT: &str = "verified_subscriber_location_report";
pub const CELL_HEARTBEAT: &str = "cell_heartbeat";
pub const CBRS_HEARTBEAT: &str = "cbrs_heartbeat";
pub const WIFI_HEARTBEAT: &str = "wifi_heartbeat";
pub const CELL_SPEEDTEST: &str = "cell_speedtest";
pub const VERIFIED_SPEEDTEST: &str = "verified_speedtest";
pub const CELL_HEARTBEAT_INGEST_REPORT: &str = "heartbeat_report";
pub const WIFI_HEARTBEAT_INGEST_REPORT: &str = "wifi_heartbeat_report";
pub const CELL_SPEEDTEST_INGEST_REPORT: &str = "speedtest_report";
pub const ENTROPY: &str = "entropy";
pub const SUBNETWORK_REWARDS: &str = "subnetwork_rewards";
Expand Down Expand Up @@ -144,11 +146,11 @@ pub const COVERAGE_OBJECT_INGEST_REPORT: &str = "coverage_object_ingest_report";
#[derive(Debug, PartialEq, Eq, Clone, Serialize, Copy, strum::EnumCount)]
#[serde(rename_all = "snake_case")]
pub enum FileType {
CellHeartbeat = 0,
CbrsHeartbeat = 0,
CellSpeedtest = 1,
Entropy = 2,
SubnetworkRewards = 3,
CellHeartbeatIngestReport,
CbrsHeartbeatIngestReport,
CellSpeedtestIngestReport,
EntropyReport,
IotBeaconIngestReport,
Expand Down Expand Up @@ -177,6 +179,8 @@ pub enum FileType {
MapperMsg,
CoverageObjectIngestReport,
VerifiedSpeedtest,
WifiHeartbeat,
WifiHeartbeatIngestReport,
}

impl fmt::Display for FileType {
Expand All @@ -187,10 +191,12 @@ impl fmt::Display for FileType {
Self::VerifiedSubscriberLocationIngestReport => {
VERIFIED_SUBSCRIBER_LOCATION_INGEST_REPORT
}
Self::CellHeartbeat => CELL_HEARTBEAT,
Self::CbrsHeartbeat => CBRS_HEARTBEAT,
Self::WifiHeartbeat => WIFI_HEARTBEAT,
Self::CellSpeedtest => CELL_SPEEDTEST,
Self::VerifiedSpeedtest => VERIFIED_SPEEDTEST,
Self::CellHeartbeatIngestReport => CELL_HEARTBEAT_INGEST_REPORT,
Self::CbrsHeartbeatIngestReport => CELL_HEARTBEAT_INGEST_REPORT,
Self::WifiHeartbeatIngestReport => WIFI_HEARTBEAT_INGEST_REPORT,
Self::CellSpeedtestIngestReport => CELL_SPEEDTEST_INGEST_REPORT,
Self::Entropy => ENTROPY,
Self::SubnetworkRewards => SUBNETWORK_REWARDS,
Expand Down Expand Up @@ -232,10 +238,12 @@ impl FileType {
Self::VerifiedSubscriberLocationIngestReport => {
VERIFIED_SUBSCRIBER_LOCATION_INGEST_REPORT
}
Self::CellHeartbeat => CELL_HEARTBEAT,
Self::CbrsHeartbeat => CBRS_HEARTBEAT,
Self::WifiHeartbeat => WIFI_HEARTBEAT,
Self::CellSpeedtest => CELL_SPEEDTEST,
Self::VerifiedSpeedtest => VERIFIED_SPEEDTEST,
Self::CellHeartbeatIngestReport => CELL_HEARTBEAT_INGEST_REPORT,
Self::CbrsHeartbeatIngestReport => CELL_HEARTBEAT_INGEST_REPORT,
Self::WifiHeartbeatIngestReport => WIFI_HEARTBEAT_INGEST_REPORT,
Self::CellSpeedtestIngestReport => CELL_SPEEDTEST_INGEST_REPORT,
Self::Entropy => ENTROPY,
Self::SubnetworkRewards => SUBNETWORK_REWARDS,
Expand Down Expand Up @@ -277,10 +285,12 @@ impl FromStr for FileType {
VERIFIED_SUBSCRIBER_LOCATION_INGEST_REPORT => {
Self::VerifiedSubscriberLocationIngestReport
}
CELL_HEARTBEAT => Self::CellHeartbeat,
CBRS_HEARTBEAT => Self::CbrsHeartbeat,
WIFI_HEARTBEAT => Self::WifiHeartbeat,
CELL_SPEEDTEST => Self::CellSpeedtest,
VERIFIED_SPEEDTEST => Self::VerifiedSpeedtest,
CELL_HEARTBEAT_INGEST_REPORT => Self::CellHeartbeatIngestReport,
CELL_HEARTBEAT_INGEST_REPORT => Self::CbrsHeartbeatIngestReport,
WIFI_HEARTBEAT_INGEST_REPORT => Self::WifiHeartbeatIngestReport,
CELL_SPEEDTEST_INGEST_REPORT => Self::CellSpeedtestIngestReport,
ENTROPY => Self::Entropy,
SUBNETWORK_REWARDS => Self::SubnetworkRewards,
Expand Down
24 changes: 12 additions & 12 deletions file_store/src/heartbeat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use helium_proto::services::poc_mobile::{CellHeartbeatIngestReportV1, CellHeartb
use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct CellHeartbeat {
pub struct CbrsHeartbeat {
pub pubkey: PublicKeyBinary,
pub hotspot_type: String,
pub cell_id: u32,
Expand All @@ -21,20 +21,20 @@ pub struct CellHeartbeat {
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct CellHeartbeatIngestReport {
pub struct CbrsHeartbeatIngestReport {
pub received_timestamp: DateTime<Utc>,
pub report: CellHeartbeat,
pub report: CbrsHeartbeat,
}

impl MsgDecode for CellHeartbeat {
impl MsgDecode for CbrsHeartbeat {
type Msg = CellHeartbeatReqV1;
}

impl MsgDecode for CellHeartbeatIngestReport {
impl MsgDecode for CbrsHeartbeatIngestReport {
type Msg = CellHeartbeatIngestReportV1;
}

impl TryFrom<CellHeartbeatReqV1> for CellHeartbeat {
impl TryFrom<CellHeartbeatReqV1> for CbrsHeartbeat {
type Error = Error;
fn try_from(v: CellHeartbeatReqV1) -> Result<Self> {
Ok(Self {
Expand All @@ -57,7 +57,7 @@ impl MsgTimestamp<Result<DateTime<Utc>>> for CellHeartbeatReqV1 {
}
}

impl TryFrom<CellHeartbeatIngestReportV1> for CellHeartbeatIngestReport {
impl TryFrom<CellHeartbeatIngestReportV1> for CbrsHeartbeatIngestReport {
type Error = Error;
fn try_from(v: CellHeartbeatIngestReportV1) -> Result<Self> {
Ok(Self {
Expand Down Expand Up @@ -108,17 +108,17 @@ mod tests {

let buffer = report.encode_to_vec();

let cellheartbeatreport = CellHeartbeatIngestReport::decode(buffer.as_slice())
.expect("unable to decode into CellHeartbeat");
let heartbeatreport = CbrsHeartbeatIngestReport::decode(buffer.as_slice())
jeffgrunewald marked this conversation as resolved.
Show resolved Hide resolved
.expect("unable to decode into CbrsHeartbeat");

assert_eq!(
cellheartbeatreport.received_timestamp,
heartbeatreport.received_timestamp,
Utc.timestamp_millis_opt(now).unwrap()
);
assert_eq!(
report.timestamp().expect("timestamp"),
cellheartbeatreport.received_timestamp
heartbeatreport.received_timestamp
);
assert_eq!(cellheartbeatreport.report.cell_id, 123);
assert_eq!(heartbeatreport.report.cell_id, 123);
}
}
1 change: 1 addition & 0 deletions file_store/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ pub mod reward_manifest;
mod settings;
pub mod speedtest;
pub mod traits;
pub mod wifi_heartbeat;

pub use crate::file_store::FileStore;
pub use cli::bucket::FileFilter;
Expand Down
3 changes: 2 additions & 1 deletion file_store/src/traits/msg_verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use helium_proto::services::{
use helium_proto::{
services::poc_mobile::{
CellHeartbeatReqV1, CoverageObjectReqV1, DataTransferSessionReqV1, SpeedtestReqV1,
SubscriberLocationReqV1,
SubscriberLocationReqV1, WifiHeartbeatReqV1,
},
Message,
};
Expand All @@ -31,6 +31,7 @@ macro_rules! impl_msg_verify {
}
impl_msg_verify!(SubscriberLocationReqV1, signature);
impl_msg_verify!(CellHeartbeatReqV1, signature);
impl_msg_verify!(WifiHeartbeatReqV1, signature);
impl_msg_verify!(SpeedtestReqV1, signature);
impl_msg_verify!(LoraBeaconReportReqV1, signature);
impl_msg_verify!(LoraWitnessReportReqV1, signature);
Expand Down
Loading