1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
use super::super::simple_up_packet;
use super::{pull_ack, write_preamble, Identifier, MacAddress, Result, SerializablePacket};
use std::io::{Cursor, Write};
#[derive(Debug, Clone)]
pub struct Packet {
    pub random_token: u16,
    pub gateway_mac: MacAddress,
}
impl Default for Packet {
    fn default() -> Packet {
        Packet {
            random_token: 0,
            gateway_mac: MacAddress::from([0; 8]),
        }
    }
}
simple_up_packet!(Packet, Identifier::PullData);
impl From<Packet> for super::Packet {
    fn from(packet: Packet) -> super::Packet {
        super::Packet::Up(super::Up::PullData(packet))
    }
}
impl Packet {
    pub fn new(random_token: u16) -> Packet {
        Packet {
            random_token,
            gateway_mac: MacAddress::from([0; 8]),
        }
    }
    pub fn into_ack(self) -> pull_ack::Packet {
        pull_ack::Packet {
            random_token: self.random_token,
        }
    }
}