1
0
mirror of https://github.com/adafruit/Adafruit_MQTT_Library.git synced 2025-07-27 15:01:49 +03:00

fixes from @ben-willmore on 83af73f4e5

This commit is contained in:
brentru
2022-11-14 16:23:51 -05:00
parent 9409c6373b
commit 28435eaf58
3 changed files with 30 additions and 72 deletions

View File

@ -34,7 +34,7 @@
#define ADAFRUIT_MQTT_VERSION_PATCH 0
// Uncomment/comment to turn on/off debug output messages.
#define MQTT_DEBUG
// #define MQTT_DEBUG
// Uncomment/comment to turn on/off error output messages.
#define MQTT_ERROR
@ -107,7 +107,7 @@
// Largest full packet we're able to send.
// Need to be able to store at least ~90 chars for a connect packet with full
// 23 char client ID.
#define MAXBUFFERSIZE (512)
#define MAXBUFFERSIZE (150)
#define MQTT_CONN_USERNAMEFLAG 0x80
#define MQTT_CONN_PASSWORDFLAG 0x40
@ -124,7 +124,7 @@
#define SUBSCRIPTIONDATALEN 20
#else
#define MAXSUBSCRIPTIONS 15
#define SUBSCRIPTIONDATALEN MAXBUFFERSIZE
#define SUBSCRIPTIONDATALEN 100
#endif
class AdafruitIO_MQTT; // forward decl
@ -189,13 +189,10 @@ public:
// Publish a message to a topic using the specified QoS level. Returns true
// if the message was published, false otherwise.
bool publish(const char *topic, const char *payload, uint8_t qos = 0);
bool publish(const char *topic, const char *payload, bool retain,
uint8_t qos = 0);
bool publish(const char *topic, const char *payload, uint8_t qos = 0,
bool retain = false);
bool publish(const char *topic, uint8_t *payload, uint16_t bLen,
uint8_t qos = 0);
bool publish(const char *topic, uint8_t *payload, uint16_t bLen, bool retain,
uint8_t qos = 0);
uint8_t qos = 0, bool retain = false);
// Add a subscription to receive messages for a topic. Returns true if the
// subscription could be added or was already present, false otherwise.
@ -272,11 +269,8 @@ private:
uint8_t connectPacket(uint8_t *packet);
uint8_t disconnectPacket(uint8_t *packet);
uint16_t publishPacket(uint8_t *packet, const char *topic, uint8_t *payload,
uint16_t bLen, uint8_t qos, uint16_t maxPacketLen = 0);
uint16_t publishPacket(uint8_t *packet, const char *topic, uint8_t *payload,
uint16_t bLen, bool retain, uint8_t qos,
uint16_t maxPacketLen = 0);
uint16_t bLen, uint8_t qos, uint16_t maxPacketLen = 0,
bool retain = false);
uint8_t subscribePacket(uint8_t *packet, const char *topic, uint8_t qos);
uint8_t unsubscribePacket(uint8_t *packet, const char *topic);
uint8_t pingPacket(uint8_t *packet);
@ -288,20 +282,16 @@ public:
Adafruit_MQTT_Publish(Adafruit_MQTT *mqttserver, const char *feed,
uint8_t qos = 0);
bool publish(const char *s);
bool publish(const char *s, bool retain);
bool publish(const char *s, bool retain = false);
bool publish(
double f,
uint8_t precision =
2); // Precision controls the minimum number of digits after decimal.
2, // Precision controls the minimum number of digits after decimal.
// This might be ignored and a higher precision value sent.
bool publish(double f, bool retain, uint8_t precision = 2);
bool publish(int32_t i);
bool publish(int32_t i, bool retain);
bool publish(uint32_t i);
bool publish(uint32_t i, bool retain);
bool publish(uint8_t *b, uint16_t bLen);
bool publish(uint8_t *b, uint16_t bLen, bool retain);
bool retain = false);
bool publish(int32_t i, bool retain = false);
bool publish(uint32_t i, bool retain = false);
bool publish(uint8_t *b, uint16_t bLen, bool retain = false);
private:
Adafruit_MQTT *mqtt;
@ -341,4 +331,4 @@ private:
Adafruit_MQTT *mqtt;
};
#endif
#endif