PubSubClient
MQTT client library for Arduino
Public Member Functions | Friends | List of all members
MQTT::Publish Class Reference

Publish a payload to a topic. More...

#include <MQTT.h>

+ Inheritance diagram for MQTT::Publish:
+ Collaboration diagram for MQTT::Publish:

Public Member Functions

 Publish (String topic, String payload)
 Constructor from string payload. More...
 
 Publish (String topic, uint8_t *payload, uint32_t length)
 Constructor from arbitrary payload. More...
 
 Publish (String topic, payload_callback_t pcb, uint32_t length)
 Constructor from a callback. More...
 
 Publish (String topic, const __FlashStringHelper *payload)
 Constructor from a string stored in flash using the F() macro.
 
bool retain (void) const
 Get retain flag.
 
Publishset_retain (bool r=true)
 Set retain flag.
 
Publishunset_retain (void)
 Unset retain flag.
 
uint8_t qos (void) const
 Get QoS value.
 
Publishset_qos (uint8_t q)
 Set QoS value.
 
Publishunset_qos (void)
 Unset QoS value.
 
bool dup (void) const
 Get dup flag.
 
Publishset_dup (bool d=true)
 Set dup flag.
 
Publishunset_dup (void)
 Unset dup flag.
 
String topic (void) const
 Get the topic string.
 
String payload_string (void) const
 Get the payload as a string.
 
uint8_t * payload (void) const
 Get the payload pointer.
 
uint32_t payload_len (void) const
 Get the payload length.
 
Client * payload_stream (void) const
 Get the network stream for reading the payload.
 
- Public Member Functions inherited from MQTT::Message
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?
 

Friends

MessagereadPacket (Client &client)
 Parser. More...
 
Publish Publish_P (String topic, PGM_P payload, uint32_t length)
 A function made to look like a constructor, reading the payload from flash.
 

Additional Inherited Members

- Protected Member Functions inherited from MQTT::Message
 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...
 
- Protected Attributes inherited from MQTT::Message
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

Publish a payload to a topic.

Constructor & Destructor Documentation

MQTT::Publish::Publish ( String  topic,
String  payload 
)

Constructor from string payload.

Parameters
topicTopic of this message
payloadPayload of this message
MQTT::Publish::Publish ( String  topic,
uint8_t *  payload,
uint32_t  length 
)
inline

Constructor from arbitrary payload.

Parameters
topicTopic of this message
payloadPointer to a block of data
lengthThe length of the data stored at 'payload'
MQTT::Publish::Publish ( String  topic,
payload_callback_t  pcb,
uint32_t  length 
)

Constructor from a callback.

Parameters
topicTopic of this message
pcbA callback function that writes the payload directly to the network Client object
lengthThe length of the data that 'pcb' will send

Friends And Related Function Documentation

Message* readPacket ( Client &  client)
friend

Parser.

remember to free the object once you're finished with it


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