Compare commits

..

10 Commits

Author SHA1 Message Date
ca2961c7b6 Bump version to 4.0.0-rc.3 2022-08-23 08:59:05 +01:00
63b0af6cf3 Remove owning_ref indirect dep by updating prometheus-client.
The owning_ref crate has a vulnerable. The updated prometheus-client no
longer uses owning_ref as a dependency.
2022-08-22 10:54:33 +01:00
d97da8ed50 Fix c > 64 to c >= 64 typo in channel-mask calculation.
Depending the channel-configuration, this would send three LinkADRReq
mac-commands while the same configuration could be send to the device in
two LinkADRReq mac-commands.
2022-08-21 21:48:27 +01:00
3b297ef221 Replace env. variables in config by localhost for .deb and .rpm
The env. variables are used such that the same configuration can be used
for Docker images, .deb and .rpm packages. However, if installing .deb
or .rpm packages, this can be confusing as executing 'chirpstack -c
/etc/chirpstack' will fail because these environment variables are only
available when using systemctl to start the ChirpStack process
(configured in the .service configuration file).
2022-08-21 21:44:36 +01:00
e917f8ea49 Remove default CA and MQTT cert gen. on install.
In case of mult-server deployments, this can be confusing as each VM
generates different certificate files by default, where all instances
must share the same certificate (or at least CA certificate + key).
The other issue is that the MQTT broker certificate must contain the
correct hostname, which can (most of the times) not automatically be
retrieved. Documentation to generate these certificates can be found
here:

https://www.chirpstack.io/docs/guides/mosquitto-tls-configuration.html
2022-08-21 19:56:49 +01:00
424306ab41 Update cpufeatures crate. This fixes an incorrect avx2 check.
In some scenarios, this check returned true while the avx2 extension was
not available (e.g. QEMU emulated CPU).

See for more details: https://github.com/RustCrypto/hashes/pull/386.
2022-08-18 11:37:03 +01:00
613f4562a2 Add config option to allow unknown gateways. 2022-08-18 10:27:55 +01:00
bf6df9c845 Fix shadowing of rx_info and setting location.
The rx_info value was shadowed, and because of this the location was set
on the cloned value, not the original value, making the location set
useless.
2022-08-14 13:49:00 +01:00
d4337b10ab Bump version to 4.0.0-rc.2 2022-08-11 12:04:21 +01:00
77dc247f66 Fix mac_version -> mac_version().
The first returns the Protobuf integer, the second the generated enum
type. The big difference is that the first .to_string() would convert
the Protobuf integer to the same but then as String type, where the
latter returns something like '1.0.3' which is provided by the
fmt::Display trait implementation by ChirpStack.
2022-08-11 11:38:43 +01:00
31 changed files with 165 additions and 133 deletions

6
.gitignore vendored
View File

