Skip to content

Commit 843f1c0

Browse files
committed
CREOWAVE: Add data rates with 4/8 coding rate in EU868 region, add README notes about our ChirpStack fork, customize GitHub Actions workflow
1 parent 188ef3d commit 843f1c0

5 files changed

Lines changed: 109 additions & 29 deletions

File tree

.github/workflows/main.yml

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,7 @@ jobs:
3434
uses: actions/cache@v4
3535
with:
3636
path: |
37-
~/.cargo/bin/
38-
~/.cargo/registry/index/
39-
~/.cargo/registry/cache/
40-
~/.cargo/git/db/
37+
~/.cargo
4138
target/
4239
key: ${{ runner.os }}-cargo-test-${{ matrix.database }}-${{ hashFiles('**/Cargo.lock') }}
4340
-
@@ -75,10 +72,7 @@ jobs:
7572
uses: actions/cache@v4
7673
with:
7774
path: |
78-
~/.cargo/bin/
79-
~/.cargo/registry/index/
80-
~/.cargo/registry/cache/
81-
~/.cargo/git/db/
75+
~/.cargo
8276
target/
8377
key: ${{ runner.os }}-cargo-dist-${{ hashFiles('**/Cargo.lock') }}
8478
-
@@ -90,25 +84,13 @@ jobs:
9084
-
9185
name: Build distributables
9286
run: nix-shell --command "make dist"
93-
-
94-
name: Configure AWS credentials
95-
uses: aws-actions/configure-aws-credentials@v1
96-
with:
97-
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
98-
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
99-
aws-region: eu-west-1
100-
-
101-
name: Upload binaries to S3
102-
run: |
103-
aws s3 sync dist s3://builds.loraserver.io/chirpstack
104-
if: startsWith(github.ref, 'refs/tags/v')
10587
-
10688
name: Docker meta
10789
id: meta
10890
uses: docker/metadata-action@v3
10991
with:
11092
images: |
111-
chirpstack/${{ github.event.repository.name }}${{ matrix.database != 'postgres' && format('-{0}', matrix.database) || '' }}
93+
creowave/${{ github.event.repository.name }}${{ matrix.database != 'postgres' && format('-{0}', matrix.database) || '' }}
11294
tags: |
11395
type=semver,pattern={{version}}
11496
type=semver,pattern={{major}}

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# Creowave fork of ChirpStack
2+
3+
This fork of ChirpStack supports non-standard LoRaWAN coding rate of 4/8 in EU868 region.
4+
5+
All modifications to the upstream codebase are maintained in separate branches following the naming scheme `cw-vX.Y.Z`. All releases are tagged as `vX.Y.Z`. The releases are published in [Docker Hub](https://hub.docker.com/r/creowave/chirpstack) as `creowave/chirpstack`.
6+
17
# ChirpStack open-source LoRaWAN(R) Network Server
28

39
![CI](https://github.com/chirpstack/chirpstack/actions/workflows/main.yml/badge.svg?branch=master)

api/rust/src/gw.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ impl FromStr for CodeRate {
3434
fn from_str(s: &str) -> Result<Self, Box<dyn Error>> {
3535
Ok(match s {
3636
"4/5" => CodeRate::Cr45,
37+
"4/5,4/8" => CodeRate::Cr45,
3738
"4/6" | "2/3" => CodeRate::Cr46,
3839
"4/7" => CodeRate::Cr47,
3940
"4/8" | "2/4" | "1/2" => CodeRate::Cr48,

lrwn/src/region/eu868.rs

Lines changed: 54 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ impl Configuration {
2828
modulation: DataRateModulation::Lora(LoraDataRate {
2929
spreading_factor: 12,
3030
bandwidth: 125000,
31-
coding_rate: "4/5".into(),
31+
coding_rate: "4/5,4/8".into(),
3232
}),
3333
},
3434
),
@@ -40,7 +40,7 @@ impl Configuration {
4040
modulation: DataRateModulation::Lora(LoraDataRate {
4141
spreading_factor: 11,
4242
bandwidth: 125000,
43-
coding_rate: "4/5".into(),
43+
coding_rate: "4/5,4/8".into(),
4444
}),
4545
},
4646
),
@@ -52,7 +52,7 @@ impl Configuration {
5252
modulation: DataRateModulation::Lora(LoraDataRate {
5353
spreading_factor: 10,
5454
bandwidth: 125000,
55-
coding_rate: "4/5".into(),
55+
coding_rate: "4/5,4/8".into(),
5656
}),
5757
},
5858
),
@@ -64,7 +64,7 @@ impl Configuration {
6464
modulation: DataRateModulation::Lora(LoraDataRate {
6565
spreading_factor: 9,
6666
bandwidth: 125000,
67-
coding_rate: "4/5".into(),
67+
coding_rate: "4/5,4/8".into(),
6868
}),
6969
},
7070
),
@@ -76,7 +76,7 @@ impl Configuration {
7676
modulation: DataRateModulation::Lora(LoraDataRate {
7777
spreading_factor: 8,
7878
bandwidth: 125000,
79-
coding_rate: "4/5".into(),
79+
coding_rate: "4/5,4/8".into(),
8080
}),
8181
},
8282
),
@@ -88,7 +88,7 @@ impl Configuration {
8888
modulation: DataRateModulation::Lora(LoraDataRate {
8989
spreading_factor: 7,
9090
bandwidth: 125000,
91-
coding_rate: "4/5".into(),
91+
coding_rate: "4/5,4/8".into(),
9292
}),
9393
},
9494
),
@@ -100,7 +100,7 @@ impl Configuration {
100100
modulation: DataRateModulation::Lora(LoraDataRate {
101101
spreading_factor: 7,
102102
bandwidth: 250000,
103-
coding_rate: "4/5".into(),
103+
coding_rate: "4/5,4/8".into(),
104104
}),
105105
},
106106
),
@@ -841,6 +841,53 @@ mod tests {
841841
}
842842
}
843843

