SNode.C
Loading...
Searching...
No Matches
iot::mqtt::packets::Connect Class Reference

#include <Connect.h>

Inheritance diagram for iot::mqtt::packets::Connect:
Collaboration diagram for iot::mqtt::packets::Connect:

Public Member Functions

 Connect ()
 Connect (const std::string &clientId, uint16_t keepAlive, bool cleanSession, const std::string &willTopic, const std::string &willMessage, uint8_t willQoS, bool willRetain, const std::string &username, const std::string &password, bool loopPrevention)
std::string getProtocol () const
uint8_t getLevel () const
uint8_t getConnectFlags () const
uint16_t getKeepAlive () const
std::string getClientId () const
bool getUsernameFlag () const
bool getPasswordFlag () const
bool getWillRetain () const
uint8_t getWillQoS () const
bool getWillFlag () const
bool getCleanSession () const
bool getReflect () const
std::string getWillTopic () const
std::string getWillMessage () const
std::string getUsername () const
std::string getPassword () const
Public Member Functions inherited from iot::mqtt::ControlPacket
 ControlPacket (uint8_t type, const std::string &name)
 ControlPacket (const ControlPacket &)=default
 ControlPacket (ControlPacket &&)=default
virtual ~ControlPacket ()
ControlPacketoperator= (const ControlPacket &)=default
ControlPacketoperator= (ControlPacket &&)=default
std::vector< char > serialize () const
const std::string & getName () const

Protected Attributes

iot::mqtt::types::String protocol
iot::mqtt::types::UInt8 level
iot::mqtt::types::UInt8 connectFlags
iot::mqtt::types::UInt16 keepAlive
iot::mqtt::types::String clientId
iot::mqtt::types::String willTopic
iot::mqtt::types::String willMessage
iot::mqtt::types::String username
iot::mqtt::types::String password
bool usernameFlag = false
bool passwordFlag = false
bool willRetain = false
uint8_t willQoS = 0
bool willFlag = false
bool cleanSession = false
bool reflect = true
bool reserved = false
Protected Attributes inherited from iot::mqtt::ControlPacket
uint8_t flags = 0

Private Member Functions

std::vector< char > serializeVP () const override

Additional Inherited Members

Protected Member Functions inherited from iot::mqtt::ControlPacket
uint8_t getType () const
uint8_t getFlags () const

Detailed Description

Definition at line 62 of file Connect.h.

Constructor & Destructor Documentation

◆ Connect() [1/2]

iot::mqtt::packets::Connect::Connect ( )

Definition at line 52 of file Connect.cpp.

53 : iot::mqtt::ControlPacket(MQTT_CONNECT, "CONNECT") {
54 }
#define MQTT_CONNECT
Definition Connect.h:58

References iot::mqtt::ControlPacket::ControlPacket().

Referenced by Connect().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Connect() [2/2]

iot::mqtt::packets::Connect::Connect ( const std::string & clientId,
uint16_t keepAlive,
bool cleanSession,
const std::string & willTopic,
const std::string & willMessage,
uint8_t willQoS,
bool willRetain,
const std::string & username,
const std::string & password,
bool loopPrevention )

Definition at line 56 of file Connect.cpp.

66 : Connect() {
67 this->protocol = "MQTT";
68 this->level =
69 MQTT_VERSION_3_1_1 | (loopPrevention ? 0x80 : 0x00); // msb 1 -> do not reflect messages to origin (try_private in mosquitto)
70 this->keepAlive = keepAlive;
71 this->clientId = clientId;
72 this->willTopic = willTopic;
74 this->willQoS = willQoS;
75 this->willRetain = willRetain;
76 this->willFlag = !willMessage.empty();
77 this->username = username;
78 this->usernameFlag = !username.empty();
79 this->password = password;
80 this->passwordFlag = !password.empty();
81
82 this->connectFlags = static_cast<uint8_t>((!usernameFlag ? 0 : 0x80) | (!passwordFlag ? 0 : 0x40) | (!willRetain ? 0 : 0x20) |
83 ((willQoS << 3) & 0x18) | (!willFlag ? 0 : 0x04) | (!cleanSession ? 0 : 0x02));
84 }
iot::mqtt::types::String willMessage
Definition Connect.h:108
iot::mqtt::types::String protocol
Definition Connect.h:102
iot::mqtt::types::String willTopic
Definition Connect.h:107
iot::mqtt::types::UInt8 connectFlags
Definition Connect.h:104
iot::mqtt::types::String username
Definition Connect.h:109
iot::mqtt::types::UInt8 level
Definition Connect.h:103
iot::mqtt::types::String clientId
Definition Connect.h:106
iot::mqtt::types::String password
Definition Connect.h:110
iot::mqtt::types::UInt16 keepAlive
Definition Connect.h:105
#define MQTT_VERSION_3_1_1
Definition Connect.h:60

