SNode.C
Loading...
Searching...
No Matches
Connack.cpp
Go to the documentation of this file.
1/*
2 * SNode.C - a slim toolkit for network communication
3 * Copyright (C) Volker Christian <me@vchrist.at>
4 * 2020, 2021, 2022, 2023, 2024, 2025
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published
8 * by the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#include "iot/mqtt/packets/Connack.h"
21
22#ifndef DOXYGEN_SHOULD_SKIP_THIS
23
24#include <string>
25#include <vector>
26
27#endif // DOXYGEN_SHOULD_SKIP_THIS
28
29namespace iot::mqtt::packets {
30
32 : iot::mqtt::ControlPacket(MQTT_CONNACK, "CONNACK") {
33 }
34
35 Connack::Connack(uint8_t returncode, uint8_t acknowledgeFlags)
36 : Connack() {
37 this->returnCode = returncode;
38 this->acknowledgeFlags = acknowledgeFlags;
39 }
40
41 std::vector<char> Connack::serializeVP() const {
42 std::vector<char> packet(acknowledgeFlags.serialize());
43
44 std::vector<char> tmpVector = returnCode.serialize();
45 packet.insert(packet.end(), tmpVector.begin(), tmpVector.end());
46
47 return packet;
48 }
49
50 uint8_t Connack::getAcknowledgeFlags() const {
51 return acknowledgeFlags;
52 }
53
54 uint8_t Connack::getReturnCode() const {
55 return returnCode;
56 }
57
58 bool Connack::getSessionPresent() const {
59 return sessionPresent;
60 }
61
62} // namespace iot::mqtt::packets
uint8_t getReturnCode() const
Definition Connack.cpp:54
std::vector< char > serializeVP() const override
Definition Connack.cpp:41
Connack(uint8_t returncode, uint8_t acknowledgeFlags)
Definition Connack.cpp:35
bool getSessionPresent() const
Definition Connack.cpp:58
uint8_t getAcknowledgeFlags() const
Definition Connack.cpp:50
#define MQTT_CONNACK
Definition Connack.h:35