Skip to main content

Txpk

Struct Txpk 

Source
pub struct Txpk {
    pub immediate: bool,
    pub timestamp_us: Option<u32>,
    pub gps_millis: Option<u64>,
    pub frequency_hz: u32,
    pub rf_chain: u8,
    pub power_dbm: i8,
    pub modulation: Modulation,
    pub frequency_deviation_hz: Option<u32>,
    pub invert_polarity: bool,
    pub preamble_symbols: Option<u16>,
    pub without_crc: bool,
    pub payload: Vec<u8>,
}
Expand description

A packet the server asks the gateway to transmit.

§Examples

use pamoja_gateway::udp::Txpk;
use pamoja_lora::LinkSettings;

let downlink = Txpk::at(3_512_348_611, 868_500_000, LinkSettings::new(9, 125_000), b"ok".to_vec())
    .with_power_dbm(27)
    .with_inverted_polarity(true);
assert!(downlink.to_json().contains("\"ipol\":true"));

Fields§

§immediate: bool

Whether to transmit at once, which ignores the timestamps.

§timestamp_us: Option<u32>

The concentrator timestamp to transmit at, in microseconds.

§gps_millis: Option<u64>

The GPS time to transmit at, in milliseconds since 6 January 1980.

§frequency_hz: u32

The carrier to transmit on, in hertz.

§rf_chain: u8

The radio chain to transmit from.

§power_dbm: i8

The power to transmit at, in dBm.

§modulation: Modulation

How to modulate it.

§frequency_deviation_hz: Option<u32>

The FSK frequency deviation in hertz.

§invert_polarity: bool

Whether to invert the LoRa polarity, which a LoRaWAN downlink does.

§preamble_symbols: Option<u16>

How long a preamble to send, in symbols.

§without_crc: bool

Whether to leave the physical CRC off, which LoRaWAN downlinks do.

§payload: Vec<u8>

The packet itself.

Implementations§

Source§

impl Txpk

Source

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

Describes a LoRa packet to transmit as soon as the gateway can.

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

The request, at 14 dBm on radio chain 0 with standard polarity.

Source

pub fn at( timestamp_us: u32, frequency_hz: u32, link: LinkSettings, payload: Vec<u8>, ) -> Txpk

Describes a LoRa packet to transmit at a concentrator timestamp, which is how a LoRaWAN receive window is hit.

§Arguments
  • timestamp_us - the concentrator counter value to transmit at.
  • frequency_hz - the carrier.
  • link - the spreading factor, bandwidth, and coding rate.
  • payload - the packet.
§Returns

The request.

Source

pub fn with_power_dbm(self, dbm: i8) -> Txpk

Returns it at another power.

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

The request.

Source

pub fn with_inverted_polarity(self, inverted: bool) -> Txpk

Returns it with the LoRa polarity inverted or not.

§Arguments
  • inverted - true for a LoRaWAN downlink, which a device listens for inverted.
§Returns

The request.

Source

pub fn without_crc(self) -> Txpk

Returns it with the physical CRC left off, as LoRaWAN downlinks are sent.

§Returns

The request.

Source

pub fn to_json(&self) -> String

Writes the payload of a PULL_RESP.

§Returns

The JSON text, with the request under txpk.

Source

pub fn from_json(body: &[u8]) -> Result<Txpk, ProtocolError>

Reads the payload of a PULL_RESP.

§Arguments
  • body - the bytes after the header.
§Returns

The request it carries.

§Errors

Returns ProtocolError::Payload when the body is not a JSON object with a txpk the protocol describes.

Trait Implementations§

Source§

impl Clone for Txpk

Source§

fn clone(&self) -> Txpk

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 Txpk

Source§

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

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

impl PartialEq for Txpk

Source§

fn eq(&self, other: &Txpk) -> 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 Txpk

Auto Trait Implementations§

§

impl Freeze for Txpk

§

impl RefUnwindSafe for Txpk

§

impl Send for Txpk

§

impl Sync for Txpk

§

impl Unpin for Txpk

§

impl UnsafeUnpin for Txpk

§

impl UnwindSafe for Txpk

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.