References clientId, Connect(), connectFlags, keepAlive, level, iot::mqtt::types::String::operator=(), iot::mqtt::types::UInt16::operator=(), iot::mqtt::types::UInt8::operator=(), password, passwordFlag, protocol, username, usernameFlag, willFlag, willMessage, willQoS, willRetain, and willTopic.

Referenced by iot::mqtt::client::Mqtt::sendConnect().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Function Documentation

◆ getCleanSession()

bool iot::mqtt::packets::Connect::getCleanSession ( ) const

Definition at line 160 of file Connect.cpp.

160 {
161 return cleanSession;
162 }

References cleanSession.

Referenced by iot::mqtt::server::Mqtt::_onConnect().

Here is the caller graph for this function:

◆ getClientId()

std::string iot::mqtt::packets::Connect::getClientId ( ) const

Definition at line 136 of file Connect.cpp.

136 {
137 return clientId;
138 }

References clientId.

Referenced by iot::mqtt::server::Mqtt::_onConnect().

Here is the caller graph for this function:

◆ getConnectFlags()

uint8_t iot::mqtt::packets::Connect::getConnectFlags ( ) const

Definition at line 128 of file Connect.cpp.

128 {
129 return connectFlags;
130 }

References connectFlags.

Referenced by iot::mqtt::server::Mqtt::_onConnect().

Here is the caller graph for this function:

◆ getKeepAlive()

uint16_t iot::mqtt::packets::Connect::getKeepAlive ( ) const

Definition at line 132 of file Connect.cpp.

132 {
133 return keepAlive;
134 }

References keepAlive.

Referenced by iot::mqtt::server::Mqtt::_onConnect().

Here is the caller graph for this function:

◆ getLevel()

uint8_t iot::mqtt::packets::Connect::getLevel ( ) const

Definition at line 124 of file Connect.cpp.

124 {
125 return level;
126 }

References level.

Referenced by iot::mqtt::server::Mqtt::_onConnect().

Here is the caller graph for this function:

◆ getPassword()

std::string iot::mqtt::packets::Connect::getPassword ( ) const

Definition at line 180 of file Connect.cpp.

180 {
181 return password;
182 }

References password.

Referenced by iot::mqtt::server::Mqtt::_onConnect().

Here is the caller graph for this function:

◆ getPasswordFlag()

bool iot::mqtt::packets::Connect::getPasswordFlag ( ) const

Definition at line 144 of file Connect.cpp.

144 {
145 return passwordFlag;
146 }

References passwordFlag.

Referenced by iot::mqtt::server::Mqtt::_onConnect().

Here is the caller graph for this function:

◆ getProtocol()

std::string iot::mqtt::packets::Connect::getProtocol ( ) const

Definition at line 120 of file Connect.cpp.

120 {
121 return protocol;
122 }

References protocol.

Referenced by iot::mqtt::server::Mqtt::_onConnect().

Here is the caller graph for this function:

◆ getReflect()

bool iot::mqtt::packets::Connect::getReflect ( ) const

Definition at line 164 of file Connect.cpp.

164 {
165 return reflect;
166 }

References reflect.

Referenced by iot::mqtt::server::Mqtt::_onConnect().

Here is the caller graph for this function:

◆ getUsername()

std::string iot::mqtt::packets::Connect::getUsername ( ) const

Definition at line 176 of file Connect.cpp.

176 {
177 return username;
178 }

References username.

Referenced by iot::mqtt::server::Mqtt::_onConnect().

Here is the caller graph for this function:

◆ getUsernameFlag()

bool iot::mqtt::packets::Connect::getUsernameFlag ( ) const

Definition at line 140 of file Connect.cpp.

140 {
141 return usernameFlag;
142 }

References usernameFlag.

Referenced by iot::mqtt::server::Mqtt::_onConnect().

Here is the caller graph for this function:

◆ getWillFlag()

bool iot::mqtt::packets::Connect::getWillFlag ( ) const

Definition at line 156 of file Connect.cpp.

156 {
157 return willFlag;
158 }

References willFlag.

Referenced by iot::mqtt::server::Mqtt::_onConnect().

Here is the caller graph for this function:

◆ getWillMessage()

std::string iot::mqtt::packets::Connect::getWillMessage ( ) const

Definition at line 172 of file Connect.cpp.

172 {
173 return willMessage;
174 }

References willMessage.

Referenced by iot::mqtt::server::Mqtt::_onConnect().

Here is the caller graph for this function:

◆ getWillQoS()

