Browse Source

Clean debug messages

fastled
Xose Pérez 7 years ago
parent
commit
4888196b5e
13 changed files with 87 additions and 67 deletions
  1. +53
    -49
      code/espurna/espurna.ino
  2. +4
    -0
      code/espurna/filters/BaseFilter.h
  3. +4
    -0
      code/espurna/filters/MaxFilter.h
  4. +4
    -0
      code/espurna/filters/MedianFilter.h
  5. +5
    -1
      code/espurna/filters/MovingAverageFilter.h
  6. +2
    -2
      code/espurna/mdns.ino
  7. +2
    -2
      code/espurna/mqtt.ino
  8. +5
    -5
      code/espurna/sensor.ino
  9. +1
    -1
      code/espurna/sensors/BMX280Sensor.h
  10. +2
    -2
      code/espurna/sensors/ECH1560Sensor.h
  11. +2
    -2
      code/espurna/sensors/EventSensor.h
  12. +2
    -2
      code/espurna/sensors/HLW8012Sensor.h
  13. +1
    -1
      code/espurna/sensors/I2CSensor.h

+ 53
- 49
code/espurna/espurna.ino View File

@ -204,56 +204,60 @@ void welcome() {
DEBUG_MSG_P(PSTR(" WEB")); DEBUG_MSG_P(PSTR(" WEB"));
#endif #endif
DEBUG_MSG_P(PSTR("\n[INIT] SENSORS:"));
#if SENSOR_SUPPORT
#if ANALOG_SUPPORT
DEBUG_MSG_P(PSTR(" ANALOG"));
#endif
#if BMX280_SUPPORT
DEBUG_MSG_P(PSTR(" BMX280"));
#endif
#if DALLAS_SUPPORT
DEBUG_MSG_P(PSTR(" DALLAS"));
#endif
#if DHT_SUPPORT
DEBUG_MSG_P(PSTR(" DHTXX"));
#endif
#if DIGITAL_SUPPORT
DEBUG_MSG_P(PSTR(" DIGITAL"));
#endif
#if ECH1560_SUPPORT
DEBUG_MSG_P(PSTR(" ECH1560"));
#endif
#if EMON_ADC121_SUPPORT
DEBUG_MSG_P(PSTR(" EMON_ADC121"));
#endif
#if EMON_ADS1X15_SUPPORT
DEBUG_MSG_P(PSTR(" EMON_ADX1X15"));
#endif
#if EMON_ANALOG_SUPPORT
DEBUG_MSG_P(PSTR(" EMON_ANALOG"));
#endif
#if EVENTS_SUPPORT
DEBUG_MSG_P(PSTR(" EVENTS"));
#endif
#if HLW8012_SUPPORT
DEBUG_MSG_P(PSTR(" HLW8012"));
#endif
#if MHZ19_SUPPORT
DEBUG_MSG_P(PSTR(" MHZ19"));
#endif
#if PMSX003_SUPPORT
DEBUG_MSG_P(PSTR(" PMSX003"));
#endif
#if SHT3X_I2C_SUPPORT
DEBUG_MSG_P(PSTR(" SHT3X_I2C"));
#endif
#if SI7021_SUPPORT
DEBUG_MSG_P(PSTR(" SI7021"));
#endif
#if V9261F_SUPPORT
DEBUG_MSG_P(PSTR(" V9261F"));
#endif
DEBUG_MSG_P(PSTR("\n[INIT] SENSORS:"));
#if ANALOG_SUPPORT
DEBUG_MSG_P(PSTR(" ANALOG"));
#endif
#if BMX280_SUPPORT
DEBUG_MSG_P(PSTR(" BMX280"));
#endif
#if DALLAS_SUPPORT
DEBUG_MSG_P(PSTR(" DALLAS"));
#endif
#if DHT_SUPPORT
DEBUG_MSG_P(PSTR(" DHTXX"));
#endif
#if DIGITAL_SUPPORT
DEBUG_MSG_P(PSTR(" DIGITAL"));
#endif
#if ECH1560_SUPPORT
DEBUG_MSG_P(PSTR(" ECH1560"));
#endif
#if EMON_ADC121_SUPPORT
DEBUG_MSG_P(PSTR(" EMON_ADC121"));
#endif
#if EMON_ADS1X15_SUPPORT
DEBUG_MSG_P(PSTR(" EMON_ADX1X15"));
#endif
#if EMON_ANALOG_SUPPORT
DEBUG_MSG_P(PSTR(" EMON_ANALOG"));
#endif
#if EVENTS_SUPPORT
DEBUG_MSG_P(PSTR(" EVENTS"));
#endif
#if HLW8012_SUPPORT
DEBUG_MSG_P(PSTR(" HLW8012"));
#endif
#if MHZ19_SUPPORT
DEBUG_MSG_P(PSTR(" MHZ19"));
#endif
#if PMSX003_SUPPORT
DEBUG_MSG_P(PSTR(" PMSX003"));
#endif
#if SHT3X_I2C_SUPPORT
DEBUG_MSG_P(PSTR(" SHT3X_I2C"));
#endif
#if SI7021_SUPPORT
DEBUG_MSG_P(PSTR(" SI7021"));
#endif
#if V9261F_SUPPORT
DEBUG_MSG_P(PSTR(" V9261F"));
#endif
#endif // SENSOR_SUPPORT
DEBUG_MSG_P(PSTR("\n\n")); DEBUG_MSG_P(PSTR("\n\n"));


+ 4
- 0
code/espurna/filters/BaseFilter.h View File

@ -3,6 +3,8 @@
// Copyright (C) 2017 by Xose Pérez <xose dot perez at gmail dot com> // Copyright (C) 2017 by Xose Pérez <xose dot perez at gmail dot com>
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
#if SENSOR_SUPPORT
#pragma once #pragma once
#include <vector> #include <vector>
@ -46,3 +48,5 @@ class BaseFilter {
std::vector<double> _data; std::vector<double> _data;
}; };
#endif // SENSOR_SUPPORT

