mirror of
https://github.com/chirpstack/chirpstack.git
synced 2025-01-31 07:55:23 +00:00
Fix clippy feedback.
This commit is contained in:
parent
f71d30ca83
commit
0a294e41b5
@ -37,11 +37,10 @@ impl Algorithm {
|
||||
}
|
||||
nb_step -= 1;
|
||||
} else {
|
||||
if tx_power_index > 0 {
|
||||
// Increase the tx-power.
|
||||
// (note that a decrease in index increases the tx-power)
|
||||
tx_power_index -= 1;
|
||||
}
|
||||
// Increase the tx-power.
|
||||
// (note that a decrease in index increases the tx-power)
|
||||
// Subtract only if > 0
|
||||
tx_power_index = tx_power_index.saturating_sub(1);
|
||||
nb_step += 1;
|
||||
}
|
||||
|
||||
|
@ -844,7 +844,7 @@ impl InternalService for Internal {
|
||||
out.rx1_delay = region_conf.network.rx1_delay as u32;
|
||||
out.rx1_dr_offset = region_conf.network.rx1_dr_offset as u32;
|
||||
out.rx2_dr = region_conf.network.rx2_dr as u32;
|
||||
out.rx2_frequency = region_conf.network.rx2_frequency as u32;
|
||||
out.rx2_frequency = region_conf.network.rx2_frequency;
|
||||
out.class_b_ping_slot_dr = region_conf.network.class_b.ping_slot_dr as u32;
|
||||
out.class_b_ping_slot_frequency = region_conf.network.class_b.ping_slot_frequency;
|
||||
}
|
||||
|
@ -223,7 +223,7 @@ pub fn ul_meta_data_to_rx_info(ul_meta_data: &ULMetaData) -> Result<Vec<gw::Upli
|
||||
gateway_id: hex::encode(&gw_info.id),
|
||||
context: gw_info.ul_token.clone(),
|
||||
rssi: gw_info.rssi.unwrap_or_default() as i32,
|
||||
snr: gw_info.snr.unwrap_or_default() as f32,
|
||||
snr: gw_info.snr.unwrap_or_default(),
|
||||
location: if gw_info.lat.is_some() && gw_info.lon.is_some() {
|
||||
Some(common::Location {
|
||||
latitude: gw_info.lat.unwrap(),
|
||||
|
@ -287,7 +287,7 @@ impl CayenneLpp {
|
||||
val.fields.insert(
|
||||
format!("{}", k),
|
||||
pbjson_types::Value {
|
||||
kind: Some(pbjson_types::value::Kind::NumberValue(*v as f64)),
|
||||
kind: Some(pbjson_types::value::Kind::NumberValue(*v)),
|
||||
},
|
||||
);
|
||||
}
|
||||
@ -305,7 +305,7 @@ impl CayenneLpp {
|
||||
val.fields.insert(
|
||||
format!("{}", k),
|
||||
pbjson_types::Value {
|
||||
kind: Some(pbjson_types::value::Kind::NumberValue(*v as f64)),
|
||||
kind: Some(pbjson_types::value::Kind::NumberValue(*v)),
|
||||
},
|
||||
);
|
||||
}
|
||||
@ -359,7 +359,7 @@ impl CayenneLpp {
|
||||
val.fields.insert(
|
||||
format!("{}", k),
|
||||
pbjson_types::Value {
|
||||
kind: Some(pbjson_types::value::Kind::NumberValue(*v as f64)),
|
||||
kind: Some(pbjson_types::value::Kind::NumberValue(*v)),
|
||||
},
|
||||
);
|
||||
}
|
||||
@ -377,7 +377,7 @@ impl CayenneLpp {
|
||||
val.fields.insert(
|
||||
format!("{}", k),
|
||||
pbjson_types::Value {
|
||||
kind: Some(pbjson_types::value::Kind::NumberValue(*v as f64)),
|
||||
kind: Some(pbjson_types::value::Kind::NumberValue(*v)),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ impl serialize::ToSql<Text, Pg> for Codec
|
||||
where
|
||||
str: serialize::ToSql<Text, Pg>,
|
||||
{
|
||||
fn to_sql<'b>(&self, out: &mut serialize::Output<'b, '_, Pg>) -> serialize::Result {
|
||||
fn to_sql(&self, out: &mut serialize::Output<'_, '_, Pg>) -> serialize::Result {
|
||||
<str as serialize::ToSql<Text, Pg>>::to_sql(&self.to_string(), &mut out.reborrow())
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ lazy_static! {
|
||||
static ref CONFIG: Mutex<Arc<Configuration>> = Mutex::new(Arc::new(Default::default()));
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
#[derive(Default, Serialize, Deserialize, Clone)]
|
||||
#[serde(default)]
|
||||
pub struct Configuration {
|
||||
pub logging: Logging,
|
||||
@ -33,27 +33,6 @@ pub struct Configuration {
|
||||
pub regions: Vec<Region>,
|
||||
}
|
||||
|
||||
impl Default for Configuration {
|
||||
fn default() -> Self {
|
||||
Configuration {
|
||||
logging: Default::default(),
|
||||
postgresql: Default::default(),
|
||||
redis: Default::default(),
|
||||
api: Default::default(),
|
||||
gateway: Default::default(),
|
||||
network: Default::default(),
|
||||
monitoring: Default::default(),
|
||||
integration: Default::default(),
|
||||
codec: Default::default(),
|
||||
user_authentication: Default::default(),
|
||||
join_server: Default::default(),
|
||||
backend_interfaces: Default::default(),
|
||||
roaming: Default::default(),
|
||||
keks: Vec::new(),
|
||||
regions: vec![],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
#[serde(default)]
|
||||
|
@ -23,27 +23,22 @@ pub fn select_downlink_gateway(
|
||||
min_snr_margin: f32,
|
||||
rx_info: &mut internal::DeviceGatewayRxInfo,
|
||||
) -> Result<internal::DeviceGatewayRxInfoItem> {
|
||||
rx_info.items = rx_info
|
||||
.items
|
||||
.iter()
|
||||
.filter(|rx_info| {
|
||||
if let Some(tenant_id) = &tenant_id {
|
||||
if tenant_id.as_bytes().to_vec() == rx_info.tenant_id {
|
||||
// The tenant is the same as the gateway tenant.
|
||||
true
|
||||
} else {
|
||||
// If tenant_id is different, filter out rx_info elements that have
|
||||
// is_private_down=true.
|
||||
!rx_info.is_private_down
|
||||
}
|
||||
rx_info.items.retain(|rx_info| {
|
||||
if let Some(tenant_id) = &tenant_id {
|
||||
if tenant_id.as_bytes().to_vec() == rx_info.tenant_id {
|
||||
// The tenant is the same as the gateway tenant.
|
||||
true
|
||||
} else {
|
||||
// If tenant_id is None, filter out rx_info elements that have
|
||||
// If tenant_id is different, filter out rx_info elements that have
|
||||
// is_private_down=true.
|
||||
!rx_info.is_private_down
|
||||
}
|
||||
})
|
||||
.cloned()
|
||||
.collect();
|
||||
} else {
|
||||
// If tenant_id is None, filter out rx_info elements that have
|
||||
// is_private_down=true.
|
||||
!rx_info.is_private_down
|
||||
}
|
||||
});
|
||||
|
||||
if rx_info.items.is_empty() {
|
||||
return Err(anyhow!(
|
||||
|
@ -113,7 +113,7 @@ impl JoinAccept<'_> {
|
||||
.gateway_tenant_id_map
|
||||
.get(&gw_id)
|
||||
.map(|v| v.into_bytes().to_vec())
|
||||
.unwrap_or_else(|| Vec::new()),
|
||||
.unwrap_or_else(Vec::new),
|
||||
}
|
||||
})
|
||||
.collect(),
|
||||
|
@ -92,7 +92,7 @@ impl PassiveRoamingDownlink {
|
||||
.gateway_tenant_id_map
|
||||
.get(&gw_id)
|
||||
.map(|v| v.into_bytes().to_vec())
|
||||
.unwrap_or_else(|| Vec::new()),
|
||||
.unwrap_or_else(Vec::new),
|
||||
}
|
||||
})
|
||||
.collect(),
|
||||
@ -127,7 +127,7 @@ impl PassiveRoamingDownlink {
|
||||
let dl_freq_1 = self.dl_meta_data.dl_freq_1.unwrap();
|
||||
let dl_freq_1 = (dl_freq_1 * 1_000_000.0) as u32;
|
||||
let data_rate_1 = self.dl_meta_data.data_rate_1.unwrap();
|
||||
let data_rate_1 = self.region_conf.get_data_rate(data_rate_1 as u8)?;
|
||||
let data_rate_1 = self.region_conf.get_data_rate(data_rate_1)?;
|
||||
let rx_delay_1 = self.dl_meta_data.rx_delay_1.unwrap();
|
||||
|
||||
let mut tx_info = gw::DownlinkTxInfo {
|
||||
@ -169,7 +169,7 @@ impl PassiveRoamingDownlink {
|
||||
let dl_freq_2 = self.dl_meta_data.dl_freq_2.unwrap();
|
||||
let dl_freq_2 = (dl_freq_2 * 1_000_000.0) as u32;
|
||||
let data_rate_2 = self.dl_meta_data.data_rate_2.unwrap();
|
||||
let data_rate_2 = self.region_conf.get_data_rate(data_rate_2 as u8)?;
|
||||
let data_rate_2 = self.region_conf.get_data_rate(data_rate_2)?;
|
||||
let rx_delay_1 = self.dl_meta_data.rx_delay_1.unwrap();
|
||||
|
||||
let mut tx_info = gw::DownlinkTxInfo {
|
||||
|
@ -554,7 +554,7 @@ impl<'de> Visitor<'de> for Eui64WrapperVisitor {
|
||||
E: de::Error,
|
||||
{
|
||||
let s = value.to_string().replace('-', "");
|
||||
let b = hex::decode(&s).map_err(|e| E::custom(format!("{}", e)))?;
|
||||
let b = hex::decode(s).map_err(|e| E::custom(format!("{}", e)))?;
|
||||
let eui64 = EUI64::from_slice(&b).map_err(|e| E::custom(format!("{}", e)))?;
|
||||
Ok(Eui64Wrapper(eui64))
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ impl serialize::ToSql<Text, Pg> for IntegrationKind
|
||||
where
|
||||
str: serialize::ToSql<Text, Pg>,
|
||||
{
|
||||
fn to_sql<'b>(&self, out: &mut serialize::Output<'b, '_, Pg>) -> serialize::Result {
|
||||
fn to_sql(&self, out: &mut serialize::Output<'_, '_, Pg>) -> serialize::Result {
|
||||
<str as serialize::ToSql<Text, Pg>>::to_sql(&self.to_string(), &mut out.reborrow())
|
||||
}
|
||||
}
|
||||
@ -158,7 +158,7 @@ impl deserialize::FromSql<Jsonb, Pg> for IntegrationConfiguration {
|
||||
}
|
||||
|
||||
impl serialize::ToSql<Jsonb, Pg> for IntegrationConfiguration {
|
||||
fn to_sql<'b>(&self, out: &mut serialize::Output<'b, '_, Pg>) -> serialize::Result {
|
||||
fn to_sql(&self, out: &mut serialize::Output<'_, '_, Pg>) -> serialize::Result {
|
||||
let value = serde_json::to_value(self)?;
|
||||
<serde_json::Value as serialize::ToSql<Jsonb, Pg>>::to_sql(&value, &mut out.reborrow())
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ impl deserialize::FromSql<Jsonb, Pg> for Measurements {
|
||||
}
|
||||
|
||||
impl serialize::ToSql<Jsonb, Pg> for Measurements {
|
||||
fn to_sql<'b>(&self, out: &mut serialize::Output<'b, '_, Pg>) -> serialize::Result {
|
||||
fn to_sql(&self, out: &mut serialize::Output<'_, '_, Pg>) -> serialize::Result {
|
||||
let value = serde_json::to_value(&self.0)?;
|
||||
<serde_json::Value as serialize::ToSql<Jsonb, Pg>>::to_sql(&value, &mut out.reborrow())
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ pub async fn global_search(
|
||||
let search = search.to_string();
|
||||
let (query, tags) = parse_search_query(&search);
|
||||
let query = format!("%{}%", query);
|
||||
let tags = serde_json::to_value(&tags).context("To serde_json value")?;
|
||||
let tags = serde_json::to_value(tags).context("To serde_json value")?;
|
||||
|
||||
move || -> Result<Vec<SearchResult>, Error> {
|
||||
let mut c = get_db_conn()?;
|
||||
|
@ -288,7 +288,7 @@ impl Data {
|
||||
.gateway_tenant_id_map
|
||||
.get(&gw_id)
|
||||
.map(|v| v.into_bytes().to_vec())
|
||||
.unwrap_or_else(|| Vec::new()),
|
||||
.unwrap_or_else(Vec::new),
|
||||
}
|
||||
})
|
||||
.collect(),
|
||||
|
@ -375,13 +375,13 @@ fn filter_rx_info_by_tenant_id(tenant_id: Uuid, uplink: &mut UplinkFrameSet) ->
|
||||
.gateway_private_up_map
|
||||
.get(&gateway_id)
|
||||
.cloned()
|
||||
.unwrap_or_else(|| true)
|
||||
.unwrap_or(true)
|
||||
|| force_gws_private)
|
||||
|| uplink
|
||||
.gateway_tenant_id_map
|
||||
.get(&gateway_id)
|
||||
.cloned()
|
||||
.unwrap_or_else(|| Uuid::new_v4())
|
||||
.unwrap_or_else(Uuid::new_v4)
|
||||
== tenant_id
|
||||
{
|
||||
rx_info_set.push(rx_info.clone());
|
||||
|
Loading…
x
Reference in New Issue
Block a user