AWS IoT C++ SDK
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Attributes
awsiotsdk::mqtt::ConnectPacket Class Reference

Connect Packet Type. More...

#include <Connect.hpp>

Inheritance diagram for awsiotsdk::mqtt::ConnectPacket:
awsiotsdk::mqtt::Packet awsiotsdk::ActionData

Public Member Functions

 ConnectPacket (const ConnectPacket &)=delete
 
 ConnectPacket (ConnectPacket &&)=delete
 
ConnectPacketoperator= (const ConnectPacket &) &=delete
 
ConnectPacketoperator= (ConnectPacket &&) &=delete
 
 ConnectPacket (bool is_clean_session, mqtt::Version mqtt_version, std::chrono::seconds keep_alive_timeout, std::unique_ptr< Utf8String > p_client_id, std::unique_ptr< Utf8String > p_username, std::unique_ptr< Utf8String > p_password, std::unique_ptr< mqtt::WillOptions > p_will_msg, bool is_metrics_enabled)
 Constructor. More...
 
 ConnectPacket (bool is_clean_session, mqtt::Version mqtt_version, std::chrono::seconds keep_alive_timeout, std::unique_ptr< Utf8String > p_client_id, std::unique_ptr< Utf8String > p_username, std::unique_ptr< Utf8String > p_password, std::unique_ptr< mqtt::WillOptions > p_will_msg)
 Constructor. More...
 
util::String ToString ()
 Serialize this packet into a String. More...
 
std::chrono::seconds GetKeepAliveTimeout ()
 Get duration of Keep alive interval in seconds. More...
 
util::String GetClientID ()
 get the client ID from the connect packet More...
 
- Public Member Functions inherited from awsiotsdk::mqtt::Packet
 Packet (const Packet &)=delete
 
 Packet (Packet &&)=delete
 
Packetoperator= (const Packet &) &=delete
 
Packetoperator= (Packet &&) &=delete
 
uint16_t GetActionId ()
 Get ID of the current run of this Action. More...
 
void SetActionId (uint16_t action_id)
 Set the Action ID for this run of the Action. More...
 
bool isPacketDataValid ()
 
uint16_t GetPacketId ()
 
void SetPacketId (uint16_t packet_id)
 
size_t Size ()
 
virtual util::String ToString ()=0
 
- Public Member Functions inherited from awsiotsdk::ActionData
 ActionData (const ActionData &)=default
 
 ActionData (ActionData &&)=default
 
ActionDataoperator= (const ActionData &) &=default
 
ActionDataoperator= (ActionData &&) &=default
 
virtual uint16_t GetActionId ()=0
 Get ID of the current run of this Action. More...
 
virtual void SetActionId (uint16_t action_id)=0
 Set the Action ID for this run of the Action. More...
 

Static Public Member Functions

static std::shared_ptr< ConnectPacketCreate (bool is_clean_session, mqtt::Version mqtt_version, std::chrono::seconds keep_alive_timeout, std::unique_ptr< Utf8String > p_client_id, std::unique_ptr< Utf8String > p_username, std::unique_ptr< Utf8String > p_password, std::unique_ptr< mqtt::WillOptions > p_will_msg, bool is_metrics_enabled)
 Create Factory method. More...
 
static std::shared_ptr< ConnectPacketCreate (bool is_clean_session, mqtt::Version mqtt_version, std::chrono::seconds keep_alive_timeout, std::unique_ptr< Utf8String > p_client_id, std::unique_ptr< Utf8String > p_username, std::unique_ptr< Utf8String > p_password, std::unique_ptr< mqtt::WillOptions > p_will_msg)
 Create Factory method, SDK metrics enabled by default. More...
 
- Static Public Member Functions inherited from awsiotsdk::mqtt::Packet
static void AppendUInt16ToBuffer (util::String &buf, uint16_t value)
 
static void AppendUtf8StringToBuffer (util::String &buf, std::unique_ptr< Utf8String > &utf8_str)
 
static void AppendUtf8StringToBuffer (util::String &buf, std::shared_ptr< Utf8String > &utf8_str)
 
static uint16_t ReadUInt16FromBuffer (const util::Vector< unsigned char > &buf, size_t &extract_index)
 
static std::unique_ptr< Utf8StringReadUtf8StringFromBuffer (const util::Vector< unsigned char > &buf, size_t &extract_index)
 

Protected Attributes

bool is_clean_session_
 MQTT clean session. True = this session is to be treated as clean. Previous server state is cleared and no information is retained from any previous connection.
 
unsigned char connect_flags_
 MQTT Connect flags byte.
 
std::chrono::seconds keep_alive_timeout_
 MQTT Keepalive timeout in seconds.
 
mqtt::Version mqtt_version_
 Desired MQTT version used during connection.
 
std::unique_ptr< Utf8Stringp_protocol_id_
 The protocol ID for this connection.
 
std::unique_ptr< Utf8Stringp_client_id_
 Pointer to a string defining the MQTT client ID (this needs to be unique per device across your AWS account)
 
std::unique_ptr< WillOptionsp_will_msg_
 MQTT LWT parameters.
 
std::unique_ptr< Utf8Stringp_username_
 MQTT Username.
 
- Protected Attributes inherited from awsiotsdk::mqtt::Packet
PacketFixedHeader fixed_header_
 Fixed header for this packet instance.
 
size_t packet_size_
 Size of the packet.
 
