@@ -23,7 +23,8 @@ typedef struct {
2323class MQTTClient ;
2424
2525typedef void (*MQTTClientCallbackSimple)(String &topic, String &payload);
26- typedef void (*MQTTClientCallbackAdvanced)(MQTTClient *client, char topic[], char bytes[], int length);
26+ typedef void (*MQTTClientCallbackAdvanced)(MQTTClient *client, char topic[], char bytes[], int length,
27+ lwmqtt_serialized_properties_t props);
2728
2829typedef struct {
2930 MQTTClient *client = nullptr ;
@@ -50,7 +51,7 @@ class MQTTClient {
5051 lwmqtt_arduino_network_t network = {nullptr };
5152 lwmqtt_arduino_timer_t timer1 = {0 , nullptr };
5253 lwmqtt_arduino_timer_t timer2 = {0 , nullptr };
53- lwmqtt_client_t client = {0 };
54+ lwmqtt_client_t client = {LWMQTT_MQTT311, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 };
5455
5556 bool _connected = false ;
5657 lwmqtt_return_code_t _returnCode = (lwmqtt_return_code_t )0 ;
@@ -61,8 +62,9 @@ class MQTTClient {
6162
6263 ~MQTTClient ();
6364
64- void begin (const char hostname[], Client &client) { this ->begin (hostname, 1883 , client); }
65- void begin (const char hostname[], int port, Client &client);
65+ void begin (const char hostname[], Client &client) { this ->begin (hostname, 1883 , client, LWMQTT_MQTT311); }
66+ void begin (const char hostname[], int port, Client &client) { this ->begin (hostname, port, client, LWMQTT_MQTT311); }
67+ void begin (const char hostname[], int port, Client &client, lwmqtt_protocol_t protocol);
6668
6769 void onMessage (MQTTClientCallbackSimple cb);
6870 void onMessageAdvanced (MQTTClientCallbackAdvanced cb);
@@ -91,6 +93,10 @@ class MQTTClient {
9193 bool publish (const String &topic, const String &payload, bool retained, int qos) {
9294 return this ->publish (topic.c_str (), payload.c_str (), retained, qos);
9395 }
96+ bool publish (const String &topic, const String &payload, bool retained, int qos, lwmqtt_properties_t props) {
97+ return this ->publish (topic.c_str (), payload.c_str (), payload.length (), retained, qos, props);
98+ }
99+
94100 bool publish (const char topic[], const String &payload) { return this ->publish (topic, payload.c_str ()); }
95101 bool publish (const char topic[], const String &payload, bool retained, int qos) {
96102 return this ->publish (topic, payload.c_str (), retained, qos);
@@ -104,23 +110,41 @@ class MQTTClient {
104110 bool publish (const char topic[], const char payload[], int length) {
105111 return this ->publish (topic, payload, length, false , 0 );
106112 }
107- bool publish (const char topic[], const char payload[], int length, bool retained, int qos);
113+ bool publish (const char topic[], const char payload[], int length, bool retained, int qos) {
114+ lwmqtt_properties_t props = lwmqtt_empty_props;
115+ return this ->publish (topic, payload, length, retained, qos, props);
116+ }
117+
118+ bool publish (const char topic[], const char payload[], int length, bool retained, int qos, lwmqtt_properties_t props);
108119
109120 bool subscribe (const String &topic) { return this ->subscribe (topic.c_str ()); }
110121 bool subscribe (const String &topic, int qos) { return this ->subscribe (topic.c_str (), qos); }
111122 bool subscribe (const char topic[]) { return this ->subscribe (topic, 0 ); }
112- bool subscribe (const char topic[], int qos);
123+ bool subscribe (const char topic[], int qos) {
124+ lwmqtt_properties_t props = lwmqtt_empty_props;
125+ return this ->subscribe (topic, qos, props);
126+ }
127+ bool subscribe (const char topic[], int qos, lwmqtt_properties_t props);
113128
114129 bool unsubscribe (const String &topic) { return this ->unsubscribe (topic.c_str ()); }
115- bool unsubscribe (const char topic[]);
130+ bool unsubscribe (const char topic[]) {
131+ lwmqtt_properties_t props = lwmqtt_empty_props;
132+ return this ->unsubscribe (topic, props);
133+ }
134+ bool unsubscribe (const char topic[], lwmqtt_properties_t props);
116135
117136 bool loop ();
118137 bool connected ();
119138
120139 lwmqtt_err_t lastError () { return this ->_lastError ; }
121140 lwmqtt_return_code_t returnCode () { return this ->_returnCode ; }
122141
123- bool disconnect ();
142+ bool disconnect () {
143+ lwmqtt_properties_t props = lwmqtt_empty_props;
144+ return this ->disconnect (0 , props);
145+ }
146+
147+ bool disconnect (uint8_t reason, lwmqtt_properties_t props);
124148
125149 private:
126150 void close ();
0 commit comments