Macros LOG
and LOGln
now will, if debugging is enabled, log to an mqtt topic as well as Serial.
This commit is contained in:
39
src/mqtt.cpp
39
src/mqtt.cpp
@ -72,6 +72,8 @@ void mqtt_loop() {
|
||||
}
|
||||
}
|
||||
|
||||
String mqtt_log_str = String();
|
||||
|
||||
void mqtt_publish(const char* topic, int number) {
|
||||
char t[127];
|
||||
sprintf(t, MQTT_TOPIC "%s", topic);
|
||||
@ -79,3 +81,40 @@ void mqtt_publish(const char* topic, int number) {
|
||||
sprintf(b, "%d", number);
|
||||
mqtt_client.publish(t, b);
|
||||
}
|
||||
|
||||
void mqtt_log(const char* message) {
|
||||
mqtt_log_str.concat(message);
|
||||
}
|
||||
|
||||
void mqtt_log(int number) {
|
||||
mqtt_log(String(number).c_str());
|
||||
}
|
||||
|
||||
void mqtt_log(long unsigned int number) {
|
||||
mqtt_log(String(number).c_str());
|
||||
}
|
||||
|
||||
void mqtt_log_ln(int number) {
|
||||
mqtt_log_ln(String(number).c_str());
|
||||
}
|
||||
|
||||
void mqtt_log_ln(long unsigned int number) {
|
||||
mqtt_log_ln(String(number).c_str());
|
||||
}
|
||||
|
||||
void mqtt_log_ln(const char* message) {
|
||||
if (mqtt_log_str.length()==0) {
|
||||
mqtt_log_send(message);
|
||||
return;
|
||||
} else {
|
||||
mqtt_log_str.concat(message);
|
||||
mqtt_log_send(mqtt_log_str.c_str());
|
||||
mqtt_log_str = String();
|
||||
}
|
||||
}
|
||||
|
||||
void mqtt_log_send(const char* message) {
|
||||
if (mqtt_client.connected()) {
|
||||
mqtt_client.publish(MQTT_TOPIC_LOG, message);
|
||||
}
|
||||
}
|
||||
|
@ -60,9 +60,9 @@ void loop() {
|
||||
}
|
||||
|
||||
EVERY_N_MILLISECONDS(1000 / FPS) {
|
||||
LOGln("Core * loop running");
|
||||
//LOGln("Core * loop running");
|
||||
current_effect->loop();
|
||||
LOGln("Core * loop ran");
|
||||
//LOGln("Core * loop ran");
|
||||
|
||||
if (current_effect->can_be_shown_with_clock()) {
|
||||
effect_clock.loop(current_effect->clock_as_mask(), CRGB(0xFFFFFF), CRGB(0x000000));
|
||||
|
Reference in New Issue
Block a user