Skip to content

Add compact chunked client API payload - #980

Open
kernel-oops wants to merge 2 commits into
meshtastic:masterfrom
kernel-oops:garmin-ble-chunked-phoneapi
Open

Add compact chunked client API payload#980
kernel-oops wants to merge 2 commits into
meshtastic:masterfrom
kernel-oops:garmin-ble-chunked-phoneapi

Conversation

@kernel-oops

@kernel-oops kernel-oops commented Jul 7, 2026

Copy link
Copy Markdown

Summary

Add a compact, ordered ClientApiChunkedPayload wrapper for Meshtastic client API transports that must carry serialized ToRadio and FromRadio messages over small BLE characteristic reads and writes.

The immediate use case is Garmin Connect IQ, where public BLE writes are limited to 20 bytes and ATT long reads are unavailable.

Related firmware implementation: meshtastic/firmware#10928

What changed

  • Adds ClientApiChunkedPayload.payload_size = 1 as uint32, with nanopb int_size:16.
  • Adds ClientApiChunkedPayload.payload_chunk = 2 as bytes, with nanopb max_size:228.
  • Adds ToRadio.chunked_payload = 8.
  • Adds FromRadio.chunked_payload = 20.

Compatibility

This uses a new message type rather than repurposing the existing ChunkedPayload schema. The existing four-field ChunkedPayload (payload_id, chunk_count, chunk_index, and payload_chunk) and ChunkedPayloadResponse remain unchanged for their current users.

Existing clients ignore the new ToRadio and FromRadio fields. Firmware emits chunked responses only after a client has successfully opted in by completing a chunked request.

Transport behavior

The first chunk carries payload_size and payload_chunk. Continuation chunks carry only payload_chunk. The transport assumes ordered, reliable delivery on one connection, avoiding IDs, counts, and indices in every 20-byte packet.

With the corresponding firmware implementation, a 20-byte transport frame carries 13 bytes in the first ToRadio chunk and 16 thereafter, or 12 bytes in the first FromRadio chunk and 15 thereafter.

Validation

  • Regenerated firmware nanopb sources reproducibly.
  • Compared the firmware's compact outbound encoder byte-for-byte with nanopb at payload totals 21, 127, 128, 511, and 512 bytes.
  • Verified every encoded wrapper remains at most 20 bytes and reconstructs the original payload.
  • Verified the existing ChunkedPayload serialization vector remains 080110021803220104.
  • Built the corresponding firmware for nrf52_promicro_diy_tcxo and heltec-v4, then completed a live Heltec V4 to Garmin D2 Mach 2 BLE round trip.

@CLAassistant

CLAassistant commented Jul 7, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@kernel-oops, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 29 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 65e46709-d018-4b04-ab87-f9e6263b21e1

📥 Commits

Reviewing files that changed from the base of the PR and between fff560d and 9597a41.

📒 Files selected for processing (2)
  • meshtastic/mesh.options
  • meshtastic/mesh.proto
📝 Walkthrough

Walkthrough

This PR introduces ClientApiChunkedPayload for ordered client API payload chunks, wires it into the FromRadio and ToRadio protobuf oneofs, and applies nanopb sizing options to its payload fields. The existing ChunkedPayload message remains unchanged.

Changes

Client API chunked payload transport

Layer / File(s) Summary
Chunked payload contract and sizing
meshtastic/mesh.proto, meshtastic/mesh.options
Adds ClientApiChunkedPayload with payload_size and payload_chunk; payload_size is sent only on the first chunk, and nanopb limits are applied to the new fields.
FromRadio/ToRadio stream wiring
meshtastic/mesh.proto
Adds chunked_payload fields to FromRadio.payload_variant as field 20 and ToRadio.payload_variant as field 8, with opt-in and PhoneAPI reassembly documentation.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: thebentern

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly matches the main change: adding a compact client API chunked payload transport.
Description check ✅ Passed The description covers the change, compatibility, transport behavior, and validation, though it omits the template's checklist and issue placeholder.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@kernel-oops

Copy link
Copy Markdown
Author

Compatibility note for reviewers: this intentionally reuses and reshapes the existing ChunkedPayload message rather than adding a second request/response pair. My understanding is that ChunkedPayload was not used by firmware/client API runtime paths yet, so changing its field layout should be acceptable, but that is the main compatibility point to confirm in review.

@kernel-oops
kernel-oops marked this pull request as ready for review July 7, 2026 17:37
@kernel-oops
kernel-oops force-pushed the garmin-ble-chunked-phoneapi branch from 90d0af5 to fff560d Compare July 23, 2026 22:57
@kernel-oops
kernel-oops force-pushed the garmin-ble-chunked-phoneapi branch from fff560d to 8bd7dda Compare July 23, 2026 23:00

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@meshtastic/mesh.proto`:
- Around line 2997-3001: Update ClientApiChunkedPayload.payload_size to an
optional uint32 field so presence distinguishes first chunks from continuation
chunks, including empty first payloads. Preserve the existing field number and
documentation.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 62d6cfc0-f153-45af-afd3-e34ec1fe35f2

📥 Commits

Reviewing files that changed from the base of the PR and between 90d0af5 and fff560d.

📒 Files selected for processing (2)
  • meshtastic/mesh.options
  • meshtastic/mesh.proto
🚧 Files skipped from review as they are similar to previous changes (1)
  • meshtastic/mesh.options

Comment thread meshtastic/mesh.proto
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