@@ -23,7 +23,8 @@ typedef struct {
23
23
class MQTTClient ;
24
24
25
25
typedef 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);
27
28
28
29
typedef struct {
29
30
MQTTClient *client = nullptr ;
@@ -50,7 +51,7 @@ class MQTTClient {
50
51
lwmqtt_arduino_network_t network = {nullptr };
51
52
lwmqtt_arduino_timer_t timer1 = {0 , nullptr };
52
53
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 };
54
55
55
56
bool _connected = false ;
56
57
lwmqtt_return_code_t _returnCode = (lwmqtt_return_code_t )0 ;
@@ -61,8 +62,9 @@ class MQTTClient {
61
62
62
63
~MQTTClient ();
63
64
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);
66
68
67
69
void onMessage (MQTTClientCallbackSimple cb);
68
70
void onMessageAdvanced (MQTTClientCallbackAdvanced cb);
@@ -91,6 +93,10 @@ class MQTTClient {
91
93
bool publish (const String &topic, const String &payload, bool retained, int qos) {
92
94
return this ->publish (topic.c_str (), payload.c_str (), retained, qos);
93
95
}
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
+
94
100
bool publish (const char topic[], const String &payload) { return this ->publish (topic, payload.c_str ()); }
95
101
bool publish (const char topic[], const String &payload, bool retained, int qos) {
96
102
return this ->publish (topic, payload.c_str (), retained, qos);
@@ -104,23 +110,41 @@ class MQTTClient {
104
110
bool publish (const char topic[], const char payload[], int length) {
105
111
return this ->publish (topic, payload, length, false , 0 );
106
112
}
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);
108
119
109
120
bool subscribe (const String &topic) { return this ->subscribe (topic.c_str ()); }
110
121
bool subscribe (const String &topic, int qos) { return this ->subscribe (topic.c_str (), qos); }
111
122
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);
113
128
114
129
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);
116
135
117
136
bool loop ();
118
137
bool connected ();
119
138
120
139
lwmqtt_err_t lastError () { return this ->_lastError ; }
121
140
lwmqtt_return_code_t returnCode () { return this ->_returnCode ; }
122
141
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);
124
148
125
149
private:
126
150
void close ();
0 commit comments