paqueteCnC
Loading...
Searching...
No Matches
packet_builder.h
Go to the documentation of this file.
1
15#ifndef PACKET_BUILDER_H
16#define PACKET_BUILDER_H
17
18#include <vector>
19#include <array>
20
21#include "packet.h"
24
26public:
27 template<typename T1, typename T2>
28 using pairs_t = std::vector<std::pair<T1, T2>>;
29
31
32 /****** getters and setters ******/
33
34 // reference to avoid an extra copy
35 Packet& getPacket();
36
37 /****** other ******/
38
50 void newPacket(const uint8_t versionNumber, const uint8_t appIdSource,
51 const uint8_t appIdDestination,
52 const Packet::SequenceFlags sequenceControlFlags,
53 const uint16_t sequenceControlCount);
54
55 void setDataFieldHeader(const Packet::Bool8Enum ack, const uint8_t serviceType,
56 const uint8_t serviceSubtype);
57
62 void addCommandVerificationAppData(const uint8_t appIdSource,
63 const uint8_t appIdDestination, const Packet::SequenceFlags sequenceFlags,
64 const uint16_t sequenceCount);
65
74 void addCommandVerificationAppData(const uint8_t appIdSource,
75 const uint8_t appIdDestination, const Packet::SequenceFlags sequenceFlags,
76 const uint16_t sequenceCount, const uint8_t code);
77
87 void addCommandVerificationAppData(const uint8_t appIdSource,
88 const uint8_t appIdDestination, const Packet::SequenceFlags sequenceFlags,
89 const uint16_t sequenceCount, const uint8_t code,
90 const std::vector<std::byte>& parameters);
91
101 void addCommandDistributionAppData(const std::vector<uint8_t>& addAppData);
102
113 template <typename T>
114 void addCommandDistributionAppData(const pairs_t<uint8_t, T>& addressAndData);
115
126 void addCommandDistributionAppData(const pairs_t<int, std::byte>& lineIDAndDuration);
127
140 void addHousekeepingReportAppData(uint16_t structureId,
141 PacketExtendedHousekeeping25::GenerationMode mode,
142 const std::vector<std::byte>& parameters);
143
144private:
145 Packet packet_;
146};
147
148// first byte may be the amount of addresses
149template <typename T>
151 const pairs_t<uint8_t, T>& addressAndData) {
152 if (addressAndData.size() > 1) {
153 packet_.pushData(static_cast<std::byte>(addressAndData.size()));
154 }
155 for (size_t i = 0; i < addressAndData.size(); ++i) {
156 packet_.pushData(static_cast<std::byte>(addressAndData[i].first));
157 packet_.pushData(static_cast<std::byte>(addressAndData[i].second));
158 }
159}
160
161#endif
Definition: packet_builder.h:25
void addCommandVerificationAppData(const uint8_t appIdSource, const uint8_t appIdDestination, const Packet::SequenceFlags sequenceFlags, const uint16_t sequenceCount)
Definition: packet_builder.cpp:32
void addCommandDistributionAppData(const std::vector< uint8_t > &addAppData)
Definition: packet_builder.cpp:73
void addHousekeepingReportAppData(uint16_t structureId, PacketExtendedHousekeeping25::GenerationMode mode, const std::vector< std::byte > &parameters)
Housekeeping parameter report with an Structure Identifier (SID), a generation mode and then the cont...
Definition: packet_builder.cpp:91
void newPacket(const uint8_t versionNumber, const uint8_t appIdSource, const uint8_t appIdDestination, const Packet::SequenceFlags sequenceControlFlags, const uint16_t sequenceControlCount)
reset current construction with a new fresh packet
Definition: packet_builder.cpp:12
Definition: packet.h:26
High level packet representation; does not care as much about size.
Higher level packet for housekeeping and diagnostic data service. Packet of subtypes 25 and 26....
Higher level packet for housekeeping and diagnostic data service. Basic packet that all the subtypes ...