mirror of
https://github.com/chirpstack/chirpstack.git
synced 2025-02-25 02:26:16 +00:00
Fix clippy feedback in lrwn crate.
This commit is contained in:
parent
e6fb1a5bc1
commit
cee3dd8d9c
@ -10,7 +10,7 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
|||||||
|
|
||||||
use crate::Error;
|
use crate::Error;
|
||||||
|
|
||||||
#[derive(Copy, Clone, PartialEq, AsExpression, FromSqlRow, Default)]
|
#[derive(Copy, Clone, PartialEq, Eq, AsExpression, FromSqlRow, Default)]
|
||||||
#[diesel(sql_type = diesel::sql_types::Binary)]
|
#[diesel(sql_type = diesel::sql_types::Binary)]
|
||||||
pub struct AES128Key([u8; 16]);
|
pub struct AES128Key([u8; 16]);
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
#[derive(Serialize, Debug, PartialEq, Clone)]
|
#[derive(Serialize, Debug, PartialEq, Eq, Clone)]
|
||||||
pub enum CFList {
|
pub enum CFList {
|
||||||
Channels(CFListChannels),
|
Channels(CFListChannels),
|
||||||
ChannelMask(CFListChannelMasks),
|
ChannelMask(CFListChannelMasks),
|
||||||
@ -16,9 +16,7 @@ impl CFList {
|
|||||||
match b[15] {
|
match b[15] {
|
||||||
0x00 => Ok(CFList::Channels(CFListChannels::from_bytes(bb))),
|
0x00 => Ok(CFList::Channels(CFListChannels::from_bytes(bb))),
|
||||||
0x01 => Ok(CFList::ChannelMask(CFListChannelMasks::from_bytes(bb))),
|
0x01 => Ok(CFList::ChannelMask(CFListChannelMasks::from_bytes(bb))),
|
||||||
_ => {
|
_ => Err(anyhow!("unexpected CFListType")),
|
||||||
return Err(anyhow!("unexpected CFListType"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,7 +38,7 @@ impl CFList {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Debug, PartialEq, Clone)]
|
#[derive(Serialize, Debug, PartialEq, Eq, Clone)]
|
||||||
pub struct CFListChannels([u32; 5]);
|
pub struct CFListChannels([u32; 5]);
|
||||||
|
|
||||||
impl CFListChannels {
|
impl CFListChannels {
|
||||||
@ -100,7 +98,7 @@ impl CFListChannels {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Debug, PartialEq, Clone)]
|
#[derive(Serialize, Debug, PartialEq, Eq, Clone)]
|
||||||
pub struct CFListChannelMasks(Vec<ChMask>);
|
pub struct CFListChannelMasks(Vec<ChMask>);
|
||||||
|
|
||||||
impl CFListChannelMasks {
|
impl CFListChannelMasks {
|
||||||
@ -143,7 +141,7 @@ impl CFListChannelMasks {
|
|||||||
|
|
||||||
/// ChMask encodes the channels usable for uplink access. 0 = channel 1,
|
/// ChMask encodes the channels usable for uplink access. 0 = channel 1,
|
||||||
/// 15 = channel 16.
|
/// 15 = channel 16.
|
||||||
#[derive(Serialize, Debug, PartialEq, Clone, Copy)]
|
#[derive(Serialize, Debug, PartialEq, Eq, Clone, Copy)]
|
||||||
pub struct ChMask([bool; 16]);
|
pub struct ChMask([bool; 16]);
|
||||||
|
|
||||||
impl ChMask {
|
impl ChMask {
|
||||||
|
@ -27,13 +27,13 @@ impl DevAddrPrefix {
|
|||||||
|
|
||||||
impl fmt::Display for DevAddrPrefix {
|
impl fmt::Display for DevAddrPrefix {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
write!(f, "{}/{}", hex::encode(&self.0), self.1)
|
write!(f, "{}/{}", hex::encode(self.0), self.1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Debug for DevAddrPrefix {
|
impl fmt::Debug for DevAddrPrefix {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
write!(f, "{}/{}", hex::encode(&self.0), self.1)
|
write!(f, "{}/{}", hex::encode(self.0), self.1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ impl FromStr for DevAddrPrefix {
|
|||||||
type Err = Error;
|
type Err = Error;
|
||||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||||
let s = s.to_string();
|
let s = s.to_string();
|
||||||
let parts: Vec<&str> = s.split("/").collect();
|
let parts: Vec<&str> = s.split('/').collect();
|
||||||
if parts.len() != 2 {
|
if parts.len() != 2 {
|
||||||
return Err(Error::DevAddrPrefixFormat);
|
return Err(Error::DevAddrPrefixFormat);
|
||||||
}
|
}
|
||||||
@ -51,7 +51,7 @@ impl FromStr for DevAddrPrefix {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let mut mask: [u8; 4] = [0; 4];
|
let mut mask: [u8; 4] = [0; 4];
|
||||||
hex::decode_to_slice(&parts[0], &mut mask)?;
|
hex::decode_to_slice(parts[0], &mut mask)?;
|
||||||
let size: u32 = parts[1].parse().map_err(|_| Error::DevAddrPrefixFormat)?;
|
let size: u32 = parts[1].parse().map_err(|_| Error::DevAddrPrefixFormat)?;
|
||||||
|
|
||||||
Ok(DevAddrPrefix(mask, size))
|
Ok(DevAddrPrefix(mask, size))
|
||||||
@ -93,7 +93,7 @@ impl<'de> Visitor<'de> for DevAddrPrefixVisitor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(PartialEq, Copy, Clone, AsExpression, FromSqlRow, Default)]
|
#[derive(PartialEq, Eq, Copy, Clone, AsExpression, FromSqlRow, Default)]
|
||||||
#[diesel(sql_type = diesel::sql_types::Binary)]
|
#[diesel(sql_type = diesel::sql_types::Binary)]
|
||||||
pub struct DevAddr([u8; 4]);
|
pub struct DevAddr([u8; 4]);
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
#[derive(Serialize, PartialEq, Debug, Clone)]
|
#[derive(Serialize, PartialEq, Eq, Debug, Clone)]
|
||||||
pub struct DLSettings {
|
pub struct DLSettings {
|
||||||
pub opt_neg: bool,
|
pub opt_neg: bool,
|
||||||
pub rx2_dr: u8,
|
pub rx2_dr: u8,
|
||||||
|
@ -4,7 +4,7 @@ use serde::Serialize;
|
|||||||
use super::devaddr::DevAddr;
|
use super::devaddr::DevAddr;
|
||||||
use super::maccommand::MACCommandSet;
|
use super::maccommand::MACCommandSet;
|
||||||
|
|
||||||
#[derive(Serialize, Debug, PartialEq, Clone)]
|
#[derive(Serialize, Debug, PartialEq, Eq, Clone)]
|
||||||
pub struct FHDR {
|
pub struct FHDR {
|
||||||
pub devaddr: DevAddr,
|
pub devaddr: DevAddr,
|
||||||
pub f_ctrl: FCtrl,
|
pub f_ctrl: FCtrl,
|
||||||
@ -82,7 +82,7 @@ impl FHDR {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Default, Debug, PartialEq, Clone)]
|
#[derive(Serialize, Default, Debug, PartialEq, Eq, Clone)]
|
||||||
pub struct FCtrl {
|
pub struct FCtrl {
|
||||||
pub adr: bool,
|
pub adr: bool,
|
||||||
pub adr_ack_req: bool,
|
pub adr_ack_req: bool,
|
||||||
|
@ -83,7 +83,7 @@ impl CID {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Debug, PartialEq, Clone)]
|
#[derive(Serialize, Debug, PartialEq, Eq, Clone)]
|
||||||
pub enum MACCommand {
|
pub enum MACCommand {
|
||||||
ResetInd(ResetIndPayload),
|
ResetInd(ResetIndPayload),
|
||||||
ResetConf(ResetConfPayload),
|
ResetConf(ResetConfPayload),
|
||||||
@ -170,7 +170,7 @@ impl MACCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Debug, PartialEq, Clone, Copy)]
|
#[derive(Serialize, Debug, PartialEq, Eq, Clone, Copy)]
|
||||||
pub enum Version {
|
pub enum Version {
|
||||||
LoRaWAN1_1,
|
LoRaWAN1_1,
|
||||||
}
|
}
|
||||||
@ -198,13 +198,13 @@ impl fmt::Display for Version {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Debug, PartialEq, Clone, Copy)]
|
#[derive(Serialize, Debug, PartialEq, Eq, Clone, Copy)]
|
||||||
pub enum DwellTime {
|
pub enum DwellTime {
|
||||||
NoLimit,
|
NoLimit,
|
||||||
Limit400ms,
|
Limit400ms,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Debug, PartialEq, Clone, Copy)]
|
#[derive(Serialize, Debug, PartialEq, Eq, Clone, Copy)]
|
||||||
pub enum DeviceModeClass {
|
pub enum DeviceModeClass {
|
||||||
ClassA,
|
ClassA,
|
||||||
ClassC,
|
ClassC,
|
||||||
@ -242,7 +242,7 @@ impl fmt::Display for DeviceModeClass {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Debug, PartialEq, Clone)]
|
#[derive(Serialize, Debug, PartialEq, Eq, Clone)]
|
||||||
pub struct MACCommandSet(Vec<MACCommand>);
|
pub struct MACCommandSet(Vec<MACCommand>);
|
||||||
|
|
||||||
impl Deref for MACCommandSet {
|
impl Deref for MACCommandSet {
|
||||||
@ -774,13 +774,13 @@ impl MACCommandSet {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Err(anyhow!(
|
Err(anyhow!(
|
||||||
"MACCommandSet must contain exactly 1 MACCommand::Raw for decoding"
|
"MACCommandSet must contain exactly 1 MACCommand::Raw for decoding"
|
||||||
));
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Debug, PartialEq, Clone)]
|
#[derive(Serialize, Debug, PartialEq, Eq, Clone)]
|
||||||
pub struct ResetIndPayload {
|
pub struct ResetIndPayload {
|
||||||
pub dev_lorawan_version: Version,
|
pub dev_lorawan_version: Version,
|
||||||
}
|
}
|
||||||
@ -803,7 +803,7 @@ impl ResetIndPayload {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Debug, PartialEq, Clone)]
|
#[derive(Serialize, Debug, PartialEq, Eq, Clone)]
|
||||||
pub struct ResetConfPayload {
|
pub struct ResetConfPayload {
|
||||||
pub serv_lorawan_version: Version,
|
pub serv_lorawan_version: Version,
|
||||||
}
|
}
|
||||||
@ -826,7 +826,7 @@ impl ResetConfPayload {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Debug, PartialEq, Clone)]
|
#[derive(Serialize, Debug, PartialEq, Eq, Clone)]
|
||||||
pub struct LinkCheckAnsPayload {
|
pub struct LinkCheckAnsPayload {
|
||||||
pub margin: u8,
|
pub margin: u8,
|
||||||
pub gw_cnt: u8,
|
pub gw_cnt: u8,
|
||||||
@ -851,7 +851,7 @@ impl LinkCheckAnsPayload {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Debug, PartialEq, Clone)]
|
#[derive(Serialize, Debug, PartialEq, Eq, Clone)]
|
||||||
pub struct LinkADRReqPayload {
|
pub struct LinkADRReqPayload {
|
||||||
pub dr: u8,
|
pub dr: u8,
|
||||||
pub tx_power: u8,
|
pub tx_power: u8,
|
||||||
@ -894,7 +894,7 @@ impl LinkADRReqPayload {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Debug, PartialEq, Clone)]
|
#[derive(Serialize, Debug, PartialEq, Eq, Clone)]
|
||||||
pub struct Redundancy {
|
pub struct Redundancy {
|
||||||
pub ch_mask_cntl: u8,
|
pub ch_mask_cntl: u8,
|
||||||
pub nb_rep: u8,
|
pub nb_rep: u8,
|
||||||
@ -922,7 +922,7 @@ impl Redundancy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Debug, PartialEq, Clone)]
|
#[derive(Serialize, Debug, PartialEq, Eq, Clone)]
|
||||||
pub struct LinkADRAnsPayload {
|
pub struct LinkADRAnsPayload {
|
||||||
pub ch_mask_ack: bool,
|
pub ch_mask_ack: bool,
|
||||||
pub dr_ack: bool,
|
pub dr_ack: bool,
|
||||||
@ -961,7 +961,7 @@ impl LinkADRAnsPayload {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Debug, PartialEq, Clone)]
|
#[derive(Serialize, Debug, PartialEq, Eq, Clone)]
|
||||||
pub struct DutyCycleReqPayload {
|
pub struct DutyCycleReqPayload {
|
||||||
pub max_duty_cycle: u8,
|
pub max_duty_cycle: u8,
|
||||||
}
|
}
|
||||||
@ -988,7 +988,7 @@ impl DutyCycleReqPayload {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Debug, PartialEq, Clone)]
|
#[derive(Serialize, Debug, PartialEq, Eq, Clone)]
|
||||||
pub struct RxParamSetupReqPayload {
|
pub struct RxParamSetupReqPayload {
|
||||||
pub frequency: u32,
|
pub frequency: u32,
|
||||||
pub dl_settings: DLSettings,
|
pub dl_settings: DLSettings,
|
||||||
@ -1029,7 +1029,7 @@ impl RxParamSetupReqPayload {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Debug, PartialEq, Clone)]
|
#[derive(Serialize, Debug, PartialEq, Eq, Clone)]
|
||||||
pub struct RxParamSetupAnsPayload {
|
pub struct RxParamSetupAnsPayload {
|
||||||
pub channel_ack: bool,
|
pub channel_ack: bool,
|
||||||
pub rx2_dr_ack: bool,
|
pub rx2_dr_ack: bool,
|
||||||
@ -1066,7 +1066,7 @@ impl RxParamSetupAnsPayload {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Debug, PartialEq, Clone)]
|
#[derive(Serialize, Debug, PartialEq, Eq, Clone)]
|
||||||
pub struct DevStatusAnsPayload {
|
pub struct DevStatusAnsPayload {
|
||||||
pub battery: u8,
|
pub battery: u8,
|
||||||
pub margin: i8,
|
pub margin: i8,
|
||||||
@ -1110,7 +1110,7 @@ impl DevStatusAnsPayload {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Debug, PartialEq, Clone)]
|
#[derive(Serialize, Debug, PartialEq, Eq, Clone)]
|
||||||
pub struct NewChannelReqPayload {
|
pub struct NewChannelReqPayload {
|
||||||
pub ch_index: u8,
|
pub ch_index: u8,
|
||||||
pub freq: u32,
|
pub freq: u32,
|
||||||
@ -1152,7 +1152,7 @@ impl NewChannelReqPayload {
|
|||||||
// See Frequency Encoding in MAC Commands
|
// See Frequency Encoding in MAC Commands
|
||||||
// https://lora-developers.semtech.com/documentation/tech-papers-and-guides/physical-layer-proposal-2.4ghz/
|
// https://lora-developers.semtech.com/documentation/tech-papers-and-guides/physical-layer-proposal-2.4ghz/
|
||||||
if freq >= 2400000000 {
|
if freq >= 2400000000 {
|
||||||
freq = freq / 2;
|
freq /= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if freq / 100 >= (1 << 24) {
|
if freq / 100 >= (1 << 24) {
|
||||||
@ -1177,7 +1177,7 @@ impl NewChannelReqPayload {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Debug, PartialEq, Clone)]
|
#[derive(Serialize, Debug, PartialEq, Eq, Clone)]
|
||||||
pub struct NewChannelAnsPayload {
|
pub struct NewChannelAnsPayload {
|
||||||
pub channel_freq_ok: bool,
|
pub channel_freq_ok: bool,
|
||||||
pub dr_range_ok: bool,
|
pub dr_range_ok: bool,
|
||||||
@ -1209,7 +1209,7 @@ impl NewChannelAnsPayload {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Debug, PartialEq, Clone)]
|
#[derive(Serialize, Debug, PartialEq, Eq, Clone)]
|
||||||
pub struct RxTimingSetupReqPayload {
|
pub struct RxTimingSetupReqPayload {
|
||||||
pub delay: u8,
|
pub delay: u8,
|
||||||
}
|
}
|
||||||
@ -1234,7 +1234,7 @@ impl RxTimingSetupReqPayload {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Debug, PartialEq, Clone)]
|
#[derive(Serialize, Debug, PartialEq, Eq, Clone)]
|
||||||
pub struct TxParamSetupReqPayload {
|
pub struct TxParamSetupReqPayload {
|
||||||
pub uplink_dwell_time: DwellTime,
|
pub uplink_dwell_time: DwellTime,
|
||||||
pub downlink_dwell_time: DwellTime,
|
pub downlink_dwell_time: DwellTime,
|
||||||
@ -1285,7 +1285,7 @@ impl TxParamSetupReqPayload {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Debug, PartialEq, Clone)]
|
#[derive(Serialize, Debug, PartialEq, Eq, Clone)]
|
||||||
pub struct DlChannelReqPayload {
|
pub struct DlChannelReqPayload {
|
||||||
pub ch_index: u8,
|
pub ch_index: u8,
|
||||||
pub freq: u32,
|
pub freq: u32,
|
||||||
@ -1327,7 +1327,7 @@ impl DlChannelReqPayload {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Debug, PartialEq, Clone)]
|
#[derive(Serialize, Debug, PartialEq, Eq, Clone)]
|
||||||
pub struct DlChannelAnsPayload {
|
pub struct DlChannelAnsPayload {
|
||||||
pub uplink_freq_exists: bool,
|
pub uplink_freq_exists: bool,
|
||||||
pub channel_freq_ok: bool,
|
pub channel_freq_ok: bool,
|
||||||
@ -1361,7 +1361,7 @@ impl DlChannelAnsPayload {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Debug, PartialEq, Clone)]
|
#[derive(Serialize, Debug, PartialEq, Eq, Clone)]
|
||||||
pub struct RekeyConfPayload {
|
pub struct RekeyConfPayload {
|
||||||
pub serv_lorawan_version: Version,
|
pub serv_lorawan_version: Version,
|
||||||
}
|
}
|
||||||
@ -1384,7 +1384,7 @@ impl RekeyConfPayload {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Debug, PartialEq, Clone)]
|
#[derive(Serialize, Debug, PartialEq, Eq, Clone)]
|
||||||
pub struct RekeyIndPayload {
|
pub struct RekeyIndPayload {
|
||||||
pub dev_lorawan_version: Version,
|
pub dev_lorawan_version: Version,
|
||||||
}
|
}
|
||||||
@ -1407,7 +1407,7 @@ impl RekeyIndPayload {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Debug, PartialEq, Clone)]
|
#[derive(Serialize, Debug, PartialEq, Eq, Clone)]
|
||||||
pub struct ADRParamSetupReqPayload {
|
pub struct ADRParamSetupReqPayload {
|
||||||
pub adr_param: ADRParam,
|
pub adr_param: ADRParam,
|
||||||
}
|
}
|
||||||
@ -1430,7 +1430,7 @@ impl ADRParamSetupReqPayload {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Debug, PartialEq, Clone)]
|
#[derive(Serialize, Debug, PartialEq, Eq, Clone)]
|
||||||
pub struct ADRParam {
|
pub struct ADRParam {
|
||||||
pub limit_exp: u8,
|
pub limit_exp: u8,
|
||||||
pub delay_exp: u8,
|
pub delay_exp: u8,
|
||||||
@ -1462,7 +1462,7 @@ impl ADRParam {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Debug, PartialEq, Clone)]
|
#[derive(Serialize, Debug, PartialEq, Eq, Clone)]
|
||||||
pub struct DeviceTimeAnsPayload {
|
pub struct DeviceTimeAnsPayload {
|
||||||
pub time_since_gps_epoch: Duration,
|
pub time_since_gps_epoch: Duration,
|
||||||
}
|
}
|
||||||
@ -1496,7 +1496,7 @@ impl DeviceTimeAnsPayload {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Debug, PartialEq, Clone)]
|
#[derive(Serialize, Debug, PartialEq, Eq, Clone)]
|
||||||
pub struct ForceRejoinReqPayload {
|
pub struct ForceRejoinReqPayload {
|
||||||
pub period: u8,
|
pub period: u8,
|
||||||
pub max_retries: u8,
|
pub max_retries: u8,
|
||||||
@ -1541,7 +1541,7 @@ impl ForceRejoinReqPayload {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Debug, PartialEq, Clone)]
|
#[derive(Serialize, Debug, PartialEq, Eq, Clone)]
|
||||||
pub struct RejoinParamSetupReqPayload {
|
pub struct RejoinParamSetupReqPayload {
|
||||||
pub max_time_n: u8,
|
pub max_time_n: u8,
|
||||||
pub max_count_n: u8,
|
pub max_count_n: u8,
|
||||||
@ -1573,7 +1573,7 @@ impl RejoinParamSetupReqPayload {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Debug, PartialEq, Clone)]
|
#[derive(Serialize, Debug, PartialEq, Eq, Clone)]
|
||||||
pub struct RejoinParamSetupAnsPayload {
|
pub struct RejoinParamSetupAnsPayload {
|
||||||
pub time_ok: bool,
|
pub time_ok: bool,
|
||||||
}
|
}
|
||||||
@ -1600,7 +1600,7 @@ impl RejoinParamSetupAnsPayload {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Debug, PartialEq, Clone)]
|
#[derive(Serialize, Debug, PartialEq, Eq, Clone)]
|
||||||
pub struct PingSlotInfoReqPayload {
|
pub struct PingSlotInfoReqPayload {
|
||||||
pub periodicity: u8,
|
pub periodicity: u8,
|
||||||
}
|
}
|
||||||
@ -1627,7 +1627,7 @@ impl PingSlotInfoReqPayload {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Debug, PartialEq, Clone)]
|
#[derive(Serialize, Debug, PartialEq, Eq, Clone)]
|
||||||
pub struct PingSlotChannelReqPayload {
|
pub struct PingSlotChannelReqPayload {
|
||||||
pub freq: u32,
|
pub freq: u32,
|
||||||
pub dr: u8,
|
pub dr: u8,
|
||||||
@ -1669,7 +1669,7 @@ impl PingSlotChannelReqPayload {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Debug, PartialEq, Clone)]
|
#[derive(Serialize, Debug, PartialEq, Eq, Clone)]
|
||||||
pub struct PingSlotChannelAnsPayload {
|
pub struct PingSlotChannelAnsPayload {
|
||||||
pub dr_ok: bool,
|
pub dr_ok: bool,
|
||||||
pub channel_freq_ok: bool,
|
pub channel_freq_ok: bool,
|
||||||
@ -1704,7 +1704,7 @@ impl PingSlotChannelAnsPayload {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Debug, PartialEq, Clone)]
|
#[derive(Serialize, Debug, PartialEq, Eq, Clone)]
|
||||||
pub struct BeaconFreqReqPayload {
|
pub struct BeaconFreqReqPayload {
|
||||||
pub freq: u32,
|
pub freq: u32,
|
||||||
}
|
}
|
||||||
@ -1741,7 +1741,7 @@ impl BeaconFreqReqPayload {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Debug, PartialEq, Clone)]
|
#[derive(Serialize, Debug, PartialEq, Eq, Clone)]
|
||||||
pub struct BeaconFreqAnsPayload {
|
pub struct BeaconFreqAnsPayload {
|
||||||
beacon_freq_ok: bool,
|
beacon_freq_ok: bool,
|
||||||
}
|
}
|
||||||
@ -1768,7 +1768,7 @@ impl BeaconFreqAnsPayload {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Debug, PartialEq, Clone)]
|
#[derive(Serialize, Debug, PartialEq, Eq, Clone)]
|
||||||
pub struct DeviceModeIndPayload {
|
pub struct DeviceModeIndPayload {
|
||||||
pub class: DeviceModeClass,
|
pub class: DeviceModeClass,
|
||||||
}
|
}
|
||||||
@ -1791,7 +1791,7 @@ impl DeviceModeIndPayload {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Debug, PartialEq, Clone)]
|
#[derive(Serialize, Debug, PartialEq, Eq, Clone)]
|
||||||
pub struct DeviceModeConfPayload {
|
pub struct DeviceModeConfPayload {
|
||||||
pub class: DeviceModeClass,
|
pub class: DeviceModeClass,
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ use std::fmt;
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
#[derive(Serialize, Debug, PartialEq, Clone, Copy)]
|
#[derive(Serialize, Debug, PartialEq, Eq, Clone, Copy)]
|
||||||
pub enum MType {
|
pub enum MType {
|
||||||
JoinRequest,
|
JoinRequest,
|
||||||
JoinAccept,
|
JoinAccept,
|
||||||
@ -21,12 +21,12 @@ impl fmt::Display for MType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Debug, PartialEq, Clone, Copy)]
|
#[derive(Serialize, Debug, PartialEq, Eq, Clone, Copy)]
|
||||||
pub enum Major {
|
pub enum Major {
|
||||||
LoRaWANR1,
|
LoRaWANR1,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Clone, Serialize)]
|
#[derive(Debug, PartialEq, Eq, Clone, Serialize)]
|
||||||
pub struct MHDR {
|
pub struct MHDR {
|
||||||
pub m_type: MType,
|
pub m_type: MType,
|
||||||
pub major: Major,
|
pub major: Major,
|
||||||
|
@ -11,7 +11,7 @@ use super::maccommand::MACCommandSet;
|
|||||||
use super::mhdr::MType;
|
use super::mhdr::MType;
|
||||||
use super::netid::NetID;
|
use super::netid::NetID;
|
||||||
|
|
||||||
#[derive(PartialEq, Debug, Clone)]
|
#[derive(PartialEq, Eq, Debug, Clone)]
|
||||||
pub enum Payload {
|
pub enum Payload {
|
||||||
JoinRequest(JoinRequestPayload),
|
JoinRequest(JoinRequestPayload),
|
||||||
JoinAccept(JoinAcceptPayload),
|
JoinAccept(JoinAcceptPayload),
|
||||||
@ -37,7 +37,7 @@ impl Serialize for Payload {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, PartialEq, Debug, Clone)]
|
#[derive(Serialize, PartialEq, Eq, Debug, Clone)]
|
||||||
pub enum JoinType {
|
pub enum JoinType {
|
||||||
Join,
|
Join,
|
||||||
RejoinType0,
|
RejoinType0,
|
||||||
@ -85,7 +85,7 @@ impl Payload {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, PartialEq, Debug, Copy, Clone)]
|
#[derive(Serialize, PartialEq, Eq, Debug, Copy, Clone)]
|
||||||
pub struct JoinRequestPayload {
|
pub struct JoinRequestPayload {
|
||||||
pub join_eui: EUI64,
|
pub join_eui: EUI64,
|
||||||
pub dev_eui: EUI64,
|
pub dev_eui: EUI64,
|
||||||
@ -120,7 +120,7 @@ impl JoinRequestPayload {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, PartialEq, Debug, Clone)]
|
#[derive(Serialize, PartialEq, Eq, Debug, Clone)]
|
||||||
pub struct JoinAcceptPayload {
|
pub struct JoinAcceptPayload {
|
||||||
pub join_nonce: u32, // the actual max value is (2^24 -1)
|
pub join_nonce: u32, // the actual max value is (2^24 -1)
|
||||||
pub home_netid: NetID,
|
pub home_netid: NetID,
|
||||||
@ -185,7 +185,7 @@ impl JoinAcceptPayload {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(PartialEq, Debug, Clone)]
|
#[derive(PartialEq, Eq, Debug, Clone)]
|
||||||
pub enum FRMPayload {
|
pub enum FRMPayload {
|
||||||
Raw(Vec<u8>),
|
Raw(Vec<u8>),
|
||||||
MACCommandSet(MACCommandSet),
|
MACCommandSet(MACCommandSet),
|
||||||
@ -197,7 +197,7 @@ impl Serialize for FRMPayload {
|
|||||||
S: Serializer,
|
S: Serializer,
|
||||||
{
|
{
|
||||||
match self {
|
match self {
|
||||||
FRMPayload::Raw(v) => serializer.serialize_str(&hex::encode(&v)),
|
FRMPayload::Raw(v) => serializer.serialize_str(&hex::encode(v)),
|
||||||
FRMPayload::MACCommandSet(v) => v.serialize(serializer),
|
FRMPayload::MACCommandSet(v) => v.serialize(serializer),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -212,7 +212,7 @@ impl FRMPayload {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, PartialEq, Debug, Clone, Default)]
|
#[derive(Serialize, PartialEq, Eq, Debug, Clone, Default)]
|
||||||
pub struct MACPayload {
|
pub struct MACPayload {
|
||||||
pub fhdr: FHDR,
|
pub fhdr: FHDR,
|
||||||
pub f_port: Option<u8>,
|
pub f_port: Option<u8>,
|
||||||
@ -287,7 +287,7 @@ impl MACPayload {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, PartialEq, Debug, Clone)]
|
#[derive(Serialize, PartialEq, Eq, Debug, Clone)]
|
||||||
pub struct RejoinRequestType02Payload {
|
pub struct RejoinRequestType02Payload {
|
||||||
pub rejoin_type: JoinType,
|
pub rejoin_type: JoinType,
|
||||||
pub netid: NetID,
|
pub netid: NetID,
|
||||||
@ -343,7 +343,7 @@ impl RejoinRequestType02Payload {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, PartialEq, Debug, Clone)]
|
#[derive(Serialize, PartialEq, Eq, Debug, Clone)]
|
||||||
pub struct RejoinRequestType1Payload {
|
pub struct RejoinRequestType1Payload {
|
||||||
pub rejoin_type: JoinType,
|
pub rejoin_type: JoinType,
|
||||||
pub join_eui: EUI64,
|
pub join_eui: EUI64,
|
||||||
|
@ -11,7 +11,7 @@ use super::maccommand::{MACCommand, MACCommandSet};
|
|||||||
use super::mhdr::{MType, MHDR};
|
use super::mhdr::{MType, MHDR};
|
||||||
use super::payload::{FRMPayload, JoinAcceptPayload, JoinType, Payload};
|
use super::payload::{FRMPayload, JoinAcceptPayload, JoinType, Payload};
|
||||||
|
|
||||||
#[derive(PartialEq, Clone, Copy, Serialize)]
|
#[derive(PartialEq, Eq, Clone, Copy, Serialize)]
|
||||||
pub enum MACVersion {
|
pub enum MACVersion {
|
||||||
LoRaWAN1_0,
|
LoRaWAN1_0,
|
||||||
LoRaWAN1_1,
|
LoRaWAN1_1,
|
||||||
@ -310,7 +310,7 @@ pub enum MACVersion {
|
|||||||
/// let phy_decoded = PhyPayload::from_slice(&bytes).unwrap();
|
/// let phy_decoded = PhyPayload::from_slice(&bytes).unwrap();
|
||||||
/// assert_eq!(phy, phy_decoded);
|
/// assert_eq!(phy, phy_decoded);
|
||||||
/// ```
|
/// ```
|
||||||
#[derive(Debug, PartialEq, Clone, Serialize)]
|
#[derive(Debug, PartialEq, Eq, Clone, Serialize)]
|
||||||
pub struct PhyPayload {
|
pub struct PhyPayload {
|
||||||
pub mhdr: MHDR,
|
pub mhdr: MHDR,
|
||||||
pub payload: Payload,
|
pub payload: Payload,
|
||||||
@ -558,7 +558,7 @@ impl PhyPayload {
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
return Err(anyhow!("payload must be of type JoinAcceptPayload"));
|
Err(anyhow!("payload must be of type JoinAcceptPayload"))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Decrypt the join-accept payload with the given key.
|
/// Decrypt the join-accept payload with the given key.
|
||||||
@ -604,7 +604,7 @@ impl PhyPayload {
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
return Err(anyhow!("payload must be of type Raw"));
|
Err(anyhow!("payload must be of type Raw"))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Encrypt the f_opts with the given key.
|
/// Encrypt the f_opts with the given key.
|
||||||
@ -633,7 +633,7 @@ impl PhyPayload {
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
return Err(anyhow!("payload must be of type MACPayload"));
|
Err(anyhow!("payload must be of type MACPayload"))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Decrypt the f_opts with the given key.
|
/// Decrypt the f_opts with the given key.
|
||||||
@ -670,7 +670,7 @@ impl PhyPayload {
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
return Err(anyhow!("payload must be of type MACPayload"));
|
Err(anyhow!("payload must be of type MACPayload"))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Decrypt the frm_payload with the given key.
|
/// Decrypt the frm_payload with the given key.
|
||||||
@ -696,7 +696,7 @@ impl PhyPayload {
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
return Err(anyhow!("payload must be of type MACPayload"));
|
Err(anyhow!("payload must be of type MACPayload"))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn calculate_uplink_data_mic(
|
fn calculate_uplink_data_mic(
|
||||||
@ -775,7 +775,7 @@ impl PhyPayload {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Err(anyhow!("payload must be of type MACPayload"));
|
Err(anyhow!("payload must be of type MACPayload"))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn calculate_downlink_data_mic(
|
fn calculate_downlink_data_mic(
|
||||||
@ -822,7 +822,7 @@ impl PhyPayload {
|
|||||||
return Ok(mic);
|
return Ok(mic);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Err(anyhow!("payload must be of type MACPayload"));
|
Err(anyhow!("payload must be of type MACPayload"))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn calculate_upink_join_mic(&self, key: &AES128Key) -> Result<[u8; 4]> {
|
fn calculate_upink_join_mic(&self, key: &AES128Key) -> Result<[u8; 4]> {
|
||||||
@ -886,7 +886,7 @@ impl PhyPayload {
|
|||||||
return Ok(mic);
|
return Ok(mic);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Err(anyhow!("payload must be of type JoinAcceptPayload"));
|
Err(anyhow!("payload must be of type JoinAcceptPayload"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,26 +274,26 @@ pub struct DataRate {
|
|||||||
pub modulation: DataRateModulation,
|
pub modulation: DataRateModulation,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Debug)]
|
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||||
pub enum DataRateModulation {
|
pub enum DataRateModulation {
|
||||||
Lora(LoraDataRate),
|
Lora(LoraDataRate),
|
||||||
Fsk(FskDataRate),
|
Fsk(FskDataRate),
|
||||||
LrFhss(LrFhssDataRate),
|
LrFhss(LrFhssDataRate),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Debug)]
|
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||||
pub struct LoraDataRate {
|
pub struct LoraDataRate {
|
||||||
pub spreading_factor: u8,
|
pub spreading_factor: u8,
|
||||||
pub bandwidth: u32,
|
pub bandwidth: u32,
|
||||||
pub coding_rate: String,
|
pub coding_rate: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Debug)]
|
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||||
pub struct FskDataRate {
|
pub struct FskDataRate {
|
||||||
pub bitrate: u32,
|
pub bitrate: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Debug)]
|
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||||
pub struct LrFhssDataRate {
|
pub struct LrFhssDataRate {
|
||||||
pub coding_rate: String,
|
pub coding_rate: String,
|
||||||
pub occupied_channel_width: u32,
|
pub occupied_channel_width: u32,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user