Metrics logging now includes average time taken per frame. Also, metrics now come in a single JSON payload to /metrics.
This commit is contained in:
20
src/mqtt.cpp
20
src/mqtt.cpp
@ -23,7 +23,10 @@ void mqtt_callback(char* original_topic, byte* pl, unsigned int length) {
|
||||
pl[length] = '\0';
|
||||
String payload((char*)pl);
|
||||
String topic (original_topic);
|
||||
if (topic.compareTo(MQTT_TOPIC "log")==0) return;
|
||||
if (topic.compareTo(MQTT_TOPIC "log")==0 || topic.compareTo(MQTT_TOPIC "status") || topic.compareTo(MQTT_TOPIC "metrics")) {
|
||||
// Return our own messages
|
||||
return;
|
||||
}
|
||||
LOGln("MQTT * In: %s = %s", topic.c_str(), payload.c_str());
|
||||
if (topic.startsWith(MQTT_TOPIC_WEATHER)) {
|
||||
// Weather stuff
|
||||
@ -51,11 +54,6 @@ void mqtt_callback(char* original_topic, byte* pl, unsigned int length) {
|
||||
|
||||
topic.remove(0, strlen(MQTT_TOPIC)); // Strip MQTT_TOPIC from the beginning
|
||||
|
||||
if (topic.compareTo("free_heap")==0 || topic.compareTo("uptime")==0 || topic.compareTo("status")==0 || topic.compareTo("fps")==0) {
|
||||
// Ignore our own messages.
|
||||
return;
|
||||
}
|
||||
|
||||
if(topic.compareTo("mode")==0) {
|
||||
LOGln("MQTT * Changing mode...");
|
||||
bool result = change_current_effect(payload);
|
||||
@ -125,11 +123,15 @@ 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);
|
||||
char b[32];
|
||||
sprintf(b, "%d", number);
|
||||
mqtt_client.publish(t, b);
|
||||
mqtt_publish(topic, b);
|
||||
}
|
||||
|
||||
void mqtt_publish(const char* topic, const char* message) {
|
||||
char t[127];
|
||||
sprintf(t, MQTT_TOPIC "%s", topic);
|
||||
mqtt_client.publish(t, message);
|
||||
}
|
||||
|
||||
void mqtt_log(const char* message) {
|
||||
|
Reference in New Issue
Block a user