@ -13,11 +13,7 @@
**/target
# Certificates
/chirpstack/configuration/certs/*.crt
/chirpstack/configuration/certs/*.key
/chirpstack/configuration/certs/*.trust
/chirpstack/configuration/certs/*.pem
/chirpstack/configuration/certs/*.csr
/chirpstack/configuration/certs/*
/chirpstack/configuration/private_*.toml
# UI

37
Cargo.lock generated
View File

@ -635,7 +635,7 @@ dependencies = [
[[package]]
name = "backend"
version = "4.0.0-rc.1"
version = "4.0.0-rc.3"
dependencies = [
"aes-kw",
"anyhow",
@ -879,7 +879,7 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "chirpstack"
version = "4.0.0-rc.1"
version = "4.0.0-rc.3"
dependencies = [
"aes 0.7.5",
"anyhow",
@ -958,7 +958,7 @@ dependencies = [
[[package]]
name = "chirpstack_api"
version = "4.0.0-rc.1"
version = "4.0.0-rc.3"
dependencies = [
"hex",
"pbjson",
@ -1118,9 +1118,9 @@ checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc"
[[package]]
name = "cpufeatures"
version = "0.2.2"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "59a6001667ab124aebae2a495118e11d30984c3a653e99d86d58971708cf5e4b"
checksum = "1079fb8528d9f9c888b1e8aa651e6e079ade467323d58f75faf1d30b1808f540"
dependencies = [
"libc",
]
@ -2222,7 +2222,7 @@ dependencies = [
[[package]]
name = "lrwn"
version = "4.0.0-rc.1"
version = "4.0.0-rc.3"
dependencies = [
"aes 0.7.5",
"anyhow",
@ -2582,15 +2582,6 @@ version = "6.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "648001efe5d5c0102d8cea768e348da85d90af8ba91f0bea908f157951493cd4"
[[package]]
name = "owning_ref"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ff55baddef9e4ad00f88b6c743a2a8062d4c6ade126c2a528644b8e444d52ce"
dependencies = [
"stable_deref_trait",
]
[[package]]
name = "p12"
version = "0.6.3"
@ -2953,21 +2944,21 @@ dependencies = [
[[package]]
name = "prometheus-client"
version = "0.16.0"
version = "0.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac1abe0255c04d15f571427a2d1e00099016506cf3297b53853acd2b7eb87825"
checksum = "3c473049631c233933d6286c88bbb7be30e62ec534cf99a9ae0079211f7fa603"
dependencies = [
"dtoa 1.0.2",
"itoa 1.0.2",
"owning_ref",
"parking_lot",
"prometheus-client-derive-text-encode",
]
[[package]]
name = "prometheus-client-derive-text-encode"
version = "0.2.0"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8e12d01b9d66ad9eb4529c57666b6263fc1993cb30261d83ead658fdd932652"
checksum = "66a455fbcb954c1a7decf3c586e860fd7889cddf4b8e164be736dbac95a953cd"
dependencies = [
"proc-macro2",
"quote",
@ -3803,12 +3794,6 @@ dependencies = [
"lock_api",
]
[[package]]
name = "stable_deref_trait"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
[[package]]
name = "string_cache"
version = "0.8.4"

View File

@ -1,6 +1,6 @@
{
"name": "@chirpstack/chirpstack-api-grpc-web",
"version": "4.0.0-rc.1",
"version": "4.0.0-rc.3",
"description": "Chirpstack gRPC-web API",
"license": "MIT",
"devDependencies": {

2
api/js/package.json vendored
View File

@ -1,6 +1,6 @@
{
"name": "@chirpstack/chirpstack-api",
"version": "4.0.0-rc.1",
"version": "4.0.0-rc.3",
"description": "Chirpstack JS and TS API",
"license": "MIT",
"devDependencies": {

View File

@ -18,7 +18,7 @@ CLASSIFIERS = [
setup(
name='chirpstack-api',
version = "4.0.0-rc.1",
version = "4.0.0-rc.3",
url='https://github.com/brocaar/chirpstack-api',
author='Orne Brocaar',
author_email='info@brocaar.com',

2
api/rust/Cargo.lock generated vendored
View File

@ -121,7 +121,7 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "chirpstack_api"
version = "4.0.0-test.18"
version = "4.0.0-rc.2"
dependencies = [
"hex",
"pbjson",

2
api/rust/Cargo.toml vendored
View File

@ -1,7 +1,7 @@
[package]
name = "chirpstack_api"
description = "ChirpStack Protobuf / gRPC API definitions."
version = "4.0.0-rc.1"
version = "4.0.0-rc.3"
authors = ["Orne Brocaar <info@brocaar.com>"]
license = "MIT"
homepage = "https://www.chirpstack.io"

View File

@ -1,6 +1,6 @@
[package]
name = "backend"
version = "4.0.0-rc.1"
version = "4.0.0-rc.3"
authors = ["Orne Brocaar <info@brocaar.com>"]
edition = "2018"
publish = false

View File

@ -1,4 +0,0 @@
[Service]
Environment="MQTT_BROKER_HOST=localhost"
Environment="POSTGRESQL_HOST=localhost"
Environment="REDIS_HOST=localhost"

View File

@ -23,6 +23,9 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
rm -rf %{buildroot}
mkdir -p %{buildroot}
cp -a * %{buildroot}
sed -i "s/\$MQTT_BROKER_HOST/localhost/" %{buildroot}/etc/chirpstack/*.toml
sed -i "s/\$POSTGRESQL_HOST/localhost/" %{buildroot}/etc/chirpstack/*.toml
sed -i "s/\$REDIS_HOST/localhost/" %{buildroot}/etc/chirpstack/*.toml
%clean
rm -rf %{buildroot}
@ -32,4 +35,3 @@ rm -rf %{buildroot}
%{_bindir}/*
/lib/systemd/system/chirpstack.service
%config /etc/chirpstack/*
%config /etc/systemd/system/chirpstack.service.d/*

View File

@ -3,7 +3,7 @@ name = "chirpstack"
description = "ChirpStack is an open-source LoRaWAN(TM) Network Server"
repository = "https://github.com/chirpstack/chirpstack"
homepage="https://www.chirpstack.io/"
version = "4.0.0-rc.1"
version = "4.0.0-rc.3"
authors = ["Orne Brocaar <info@brocaar.com>"]
edition = "2021"
publish = false
@ -107,7 +107,7 @@ base64 = "0.13"
async-recursion = "1.0"
regex = "1"
petgraph = "0.6"
prometheus-client = "0.16"
prometheus-client = "0.18"
pin-project = "1.0"
# Development and testing
@ -120,13 +120,8 @@ bytes = "1.1"
assets = [
["target/release/chirpstack", "usr/bin/", "755"],
["configuration/*.toml", "etc/chirpstack/", "640"],
["configuration/certs/*.json", "etc/chirpstack/certs", "640"],
["debian/environment.conf", "etc/systemd/system/chirpstack.service.d/environment.conf", "640"],
]
conf-files = [
"/etc/chirpstack/certs/ca-config.json",
"/etc/chirpstack/certs/ca-csr.json",
"/etc/chirpstack/certs/mqtt-server.json",
"/etc/chirpstack/chirpstack.toml",
"/etc/chirpstack/region_as923.toml",
"/etc/chirpstack/region_as923_2.toml",
@ -156,7 +151,6 @@ conf-files = [
"/etc/chirpstack/region_us915_6.toml",
"/etc/chirpstack/region_us915_7.toml",
]
depends = "$auto, golang-cfssl"
suggests = "postgresql, mosquitto, redis"
maintainer-scripts = "debian/"
systemd-units = { enable = true }
@ -167,7 +161,6 @@ package = "chirpstack"
[package.metadata.rpm.files]
"configuration/" = { path = "/etc/chirpstack/" }
"chirpstack.service" = { path = "/lib/systemd/system/chirpstack.service" }
"chirpstack.env" = { path = "/etc/systemd/system/chirpstack.service.d/environment" }
[package.metadata.rpm.cargo]
buildflags = ["--release"]

View File

@ -111,14 +111,8 @@ test:
test-lrwn:
cd ../lrwn && make test
test-server: debug-amd64 configuration/certs/ca.pem
test-server: debug-amd64
../target/debug/chirpstack -c ./configuration
dbshell:
psql -h postgres -U chirpstack chirpstack
configuration/certs/ca.pem:
cfssl gencert -initca configuration/certs/ca-csr.json | cfssljson -bare configuration/certs/ca
configuration/certs/mqtt-server.pem: configuration/certs/ca.pem
cfssl gencert -ca configuration/certs/ca.pem -ca-key configuration/certs/ca-key.pem -config configuration/certs/ca-config.json -profile server configuration/certs/mqtt-server.json | cfssljson -bare configuration/certs/mqtt-server

View File

@ -1,17 +0,0 @@
{
"signing": {
"default": {
"expiry": "8760h"
},
"profiles": {
"server": {
"expiry": "8760h",
"usages": [
"signing",
"key encipherment",
"server auth"
]
}
}
}
}

View File

@ -1,7 +0,0 @@
{
"CN": "ChirpStack CA",
"key": {
"algo": "rsa",
"size": 4096
}
}

View File

@ -1,10 +0,0 @@
{
"CN": "mqtt-broker",
"hosts": [
"*"
],
"key": {
"algo": "rsa",
"size": 4096
}
}

View File

@ -97,19 +97,9 @@
secret="you-must-replace-this"
[gateway]
client_cert_lifetime="365days"
ca_cert="configuration/certs/ca.pem"
ca_key="configuration/certs/ca-key.pem"
[integration]
enabled=["mqtt"]
[integration.mqtt]
server="tcp://$MQTT_BROKER_HOST:1883/"
json=true
[integration.mqtt.client]
client_cert_lifetime="365days"
ca_cert="configuration/certs/ca.pem"
ca_key="configuration/certs/ca-key.pem"

View File

@ -1,4 +0,0 @@
[Service]
Environment="MQTT_BROKER_HOST=localhost"
Environment="POSTGRESQL_HOST=localhost"
Environment="REDIS_HOST=localhost"

View File

@ -3,18 +3,11 @@
# Set config-file permissions
chown -R chirpstack:chirpstack /etc/chirpstack
chmod 750 /etc/chirpstack
chmod 750 /etc/chirpstack/certs
chmod 640 /etc/chirpstack/*.toml
# Generate certificates
CERTROOT=/etc/chirpstack/certs
if [ ! -f $CERTROOT/ca.pem ]; then
cfssl gencert -initca $CERTROOT/ca-csr.json | cfssljson -bare $CERTROOT/ca
fi
if [ ! -f $CERTROOT/mqtt-server.pem ]; then
cfssl gencert -ca $CERTROOT/ca.pem -ca-key $CERTROOT/ca-key.pem -config $CERTROOT/ca-config.json -profile server $CERTROOT/mqtt-server.json | cfssljson -bare $CERTROOT/mqtt-server
fi
# Set environment variables to localhost
sed -i "s/\$MQTT_BROKER_HOST/localhost/" /etc/chirpstack/*.toml
sed -i "s/\$POSTGRESQL_HOST/localhost/" /etc/chirpstack/*.toml
sed -i "s/\$REDIS_HOST/localhost/" /etc/chirpstack/*.toml
#DEBHELPER#

View File

@ -104,6 +104,12 @@ pub fn run() {
# This defines how long (after generating) the certificate remains valid.
client_cert_lifetime="{{ gateway.client_cert_lifetime }}"
# Allow unknown gateways.
#
# If set to true, then uplinks received from gateways not configured in
# ChirpStack will be allowed.
allow_unknown_gateways={{ gateway.allow_unknown_gateways }}
# Network related configuration.
[network]

View File

@ -132,6 +132,7 @@ pub struct Gateway {
pub client_cert_lifetime: Duration,
pub ca_cert: String,
pub ca_key: String,
pub allow_unknown_gateways: bool,
}
impl Default for Gateway {
@ -140,6 +141,7 @@ impl Default for Gateway {
client_cert_lifetime: Duration::from_secs(60 * 60 * 24 * 365),
ca_cert: "".to_string(),
ca_key: "".to_string(),
allow_unknown_gateways: false,
}
}
}

View File

@ -262,7 +262,7 @@ impl TxAck {
let mut ds = self.device_session.as_mut().unwrap();
if ds.mac_version.to_string().starts_with("1.0") {
if ds.mac_version().to_string().starts_with("1.0") {
ds.n_f_cnt_down += 1;
} else {
ds.a_f_cnt_down += 1;

View File

@ -60,6 +60,12 @@ async fn test_fns_uplink() {
let mut rx_info = gw::UplinkRxInfo {
gateway_id: gw.gateway_id.to_string(),
time: Some(recv_time.into()),
location: Some(common::Location {
latitude: 0.0,
longitude: 0.0,
altitude: 0.0,
..Default::default()
}),
..Default::default()
};
rx_info.set_metadata_string("region_name", "eu868");

View File

@ -98,6 +98,7 @@ async fn test_gateway_filtering() {
let mut rx_info_a = gw::UplinkRxInfo {
gateway_id: gw_a.gateway_id.to_string(),
location: Some(Default::default()),
..Default::default()
};
rx_info_a.set_metadata_string("region_name", "eu868");
@ -105,6 +106,7 @@ async fn test_gateway_filtering() {
let mut rx_info_b = gw::UplinkRxInfo {
gateway_id: gw_b.gateway_id.to_string(),
location: Some(Default::default()),
..Default::default()
};
rx_info_b.set_metadata_string("region_name", "eu868");
@ -247,6 +249,7 @@ async fn test_lorawan_10_errors() {
let mut rx_info = gw::UplinkRxInfo {
gateway_id: gw.gateway_id.to_string(),
location: Some(Default::default()),
..Default::default()
};
rx_info.set_metadata_string("region_name", "eu868");
@ -426,6 +429,7 @@ async fn test_lorawan_11_errors() {
let mut rx_info = gw::UplinkRxInfo {
gateway_id: gw.gateway_id.to_string(),
location: Some(Default::default()),
..Default::default()
};
rx_info.set_metadata_string("region_name", "eu868");
@ -575,6 +579,7 @@ async fn test_lorawan_10_skip_f_cnt() {
let mut rx_info = gw::UplinkRxInfo {
gateway_id: gw.gateway_id.to_string(),
location: Some(Default::default()),
..Default::default()
};
rx_info.set_metadata_string("region_name", "eu868");
@ -763,6 +768,7 @@ async fn test_lorawan_10_device_disabled() {
let mut rx_info = gw::UplinkRxInfo {
gateway_id: gw.gateway_id.to_string(),
location: Some(Default::default()),
..Default::default()
};
rx_info.set_metadata_string("region_name", "eu868");
@ -881,6 +887,7 @@ async fn test_lorawan_10_uplink() {
let mut rx_info = gw::UplinkRxInfo {
gateway_id: gw.gateway_id.to_string(),
location: Some(Default::default()),
..Default::default()
};
rx_info.set_metadata_string("region_name", "eu868");
@ -1495,6 +1502,7 @@ async fn test_lorawan_11_uplink() {
let mut rx_info = gw::UplinkRxInfo {
gateway_id: gw.gateway_id.to_string(),
location: Some(Default::default()),
..Default::default()
};
rx_info.set_metadata_string("region_name", "eu868");
@ -1728,6 +1736,7 @@ async fn test_lorawan_10_rx_delay() {
let mut rx_info = gw::UplinkRxInfo {
gateway_id: gw.gateway_id.to_string(),
location: Some(Default::default()),
..Default::default()
};
rx_info.set_metadata_string("region_name", "eu868");
@ -1936,6 +1945,7 @@ async fn test_lorawan_10_mac_commands() {
let mut rx_info = gw::UplinkRxInfo {
gateway_id: gw.gateway_id.to_string(),
location: Some(Default::default()),
..Default::default()
};
rx_info.set_metadata_string("region_name", "eu868");
@ -2300,6 +2310,7 @@ async fn test_lorawan_11_mac_commands() {
let mut rx_info = gw::UplinkRxInfo {
gateway_id: gw.gateway_id.to_string(),
location: Some(Default::default()),
..Default::default()
};
rx_info.set_metadata_string("region_name", "eu868");
@ -2489,6 +2500,7 @@ async fn test_lorawan_10_device_queue() {
let mut rx_info = gw::UplinkRxInfo {
gateway_id: gw.gateway_id.to_string(),
location: Some(Default::default()),
..Default::default()
};
rx_info.set_metadata_string("region_name", "eu868");
@ -2957,6 +2969,7 @@ async fn test_lorawan_11_device_queue() {
let mut rx_info = gw::UplinkRxInfo {
gateway_id: gw.gateway_id.to_string(),
location: Some(Default::default()),
..Default::default()
};
rx_info.set_metadata_string("region_name", "eu868");
@ -3429,6 +3442,7 @@ async fn test_lorawan_10_adr() {
let mut rx_info = gw::UplinkRxInfo {
gateway_id: gw.gateway_id.to_string(),
location: Some(Default::default()),
..Default::default()
};
rx_info.set_metadata_string("region_name", "eu868");
@ -4266,6 +4280,7 @@ async fn test_lorawan_10_device_status_request() {
let mut rx_info = gw::UplinkRxInfo {
gateway_id: gw.gateway_id.to_string(),
location: Some(Default::default()),
..Default::default()
};
rx_info.set_metadata_string("region_name", "eu868");
@ -4524,6 +4539,7 @@ async fn test_lorawan_11_receive_window_selection() {
let mut rx_info = gw::UplinkRxInfo {
gateway_id: gw.gateway_id.to_string(),
location: Some(Default::default()),
..Default::default()
};
rx_info.set_metadata_string("region_name", "eu868");

View File

@ -67,6 +67,7 @@ async fn test_fns() {
let mut rx_info = gw::UplinkRxInfo {
gateway_id: gw.gateway_id.to_string(),
time: Some(recv_time.into()),
location: Some(Default::default()),
..Default::default()
};
rx_info.set_metadata_string("region_name", "eu868");
@ -327,6 +328,7 @@ async fn test_sns() {
let mut rx_info = gw::UplinkRxInfo {
gateway_id: "0302030405060708".to_string(),
time: Some(recv_time.into()),
location: Some(Default::default()),
..Default::default()
};
rx_info.set_metadata_string("region_name", "eu868");

View File

@ -106,6 +106,7 @@ async fn test_gateway_filtering() {
let mut rx_info_a = gw::UplinkRxInfo {
gateway_id: gw_a.gateway_id.to_string(),
location: Some(Default::default()),
..Default::default()
};
rx_info_a.set_metadata_string("region_name", "eu868");
@ -113,6 +114,7 @@ async fn test_gateway_filtering() {
let mut rx_info_b = gw::UplinkRxInfo {
gateway_id: gw_b.gateway_id.to_string(),
location: Some(Default::default()),
..Default::default()
};
rx_info_b.set_metadata_string("region_name", "eu868");
@ -267,6 +269,7 @@ async fn test_lorawan_10() {
let mut rx_info = gw::UplinkRxInfo {
gateway_id: gw.gateway_id.to_string(),
location: Some(Default::default()),
..Default::default()
};
rx_info.set_metadata_string("region_name", "eu868");
@ -910,6 +913,7 @@ async fn test_lorawan_11() {
let mut rx_info = gw::UplinkRxInfo {
gateway_id: gw.gateway_id.to_string(),
location: Some(Default::default()),
..Default::default()
};
rx_info.set_metadata_string("region_name", "eu868");

View File

@ -13,7 +13,7 @@ use uuid::Uuid;
use crate::config;
use crate::framelog;
use crate::storage::{gateway, get_redis_conn, redis_key};
use crate::storage::{error::Error as StorageError, gateway, get_redis_conn, redis_key};
use chirpstack_api::{api, common, gw};
use lrwn::region::CommonName;
use lrwn::{MType, PhyPayload, EUI64};
@ -304,11 +304,19 @@ pub async fn handle_uplink(deduplication_id: Uuid, uplink: gw::UplinkFrameSet) -
}
async fn update_gateway_metadata(ufs: &mut UplinkFrameSet) -> Result<()> {
let conf = config::get();
for rx_info in &mut ufs.rx_info_set {
let gw_id = EUI64::from_str(&rx_info.gateway_id)?;
let gw_meta = match gateway::get_meta(&gw_id).await {
Ok(v) => v,
Err(e) => {
if conf.gateway.allow_unknown_gateways {
if let StorageError::NotFound(_) = e {
ufs.gateway_private_map.insert(gw_id, false);
continue;
}
}
error!(
gateway_id = gw_id.to_string().as_str(),
error = format!("{}", e).as_str(),
@ -318,7 +326,6 @@ async fn update_gateway_metadata(ufs: &mut UplinkFrameSet) -> Result<()> {
}
};
let mut rx_info = rx_info.clone();
rx_info.location = Some(common::Location {
latitude: gw_meta.latitude,
longitude: gw_meta.longitude,

View File

@ -3,7 +3,7 @@ name = "lrwn"
description = "Library for encoding / decoding LoRaWAN frames."
homepage = "https://www.chirpstack.io"
license = "MIT"
version = "4.0.0-rc.1"
version = "4.0.0-rc.3"
authors = ["Orne Brocaar <info@brocaar.com>"]
edition = "2018"
repository = "https://github.com/chirpstack/chirpstack"

View File

@ -1107,7 +1107,7 @@ impl Region for Configuration {
// use the ChMask of the first LinkADRReqPayload, besides
// turning off all 125 kHz this payload contains the ChMask
// for the last block of channels.
if c > 64 {
if c >= 64 {
out[0].ch_mask.set(c % 16, true);
continue;
}
@ -1419,11 +1419,11 @@ pub mod test {
expected_uplink_channels: c.get_uplink_channel_indices(),
expected_link_adr_req_payloads: vec![],
},
// Only activate 0 - 7.
// Only activate 0 - 7 + 64.
Test {
device_channels: c.get_uplink_channel_indices(),
enabled_channels: vec![0, 1, 2, 3, 4, 5, 6, 7],
expected_uplink_channels: vec![0, 1, 2, 3, 4, 5, 6, 7],
enabled_channels: vec![0, 1, 2, 3, 4, 5, 6, 7, 64],
expected_uplink_channels: vec![0, 1, 2, 3, 4, 5, 6, 7, 64],
expected_link_adr_req_payloads: vec![
LinkADRReqPayload {
dr: 0,
@ -1432,7 +1432,10 @@ pub mod test {
ch_mask_cntl: 7,
nb_rep: 0,
},
ch_mask: ChMask::new([false; 16]),
ch_mask: ChMask::new([
true, false, false, false, false, false, false, false, false, false,
false, false, false, false, false, false,
]),
},
LinkADRReqPayload {
dr: 0,
@ -1448,6 +1451,42 @@ pub mod test {
},
],
},
// Only activate 0 - 15 + 64 & 65.
Test {
device_channels: c.get_uplink_channel_indices(),
enabled_channels: vec![
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 64, 65,
],
expected_uplink_channels: vec![
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 64, 65,
],
expected_link_adr_req_payloads: vec![
LinkADRReqPayload {
dr: 0,
tx_power: 0,
redundancy: Redundancy {
ch_mask_cntl: 7,
nb_rep: 0,
},
ch_mask: ChMask::new([
true, true, false, false, false, false, false, false, false, false,
false, false, false, false, false, false,
]),
},
LinkADRReqPayload {
dr: 0,
tx_power: 0,
redundancy: Redundancy {
ch_mask_cntl: 0,
nb_rep: 0,
},
ch_mask: ChMask::new([
true, true, true, true, true, true, true, true, true, true, true, true,
true, true, true, true,
]),
},
],
},
];
for tst in &tests {

View File

@ -797,7 +797,7 @@ impl Region for Configuration {
// use the ChMask of the first LinkADRReqPayload, besides
// turning off all 125 kHz this payload contains the ChMask
// for the last block of channels.
if c > 64 {
if c >= 64 {
out[0].ch_mask.set(c % 16, true);
continue;
}
@ -1111,11 +1111,11 @@ pub mod test {
expected_uplink_channels: c.get_uplink_channel_indices(),
expected_link_adr_req_payloads: vec![],
},
// Only activate 0 - 7.
// Only activate 0 - 7 + 64.
Test {
device_channels: c.get_uplink_channel_indices(),
enabled_channels: vec![0, 1, 2, 3, 4, 5, 6, 7],
expected_uplink_channels: vec![0, 1, 2, 3, 4, 5, 6, 7],
enabled_channels: vec![0, 1, 2, 3, 4, 5, 6, 7, 64],
expected_uplink_channels: vec![0, 1, 2, 3, 4, 5, 6, 7, 64],
expected_link_adr_req_payloads: vec![
LinkADRReqPayload {
dr: 0,
@ -1124,7 +1124,10 @@ pub mod test {
ch_mask_cntl: 7,
nb_rep: 0,
},
ch_mask: ChMask::new([false; 16]),
ch_mask: ChMask::new([
true, false, false, false, false, false, false, false, false, false,
false, false, false, false, false, false,
]),
},
LinkADRReqPayload {
dr: 0,
@ -1140,6 +1143,42 @@ pub mod test {
},
],
},
// Only activate 0 - 15 + 64 & 65.
Test {
device_channels: c.get_uplink_channel_indices(),
enabled_channels: vec![
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 64, 65,
],
expected_uplink_channels: vec![
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 64, 65,
],
expected_link_adr_req_payloads: vec![
LinkADRReqPayload {
dr: 0,
tx_power: 0,
redundancy: Redundancy {
ch_mask_cntl: 7,
nb_rep: 0,
},
ch_mask: ChMask::new([
true, true, false, false, false, false, false, false, false, false,
false, false, false, false, false, false,
]),
},
LinkADRReqPayload {
dr: 0,
tx_power: 0,
redundancy: Redundancy {
ch_mask_cntl: 0,
nb_rep: 0,
},
ch_mask: ChMask::new([
true, true, true, true, true, true, true, true, true, true, true, true,
true, true, true, true,
]),
},
],
},
];
for tst in &tests {

View File

@ -1,6 +1,6 @@
{
"name": "chirpstack-ui",
"version": "4.0.0-rc.1",
"version": "4.0.0-rc.3",
"private": true,
"dependencies": {
"@ant-design/colors": "^6.0.0",

View File

@ -1881,7 +1881,7 @@
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
"@chirpstack/chirpstack-api-grpc-web@file:../api/grpc-web":
version "4.0.0-rc.1"
version "4.0.0-rc.2"
dependencies:
"@types/google-protobuf" "^3.15.2"
google-protobuf "^3.17.3"