size_t serialized_packet_length_
 Serialized length of the entire packet including fixed header.
 
std::atomic_uint_fast16_t packet_id_
 Message sequence identifier. Handled automatically by the MQTT client.
 

Additional Inherited Members

- Public Types inherited from awsiotsdk::ActionData
typedef std::function< void(uint16_t action_id, ResponseCode rc)> AsyncAckNotificationHandlerPtr
 
- Data Fields inherited from awsiotsdk::ActionData
AsyncAckNotificationHandlerPtr p_async_ack_handler_
 Handler to call when response is received for this action.
 

Detailed Description

Defines a type for MQTT Connect message

Constructor & Destructor Documentation

◆ ConnectPacket() [1/2]

awsiotsdk::mqtt::ConnectPacket::ConnectPacket ( bool  is_clean_session,
mqtt::Version  mqtt_version,
std::chrono::seconds  keep_alive_timeout,
std::unique_ptr< Utf8String p_client_id,
std::unique_ptr< Utf8String p_username,
std::unique_ptr< Utf8String p_password,
std::unique_ptr< mqtt::WillOptions p_will_msg,
bool  is_metrics_enabled 
)
Warning
This constructor can throw exceptions, it is recommended to use Factory create method Constructor is kept public to not restrict usage possibilities (eg. make_shared)
Parameters
is_clean_session- Is this a clean session? Currently we do not support setting this to false
mqtt_version- Which version of the MQTT protocol to use. Currently the only allowed value is 3.1.1
p_client_id- Client ID to use to make the connection
p_username- Username, currently unused in AWS IoT and will be ignored
p_password- Password, currently unused in AWS IoT and will be ignored
p_will_msg- MQTT Last Will and Testament message
is_metrics_enabled- enable SDK metrics in username string

◆ ConnectPacket() [2/2]

awsiotsdk::mqtt::ConnectPacket::ConnectPacket ( bool  is_clean_session,
mqtt::Version  mqtt_version,
std::chrono::seconds  keep_alive_timeout,
std::unique_ptr< Utf8String p_client_id,
std::unique_ptr< Utf8String p_username,
std::unique_ptr< Utf8String p_password,
std::unique_ptr< mqtt::WillOptions p_will_msg 
)
Warning
This constructor can throw exceptions, it is recommended to use Factory create method Constructor is kept public to not restrict usage possibilities (eg. make_shared). SDK metrics are enabled by default
Parameters
is_clean_session- Is this a clean session? Currently we do not support setting this to false
mqtt_version- Which version of the MQTT protocol to use. Currently the only allowed value is 3.1.1
p_client_id- Client ID to use to make the connection
p_username- Username, currently unused in AWS IoT and will be ignored
p_password- Password, currently unused in AWS IoT and will be ignored
p_will_msg- MQTT Last Will and Testament message

Member Function Documentation

◆ Create() [1/2]

std::shared_ptr< ConnectPacket > awsiotsdk::mqtt::ConnectPacket::Create ( bool  is_clean_session,
mqtt::Version  mqtt_version,
std::chrono::seconds  keep_alive_timeout,
std::unique_ptr< Utf8String p_client_id,
std::unique_ptr< Utf8String p_username,
std::unique_ptr< Utf8String p_password,
std::unique_ptr< mqtt::WillOptions p_will_msg 
)
static
Parameters
is_clean_session- Is this a clean session? Currently we do not support setting this to false
mqtt_version- Which version of the MQTT protocol to use. Currently the only allowed value is 3.1.1
p_client_id- Client ID to use to make the connection
p_username- Username, currently unused in AWS IoT
p_password- Password, currently unused in AWS IoT
p_will_msg- MQTT Last Will and Testament message
Returns
nullptr on error, shared_ptr pointing to a created ConnectPacket instance if successful

◆ Create() [2/2]

std::shared_ptr< ConnectPacket > awsiotsdk::mqtt::ConnectPacket::Create ( bool  is_clean_session,
mqtt::Version  mqtt_version,
std::chrono::seconds  keep_alive_timeout,
std::unique_ptr< Utf8String p_client_id,
std::unique_ptr< Utf8String p_username,
std::unique_ptr< Utf8String p_password,
std::unique_ptr< mqtt::WillOptions p_will_msg,
bool  is_metrics_enabled 
)
static
Parameters
is_clean_session- Is this a clean session? Currently we do not support setting this to false
mqtt_version- Which version of the MQTT protocol to use. Currently the only allowed value is 3.1.1
p_client_id- Client ID to use to make the connection
p_username- Username, currently unused in AWS IoT
p_password- Password, currently unused in AWS IoT
p_will_msg- MQTT Last Will and Testament message
is_metrics_enabled- enable SDK metrics in username string
Returns
nullptr on error, shared_ptr pointing to a created ConnectPacket instance if successful

◆ GetClientID()

util::String awsiotsdk::mqtt::ConnectPacket::GetClientID ( )
inline
Returns
String containing the client ID

◆ GetKeepAliveTimeout()

std::chrono::seconds awsiotsdk::mqtt::ConnectPacket::GetKeepAliveTimeout ( )
inline
Returns
std::chrono::seconds Keep alive interval duration

◆ ToString()

util::String awsiotsdk::mqtt::ConnectPacket::ToString ( )
virtual
Returns
String containing serialized packet

Implements awsiotsdk::mqtt::Packet.