pub enum Packet {
PushData {
token: u16,
gateway: Eui,
uplink: Uplink,
},
PushAck {
token: u16,
},
PullData {
token: u16,
gateway: Eui,
},
PullAck {
token: u16,
},
PullResp {
token: u16,
transmit: Txpk,
},
TxAck {
token: u16,
gateway: Eui,
status: TxStatus,
},
}Expand description
Variants§
PushData
What the gateway heard, and how its own radio is doing.
Fields
PushAck
The server acknowledging a PUSH_DATA, which says only that it arrived.
PullData
The gateway holding a route open for downlinks.
Fields
PullAck
The server acknowledging a PULL_DATA.
PullResp
The server asking the gateway to transmit a packet.
Fields
TxAck
The gateway reporting what became of a PULL_RESP.
Implementations§
Source§impl Packet
impl Packet
Sourcepub const fn kind(&self) -> PacketKind
pub const fn kind(&self) -> PacketKind
Sourcepub const fn gateway(&self) -> Option<Eui>
pub const fn gateway(&self) -> Option<Eui>
Returns the gateway’s identifier, for the kinds that carry it.
§Returns
The identifier, or None for the datagrams a server sends, which do not name one.
Sourcepub fn acknowledgment(&self) -> Option<Packet>
pub fn acknowledgment(&self) -> Option<Packet>
Returns the acknowledgment a server owes this datagram.
§Returns
The PUSH_ACK or PULL_ACK to send back, or None for a datagram that is itself an
answer. A PULL_RESP is answered with a TX_ACK, which names the gateway and what
became of the transmission, so the gateway builds that one itself.
Sourcepub fn parse(bytes: &[u8]) -> Result<Packet, ProtocolError>
pub fn parse(bytes: &[u8]) -> Result<Packet, ProtocolError>
Reads a datagram.
§Arguments
bytes- the datagram as it arrived.
§Returns
The packet.
§Errors
Returns ProtocolError for a datagram shorter than its header, another protocol
version, an identifier the protocol does not define, a datagram missing the fields its
kind carries, or a payload that is not the JSON object described for it.