Skip to content

feat(gateway): sync internal-DRAM fields into the shared status schema - #4495

Merged
springfall2008 merged 3 commits into
mainfrom
feat/gateway-heap-telemetry
Aug 13, 2026
Merged

springfall2008 merged 3 commits into
mainfrom
feat/gateway-heap-telemetry

Conversation

@mgazza

@mgazza mgazza commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

Keeps apps/predbat/gateway_status.proto in sync with the gateway firmware's copy — the two must match for wire compatibility.

Adds three fields to GatewayStatus:

uint32 heap_internal_free     = 15;
uint32 heap_internal_largest  = 16;
uint32 heap_internal_min_free = 17;

Why: free_heap_bytes (9) is ESP.getFreeHeap(), which can include PSRAM and so cannot predict the allocations that actually fail on the device — WiFi/lwIP/TLS/AsyncTCP buffers, task stacks and lwIP PCBs all need internal DRAM specifically.

A hub silently lost its port-80 listener, and with it the OCPP endpoint its EV charger connects to, for two days. Field 9 looked healthy throughout; largest-contiguous-block was the number that showed the squeeze (19,851 B free but only 17,396 B largest).

Compatibility: fields are appended, so both directions work. Verified by round-tripping across the old and new generated bindings in separate processes:

  • new firmware → old PredBat: parses cleanly, unknown fields ignored
  • old firmware → new PredBat: parses, heap fields default to 0

That matters because gateway firmware and PredBat version independently.

No entities are published from these — the cloud consumes the status message directly. Exposing them in Home Assistant would add entities to every install and is a separate decision.

Regenerated with protoc 34.1. pytest apps/predbat/tests/test_gateway.py — 263 pass.

🤖 Generated with Claude Code

mgazza and others added 3 commits August 12, 2026 10:23
Mirrors the three fields added to the gateway firmware's copy of
gateway_status.proto. The two copies must stay in sync for wire compatibility.

  heap_internal_free     (15)
  heap_internal_largest  (16)
  heap_internal_min_free (17)

Why they exist: free_heap_bytes (9) is ESP.getFreeHeap(), which can include
PSRAM and so cannot predict the allocations that actually fail on the device —
WiFi/lwIP/TLS/AsyncTCP buffers, task stacks and lwIP PCBs all need internal DRAM
specifically. A hub silently lost its :80 listener (and with it the OCPP endpoint
its EV charger connects to) for two days; field 9 looked fine throughout, while
largest-contiguous-block was the number that showed the squeeze.

Fields are appended, so both directions stay compatible — verified by round-trip
across the old and new generated bindings:
  new firmware -> old PredBat: parses cleanly, unknown fields ignored
  old firmware -> new PredBat: parses, heap fields default to 0
That matters because firmware and PredBat version independently.

No entities are published from these yet; the cloud consumes the status message
directly. Exposing them in Home Assistant would add entities to every install
and is a separate decision.

Regenerated with protoc 34.1, then reformatted by the repo's black hook.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…nal DRAM

Comment-only, mirroring the firmware copy. MALLOC_CAP_INTERNAL alone can include
regions that are not byte-addressable; lwIP objects, task stacks and most library
allocations need internal 8-bit-capable memory specifically, so the firmware
queries MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT for these fields. Querying the
wider set would overstate usable headroom — several KB can remain in an internal
32-bit/IRAM region while 8-bit DRAM is exhausted and allocations still fail.

No wire or field-number change.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@springfall2008
springfall2008 merged commit 85975ef into main Aug 13, 2026
2 checks passed
@springfall2008
springfall2008 deleted the feat/gateway-heap-telemetry branch August 13, 2026 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants