mirror of
https://github.com/meshtastic/firmware.git
synced 2025-04-26 09:59:01 +00:00
update enviro module to not create copies
This commit is contained in:
parent
a13adfb598
commit
f6c6c2912f
@ -193,6 +193,10 @@ bool EnvironmentTelemetryModule::handleReceivedProtobuf(const meshtastic_MeshPac
|
|||||||
t->variant.environment_metrics.gas_resistance, t->variant.environment_metrics.relative_humidity,
|
t->variant.environment_metrics.gas_resistance, t->variant.environment_metrics.relative_humidity,
|
||||||
t->variant.environment_metrics.temperature, t->variant.environment_metrics.voltage);
|
t->variant.environment_metrics.temperature, t->variant.environment_metrics.voltage);
|
||||||
|
|
||||||
|
// release previous packet before occupying a new spot
|
||||||
|
if (lastMeasurementPacket != nullptr)
|
||||||
|
packetPool.release(lastMeasurementPacket);
|
||||||
|
|
||||||
lastMeasurementPacket = packetPool.allocCopy(mp);
|
lastMeasurementPacket = packetPool.allocCopy(mp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -244,6 +248,10 @@ bool EnvironmentTelemetryModule::sendTelemetry(NodeNum dest, bool phoneOnly)
|
|||||||
p->decoded.want_response = false;
|
p->decoded.want_response = false;
|
||||||
p->priority = meshtastic_MeshPacket_Priority_MIN;
|
p->priority = meshtastic_MeshPacket_Priority_MIN;
|
||||||
|
|
||||||
|
// release previous packet before occupying a new spot
|
||||||
|
if (lastMeasurementPacket != nullptr)
|
||||||
|
packetPool.release(lastMeasurementPacket);
|
||||||
|
|
||||||
lastMeasurementPacket = packetPool.allocCopy(*p);
|
lastMeasurementPacket = packetPool.allocCopy(*p);
|
||||||
if (phoneOnly) {
|
if (phoneOnly) {
|
||||||
LOG_INFO("Sending packet to phone\n");
|
LOG_INFO("Sending packet to phone\n");
|
||||||
|
@ -36,7 +36,7 @@ class EnvironmentTelemetryModule : private concurrency::OSThread, public Protobu
|
|||||||
private:
|
private:
|
||||||
float CelsiusToFahrenheit(float c);
|
float CelsiusToFahrenheit(float c);
|
||||||
bool firstTime = 1;
|
bool firstTime = 1;
|
||||||
const meshtastic_MeshPacket *lastMeasurementPacket;
|
meshtastic_MeshPacket *lastMeasurementPacket;
|
||||||
uint32_t sendToPhoneIntervalMs = SECONDS_IN_MINUTE * 1000; // Send to phone every minute
|
uint32_t sendToPhoneIntervalMs = SECONDS_IN_MINUTE * 1000; // Send to phone every minute
|
||||||
uint32_t lastSentToMesh = 0;
|
uint32_t lastSentToMesh = 0;
|
||||||
uint32_t sensor_read_error_count = 0;
|
uint32_t sensor_read_error_count = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user