Skip to content
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
1 change: 1 addition & 0 deletions Cargo.lock

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

10 changes: 5 additions & 5 deletions mobile_config/src/gateway_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ use helium_proto::services::mobile_config::{
GatewayMetadata as GatewayMetadataProto, GatewayMetadataV2 as GatewayMetadataProtoV2,
WifiDeploymentInfo as WifiDeploymentInfoProto,
};
use serde::Deserialize;
use serde::{Deserialize, Serialize};

pub type GatewayInfoStream = BoxStream<'static, GatewayInfo>;

#[derive(Clone, Debug, Deserialize)]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct WifiDeploymentInfo {
/// Antenna ID
pub antenna: u32,
Expand All @@ -37,7 +37,7 @@ impl From<WifiDeploymentInfoProto> for WifiDeploymentInfo {
}
}

#[derive(Clone, Debug, Deserialize)]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct CbrsDeploymentInfo {
pub cbrs_radios_deployment_info: Vec<CbrsRadioDeploymentInfo>,
}
Expand All @@ -63,15 +63,15 @@ impl From<CbrsRadioDeploymentInfoProto> for CbrsRadioDeploymentInfo {
}
}

#[derive(Clone, Debug, Deserialize)]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct CbrsRadioDeploymentInfo {
/// CBSD_ID
pub radio_id: String,
/// The asserted elevation of the gateway above ground level in whole meters
pub elevation: u32,
}

#[derive(Clone, Debug, Deserialize)]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub enum DeploymentInfo {
#[serde(rename = "wifiInfoV0")]
WifiDeploymentInfo(WifiDeploymentInfo),
Expand Down
2 changes: 2 additions & 0 deletions mobile_config_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ tokio = {workspace = true, features = ["macros", "rt-multi-thread"]}
tokio-stream = {workspace = true}
tonic = {workspace = true, features = ["tls", "tls-roots"]}
tracing = {workspace = true}
custom-tracing = { path = "../custom_tracing" }

17 changes: 10 additions & 7 deletions mobile_config_cli/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ use helium_proto::{
AdminAddKeyReqV1, AdminKeyResV1, AdminRemoveKeyReqV1, AuthorizationListReqV1,
AuthorizationListResV1, AuthorizationVerifyReqV1, AuthorizationVerifyResV1,
CarrierIncentivePromotionListReqV1, CarrierIncentivePromotionListResV1, EntityVerifyReqV1,
EntityVerifyResV1, GatewayInfoBatchReqV1, GatewayInfoReqV1, GatewayInfoResV1,
GatewayInfoStreamResV1,
EntityVerifyResV1, GatewayInfoBatchReqV1, GatewayInfoReqV1, GatewayInfoResV2,
GatewayInfoStreamResV2,
},
Message,
};
Expand Down Expand Up @@ -223,7 +223,7 @@ impl GatewayClient {
signature: vec![],
};
request.signature = request.sign(keypair)?;
let response = self.client.info(request).await?.into_inner();
let response = self.client.info_v2(request).await?.into_inner();
response.verify(&self.server_pubkey)?;
let info = response
.info
Expand All @@ -247,15 +247,18 @@ impl GatewayClient {
let config_pubkey = self.server_pubkey.clone();
let stream = self
.client
.info_batch(request)
.info_batch_v2(request)
.await?
.into_inner()
.filter_map(|res| async move { res.ok() })
.map(move |res| (res, config_pubkey.clone()))
.filter_map(|(res, pubkey)| async move {
match res.verify(&pubkey) {
Ok(()) => Some(res),
Err(_) => None,
Err(err) => {
tracing::error!(?err, "Response verification failed");
None
}
}
})
.flat_map(|res| stream::iter(res.gateways.into_iter()))
Expand Down Expand Up @@ -320,6 +323,6 @@ impl_verify!(AdminKeyResV1, signature);
impl_verify!(AuthorizationVerifyResV1, signature);
impl_verify!(AuthorizationListResV1, signature);
impl_verify!(EntityVerifyResV1, signature);
impl_verify!(GatewayInfoResV1, signature);
impl_verify!(GatewayInfoStreamResV1, signature);
impl_verify!(GatewayInfoResV2, signature);
impl_verify!(GatewayInfoStreamResV2, signature);
impl_verify!(CarrierIncentivePromotionListResV1, signature);
6 changes: 4 additions & 2 deletions mobile_config_cli/src/cmds/gateway.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ use angry_purple_tiger::AnimalName;
use futures::StreamExt;
use helium_crypto::PublicKey;
use helium_proto::services::mobile_config::{
GatewayInfo as GatewayInfoProto, GatewayMetadata as GatewayMetadataProto,
GatewayInfoV2 as GatewayInfoProto, GatewayMetadataV2 as GatewayMetadataProto,
};
use mobile_config::gateway_info::DeviceType;
use mobile_config::gateway_info::{DeploymentInfo, DeviceType};
use serde::Serialize;
use std::str::FromStr;

Expand All @@ -23,6 +23,7 @@ pub struct GatewayInfo {
#[derive(Debug, Serialize)]
pub struct GatewayMetadata {
location: String,
deployment_info: Option<DeploymentInfo>,
lat: f64,
lon: f64,
}
Expand Down Expand Up @@ -89,6 +90,7 @@ impl TryFrom<GatewayMetadataProto> for GatewayMetadata {
location,
lat: latlng.lat(),
lon: latlng.lng(),
deployment_info: md.deployment_info.map(DeploymentInfo::from),
})
}
}
9 changes: 9 additions & 0 deletions mobile_config_cli/src/cmds/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pub mod gateway;
pub const ENV_CONFIG_HOST: &str = "HELIUM_CONFIG_HOST";
pub const ENV_CONFIG_PUBKEY: &str = "HELIUM_CONFIG_PUBKEY";
pub const ENV_KEYPAIR_BIN: &str = "HELIUM_KEYPAIR_BIN";
pub const ENV_LOG_FILTER: &str = "HELIUM_LOG_FILTER";

#[derive(Debug, Parser)]
#[command(name = "mobile-config")]
Expand Down Expand Up @@ -49,6 +50,14 @@ pub struct Cli {

#[arg(global = true, long)]
pub print_command: bool,

#[arg(
global = true,
long,
env = ENV_LOG_FILTER,
default_value = "Error"
)]
pub log_filter: String,
}

#[derive(Debug, Subcommand)]
Expand Down
2 changes: 2 additions & 0 deletions mobile_config_cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ use mobile_config_cli::{
async fn main() -> Result {
let cli = Cli::parse();

custom_tracing::init(cli.log_filter.clone(), custom_tracing::Settings::default()).await?;

if cli.print_command {
println!("cli:#?");
}
Expand Down