11
11
12
12
#define MQTT_TOPIC_MAX_LENGTH 128
13
13
14
- typedef enum {
15
- AT_MOST_ONCE = 0 , // default
16
- AT_LEAST_ONCE,
17
- EXACTLY_ONCE
18
- } MqttQoS;
14
+ typedef enum { AT_MOST_ONCE = 0 , AT_LEAST_ONCE, EXACTLY_ONCE } MqttQoS;
19
15
20
16
class MqttClientClass {
21
17
@@ -30,7 +26,7 @@ class MqttClientClass {
30
26
/* *
31
27
* @brief Singleton instance.
32
28
*/
33
- static MqttClientClass & instance (void ) {
29
+ static MqttClientClass& instance (void ) {
34
30
static MqttClientClass instance;
35
31
return instance;
36
32
}
@@ -54,14 +50,14 @@ class MqttClientClass {
54
50
*
55
51
* @return true if configuration and connection was succesful.
56
52
*/
57
- bool begin (const char * client_id,
58
- const char * host,
53
+ bool begin (const char * client_id,
54
+ const char * host,
59
55
const uint16_t port,
60
56
const bool use_tls,
61
57
const size_t keep_alive = 60 ,
62
- const bool use_ecc = true ,
63
- const char * username = " " ,
64
- const char * password = " " );
58
+ const bool use_ecc = true ,
59
+ const char * username = " " ,
60
+ const char * password = " " );
65
61
66
62
/* *
67
63
* @brief Will configure and connect to the device specific AWS broker.
@@ -97,10 +93,10 @@ class MqttClientClass {
97
93
*
98
94
* @return true if publish was successful.
99
95
*/
100
- bool publish (const char * topic,
101
- const uint8_t * buffer,
96
+ bool publish (const char * topic,
97
+ const uint8_t * buffer,
102
98
const uint32_t buffer_size,
103
- const MqttQoS quality_of_service = AT_MOST_ONCE );
99
+ const MqttQoS quality_of_service = AT_LEAST_ONCE );
104
100
105
101
/* *
106
102
* @brief Publishes the contents of the message to the given topic.
@@ -111,9 +107,9 @@ class MqttClientClass {
111
107
*
112
108
* @return true if publish was successful.
113
109
*/
114
- bool publish (const char * topic,
115
- const char * message,
116
- const MqttQoS quality_of_service = AT_MOST_ONCE );
110
+ bool publish (const char * topic,
111
+ const char * message,
112
+ const MqttQoS quality_of_service = AT_LEAST_ONCE );
117
113
118
114
/* *
119
115
* @brief Subscribes to a given topic.
@@ -123,7 +119,7 @@ class MqttClientClass {
123
119
*
124
120
* @return true if subscription was successful.
125
121
*/
126
- bool subscribe (const char * topic,
122
+ bool subscribe (const char * topic,
127
123
const MqttQoS quality_of_service = AT_MOST_ONCE);
128
124
129
125
/* *
@@ -134,7 +130,7 @@ class MqttClientClass {
134
130
* @param message_id This value will be -1 if the MqttQoS is set to
135
131
* AT_MOST_ONCE.
136
132
*/
137
- void onReceive (void (*callback)(const char * topic,
133
+ void onReceive (void (*callback)(const char * topic,
138
134
const uint16_t message_length,
139
135
const int32_t message_id));
140
136
@@ -152,8 +148,8 @@ class MqttClientClass {
152
148
* message or the message buffer was over 1024, which is a limitation from
153
149
* the LTE module.
154
150
*/
155
- bool readMessage (const char * topic,
156
- char * buffer,
151
+ bool readMessage (const char * topic,
152
+ char * buffer,
157
153
const uint16_t buffer_size,
158
154
const int32_t message_id = -1 );
159
155
@@ -165,7 +161,7 @@ class MqttClientClass {
165
161
* @return The message or an empty string if no new message was retrieved on
166
162
* the given topic.
167
163
*/
168
- String readMessage (const char * topic, const uint16_t size = 256 );
164
+ String readMessage (const char * topic, const uint16_t size = 256 );
169
165
170
166
/* *
171
167
* @brief Reads @p num_messages MQTT messages from the Sequans modem and
@@ -174,7 +170,7 @@ class MqttClientClass {
174
170
* @param topic Topic to clear the messages from.
175
171
* @param num_messages Number of messages to discard.
176
172
*/
177
- void clearMessages (const char * topic, const uint16_t num_messages);
173
+ void clearMessages (const char * topic, const uint16_t num_messages);
178
174
};
179
175
180
176
extern MqttClientClass MqttClient;
0 commit comments