PubSubClient3 v3.1.0
Located at <a href='https://github.com/hmueller01/pubsubclient3'>GitHub</a>
 
Loading...
Searching...
No Matches
PubSubClient.h File Reference

A simple client for MQTT. More...

#include <Arduino.h>
#include "Client.h"
#include "IPAddress.h"
#include "Stream.h"

Go to the source code of this file.

Classes

class  PubSubClient
 This class provides a client for doing simple publish and subscribe messaging with a server that supports MQTT. More...
 

Macros

#define MQTT_VERSION_3_1   3
 Defines MQTT 3.1 protocol version, see MQTT_VERSION.
 
#define MQTT_VERSION_3_1_1   4
 Defines MQTT 3.1.1 protocol version, see MQTT_VERSION.
 
#define MQTT_VERSION   MQTT_VERSION_3_1_1
 Sets the version of the MQTT protocol to use (3.1 or 3.1.1). [MQTT_VERSION_3_1, MQTT_VERSION_3_1_1].
 
#define MQTT_MAX_POSSIBLE_PACKET_SIZE   268435455
 Maximum packet size defined by MQTT protocol.
 
#define MQTT_MAX_PACKET_SIZE   256
 Sets the largest packet size, in bytes, the client will handle. Any packet received that exceeds this size will be ignored. This value can be overridden by calling setBufferSize.
 
#define MQTT_KEEPALIVE   15
 Sets the keepalive interval, in seconds, the client will use. This is used to maintain the connection when no other packets are being sent or received. This value can be overridden by calling setKeepAlive.
 
#define MQTT_SOCKET_TIMEOUT   15
 Sets the timeout, in seconds, when reading from the network. This also applies as the timeout for calls to connect. This value can be overridden by calling setSocketTimeout.
 
#define MQTT_MAX_TRANSFER_SIZE   80
 Sets the maximum number of bytes passed to the network client in each write call. Some hardware has a limit to how much data can be passed to them in one go, such as the Arduino Wifi Shield e.g. use 80.
 
#define MQTT_CONNECTION_TIMEOUT   -4
 The network connection timed out or server didn't respond within the keepalive time.
 
#define MQTT_CONNECTION_LOST   -3
 The network connection was lost/broken.
 
#define MQTT_CONNECT_FAILED   -2
 The network connection failed.
 
#define MQTT_DISCONNECTED   -1
 The client is disconnected cleanly.
 
#define MQTT_CONNECTED   0
 The client is connected.
 
#define MQTT_CONNECT_BAD_PROTOCOL   1
 The server does not support the requested MQTT version.
 
#define MQTT_CONNECT_BAD_CLIENT_ID   2
 The server rejected the client identifier.
 
#define MQTT_CONNECT_UNAVAILABLE   3
 The server was unable to accept the connection.
 
#define MQTT_CONNECT_BAD_CREDENTIALS   4
 The username or password is not valid.
 
#define MQTT_CONNECT_UNAUTHORIZED   5
 The client is not authorized to connect to the server.
 
#define MQTT_QOS0   ((uint8_t)0)
 Quality of Service 0: At most once.
 
#define MQTT_QOS1   ((uint8_t)1)
 Quality of Service 1: At least once.
 
#define MQTT_QOS2   ((uint8_t)2)
 
#define MQTT_CALLBACK_SIGNATURE   void (*callback)(char* topic, uint8_t* payload, size_t plength)
 
 

Detailed Description

A simple client for MQTT.

Author
Nicholas O'Leary - http://knolleary.net
Holger Mueller - https://github.com/hmueller01/pubsubclient3

This file is part of the PubSubClient library.

Definition in file PubSubClient.h.

Macro Definition Documentation

◆ MQTT_CALLBACK_SIGNATURE

#define MQTT_CALLBACK_SIGNATURE   void (*callback)(char* topic, uint8_t* payload, size_t plength)

Define the signature required by any callback function.

Parameters
topicThe topic of the message.
payloadThe payload of the message.
plengthThe length of the payload.

Definition at line 146 of file PubSubClient.h.

◆ MQTT_KEEPALIVE

#define MQTT_KEEPALIVE   15

Sets the keepalive interval, in seconds, the client will use. This is used to maintain the connection when no other packets are being sent or received. This value can be overridden by calling setKeepAlive.

Note
Default value is 15 seconds.

Definition at line 57 of file PubSubClient.h.

◆ MQTT_MAX_PACKET_SIZE

#define MQTT_MAX_PACKET_SIZE   256

Sets the largest packet size, in bytes, the client will handle. Any packet received that exceeds this size will be ignored. This value can be overridden by calling setBufferSize.

Note
Default value is 256 bytes.

Definition at line 47 of file PubSubClient.h.

◆ MQTT_MAX_POSSIBLE_PACKET_SIZE

#define MQTT_MAX_POSSIBLE_PACKET_SIZE   268435455

Maximum packet size defined by MQTT protocol.

Definition at line 37 of file PubSubClient.h.

◆ MQTT_MAX_TRANSFER_SIZE

#define MQTT_MAX_TRANSFER_SIZE   80

Sets the maximum number of bytes passed to the network client in each write call. Some hardware has a limit to how much data can be passed to them in one go, such as the Arduino Wifi Shield e.g. use 80.

Note
Defaults to undefined, which passes the entire packet in each write call.

Definition at line 77 of file PubSubClient.h.

◆ MQTT_SOCKET_TIMEOUT

#define MQTT_SOCKET_TIMEOUT   15

Sets the timeout, in seconds, when reading from the network. This also applies as the timeout for calls to connect. This value can be overridden by calling setSocketTimeout.

Note
Default value is 15 seconds.

Definition at line 67 of file PubSubClient.h.

◆ MQTT_VERSION

#define MQTT_VERSION   MQTT_VERSION_3_1_1

Sets the version of the MQTT protocol to use (3.1 or 3.1.1). [MQTT_VERSION_3_1, MQTT_VERSION_3_1_1].

Note
Default value is MQTT_VERSION_3_1_1 for MQTT 3.1.1.

Definition at line 30 of file PubSubClient.h.

◆ MQTT_VERSION_3_1

#define MQTT_VERSION_3_1   3

Defines MQTT 3.1 protocol version, see MQTT_VERSION.

Definition at line 20 of file PubSubClient.h.

◆ MQTT_VERSION_3_1_1

#define MQTT_VERSION_3_1_1   4

Defines MQTT 3.1.1 protocol version, see MQTT_VERSION.

Definition at line 21 of file PubSubClient.h.