mirror of
https://github.com/chirpstack/chirpstack.git
synced 2025-04-07 11:26:45 +00:00
Fix region config defaults + use region id if description is missing.
In case the region description was missing, EU868 was set as default. As well the default configuration (in case no regions were set) would always fallback to EU868 which was used for testing. This removes the default EU868 configuration and moves this configuration to tests. This updates the region API methods to use the region id as description, in case the description is not configured. Closes #120.
This commit is contained in:
parent
c568586281
commit
a3c1638c75
@ -802,7 +802,11 @@ impl InternalService for Internal {
|
||||
|
||||
out.regions.push(api::RegionListItem {
|
||||
id: region_config.id.clone(),
|
||||
description: region_config.description.clone(),
|
||||
description: if region_config.description.is_empty() {
|
||||
region_config.id.clone()
|
||||
} else {
|
||||
region_config.description.clone()
|
||||
},
|
||||
region: region_config.common_name.to_proto().into(),
|
||||
});
|
||||
}
|
||||
@ -830,7 +834,11 @@ impl InternalService for Internal {
|
||||
for region_conf in &conf.regions {
|
||||
if req.id == region_conf.id {
|
||||
out.id = region_conf.id.clone();
|
||||
out.description = region_conf.description.clone();
|
||||
out.description = if region_conf.description.is_empty() {
|
||||
region_conf.id.clone()
|
||||
} else {
|
||||
region_conf.description.clone()
|
||||
};
|
||||
out.region = region_conf.common_name.to_proto().into();
|
||||
out.user_info = region_conf.user_info.clone();
|
||||
out.rx1_delay = region_conf.network.rx1_delay as u32;
|
||||
|
@ -50,7 +50,7 @@ impl Default for Configuration {
|
||||
backend_interfaces: Default::default(),
|
||||
roaming: Default::default(),
|
||||
keks: Vec::new(),
|
||||
regions: vec![Default::default()],
|
||||
regions: vec![],
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -168,7 +168,7 @@ impl Default for Network {
|
||||
Network {
|
||||
net_id: NetID::from_be_bytes([0x00, 0x00, 0x00]),
|
||||
dev_addr_prefixes: vec![],
|
||||
enabled_regions: vec!["eu868".into()],
|
||||
enabled_regions: vec![],
|
||||
device_session_ttl: Duration::from_secs(60 * 60 * 24 * 31),
|
||||
deduplication_delay: Duration::from_millis(200),
|
||||
get_downlink_data_delay: Duration::from_millis(100),
|
||||
@ -516,43 +516,17 @@ pub struct Region {
|
||||
impl Default for Region {
|
||||
fn default() -> Self {
|
||||
Region {
|
||||
id: "eu868".to_string(),
|
||||
description: "EU868".to_string(),
|
||||
id: "".to_string(),
|
||||
description: "".to_string(),
|
||||
common_name: CommonName::EU868,
|
||||
user_info: "".into(),
|
||||
network: RegionNetwork {
|
||||
installation_margin: 10.0,
|
||||
rx1_delay: 1,
|
||||
rx2_frequency: 869525000,
|
||||
gateway_prefer_min_margin: 10.0,
|
||||
downlink_tx_power: -1,
|
||||
min_dr: 0,
|
||||
max_dr: 5,
|
||||
uplink_max_eirp: 16.0,
|
||||
class_b: ClassB {
|
||||
ping_slot_dr: 0,
|
||||
ping_slot_frequency: 868100000,
|
||||
},
|
||||
extra_channels: Vec::new(),
|
||||
enabled_uplink_channels: Vec::new(),
|
||||
..Default::default()
|
||||
},
|
||||
gateway: RegionGateway {
|
||||
force_gws_private: false,
|
||||
channels: vec![],
|
||||
backend: GatewayBackend {
|
||||
enabled: "mqtt".into(),
|
||||
mqtt: GatewayBackendMqtt {
|
||||
topic_prefix: "eu868".into(),
|
||||
..Default::default()
|
||||
},
|
||||
},
|
||||
},
|
||||
network: RegionNetwork::default(),
|
||||
gateway: RegionGateway::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default, Serialize, Deserialize, Clone)]
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
#[serde(default)]
|
||||
pub struct RegionNetwork {
|
||||
pub installation_margin: f32,
|
||||
@ -579,6 +553,35 @@ pub struct RegionNetwork {
|
||||
pub dwell_time_400ms: bool,
|
||||
}
|
||||
|
||||
impl Default for RegionNetwork {
|
||||
fn default() -> Self {
|
||||
RegionNetwork {
|
||||
installation_margin: 10.0,
|
||||
rx_window: 0,
|
||||
rx1_delay: 1,
|
||||
rx1_dr_offset: 0,
|
||||
rx2_dr: 0,
|
||||
rx2_frequency: 0,
|
||||
rx2_prefer_on_rx1_dr_lt: 0,
|
||||
rx2_prefer_on_link_budget: false,
|
||||
gateway_prefer_min_margin: 10.0,
|
||||
downlink_tx_power: -1,
|
||||
adr_disabled: false,
|
||||
min_dr: 0,
|
||||
max_dr: 0,
|
||||
uplink_dwell_time_400ms: false,
|
||||
downlink_dwell_time_400ms: false,
|
||||
uplink_max_eirp: 0.0,
|
||||
rejoin_request: RejoinRequest::default(),
|
||||
class_b: ClassB::default(),
|
||||
extra_channels: vec![],
|
||||
enabled_uplink_channels: vec![],
|
||||
repeater_compatible: false,
|
||||
dwell_time_400ms: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default, Serialize, Deserialize, Clone)]
|
||||
#[serde(default)]
|
||||
pub struct RejoinRequest {
|
||||
|
@ -34,6 +34,41 @@ pub async fn prepare<'a>() -> std::sync::MutexGuard<'a, ()> {
|
||||
"postgres://chirpstack_test:chirpstack_test@postgres/chirpstack_test?sslmode=disable"
|
||||
.to_string();
|
||||
conf.redis.servers = vec!["redis://redis/".to_string()];
|
||||
conf.network.enabled_regions = vec!["eu868".to_string()];
|
||||
conf.regions = vec![config::Region {
|
||||
id: "eu868".to_string(),
|
||||
description: "EU868".to_string(),
|
||||
common_name: lrwn::region::CommonName::EU868,
|
||||
user_info: "".into(),
|
||||
network: config::RegionNetwork {
|
||||
installation_margin: 10.0,
|
||||
rx1_delay: 1,
|
||||
rx2_frequency: 869525000,
|
||||
gateway_prefer_min_margin: 10.0,
|
||||
downlink_tx_power: -1,
|
||||
min_dr: 0,
|
||||
max_dr: 5,
|
||||
uplink_max_eirp: 16.0,
|
||||
class_b: config::ClassB {
|
||||
ping_slot_dr: 0,
|
||||
ping_slot_frequency: 868100000,
|
||||
},
|
||||
extra_channels: Vec::new(),
|
||||
enabled_uplink_channels: Vec::new(),
|
||||
..Default::default()
|
||||
},
|
||||
gateway: config::RegionGateway {
|
||||
force_gws_private: false,
|
||||
channels: vec![],
|
||||
backend: config::GatewayBackend {
|
||||
enabled: "mqtt".into(),
|
||||
mqtt: config::GatewayBackendMqtt {
|
||||
topic_prefix: "eu868".into(),
|
||||
..Default::default()
|
||||
},
|
||||
},
|
||||
},
|
||||
}];
|
||||
config::set(conf);
|
||||
|
||||
// setup storage
|
||||
|
@ -1220,7 +1220,7 @@ async fn run_test(t: &Test) {
|
||||
|
||||
reset_redis().await.unwrap();
|
||||
|
||||
let mut conf: config::Configuration = Default::default();
|
||||
let mut conf: config::Configuration = (*config::get()).clone();
|
||||
for f in &t.extra_uplink_channels {
|
||||
conf.regions[0]
|
||||
.network
|
||||
|
Loading…
x
Reference in New Issue
Block a user