mavtables  0.2.1
MAVLink router and firewall.
PacketVersion1.hpp
Go to the documentation of this file.
1 // MAVLink router and firewall.
2 // Copyright (C) 2018 Michael R. Shannon <mrshannon.aerospace@gmail.com>
3 //
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 2 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 
17 
18 #ifndef PACKETVERSION1_HPP_
19 #define PACKETVERSION1_HPP_
20 
21 
22 #include <cstdint>
23 #include <memory>
24 #include <string>
25 #include <vector>
26 
27 #include "mavlink.hpp"
28 #include "Packet.hpp"
29 
30 
31 namespace packet_v1
32 {
33 
34  /** MAVLink v1.0 start byte (0xFE).
35  */
36  const uint8_t START_BYTE = MAVLINK_STX_MAVLINK1;
37 
38 
39  /** MAVLink v1.0 header length (6 bytes).
40  */
41  const size_t HEADER_LENGTH = 1 + MAVLINK_CORE_HEADER_MAVLINK1_LEN;
42 
43 
44  /** MAVLink v1.0 checksum length (2 bytes).
45  */
46  const size_t CHECKSUM_LENGTH = MAVLINK_NUM_CHECKSUM_BYTES;
47 
48 
49  /** MAVLink v1.0 version.
50  */
51  const ::Packet::Version VERSION = ::Packet::V1;
52 
53 
54  /** A MAVLink packet with the version 1 wire protocol.
55  */
56  class Packet : public ::Packet
57  {
58  public:
59  /** Copy constructor.
60  *
61  * \param other Packet to copy from.
62  */
63  Packet(const Packet &other) = default;
64  /** Move constructor.
65  *
66  * \param other Packet to move from.
67  */
68  Packet(Packet &&other) = default;
69  Packet(std::vector<uint8_t> data);
70  virtual ::Packet::Version version() const;
71  virtual unsigned long id() const;
72  virtual std::string name() const;
73  virtual MAVAddress source() const;
74  virtual std::optional<MAVAddress> dest() const;
75  /** Assignment operator.
76  *
77  * \param other Packet to copy from.
78  */
79  Packet &operator=(const Packet &other) = default;
80  /** Assignment operator (by move semantics).
81  *
82  * \param other Packet to move from.
83  */
84  Packet &operator=(Packet &&other) = default;
85  };
86 
87 
88  bool header_complete(const std::vector<uint8_t> &data);
89  bool packet_complete(const std::vector<uint8_t> &data);
90  const struct mavlink::v1_header *header(
91  const std::vector<uint8_t> &data);
92 
93 }
94 
95 
96 #endif // PACKETVERSION1_HPP_
Packet(const Packet &other)=default
Packet & operator=(const Packet &other)=default
virtual ::Packet::Version version() const
const size_t CHECKSUM_LENGTH
virtual std::string name() const
const uint8_t START_BYTE
const ::Packet::Version VERSION
virtual MAVAddress source() const
virtual std::optional< MAVAddress > dest() const
bool header_complete(const std::vector< uint8_t > &data)
const size_t HEADER_LENGTH
virtual unsigned long id() const
const struct mavlink::v1_header * header(const std::vector< uint8_t > &data)
MAVLink Version 1.0.
Definition: Packet.hpp:49
const std::vector< uint8_t > & data() const
Definition: Packet.cpp:52
bool packet_complete(const std::vector< uint8_t > &data)