mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-11-02 19:02:00 +00:00
fix(bot): !temp and {temp} fall back to the chip's temperature
Same gap as the screens had: the bot reply, a typed message's {temp} and
the placeholder lists read only the sensors, so a board without one (the
L1) answered !temp with n/a while its telemetry carried a temperature.
The fallback moves to LocalSensors.h, shared by the screens, expandMsg()
and sensorPlaceholders(); the latter now takes the chip's temperature.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
// This device's own readings, as the screens, the bot and message placeholders
|
||||
// read them.
|
||||
|
||||
#include <math.h>
|
||||
#include <helpers/SensorManager.h>
|
||||
#include <helpers/sensors/LPPDataHelpers.h>
|
||||
|
||||
// The sensors' readings, plus the chip's own temperature (NaN where a board has
|
||||
// none) when no sensor reads one: the telemetry reply sends it too, so a board
|
||||
// without a temperature sensor shows on screen and in {temp} what the app shows.
|
||||
inline void queryLocalSensors(SensorManager& sm, float mcu_temp, CayenneLPP& lpp) {
|
||||
sm.querySensors(0xFF, lpp);
|
||||
if (isnan(mcu_temp)) return;
|
||||
LPPReader r(lpp.getBuffer(), lpp.getSize());
|
||||
uint8_t ch, type;
|
||||
while (r.readHeader(ch, type)) {
|
||||
if (type == LPP_TEMPERATURE) return;
|
||||
r.skipData(type);
|
||||
}
|
||||
lpp.addTemperature(TELEM_CHANNEL_SELF, mcu_temp);
|
||||
}
|
||||
Reference in New Issue
Block a user