uint8_t iot::mqtt::packets::Connect::getWillQoS ( ) const

Definition at line 152 of file Connect.cpp.

152 {
153 return willQoS;
154 }

References willQoS.

Referenced by iot::mqtt::server::Mqtt::_onConnect().

Here is the caller graph for this function:

◆ getWillRetain()

bool iot::mqtt::packets::Connect::getWillRetain ( ) const

Definition at line 148 of file Connect.cpp.

148 {
149 return willRetain;
150 }

References willRetain.

Referenced by iot::mqtt::server::Mqtt::_onConnect().

Here is the caller graph for this function:

◆ getWillTopic()

std::string iot::mqtt::packets::Connect::getWillTopic ( ) const

Definition at line 168 of file Connect.cpp.

168 {
169 return willTopic;
170 }

References willTopic.

Referenced by iot::mqtt::server::Mqtt::_onConnect().

Here is the caller graph for this function:

◆ serializeVP()

std::vector< char > iot::mqtt::packets::Connect::serializeVP ( ) const
overrideprivatevirtual

Implements iot::mqtt::ControlPacket.

Definition at line 86 of file Connect.cpp.

86 {
87 std::vector<char> packet(protocol.serialize());
88
89 std::vector<char> tmpVector = level.serialize();
90 packet.insert(packet.end(), tmpVector.begin(), tmpVector.end());
91
92 tmpVector = connectFlags.serialize();
93 packet.insert(packet.end(), tmpVector.begin(), tmpVector.end());
94
95 tmpVector = keepAlive.serialize();
96 packet.insert(packet.end(), tmpVector.begin(), tmpVector.end());
97
98 tmpVector = clientId.serialize();
99 packet.insert(packet.end(), tmpVector.begin(), tmpVector.end());
100
101 if (willFlag) {
102 tmpVector = willTopic.serialize();
103 packet.insert(packet.end(), tmpVector.begin(), tmpVector.end());
104
105 tmpVector = willMessage.serialize();
106 packet.insert(packet.end(), tmpVector.begin(), tmpVector.end());
107 }
108 if (usernameFlag) {
109 tmpVector = username.serialize();
110 packet.insert(packet.end(), tmpVector.begin(), tmpVector.end());
111 }
112 if (passwordFlag) {
113 tmpVector = password.serialize();
114 packet.insert(packet.end(), tmpVector.begin(), tmpVector.end());
115 }
116
117 return packet;
118 }

References clientId, connectFlags, keepAlive, level, password, passwordFlag, protocol, iot::mqtt::types::String::serialize(), iot::mqtt::types::TypeBase< ValueTypeT >::serialize(), username, usernameFlag, willFlag, willMessage, and willTopic.

Here is the call graph for this function:

Member Data Documentation

◆ cleanSession

bool iot::mqtt::packets::Connect::cleanSession = false
protected

◆ clientId

iot::mqtt::types::String iot::mqtt::packets::Connect::clientId
protected

◆ connectFlags

iot::mqtt::types::UInt8 iot::mqtt::packets::Connect::connectFlags
protected

◆ keepAlive

iot::mqtt::types::UInt16 iot::mqtt::packets::Connect::keepAlive
protected

◆ level

iot::mqtt::types::UInt8 iot::mqtt::packets::Connect::level
protected

◆ password

iot::mqtt::types::String iot::mqtt::packets::Connect::password
protected

◆ passwordFlag

bool iot::mqtt::packets::Connect::passwordFlag = false
protected

◆ protocol

iot::mqtt::types::String iot::mqtt::packets::Connect::protocol
protected

◆ reflect

bool iot::mqtt::packets::Connect::reflect = true
protected

Definition at line 118 of file Connect.h.

Referenced by iot::mqtt::server::packets::Connect::deserializeVP(), and getReflect().

◆ reserved

bool iot::mqtt::packets::Connect::reserved = false
protected

Definition at line 119 of file Connect.h.

Referenced by iot::mqtt::server::packets::Connect::deserializeVP().

◆ username

iot::mqtt::types::String iot::mqtt::packets::Connect::username
protected

◆ usernameFlag

bool iot::mqtt::packets::Connect::usernameFlag = false
protected

◆ willFlag

bool iot::mqtt::packets::Connect::willFlag = false
protected

◆ willMessage

iot::mqtt::types::String iot::mqtt::packets::Connect::willMessage
protected

◆ willQoS

uint8_t iot::mqtt::packets::Connect::willQoS = 0
protected

◆ willRetain

bool iot::mqtt::packets::Connect::willRetain = false
protected

◆ willTopic

iot::mqtt::types::String iot::mqtt::packets::Connect::willTopic
protected

The documentation for this class was generated from the following files: