Skip to content

Commit 9236f06

Browse files
committed
Make default QoS for publish at least once and update make script
1 parent 6e301c4 commit 9236f06

File tree

2 files changed

+20
-24
lines changed

2 files changed

+20
-24
lines changed

scripts/make.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22

33
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
4-
TARGET=$SCRIPTPATH/../examples/power_down/power_down.ino
4+
TARGET=$SCRIPTPATH/../examples/sandbox/sandbox.ino
55
BOARD_CONFIG="DxCore:megaavr:avrdb:appspm=no,chip=avr128db48,clock=24internal,bodvoltage=1v9,bodmode=disabled,eesave=enable,resetpin=reset,millis=tcb2,startuptime=8,wiremode=mors2,printf=full"
66

77
if [ -d "$SCRIPTPATH/../build" ]; then

src/mqtt_client.h

+19-23
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,7 @@
1111

1212
#define MQTT_TOPIC_MAX_LENGTH 128
1313

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;
1915

2016
class MqttClientClass {
2117

@@ -30,7 +26,7 @@ class MqttClientClass {
3026
/**
3127
* @brief Singleton instance.
3228
*/
33-
static MqttClientClass &instance(void) {
29+
static MqttClientClass& instance(void) {
3430
static MqttClientClass instance;
3531
return instance;
3632
}
@@ -54,14 +50,14 @@ class MqttClientClass {
5450
*
5551
* @return true if configuration and connection was succesful.
5652
*/
57-
bool begin(const char *client_id,
58-
const char *host,
53+
bool begin(const char* client_id,
54+
const char* host,
5955
const uint16_t port,
6056
const bool use_tls,
6157
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 = "");
6561

6662
/**
6763
* @brief Will configure and connect to the device specific AWS broker.
@@ -97,10 +93,10 @@ class MqttClientClass {
9793
*
9894
* @return true if publish was successful.
9995
*/
100-
bool publish(const char *topic,
101-
const uint8_t *buffer,
96+
bool publish(const char* topic,
97+
const uint8_t* buffer,
10298
const uint32_t buffer_size,
103-
const MqttQoS quality_of_service = AT_MOST_ONCE);
99+
const MqttQoS quality_of_service = AT_LEAST_ONCE);
104100

105101
/**
106102
* @brief Publishes the contents of the message to the given topic.
@@ -111,9 +107,9 @@ class MqttClientClass {
111107
*
112108
* @return true if publish was successful.
113109
*/
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);
117113

118114
/**
119115
* @brief Subscribes to a given topic.
@@ -123,7 +119,7 @@ class MqttClientClass {
123119
*
124120
* @return true if subscription was successful.
125121
*/
126-
bool subscribe(const char *topic,
122+
bool subscribe(const char* topic,
127123
const MqttQoS quality_of_service = AT_MOST_ONCE);
128124

129125
/**
@@ -134,7 +130,7 @@ class MqttClientClass {
134130
* @param message_id This value will be -1 if the MqttQoS is set to
135131
* AT_MOST_ONCE.
136132
*/
137-
void onReceive(void (*callback)(const char *topic,
133+
void onReceive(void (*callback)(const char* topic,
138134
const uint16_t message_length,
139135
const int32_t message_id));
140136

@@ -152,8 +148,8 @@ class MqttClientClass {
152148
* message or the message buffer was over 1024, which is a limitation from
153149
* the LTE module.
154150
*/
155-
bool readMessage(const char *topic,
156-
char *buffer,
151+
bool readMessage(const char* topic,
152+
char* buffer,
157153
const uint16_t buffer_size,
158154
const int32_t message_id = -1);
159155

@@ -165,7 +161,7 @@ class MqttClientClass {
165161
* @return The message or an empty string if no new message was retrieved on
166162
* the given topic.
167163
*/
168-
String readMessage(const char *topic, const uint16_t size = 256);
164+
String readMessage(const char* topic, const uint16_t size = 256);
169165

170166
/**
171167
* @brief Reads @p num_messages MQTT messages from the Sequans modem and
@@ -174,7 +170,7 @@ class MqttClientClass {
174170
* @param topic Topic to clear the messages from.
175171
* @param num_messages Number of messages to discard.
176172
*/
177-
void clearMessages(const char *topic, const uint16_t num_messages);
173+
void clearMessages(const char* topic, const uint16_t num_messages);
178174
};
179175

180176
extern MqttClientClass MqttClient;

0 commit comments

Comments
 (0)