aboutsummaryrefslogtreecommitdiff
path: root/src/mqtt/rx.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/mqtt/rx.rs')
-rw-r--r--src/mqtt/rx.rs13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/mqtt/rx.rs b/src/mqtt/rx.rs
index e81171d..10b775a 100644
--- a/src/mqtt/rx.rs
+++ b/src/mqtt/rx.rs
@@ -65,6 +65,7 @@ pub enum Packet<'a> {
65 UnsubscribeAck { 65 UnsubscribeAck {
66 packet_id: PacketId, 66 packet_id: PacketId,
67 }, 67 },
68 PingResp,
68} 69}
69 70
70pub fn decode<'a>(buf: &'a [u8]) -> Result<(Packet<'a>, usize), Error> { 71pub fn decode<'a>(buf: &'a [u8]) -> Result<(Packet<'a>, usize), Error> {
@@ -156,6 +157,15 @@ pub fn decode<'a>(buf: &'a [u8]) -> Result<(Packet<'a>, usize), Error> {
156 let packet_id = PacketId::from(reader.read_u16()?); 157 let packet_id = PacketId::from(reader.read_u16()?);
157 Packet::UnsubscribeAck { packet_id } 158 Packet::UnsubscribeAck { packet_id }
158 } 159 }
160 protocol::PACKET_TYPE_PINGRESP => {
161 if packet_flags != 0 {
162 return Err(Error::InvalidPacket("PINGRESP flags must be zero"));
163 }
164 if packet_len != 0 {
165 return Err(Error::InvalidPacket("PINGRESP remaining length must be 0"));
166 }
167 Packet::PingResp
168 }
159 protocol::PACKET_TYPE_CONNECT 169 protocol::PACKET_TYPE_CONNECT
160 | protocol::PACKET_TYPE_PUBREC 170 | protocol::PACKET_TYPE_PUBREC
161 | protocol::PACKET_TYPE_PUBREL 171 | protocol::PACKET_TYPE_PUBREL
@@ -163,8 +173,7 @@ pub fn decode<'a>(buf: &'a [u8]) -> Result<(Packet<'a>, usize), Error> {
163 | protocol::PACKET_TYPE_DISCONNECT 173 | protocol::PACKET_TYPE_DISCONNECT
164 | protocol::PACKET_TYPE_SUBSCRIBE 174 | protocol::PACKET_TYPE_SUBSCRIBE
165 | protocol::PACKET_TYPE_UNSUBSCRIBE 175 | protocol::PACKET_TYPE_UNSUBSCRIBE
166 | protocol::PACKET_TYPE_PINGREQ 176 | protocol::PACKET_TYPE_PINGREQ => {
167 | protocol::PACKET_TYPE_PINGRESP => {
168 return Err(Error::UnsupportedPacket { 177 return Err(Error::UnsupportedPacket {
169 packet_type, 178 packet_type,
170 packet_len, 179 packet_len,