844+
#[test]
845+
fn get_data_rate_index_with_multiple_coding_rates() {
846+
let c = Configuration::new(false);
847+
let tests: Vec<(bool, DataRateModulation, u8)> = vec![
848+
(
849+
true,
850+
DataRateModulation::Lora(LoraDataRate {
851+
spreading_factor: 12,
852+
bandwidth: 125000,
853+
coding_rate: "4/5".into(),
854+
}),
855+
0,
856+
),
857+
(
858+
true,
859+
DataRateModulation::Lora(LoraDataRate {
860+
spreading_factor: 12,
861+
bandwidth: 125000,
862+
coding_rate: "4/8".into(),
863+
}),
864+
0,
865+
),
866+
(
867+
true,
868+
DataRateModulation::Lora(LoraDataRate {
869+
spreading_factor: 7,
870+
bandwidth: 125000,
871+
coding_rate: "4/5".into(),
872+
}),
873+
5,
874+
),
875+
(
876+
true,
877+
DataRateModulation::Lora(LoraDataRate {
878+
spreading_factor: 7,
879+
bandwidth: 125000,
880+
coding_rate: "4/8".into(),
881+
}),
882+
5,
883+
),
884+
];
885+
886+
for t in &tests {
887+
assert_eq!(t.2, c.get_data_rate_index(t.0, &t.1).unwrap());
888+
}
889+
}
890+
844891
#[test]
845892
fn get_user_defined_uplink_channel_indices() {
846893
assert_eq!(

lrwn/src/region/mod.rs

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,14 @@ pub struct LoraDataRate {
364364
pub coding_rate: String,
365365
}
366366

367+
impl LoraDataRate {
368+
pub fn supports_coding_rate(&self, coding_rate: &str) -> bool {
369+
self.coding_rate
370+
.split(',')
371+
.any(|cr| cr.trim() == coding_rate)
372+
}
373+
}
374+
367375
#[derive(Clone, PartialEq, Eq, Debug)]
368376
pub struct FskDataRate {
369377
pub bitrate: u32,
@@ -537,7 +545,16 @@ impl RegionBaseConfig {
537545
continue;
538546
}
539547

540-
if modulation == &dr.modulation {
548+
if let DataRateModulation::Lora(lora) = modulation {
549+
if let DataRateModulation::Lora(config) = &dr.modulation {
550+
if config.spreading_factor == lora.spreading_factor
551+
&& config.bandwidth == lora.bandwidth
552+
&& config.supports_coding_rate(&lora.coding_rate)
553+
{
554+
return Ok(*i);
555+
}
556+
}
557+
} else if modulation == &dr.modulation {
541558
return Ok(*i);
542559
}
543560
}
@@ -965,3 +982,30 @@ pub fn get(
965982
CommonName::US915 => Box::new(us915::Configuration::new(repeater_compatible)),
966983
}
967984
}
985+
986+
#[cfg(test)]
987+
mod tests {
988+
use super::*;
989+
990+
#[test]
991+
fn test_supports_coding_rate() {
992+
let single_rate = LoraDataRate {
993+
spreading_factor: 12,
994+
bandwidth: 125000,
995+
coding_rate: "4/5".into(),
996+
};
997+
998+
let multiple_rates = LoraDataRate {
999+
spreading_factor: 12,
1000+
bandwidth: 125000,
1001+
coding_rate: "4/5,4/8".into(),
1002+
};
1003+
1004+
assert!(single_rate.supports_coding_rate("4/5"));
1005+
assert!(!single_rate.supports_coding_rate("4/8"));
1006+
1007+
assert!(multiple_rates.supports_coding_rate("4/5"));
1008+
assert!(multiple_rates.supports_coding_rate("4/8"));
1009+
assert!(!multiple_rates.supports_coding_rate("3/5"));
1010+
}
1011+
}

0 commit comments

Comments
 (0)