PubSubClient
MQTT client library for Arduino
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
MQTT::Message Class Reference

Abstract base class. More...

#include <MQTT.h>

+ Inheritance diagram for MQTT::Message:

Public Member Functions

bool send (Client &client)
 Send the message out.
 
message_type type (void) const
 Get the message type.
 
bool has_stream (void) const
 Does this message have a network stream for reading the (large) payload?
 

Protected Member Functions

 Message (message_type t, uint8_t f=0)
 Private constructor from type and flags.
 
virtual ~Message ()
 Virtual destructor.
 
uint8_t fixed_header_length (uint32_t rlength) const
 Length of the fixed header. More...
 
void write_fixed_header (uint8_t *buf, uint32_t &bufpos, uint32_t rlength) const
 Write the fixed header to a buffer. More...
 
bool need_packet_id (void) const
 Does this message need a packet id before being sent?
 
void set_packet_id (uint16_t pid)
 Set the packet id.
 
uint16_t packet_id (void) const
 Get the packet id.
 
void write_packet_id (uint8_t *buf, uint32_t &bufpos) const
 Write the packet id to a buffer. More...
 
virtual uint32_t variable_header_length (void) const
 Length of variable header.
 
virtual void write_variable_header (uint8_t *buf, uint32_t &bufpos) const
 Write variable header. More...
 
virtual uint32_t payload_length (void) const
 Length of payload.
 
virtual void write_payload (uint8_t *buf, uint32_t &bufpos) const
 Write payload. More...
 
virtual message_type response_type (void) const
 Message type to expect in response to this message.
 

Protected Attributes

message_type _type
 
uint8_t _flags
 
uint16_t _packet_id
 
bool _need_packet_id
 Not all message types use a packet id, but most do.
 
Client * _stream_client
 
payload_callback_t _payload_callback
 
friend PubSubClient
 

Detailed Description

Abstract base class.

Member Function Documentation

uint8_t MQTT::Message::fixed_header_length ( uint32_t  rlength) const
protected

Length of the fixed header.

Parameters
rlengthRemaining lengh i.e variable header + payload
void MQTT::Message::write_fixed_header ( uint8_t *  buf,
uint32_t &  bufpos,
uint32_t  rlength 
) const
protected

Write the fixed header to a buffer.

Parameters
bufPointer to start of buffer (never advances)
bufposCurrent position in buffer
rlengthRemaining lengh i.e variable header + payload
void MQTT::Message::write_packet_id ( uint8_t *  buf,
uint32_t &  bufpos 
) const
protected

Write the packet id to a buffer.

Parameters
bufPointer to start of buffer (never advances)
bufposCurrent position in buffer
virtual void MQTT::Message::write_payload ( uint8_t *  buf,
uint32_t &  bufpos 
) const
inlineprotectedvirtual

Write payload.

Parameters
bufPointer to start of buffer (never advances)
bufposCurrent position in buffer
virtual void MQTT::Message::write_variable_header ( uint8_t *  buf,
uint32_t &  bufpos 
) const
inlineprotectedvirtual

Write variable header.

Parameters
bufPointer to start of buffer (never advances)
bufposCurrent position in buffer

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