mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-29 22:20:37 +00:00
Put guards in place around debug heap operations (#7955)
* Put guards in place around debug heap operations * Add macros to clean up code * Add pointer as well
This commit is contained in:
@@ -44,11 +44,10 @@ void NodeInfoModule::sendOurNodeInfo(NodeNum dest, bool wantReplies, uint8_t cha
|
||||
if (prevPacketId) // if we wrap around to zero, we'll simply fail to cancel in that rare case (no big deal)
|
||||
service->cancelSending(prevPacketId);
|
||||
shorterTimeout = _shorterTimeout;
|
||||
auto heapBefore = memGet.getFreeHeap();
|
||||
DEBUG_HEAP_BEFORE;
|
||||
meshtastic_MeshPacket *p = allocReply();
|
||||
auto heapAfter = memGet.getFreeHeap();
|
||||
DEBUG_HEAP_AFTER("NodeInfoModule::sendOurNodeInfo", p);
|
||||
|
||||
LOG_HEAP("Alloc in NodeInfoModule::sendOurNodeInfo pointer 0x%x, size: %u, free: %u", p, heapBefore - heapAfter, heapAfter);
|
||||
if (p) { // Check whether we didn't ignore it
|
||||
p->to = dest;
|
||||
p->decoded.want_response = (config.device.role != meshtastic_Config_DeviceConfig_Role_TRACKER &&
|
||||
|
||||
@@ -172,11 +172,9 @@ bool DeviceTelemetryModule::sendTelemetry(NodeNum dest, bool phoneOnly)
|
||||
telemetry.variant.device_metrics.battery_level, telemetry.variant.device_metrics.voltage,
|
||||
telemetry.variant.device_metrics.uptime_seconds);
|
||||
|
||||
auto heapBefore = memGet.getFreeHeap();
|
||||
DEBUG_HEAP_BEFORE;
|
||||
meshtastic_MeshPacket *p = allocDataProtobuf(telemetry);
|
||||
auto heapAfter = memGet.getFreeHeap();
|
||||
LOG_HEAP("Alloc in DeviceTelemetryModule::sendTelemetry() pointer 0x%x, size: %u, free: %u", p, heapBefore - heapAfter,
|
||||
heapAfter);
|
||||
DEBUG_HEAP_AFTER("DeviceTelemetryModule::sendTelemetry", p);
|
||||
|
||||
p->to = dest;
|
||||
p->decoded.want_response = false;
|
||||
|
||||
Reference in New Issue
Block a user