From c38911beaea9afbfdd5ee80dd76007a2ddfcc804 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Mon, 8 Jan 2018 10:41:21 +0100 Subject: [PATCH] Fix reference to sensor slot method --- code/espurna/sensors/AnalogSensor.h | 5 +++++ code/espurna/sensors/BaseSensor.h | 2 +- code/espurna/sensors/DHTSensor.h | 5 +++++ code/espurna/sensors/DigitalSensor.h | 5 +++++ code/espurna/sensors/ECH1560Sensor.h | 5 +++++ code/espurna/sensors/EventSensor.h | 5 +++++ code/espurna/sensors/HLW8012Sensor.h | 5 +++++ code/espurna/sensors/I2CSensor.h | 5 +++++ code/espurna/sensors/MHZ19Sensor.h | 5 +++++ code/espurna/sensors/SI7021Sensor.h | 5 +++++ code/espurna/sensors/V9261FSensor.h | 5 +++++ 11 files changed, 51 insertions(+), 1 deletion(-) diff --git a/code/espurna/sensors/AnalogSensor.h b/code/espurna/sensors/AnalogSensor.h index abf23460..108a00a2 100644 --- a/code/espurna/sensors/AnalogSensor.h +++ b/code/espurna/sensors/AnalogSensor.h @@ -37,6 +37,11 @@ class AnalogSensor : public BaseSensor { return String("ANALOG @ GPIO0"); } + // Descriptive name of the slot # index + String slot(unsigned char index) { + return description(); + }; + // Type for slot # index unsigned char type(unsigned char index) { _error = SENSOR_ERROR_OK; diff --git a/code/espurna/sensors/BaseSensor.h b/code/espurna/sensors/BaseSensor.h index 04840d1c..2fb469f7 100644 --- a/code/espurna/sensors/BaseSensor.h +++ b/code/espurna/sensors/BaseSensor.h @@ -62,7 +62,7 @@ class BaseSensor { static void manifest(JsonArray& root) {}; // Descriptive name of the slot # index - String slot(unsigned char index) { return description(); } + virtual String slot(unsigned char index) {}; // Sensor ID unsigned char getID() { return _sensor_id; }; diff --git a/code/espurna/sensors/DHTSensor.h b/code/espurna/sensors/DHTSensor.h index 8fa295ba..f7427968 100644 --- a/code/espurna/sensors/DHTSensor.h +++ b/code/espurna/sensors/DHTSensor.h @@ -90,6 +90,11 @@ class DHTSensor : public BaseSensor { return String(buffer); } + // Descriptive name of the slot # index + String slot(unsigned char index) { + return description(); + }; + // Type for slot # index unsigned char type(unsigned char index) { _error = SENSOR_ERROR_OK; diff --git a/code/espurna/sensors/DigitalSensor.h b/code/espurna/sensors/DigitalSensor.h index 39205cc4..8ae7f9a4 100644 --- a/code/espurna/sensors/DigitalSensor.h +++ b/code/espurna/sensors/DigitalSensor.h @@ -67,6 +67,11 @@ class DigitalSensor : public BaseSensor { return String(buffer); } + // Descriptive name of the slot # index + String slot(unsigned char index) { + return description(); + }; + // Type for slot # index unsigned char type(unsigned char index) { _error = SENSOR_ERROR_OK; diff --git a/code/espurna/sensors/ECH1560Sensor.h b/code/espurna/sensors/ECH1560Sensor.h index c5b40946..9c7c6089 100644 --- a/code/espurna/sensors/ECH1560Sensor.h +++ b/code/espurna/sensors/ECH1560Sensor.h @@ -82,6 +82,11 @@ class ECH1560Sensor : public BaseSensor { return String(buffer); } + // Descriptive name of the slot # index + String slot(unsigned char index) { + return description(); + }; + // Type for slot # index unsigned char type(unsigned char index) { _error = SENSOR_ERROR_OK; diff --git a/code/espurna/sensors/EventSensor.h b/code/espurna/sensors/EventSensor.h index e10b4bb8..96787dc0 100644 --- a/code/espurna/sensors/EventSensor.h +++ b/code/espurna/sensors/EventSensor.h @@ -81,6 +81,11 @@ class EventSensor : public BaseSensor { return String(buffer); } + // Descriptive name of the slot # index + String slot(unsigned char index) { + return description(); + }; + // Type for slot # index unsigned char type(unsigned char index) { _error = SENSOR_ERROR_OK; diff --git a/code/espurna/sensors/HLW8012Sensor.h b/code/espurna/sensors/HLW8012Sensor.h index e20cc83b..0ff36183 100644 --- a/code/espurna/sensors/HLW8012Sensor.h +++ b/code/espurna/sensors/HLW8012Sensor.h @@ -162,6 +162,11 @@ class HLW8012Sensor : public BaseSensor { return String(buffer); } + // Descriptive name of the slot # index + String slot(unsigned char index) { + return description(); + }; + // Type for slot # index unsigned char type(unsigned char index) { _error = SENSOR_ERROR_OK; diff --git a/code/espurna/sensors/I2CSensor.h b/code/espurna/sensors/I2CSensor.h index 1d6cebc6..73e4522d 100644 --- a/code/espurna/sensors/I2CSensor.h +++ b/code/espurna/sensors/I2CSensor.h @@ -23,6 +23,11 @@ class I2CSensor : public BaseSensor { return _address; } + // Descriptive name of the slot # index + String slot(unsigned char index) { + return description(); + }; + protected: // Specific for I2C sensors diff --git a/code/espurna/sensors/MHZ19Sensor.h b/code/espurna/sensors/MHZ19Sensor.h index fc08fb9b..41c550a4 100644 --- a/code/espurna/sensors/MHZ19Sensor.h +++ b/code/espurna/sensors/MHZ19Sensor.h @@ -89,6 +89,11 @@ class MHZ19Sensor : public BaseSensor { return String(buffer); } + // Descriptive name of the slot # index + String slot(unsigned char index) { + return description(); + }; + // Type for slot # index unsigned char type(unsigned char index) { _error = SENSOR_ERROR_OK; diff --git a/code/espurna/sensors/SI7021Sensor.h b/code/espurna/sensors/SI7021Sensor.h index 04d75775..b69f60a0 100644 --- a/code/espurna/sensors/SI7021Sensor.h +++ b/code/espurna/sensors/SI7021Sensor.h @@ -85,6 +85,11 @@ class SI7021Sensor : public I2CSensor { return String(buffer); } + // Descriptive name of the slot # index + String slot(unsigned char index) { + return description(); + }; + // Type for slot # index unsigned char type(unsigned char index) { if (index < _count) { diff --git a/code/espurna/sensors/V9261FSensor.h b/code/espurna/sensors/V9261FSensor.h index b38a36b5..874c9e66 100644 --- a/code/espurna/sensors/V9261FSensor.h +++ b/code/espurna/sensors/V9261FSensor.h @@ -77,6 +77,11 @@ class V9261FSensor : public BaseSensor { return String(buffer); } + // Descriptive name of the slot # index + String slot(unsigned char index) { + return description(); + }; + // Loop-like method, call it in your main loop void tick() { _read();