From 765a6fcc627c6a53d3b770201ade1a6abc06f5ee Mon Sep 17 00:00:00 2001 From: Charles Crossan Date: Sun, 21 Feb 2021 11:39:45 -0500 Subject: [PATCH] Display received measurements in logs and on screen --- .../esp32/EnvironmentalMeasurementPlugin.cpp | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/plugins/esp32/EnvironmentalMeasurementPlugin.cpp b/src/plugins/esp32/EnvironmentalMeasurementPlugin.cpp index 0497a2b67..d141bf8d8 100644 --- a/src/plugins/esp32/EnvironmentalMeasurementPlugin.cpp +++ b/src/plugins/esp32/EnvironmentalMeasurementPlugin.cpp @@ -20,7 +20,8 @@ uint32_t sensor_read_error_count = 0; #define DHT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS 1000 #define SENSOR_READ_ERROR_COUNT_THRESHOLD 5 #define SENSOR_READ_MULTIPLIER 3 - +#define FAILED_STATE_SENSOR_READ_MULTIPLIER 10 +#define DISPLAY_RECEIVEID_MEASUREMENTS_ON_SCREEN true DHT dht(DHT_11_GPIO_PIN,DHT11); @@ -66,7 +67,27 @@ int32_t EnvironmentalMeasurementPlugin::runOnce() { bool EnvironmentalMeasurementPluginRadio::handleReceivedProtobuf(const MeshPacket &mp, const EnvironmentalMeasurement &p) { - // This plugin doesn't really do anything with the messages it receives. + bool wasBroadcast = mp.to == NODENUM_BROADCAST; + String sender; + + if (nodeDB.getNode(mp.from)){ + sender = nodeDB.getNode(mp.from)->user.short_name; + } + else { + sender = "UNK"; + } + // Show new nodes on LCD screen + if (DISPLAY_RECEIVEID_MEASUREMENTS_ON_SCREEN && wasBroadcast) { + String lcd = String("Env Measured: ") + sender + "\n" + + "T: " + p.temperature + "\n" + + "H: " + p.relative_humidity + "\n"; + screen->print(lcd.c_str()); + } + DEBUG_MSG("-----------------------------------------\n"); + + DEBUG_MSG("EnvironmentalMeasurement: Received data from %s\n",sender); + DEBUG_MSG("EnvironmentalMeasurement->relative_humidity: %f\n", p.relative_humidity); + DEBUG_MSG("EnvironmentalMeasurement->temperature: %f\n", p.temperature); return false; // Let others look at this message also if they want }