Skip to content

Commit

Permalink
handle unknown lora region in config service gateway api
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffgrunewald committed Apr 6, 2023
1 parent d2532d0 commit 501b237
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 61 deletions.
67 changes: 8 additions & 59 deletions Cargo.lock

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

6 changes: 4 additions & 2 deletions iot_config/src/gateway_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use helium_proto::{
GatewayLocationReqV1, GatewayLocationResV1, GatewayRegionParamsReqV1,
GatewayRegionParamsResV1,
},
Message,
Message, Region,
};
use hextree::Cell;
use node_follower::{
Expand Down Expand Up @@ -84,7 +84,9 @@ impl iot_config::Gateway for GatewayService {
let pubkey: &PublicKeyBinary = &pubkey.into();
tracing::debug!(pubkey = pubkey.to_string(), "fetching region params");

let default_region = request.region();
let default_region = Region::from_i32(request.region).ok_or(Status::invalid_argument(
format!("invalid lora region {}", request.region),
))?;

let (region, gain) = match self
.follower_service
Expand Down
8 changes: 8 additions & 0 deletions iot_config/src/region_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,14 @@ pub async fn build_params_map(
let params = BlockchainRegionParamsV1::decode(region_row.params.as_slice())?;
params_map.insert(region, params);
}

// insert the Unknown region with Empty params
params_map.insert(
Region::Unknown,
BlockchainRegionParamsV1 {
region_params: vec![],
},
);
Ok(params_map)
}

Expand Down

0 comments on commit 501b237

Please sign in to comment.