Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ jobs:
run: cargo make --profile ${{ matrix.target }} pkg

- name: Build | Artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: helium-gateway-${{ matrix.target }}
if-no-files-found: error
Expand Down Expand Up @@ -127,6 +127,11 @@ jobs:
# Ensure we don't publish images until we pass clippy.
needs: [hygiene]
runs-on: ubuntu-22.04
# Only run Quay.io uploads from the main repository
if: |
github.repository == 'helium/gateway-rs' &&
(github.event_name != 'pull_request' ||
github.event.pull_request.head.repo.full_name == 'helium/gateway-rs')
steps:
- name: Setup | Cancel Previous Runs
uses: styfle/[email protected]
Expand Down
67 changes: 52 additions & 15 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ angry-purple-tiger = "0"
lorawan = { package = "lorawan", path = "lorawan" }
beacon = { git = "https://github.com/helium/proto", branch = "master" }
exponential-backoff = { git = "https://github.com/yoshuawuyts/exponential-backoff", branch = "master" }
semtech-udp = { version = ">=0.11", default-features = false, features = [
semtech-udp = { version = ">=0.12", default-features = false, features = [
"server",
] }
helium-crypto = ">=0.8.3"
Expand Down
2 changes: 1 addition & 1 deletion src/gateway.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ pub fn beacon_to_pull_resp(beacon: &Beacon, tx_power: u64) -> Result<pull_resp::
time: Time::immediate(),
ipol: false,
modu: Modulation::LORA,
codr: CodingRate::_4_5,
codr: Some(CodingRate::_4_5),
datr,
freq,
data: pull_resp::PhyData::new(data),
Expand Down
2 changes: 1 addition & 1 deletion src/keypair.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ impl<'de> de::Deserialize<'de> for Keypair {
{
struct _Visitor;

impl<'de> de::Visitor<'de> for _Visitor {
impl de::Visitor<'_> for _Visitor {
type Value = Keypair;
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
formatter.write_str("keypair uri")
Expand Down
104 changes: 50 additions & 54 deletions src/packet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,23 +85,21 @@ impl TryFrom<PacketUp> for poc_lora::LoraWitnessReportReqV1 {

impl PacketUp {
pub fn from_rxpk(rxpk: push_data::RxPk, gateway: &PublicKey, region: Region) -> Result<Self> {
match rxpk.get_crc_status() {
match rxpk.crc_status() {
CRC::OK => (),
CRC::Disabled => return Err(DecodeError::crc_disabled()),
CRC::Fail => return Err(DecodeError::crc_invalid()),
}

let rssi = rxpk
.get_signal_rssi()
.unwrap_or_else(|| rxpk.get_channel_rssi());
let rssi = rxpk.signal_rssi().unwrap_or_else(|| rxpk.channel_rssi());

let packet = PacketRouterPacketUpV1 {
rssi,
timestamp: *rxpk.get_timestamp() as u64,
payload: rxpk.get_data().to_vec(),
frequency: to_hz(*rxpk.get_frequency()) as u32,
datarate: datarate::to_proto(rxpk.get_datarate())? as i32,
snr: rxpk.get_snr(),
timestamp: rxpk.timestamp() as u64,
payload: rxpk.data().to_vec(),
frequency: to_hz(rxpk.frequency()) as u32,
datarate: datarate::to_proto(rxpk.datarate())? as i32,
snr: rxpk.snr(),
region: region.into(),
hold_time: 0,
gateway: gateway.into(),
Expand Down Expand Up @@ -199,7 +197,7 @@ impl PacketDown {
time,
ipol: true,
modu: Modulation::LORA,
codr: CodingRate::_4_5,
codr: Some(CodingRate::_4_5),
datr: datarate,
// for normal lorawan packets we're not selecting different frequencies
// like we are for PoC
Expand Down Expand Up @@ -229,26 +227,26 @@ pub(crate) mod datarate {

pub fn from_proto(rate: ProtoRate) -> Result<DataRate> {
let (spreading_factor, bandwidth) = match rate {
ProtoRate::Sf12bw125 => (SpreadingFactor::SF12, Bandwidth::BW125),
ProtoRate::Sf11bw125 => (SpreadingFactor::SF11, Bandwidth::BW125),
ProtoRate::Sf10bw125 => (SpreadingFactor::SF10, Bandwidth::BW125),
ProtoRate::Sf9bw125 => (SpreadingFactor::SF9, Bandwidth::BW125),
ProtoRate::Sf8bw125 => (SpreadingFactor::SF8, Bandwidth::BW125),
ProtoRate::Sf7bw125 => (SpreadingFactor::SF7, Bandwidth::BW125),

ProtoRate::Sf12bw250 => (SpreadingFactor::SF12, Bandwidth::BW250),
ProtoRate::Sf11bw250 => (SpreadingFactor::SF11, Bandwidth::BW250),
ProtoRate::Sf10bw250 => (SpreadingFactor::SF10, Bandwidth::BW250),
ProtoRate::Sf9bw250 => (SpreadingFactor::SF9, Bandwidth::BW250),
ProtoRate::Sf8bw250 => (SpreadingFactor::SF8, Bandwidth::BW250),
ProtoRate::Sf7bw250 => (SpreadingFactor::SF7, Bandwidth::BW250),

ProtoRate::Sf12bw500 => (SpreadingFactor::SF12, Bandwidth::BW500),
ProtoRate::Sf11bw500 => (SpreadingFactor::SF11, Bandwidth::BW500),
ProtoRate::Sf10bw500 => (SpreadingFactor::SF10, Bandwidth::BW500),
ProtoRate::Sf9bw500 => (SpreadingFactor::SF9, Bandwidth::BW500),
ProtoRate::Sf8bw500 => (SpreadingFactor::SF8, Bandwidth::BW500),
ProtoRate::Sf7bw500 => (SpreadingFactor::SF7, Bandwidth::BW500),
ProtoRate::Sf12bw125 => (SpreadingFactor::_12, Bandwidth::_125KHz),
ProtoRate::Sf11bw125 => (SpreadingFactor::_11, Bandwidth::_125KHz),
ProtoRate::Sf10bw125 => (SpreadingFactor::_10, Bandwidth::_125KHz),
ProtoRate::Sf9bw125 => (SpreadingFactor::_9, Bandwidth::_125KHz),
ProtoRate::Sf8bw125 => (SpreadingFactor::_8, Bandwidth::_125KHz),
ProtoRate::Sf7bw125 => (SpreadingFactor::_7, Bandwidth::_125KHz),

ProtoRate::Sf12bw250 => (SpreadingFactor::_12, Bandwidth::_250KHz),
ProtoRate::Sf11bw250 => (SpreadingFactor::_11, Bandwidth::_250KHz),
ProtoRate::Sf10bw250 => (SpreadingFactor::_10, Bandwidth::_250KHz),
ProtoRate::Sf9bw250 => (SpreadingFactor::_9, Bandwidth::_250KHz),
ProtoRate::Sf8bw250 => (SpreadingFactor::_8, Bandwidth::_250KHz),
ProtoRate::Sf7bw250 => (SpreadingFactor::_7, Bandwidth::_250KHz),

ProtoRate::Sf12bw500 => (SpreadingFactor::_12, Bandwidth::_500KHz),
ProtoRate::Sf11bw500 => (SpreadingFactor::_11, Bandwidth::_500KHz),
ProtoRate::Sf10bw500 => (SpreadingFactor::_10, Bandwidth::_500KHz),
ProtoRate::Sf9bw500 => (SpreadingFactor::_9, Bandwidth::_500KHz),
ProtoRate::Sf8bw500 => (SpreadingFactor::_8, Bandwidth::_500KHz),
ProtoRate::Sf7bw500 => (SpreadingFactor::_7, Bandwidth::_500KHz),

ProtoRate::Lrfhss2bw137
| ProtoRate::Lrfhss1bw336
Expand All @@ -265,30 +263,28 @@ pub(crate) mod datarate {

pub fn to_proto(rate: DataRate) -> Result<ProtoRate> {
let rate = match (rate.spreading_factor(), rate.bandwidth()) {
(SpreadingFactor::SF12, Bandwidth::BW125) => ProtoRate::Sf12bw125,
(SpreadingFactor::SF11, Bandwidth::BW125) => ProtoRate::Sf11bw125,
(SpreadingFactor::SF10, Bandwidth::BW125) => ProtoRate::Sf10bw125,
(SpreadingFactor::SF9, Bandwidth::BW125) => ProtoRate::Sf9bw125,
(SpreadingFactor::SF8, Bandwidth::BW125) => ProtoRate::Sf8bw125,
(SpreadingFactor::SF7, Bandwidth::BW125) => ProtoRate::Sf7bw125,

(SpreadingFactor::SF12, Bandwidth::BW250) => ProtoRate::Sf12bw250,
(SpreadingFactor::SF11, Bandwidth::BW250) => ProtoRate::Sf11bw250,
(SpreadingFactor::SF10, Bandwidth::BW250) => ProtoRate::Sf10bw250,
(SpreadingFactor::SF9, Bandwidth::BW250) => ProtoRate::Sf9bw250,
(SpreadingFactor::SF8, Bandwidth::BW250) => ProtoRate::Sf8bw250,
(SpreadingFactor::SF7, Bandwidth::BW250) => ProtoRate::Sf7bw250,

(SpreadingFactor::SF12, Bandwidth::BW500) => ProtoRate::Sf12bw500,
(SpreadingFactor::SF11, Bandwidth::BW500) => ProtoRate::Sf11bw500,
(SpreadingFactor::SF10, Bandwidth::BW500) => ProtoRate::Sf10bw500,
(SpreadingFactor::SF9, Bandwidth::BW500) => ProtoRate::Sf9bw500,
(SpreadingFactor::SF8, Bandwidth::BW500) => ProtoRate::Sf8bw500,
(SpreadingFactor::SF7, Bandwidth::BW500) => ProtoRate::Sf7bw500,

(SpreadingFactor::SF6, _) | (SpreadingFactor::SF5, _) => {
return Err(DecodeError::invalid_data_rate(rate.to_string()))
}
(SpreadingFactor::_12, Bandwidth::_125KHz) => ProtoRate::Sf12bw125,
(SpreadingFactor::_11, Bandwidth::_125KHz) => ProtoRate::Sf11bw125,
(SpreadingFactor::_10, Bandwidth::_125KHz) => ProtoRate::Sf10bw125,
(SpreadingFactor::_9, Bandwidth::_125KHz) => ProtoRate::Sf9bw125,
(SpreadingFactor::_8, Bandwidth::_125KHz) => ProtoRate::Sf8bw125,
(SpreadingFactor::_7, Bandwidth::_125KHz) => ProtoRate::Sf7bw125,

(SpreadingFactor::_12, Bandwidth::_250KHz) => ProtoRate::Sf12bw250,
(SpreadingFactor::_11, Bandwidth::_250KHz) => ProtoRate::Sf11bw250,
(SpreadingFactor::_10, Bandwidth::_250KHz) => ProtoRate::Sf10bw250,
(SpreadingFactor::_9, Bandwidth::_250KHz) => ProtoRate::Sf9bw250,
(SpreadingFactor::_8, Bandwidth::_250KHz) => ProtoRate::Sf8bw250,
(SpreadingFactor::_7, Bandwidth::_250KHz) => ProtoRate::Sf7bw250,

(SpreadingFactor::_12, Bandwidth::_500KHz) => ProtoRate::Sf12bw500,
(SpreadingFactor::_11, Bandwidth::_500KHz) => ProtoRate::Sf11bw500,
(SpreadingFactor::_10, Bandwidth::_500KHz) => ProtoRate::Sf10bw500,
(SpreadingFactor::_9, Bandwidth::_500KHz) => ProtoRate::Sf9bw500,
(SpreadingFactor::_8, Bandwidth::_500KHz) => ProtoRate::Sf8bw500,
(SpreadingFactor::_7, Bandwidth::_500KHz) => ProtoRate::Sf7bw500,

(_, _) => return Err(DecodeError::invalid_data_rate(rate.to_string())),
};
Ok(rate)
}
Expand Down
3 changes: 3 additions & 0 deletions src/packet_router/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ impl PacketRouter {
}
self.reconnect.update_next_time(session_result.is_err());
},
Ok(envelope_down_v1::Data::PacketAck(_)) => {
warn!("received packet_ack from router but this is not handled")
}
Err(err) => {
warn!(?err, "router error");
self.reconnect.update_next_time(true);
Expand Down
1 change: 1 addition & 0 deletions src/service/packet_router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ impl ConduitClient<EnvelopeUpV1, EnvelopeDownV1> for PacketRouterConduitClient {
gateway: keypair.public_key().into(),
signature: vec![],
session_capable: true,
packet_ack_interval: 0,
};
msg.sign(keypair.clone()).await?;
let msg = EnvelopeUpV1 {
Expand Down
2 changes: 1 addition & 1 deletion src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ pub mod log_level {
{
struct LevelVisitor;

impl<'de> Visitor<'de> for LevelVisitor {
impl Visitor<'_> for LevelVisitor {
type Value = Level;
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
formatter.write_str("log level")
Expand Down