Files
MeshCore-Solo/examples/companion_radio/LocalSensors.h
T
JakubandClaude Opus 5.5 24156769f0 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>
2026-10-23 22:55:19 +02:00

23 lines
817 B
C

#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);
}