Skip to main content

Rxpk

Struct Rxpk 

Source
pub struct Rxpk {
    pub received_at: Option<String>,
    pub gps_millis: Option<u64>,
    pub timestamp_us: Option<u32>,
    pub frequency_hz: u32,
    pub channel: u8,
    pub rf_chain: u8,
    pub crc: CrcStatus,
    pub modulation: Modulation,
    pub rssi_dbm: Decibels,
    pub snr_db: Option<Decibels>,
    pub payload: Vec<u8>,
}
Expand description

A packet the gateway heard, with the metadata the protocol carries beside it.

§Examples

use pamoja_gateway::udp::Rxpk;
use pamoja_lora::LinkSettings;

let heard = Rxpk::new(868_100_000, LinkSettings::new(7, 125_000), b"hello".to_vec())
    .with_rssi_dbm(-35)
    .with_snr_db(5.1);
assert!(heard.to_json().contains("\"datr\":\"SF7BW125\""));
assert!(heard.to_json().contains("\"freq\":868.1"));

Fields§

§received_at: Option<String>

When the packet arrived, as time::compact writes it.

§gps_millis: Option<u64>

When it arrived on the GPS clock, in milliseconds since 6 January 1980.

§timestamp_us: Option<u32>

The concentrator’s own timestamp of the end of reception, in microseconds.

§frequency_hz: u32

The carrier the packet arrived on, in hertz.

§channel: u8

The concentrator channel it arrived on.

§rf_chain: u8

The radio chain it arrived on.

§crc: CrcStatus

What the CRC said.

§modulation: Modulation

How it was modulated.

§rssi_dbm: Decibels

The received signal strength, to the decibel.

§snr_db: Option<Decibels>

The signal-to-noise ratio, to a tenth of a decibel, for a LoRa packet.

§payload: Vec<u8>

The packet itself.

Implementations§

Source§

impl Rxpk

Source

pub fn new(frequency_hz: u32, link: LinkSettings, payload: Vec<u8>) -> Rxpk

Describes a LoRa packet that arrived with a good CRC.

§Arguments
  • frequency_hz - the carrier it arrived on.
  • link - the spreading factor, bandwidth, and coding rate it used.
  • payload - the packet.
§Returns

The description, on channel 0 and radio chain 0 with no levels yet.

Source

pub fn with_rssi_dbm(self, dbm: i32) -> Rxpk

Returns it with the signal strength it was heard at.

§Arguments
  • dbm - the strength in dBm.
§Returns

The description.

Source

pub fn with_snr_db(self, db: f64) -> Rxpk

Returns it with the signal-to-noise ratio it was heard at.

§Arguments
  • db - the ratio in decibels, which the protocol carries to a tenth.
§Returns

The description.

Source

pub fn with_timestamp_us(self, micros: u32) -> Rxpk

Returns it with the concentrator’s timestamp of the reception.

§Arguments
  • micros - the counter value, which wraps every 71 minutes.
§Returns

The description.

Source

pub fn with_received_at(self, micros_since_epoch: u64) -> Rxpk

Returns it with the time it arrived.

§Arguments
  • micros_since_epoch - the time in microseconds since 1970-01-01 UTC.
§Returns

The description.

Source

pub fn on_channel(self, channel: u8, rf_chain: u8) -> Rxpk

Returns it on another concentrator channel and radio chain.

§Arguments
  • channel - the concentrator channel.
  • rf_chain - the radio chain.
§Returns

The description.

Source

pub fn to_json(&self) -> String

Writes the object as the protocol carries it.

§Returns

The JSON text of one rxpk entry.

Trait Implementations§

Source§

impl Clone for Rxpk

Source§

fn clone(&self) -> Rxpk

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Rxpk

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

fn from(packet: Rxpk) -> Uplink

Converts to this type from the input type.
Source§

impl PartialEq for Rxpk

Source§

fn eq(&self, other: &Rxpk) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Rxpk

Auto Trait Implementations§

§

impl Freeze for Rxpk

§

impl RefUnwindSafe for Rxpk

§

impl Send for Rxpk

§

impl Sync for Rxpk

§

impl Unpin for Rxpk

§

impl UnsafeUnpin for Rxpk

§

impl UnwindSafe for Rxpk

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.