1
0
mirror of https://github.com/adafruit/Adafruit_MQTT_Library.git synced 2025-07-30 13:23:06 +03:00

Use const pointers for payload

The payload data is never modified by the library, so using const is
possible without any further changes. Using const allows using a string
literal, or String::c_str() as the payload.
This commit is contained in:
Matthijs Kooijman
2015-07-02 12:59:46 +02:00
parent d4e27c9b3f
commit 73f5be4e5c
2 changed files with 6 additions and 6 deletions

View File

@ -116,7 +116,7 @@ class Adafruit_MQTT {
// 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, char *payload, uint8_t qos);
bool publish(const char *topic, const char *payload, uint8_t qos);
// Add a subscription to receive messages for a topic. Returns true if the
// subscription could be added, false otherwise.
@ -161,7 +161,7 @@ class Adafruit_MQTT {
// Functions to generate MQTT packets.
uint8_t connectPacket(uint8_t *packet);
uint8_t publishPacket(uint8_t *packet, const char *topic, char *payload, uint8_t qos);
uint8_t publishPacket(uint8_t *packet, const char *topic, const char *payload, uint8_t qos);
uint8_t subscribePacket(uint8_t *packet, const char *topic, uint8_t qos);
uint8_t pingPacket(uint8_t *packet);
};
@ -171,7 +171,7 @@ class Adafruit_MQTT_Publish {
public:
Adafruit_MQTT_Publish(Adafruit_MQTT *mqttserver, const char *feed, uint8_t qos = 0);
bool publish(char *s);
bool publish(const char *s);
bool publish(double f, uint8_t precision=2); // Precision controls the minimum number of digits after decimal.
// This might be ignored and a higher precision value sent.
bool publish(int32_t i);