Compare commits

..

4 Commits

Author SHA1 Message Date
eaad8586a1 Bump version to 4.3.0-test.3 2023-03-02 14:32:56 +00:00
43567ccfd2 Show fcnt in event log.
Closes #121.
2023-03-02 13:40:06 +00:00
ddea09d9d4 Decode frm_payload mac-commands in device frame log. 2023-03-02 12:21:42 +00:00
9ab059a552 Fix disabling mac-commands. 2023-03-02 09:19:36 +00:00
20 changed files with 65 additions and 20 deletions

8
Cargo.lock generated
View File

@ -666,7 +666,7 @@ dependencies = [
[[package]]
name = "backend"
version = "4.3.0-test.2"
version = "4.3.0-test.3"
dependencies = [
"aes-kw",
"anyhow",
@ -880,7 +880,7 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "chirpstack"
version = "4.3.0-test.2"
version = "4.3.0-test.3"
dependencies = [
"aes",
"anyhow",
@ -959,7 +959,7 @@ dependencies = [
[[package]]
name = "chirpstack_api"
version = "4.3.0-test.2"
version = "4.3.0-test.3"
dependencies = [
"hex",
"pbjson",
@ -2367,7 +2367,7 @@ dependencies = [
[[package]]
name = "lrwn"
version = "4.3.0-test.2"
version = "4.3.0-test.3"
dependencies = [
"aes",
"anyhow",

View File

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

View File

@ -8,7 +8,7 @@ plugins {
}
group = "io.chirpstack"
version = "4.3.0-test.2"
version = "4.3.0-test.3"
repositories {
mavenCentral()

2
api/js/package.json vendored
View File

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

View File

@ -9,7 +9,7 @@ plugins {
}
group = "io.chirpstack"
version = "4.3.0-test.2"
version = "4.3.0-test.3"
repositories {
mavenCentral()

View File

@ -229,8 +229,11 @@ message DownlinkFrame {
// Encrypted FOpts (LoRaWAN 1.1).
bool encrypted_fopts = 8;
// Network session encryption key (for FOpts).
// Network session encryption key (for FOpts and FRMPayload mac-commands).
bytes nwk_s_enc_key = 9;
// NFCntDown (for decrypting mac-commands).
uint32 n_f_cnt_down = 10;
}
message LoraCloudGeolocBuffer {

View File

@ -229,8 +229,11 @@ message DownlinkFrame {
// Encrypted FOpts (LoRaWAN 1.1).
bool encrypted_fopts = 8;
// Network session encryption key (for FOpts).
// Network session encryption key (for FOpts and FRMPayload mac-commands).
bytes nwk_s_enc_key = 9;
// NFCntDown (for decrypting mac-commands).
uint32 n_f_cnt_down = 10;
}
message LoraCloudGeolocBuffer {

View File

@ -18,7 +18,7 @@ CLASSIFIERS = [
setup(
name='chirpstack-api',
version = "4.3.0-test.2",
version = "4.3.0-test.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

@ -118,7 +118,7 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "chirpstack_api"
version = "4.3.0-test.2"
version = "4.3.0-test.3"
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.3.0-test.2"
version = "4.3.0-test.3"
authors = ["Orne Brocaar <info@brocaar.com>"]
license = "MIT"
homepage = "https://www.chirpstack.io"

View File

@ -229,8 +229,11 @@ message DownlinkFrame {
// Encrypted FOpts (LoRaWAN 1.1).
bool encrypted_fopts = 8;
// Network session encryption key (for FOpts).
// Network session encryption key (for FOpts and FRMPayload mac-commands).
bytes nwk_s_enc_key = 9;
// NFCntDown (for decrypting mac-commands).
uint32 n_f_cnt_down = 10;
}
message LoraCloudGeolocBuffer {

View File

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

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.3.0-test.2"
version = "4.3.0-test.3"
authors = ["Orne Brocaar <info@brocaar.com>"]
edition = "2021"
publish = false

View File

@ -288,6 +288,7 @@ impl Data {
// The queue item should fit within the max payload size and should not be pending
// already.
if qi.data.len() <= max_payload_size && !qi.is_pending {
trace!(id = %qi.id, more_in_queue = more_in_queue, "Found device queue-item for downlink");
self.device_queue_item = Some(qi);
self.more_device_queue_items = more_in_queue;
return Ok(());
@ -373,6 +374,11 @@ impl Data {
}
async fn set_mac_commands(&mut self) -> Result<()> {
let conf = config::get();
if conf.network.mac_commands_disabled {
return Ok(());
}
// First we set all mac-commands. This does not take the max. payload size in mind, that
// will be taken care of in one of the next steps.
self._request_custom_channel_reconfiguration().await?;
@ -629,6 +635,7 @@ impl Data {
.starts_with("1.1"),
nwk_s_enc_key: self.device_session.nwk_s_enc_key.clone(),
downlink_frame: Some(self.downlink_frame.clone()),
n_f_cnt_down: self.device_session.n_f_cnt_down,
..Default::default()
})
.await

View File

@ -433,6 +433,13 @@ impl TxAck {
let nwk_s_enc_key = AES128Key::from_slice(&df.nwk_s_enc_key)?;
if let Payload::MACPayload(pl) = &mut phy.payload {
if pl.f_port.unwrap_or(0) == 0 {
// We need to set the full NFcntDown to decrypt the mac-commands.
pl.fhdr.f_cnt = df.n_f_cnt_down;
}
}
if let Payload::MACPayload(pl) = &phy.payload {
// f_port must be either None or 0
if pl.f_port.unwrap_or(0) == 0 {

View File

@ -116,8 +116,9 @@ pub async fn get_event_logs(
description: k.clone(),
body: serde_json::to_string(&pl)?,
properties: [
("DR".to_string(), format!("{}", pl.dr)),
("FPort".to_string(), format!("{}", pl.f_port)),
("DR".to_string(), pl.dr.to_string()),
("FPort".to_string(), pl.f_port.to_string()),
("FCnt".to_string(), pl.f_cnt.to_string()),
("Data".to_string(), hex::encode(&pl.data)),
]
.iter()

View File

@ -283,6 +283,7 @@ pub async fn get_frame_logs(
let mut phy = lrwn::PhyPayload::from_slice(&pl.phy_payload)?;
if pl.plaintext_mac_commands {
phy.decode_f_opts_to_mac_commands()?;
phy.decode_frm_payload_to_mac_commands()?;
}
let pl = api::LogItem {
@ -314,6 +315,7 @@ pub async fn get_frame_logs(
let mut phy = lrwn::PhyPayload::from_slice(&pl.phy_payload)?;
if pl.plaintext_mac_commands {
phy.decode_f_opts_to_mac_commands()?;
phy.decode_frm_payload_to_mac_commands()?;
}
let pl = api::LogItem {

View File

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

View File

@ -654,6 +654,25 @@ impl PhyPayload {
Ok(())
}
/// Decode frm_payload to mac-commands.
pub fn decode_frm_payload_to_mac_commands(&mut self) -> Result<()> {
if let Payload::MACPayload(pl) = &mut self.payload {
let uplink = is_uplink(self.mhdr.m_type);
if pl.f_port.unwrap_or(0) == 0 {
let b = match &pl.frm_payload {
Some(FRMPayload::Raw(v)) => v.clone(),
_ => vec![],
};
let mut macs = MACCommandSet::new(vec![MACCommand::Raw(b)]);
macs.decode_from_raw(uplink)?;
pl.frm_payload = Some(FRMPayload::MACCommandSet(macs));
}
}
Ok(())
}
/// Encrypt the frm_payload with the given key.
pub fn encrypt_frm_payload(&mut self, key: &AES128Key) -> Result<()> {
if let Payload::MACPayload(pl) = &mut self.payload {

View File

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