MQTT messages can now be retained.

This commit is contained in:
Fabian Schlenz 2020-04-29 20:25:41 +02:00
parent 8e2d2225cb
commit 4762a852d8
2 changed files with 6 additions and 6 deletions

View File

@ -17,8 +17,8 @@ void mqtt_setup();
void mqtt_loop(); void mqtt_loop();
void mqtt_publish(const char* topic, int number); void mqtt_publish(const char* topic, int number, bool retain=false);
void mqtt_publish(const char* topic, const char* message); void mqtt_publish(const char* topic, const char* message, bool retain=false);
void mqtt_log(const char* message); void mqtt_log(const char* message);
void mqtt_log(int number); void mqtt_log(int number);

View File

@ -133,16 +133,16 @@ void mqtt_loop() {
String mqtt_log_str = String(); String mqtt_log_str = String();
void mqtt_publish(const char* topic, int number) { void mqtt_publish(const char* topic, int number, bool retain) {
char b[32]; char b[32];
sprintf(b, "%d", number); sprintf(b, "%d", number);
mqtt_publish(topic, b); mqtt_publish(topic, b, retain);
} }
void mqtt_publish(const char* topic, const char* message) { void mqtt_publish(const char* topic, const char* message, bool retain) {
char t[127]; char t[127];
sprintf(t, MQTT_TOPIC "%s", topic); sprintf(t, MQTT_TOPIC "%s", topic);
mqtt_client.publish(t, message); mqtt_client.publish(t, message, retain);
} }
void mqtt_log(const char* message) { void mqtt_log(const char* message) {