+ 4
- 0
code/espurna/filters/MaxFilter.h View File

@ -3,6 +3,8 @@
// Copyright (C) 2017 by Xose Pérez <xose dot perez at gmail dot com> // Copyright (C) 2017 by Xose Pérez <xose dot perez at gmail dot com>
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
#if SENSOR_SUPPORT
#pragma once #pragma once
#include <vector> #include <vector>
@ -17,3 +19,5 @@ class MaxFilter : public BaseFilter {
} }
}; };
#endif // SENSOR_SUPPORT

+ 4
- 0
code/espurna/filters/MedianFilter.h View File

@ -3,6 +3,8 @@
// Copyright (C) 2017 by Xose Pérez <xose dot perez at gmail dot com> // Copyright (C) 2017 by Xose Pérez <xose dot perez at gmail dot com>
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
#if SENSOR_SUPPORT
#pragma once #pragma once
#include "BaseFilter.h" #include "BaseFilter.h"
@ -58,3 +60,5 @@ class MedianFilter : public BaseFilter {
} }
}; };
#endif // SENSOR_SUPPORT

+ 5
- 1
code/espurna/filters/MovingAverageFilter.h View File

@ -3,6 +3,8 @@
// Copyright (C) 2017 by Xose Pérez <xose dot perez at gmail dot com> // Copyright (C) 2017 by Xose Pérez <xose dot perez at gmail dot com>
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
#if SENSOR_SUPPORT
#pragma once #pragma once
#include <vector> #include <vector>
@ -26,7 +28,7 @@ class MovingAverageFilter : public BaseFilter {
} }
_pointer++; _pointer++;
} }
void reset() { void reset() {
@ -58,3 +60,5 @@ class MovingAverageFilter : public BaseFilter {
double _sum = 0; double _sum = 0;
}; };
#endif // SENSOR_SUPPORT

+ 2
- 2
code/espurna/mdns.ino View File

@ -16,9 +16,9 @@ WiFiEventHandler _mdns_wifi_onAP;
#if MQTT_SUPPORT #if MQTT_SUPPORT
void mdnsFindMQTT() { void mdnsFindMQTT() {
int count = MDNS.queryService("mqtt", "tcp"); int count = MDNS.queryService("mqtt", "tcp");
DEBUG_MSG_P("[MQTT] MQTT brokers found: %d\n", count);
DEBUG_MSG_P(PSTR("[MQTT] MQTT brokers found: %d\n"), count);
for (int i=0; i<count; i++) { for (int i=0; i<count; i++) {
DEBUG_MSG_P("[MQTT] Broker at %s:%d\n", MDNS.IP(i).toString().c_str(), MDNS.port(i));
DEBUG_MSG_P(PSTR("[MQTT] Broker at %s:%d\n"), MDNS.IP(i).toString().c_str(), MDNS.port(i));
mqttSetBrokerIfNone(MDNS.IP(i), MDNS.port(i)); mqttSetBrokerIfNone(MDNS.IP(i), MDNS.port(i));
} }
} }


+ 2
- 2
code/espurna/mqtt.ino View File

@ -65,7 +65,7 @@ bool mqttConnected() {
void mqttDisconnect() { void mqttDisconnect() {
if (_mqtt.connected()) { if (_mqtt.connected()) {
DEBUG_MSG_P("[MQTT] Disconnecting\n");
DEBUG_MSG_P(PSTR("[MQTT] Disconnecting\n"));
_mqtt.disconnect(); _mqtt.disconnect();
} }
} }
@ -148,7 +148,7 @@ void mqttSend(const char * topic, const char * message, bool force) {
element.message = strdup(message); element.message = strdup(message);
_mqtt_queue.push_back(element); _mqtt_queue.push_back(element);
_mqtt_flush_ticker.once_ms(MQTT_USE_JSON_DELAY, _mqttFlush); _mqtt_flush_ticker.once_ms(MQTT_USE_JSON_DELAY, _mqttFlush);
} else { } else {
String path = _mqtt_topic + String(topic) + _mqtt_getter; String path = _mqtt_topic + String(topic) + _mqtt_getter;
mqttSendRaw(path.c_str(), message); mqttSendRaw(path.c_str(), message);


+ 5
- 5
code/espurna/sensor.ino View File

@ -183,7 +183,7 @@ void _sensorPre() {
for (unsigned char i=0; i<_sensors.size(); i++) { for (unsigned char i=0; i<_sensors.size(); i++) {
_sensors[i]->pre(); _sensors[i]->pre();
if (!_sensors[i]->status()) { if (!_sensors[i]->status()) {
DEBUG_MSG("[SENSOR] Error reading data from %s (error: %d)\n",
DEBUG_MSG_P(PSTR("[SENSOR] Error reading data from %s (error: %d)\n"),
_sensors[i]->description().c_str(), _sensors[i]->description().c_str(),
_sensors[i]->error() _sensors[i]->error()
); );
@ -454,8 +454,8 @@ void _magnitudesInit() {
BaseSensor * sensor = _sensors[i]; BaseSensor * sensor = _sensors[i];
DEBUG_MSG("[SENSOR] %s\n", sensor->description().c_str());
if (sensor->error() != 0) DEBUG_MSG("[SENSOR] -> ERROR %d\n", sensor->error());
DEBUG_MSG_P(PSTR("[SENSOR] %s\n"), sensor->description().c_str());
if (sensor->error() != 0) DEBUG_MSG_P(PSTR("[SENSOR] -> ERROR %d\n"), sensor->error());
for (unsigned char k=0; k<sensor->count(); k++) { for (unsigned char k=0; k<sensor->count(); k++) {
@ -479,7 +479,7 @@ void _magnitudesInit() {
} }
_magnitudes.push_back(new_magnitude); _magnitudes.push_back(new_magnitude);
DEBUG_MSG("[SENSOR] -> %s:%d\n", _magnitudeTopic(type).c_str(), _counts[type]);
DEBUG_MSG_P(PSTR("[SENSOR] -> %s:%d\n"), _magnitudeTopic(type).c_str(), _counts[type]);
_counts[type] = _counts[type] + 1; _counts[type] = _counts[type] + 1;
@ -595,7 +595,7 @@ void sensorLoop() {
#if SENSOR_DEBUG #if SENSOR_DEBUG
{ {
dtostrf(current, 1-sizeof(buffer), decimals, buffer); dtostrf(current, 1-sizeof(buffer), decimals, buffer);
DEBUG_MSG("[SENSOR] %s - %s: %s%s\n",
DEBUG_MSG_P(PSTR("[SENSOR] %s - %s: %s%s\n"),
magnitude.sensor->slot(magnitude.local).c_str(), magnitude.sensor->slot(magnitude.local).c_str(),
_magnitudeTopic(magnitude.type).c_str(), _magnitudeTopic(magnitude.type).c_str(),
buffer, buffer,


+ 1
- 1
code/espurna/sensors/BMX280Sensor.h View File

@ -248,4 +248,4 @@ class BMX280Sensor : public I2CSensor {
unsigned char BMX280Sensor::addresses[2] = {0x76, 0x77}; unsigned char BMX280Sensor::addresses[2] = {0x76, 0x77};
// SENSOR_SUPPORT && BMX280_SUPPORT
#endif // SENSOR_SUPPORT && BMX280_SUPPORT

+ 2
- 2
code/espurna/sensors/ECH1560Sensor.h View File

@ -311,7 +311,7 @@ void ECH1560Sensor::_attach(ECH1560Sensor * instance, unsigned char gpio, unsign
_ech1560_sensor_instance[index] = instance; _ech1560_sensor_instance[index] = instance;
attachInterrupt(gpio, _ech1560_sensor_isr_list[index], mode); attachInterrupt(gpio, _ech1560_sensor_isr_list[index], mode);
#if SENSOR_DEBUG #if SENSOR_DEBUG
DEBUG_MSG("[SENSOR] GPIO%d interrupt attached to %s\n", gpio, instance->description().c_str());
DEBUG_MSG_P(PSTR("[SENSOR] GPIO%d interrupt attached to %s\n"), gpio, instance->description().c_str());
#endif #endif
} }
@ -321,7 +321,7 @@ void ECH1560Sensor::_detach(unsigned char gpio) {
if (_ech1560_sensor_instance[index]) { if (_ech1560_sensor_instance[index]) {
detachInterrupt(gpio); detachInterrupt(gpio);
#if SENSOR_DEBUG #if SENSOR_DEBUG
DEBUG_MSG("[SENSOR] GPIO%d interrupt detached from %s\n", gpio, _ech1560_sensor_instance[index]->description().c_str());
DEBUG_MSG_P(PSTR("[SENSOR] GPIO%d interrupt detached from %s\n"), gpio, _ech1560_sensor_instance[index]->description().c_str());
#endif #endif
_ech1560_sensor_instance[index] = NULL; _ech1560_sensor_instance[index] = NULL;
} }


+ 2
- 2
code/espurna/sensors/EventSensor.h View File

@ -185,7 +185,7 @@ void EventSensor::_attach(EventSensor * instance, unsigned char gpio, unsigned c
_event_sensor_instance[index] = instance; _event_sensor_instance[index] = instance;
attachInterrupt(gpio, _event_sensor_isr_list[index], mode); attachInterrupt(gpio, _event_sensor_isr_list[index], mode);
#if SENSOR_DEBUG #if SENSOR_DEBUG
DEBUG_MSG("[SENSOR] GPIO%d interrupt attached to %s\n", gpio, instance->description().c_str());
DEBUG_MSG_P(PSTR("[SENSOR] GPIO%d interrupt attached to %s\n"), gpio, instance->description().c_str());
#endif #endif
} }
@ -195,7 +195,7 @@ void EventSensor::_detach(unsigned char gpio) {
if (_event_sensor_instance[index]) { if (_event_sensor_instance[index]) {
detachInterrupt(gpio); detachInterrupt(gpio);
#if SENSOR_DEBUG #if SENSOR_DEBUG
DEBUG_MSG("[SENSOR] GPIO%d interrupt detached from %s\n", gpio, _event_sensor_instance[index]->description().c_str());
DEBUG_MSG_P(PSTR("[SENSOR] GPIO%d interrupt detached from %s\n"), gpio, _event_sensor_instance[index]->description().c_str());
#endif #endif
_event_sensor_instance[index] = NULL; _event_sensor_instance[index] = NULL;
} }


+ 2
- 2
code/espurna/sensors/HLW8012Sensor.h View File

@ -295,7 +295,7 @@ void HLW8012Sensor::_attach(HLW8012Sensor * instance, unsigned char gpio, unsign
_hlw8012_sensor_instance[index] = instance; _hlw8012_sensor_instance[index] = instance;
attachInterrupt(gpio, _hlw8012_sensor_isr_list[index], mode); attachInterrupt(gpio, _hlw8012_sensor_isr_list[index], mode);
#if SENSOR_DEBUG #if SENSOR_DEBUG
DEBUG_MSG("[SENSOR] GPIO%d interrupt attached to %s\n", gpio, instance->description().c_str());
DEBUG_MSG_P(PSTR("[SENSOR] GPIO%d interrupt attached to %s\n"), gpio, instance->description().c_str());
#endif #endif
} }
@ -305,7 +305,7 @@ void HLW8012Sensor::_detach(unsigned char gpio) {
if (_hlw8012_sensor_instance[index]) { if (_hlw8012_sensor_instance[index]) {
detachInterrupt(gpio); detachInterrupt(gpio);
#if SENSOR_DEBUG #if SENSOR_DEBUG
DEBUG_MSG("[SENSOR] GPIO%d interrupt detached from %s\n", gpio, _hlw8012_sensor_instance[index]->description().c_str());
DEBUG_MSG_P(PSTR("[SENSOR] GPIO%d interrupt detached from %s\n"), gpio, _hlw8012_sensor_instance[index]->description().c_str());
#endif #endif
_hlw8012_sensor_instance[index] = NULL; _hlw8012_sensor_instance[index] = NULL;
} }


+ 1
- 1
code/espurna/sensors/I2CSensor.h View File

@ -3,7 +3,7 @@
// Copyright (C) 2017 by Xose Pérez <xose dot perez at gmail dot com> // Copyright (C) 2017 by Xose Pérez <xose dot perez at gmail dot com>
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
#if SENSOR_SUPPORT && I2C_SUPPORT
#if SENSOR_SUPPORT && ( I2C_SUPPORT || EMON_ANALOG_SUPPORT )
#pragma once #pragma once


Loading…
Cancel
Save