Skip to content

fix(companion): gate CMD_SEND_CHANNEL_DATA payload on MAX_GROUP_DATA_LENGTH - #3386

Open
tekk wants to merge 1 commit into
meshcore-dev:devfrom
tekk:fix/channel-data-payload-bound
Open

fix(companion): gate CMD_SEND_CHANNEL_DATA payload on MAX_GROUP_DATA_LENGTH#3386
tekk wants to merge 1 commit into
meshcore-dev:devfrom
tekk:fix/channel-data-payload-bound

Conversation

@tekk

@tekk tekk commented Sep 9, 2026

Copy link
Copy Markdown

Summary

Fixes #3345.

CMD_SEND_CHANNEL_DATA (0x3E) in examples/companion_radio/MyMesh.cpp gated outbound payloads against MAX_CHANNEL_DATA_LENGTH (MAX_FRAME_SIZE - 9 = 167 bytes) instead of the radio-side bound MAX_GROUP_DATA_LENGTH (184 - 16 - 3 = 165 bytes).

Payloads of 166 or 167 bytes passed the handler check, but were rejected by BaseChatMesh::sendGroupData (data_len > MAX_GROUP_DATA_LENGTH). Because sendGroupData returns false, MyMesh.cpp returned ERR_CODE_TABLE_FULL (3) instead of ERR_CODE_ILLEGAL_ARG (6).

Since ERR_CODE_TABLE_FULL indicates a transient queue-full condition, conforming clients would retry indefinitely on a payload that can never succeed.

Changes

  • In examples/companion_radio/MyMesh.cpp, check payload_len > MAX_GROUP_DATA_LENGTH instead of MAX_CHANNEL_DATA_LENGTH and update the accompanying debug log.
  • MAX_CHANNEL_DATA_LENGTH is preserved in onChannelDataRecv, where it correctly bounds inbound host frames.

Verification

  • pio test -e native (PASSED 46/46)
  • pio test -e native_kiss_modem (PASSED 8/8)
  • pio run -e Heltec_v3_companion_radio_ble (SUCCESS)

…LENGTH

Payloads of 166 or 167 bytes previously passed the frame-sized bound
(MAX_CHANNEL_DATA_LENGTH = 167) but were rejected by sendGroupData
against MAX_GROUP_DATA_LENGTH (165), causing ERR_CODE_TABLE_FULL (retry
later) to be returned instead of ERR_CODE_ILLEGAL_ARG.

Fixes meshcore-dev#3345
Copilot AI lite review requested due to automatic review settings September 9, 2026 20:10

Copilot AI 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.

🟢 Approval recommended

The updated bound matches the radio-side constraint and resolves the incorrect error mapping without introducing new behavioral or build issues in the touched code path.

Pull request overview

This PR fixes an outbound payload-length validation bug in the companion radio protocol handler so CMD_SEND_CHANNEL_DATA rejects oversized payloads with a permanent error (ERR_CODE_ILLEGAL_ARG) instead of misreporting a transient condition (ERR_CODE_TABLE_FULL) that would cause compliant clients to retry indefinitely.

Changes:

  • Gate CMD_SEND_CHANNEL_DATA outbound payloads against the radio payload limit (MAX_GROUP_DATA_LENGTH) rather than the host-frame limit (MAX_CHANNEL_DATA_LENGTH).
  • Update the associated debug log to report the correct bound.
  • Leave MAX_CHANNEL_DATA_LENGTH in place for inbound onChannelDataRecv, where it correctly enforces the host frame budget.
File summaries
File Description
examples/companion_radio/MyMesh.cpp Fixes outbound payload-length validation for CMD_SEND_CHANNEL_DATA to align with the radio-side maximum payload size.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

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