Skip to content

fix(tak): gate V2 packets on known firmware - #6600

Merged
jamesarich merged 2 commits into
meshtastic:mainfrom
RCGV1:codex/fix/tak-v2-capability
Aug 11, 2026
Merged

fix(tak): gate V2 packets on known firmware#6600
jamesarich merged 2 commits into
meshtastic:mainfrom
RCGV1:codex/fix/tak-v2-capability

Conversation

@RCGV1

@RCGV1 RCGV1 commented Aug 9, 2026

Copy link
Copy Markdown
Member

Summary

  • use the legacy TAK packet format until the connected radio reports a V2-capable firmware version
  • add strict protocol-gating coverage for unknown, legacy, and V2-capable firmware

Testing

  • :core:takserver:spotlessCheck
  • :core:takserver:jvmTest --tests org.meshtastic.core.takserver.TAKMeshIntegrationTest

Summary by CodeRabbit

  • Bug Fixes
    • Improved TAK protocol selection when the device firmware version is unavailable.
    • Devices with unknown firmware now use the legacy V1 connection instead of incorrectly defaulting to V2.
    • Updated firmware compatibility handling to ensure V1 and V2 devices connect through the appropriate ports.

@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 2ef96b7c-b5f8-4f98-a952-5b7f1693913e

📥 Commits

Reviewing files that changed from the base of the PR and between a0e96b9 and 6eec0a6.

📒 Files selected for processing (1)
  • core/takserver/src/commonTest/kotlin/org/meshtastic/core/takserver/TAKMeshIntegrationTest.kt

📝 Walkthrough

Walkthrough

useTakV2() now selects the legacy V1 protocol when firmware is unknown. Tests update MyNodeInfo consistently and verify V1 and V2 ATAK ports for unknown, legacy, and V2-capable firmware.

Changes

TAK protocol selection

Layer / File(s) Summary
Firmware-gated ATAK protocol selection
core/takserver/src/commonMain/.../TAKMeshIntegration.kt, core/takserver/src/commonTest/.../TAKMeshIntegrationTest.kt
Unknown firmware now selects the V1 ATAK port. V2-capable firmware selects the V2 port. Tests require one outbound packet and validate the selected port. FakeNodeRepository keeps MyNodeInfo populated while updating firmware values.

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

Possibly related PRs

Suggested reviewers: jamesarich, jeremiah-k, thebentern

🚥 Pre-merge checks | ✅ 6
✅ Passed checks (6 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: V2 packets now require known firmware capability.
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.
Sibling Call Sites And Presence Semantics ✅ Passed The change is test-only firmware presence modeling; TAK send and start logging treat null firmware as V1, other myNodeInfo accesses remain nullable-safe, and no physical metric defaults were added.
Tests Prove The Path, Not The End State ✅ Passed Changed gating tests assert the send side effect and exact V1/V2 port; unknown firmware uses a populated fake with null version, and no test relies on collection size or Unconfined emission order.

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
core/takserver/src/jvmAndroidMain/kotlin/org/meshtastic/core/takserver/TAKServerJvm.kt (1)

166-185: 🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift

Prevent connection admission after stop().

stop() can clear connections while this coroutine is in authenticateTlsClient(). The coroutine can then add and start a TAKClientConnection after shutdown completes.

Track pending authentication sockets or jobs. Serialize the running-state check and connection registration with shutdown. Close a socket when shutdown has started.

🤖 Prompt for 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.

In
`@core/takserver/src/jvmAndroidMain/kotlin/org/meshtastic/core/takserver/TAKServerJvm.kt`
around lines 166 - 185, Update the connection-launch flow around
authenticateTlsClient and the connectionsLock registration to track pending
authentication jobs or sockets and serialize admission with stop(). Recheck the
running state while holding the same synchronization used by shutdown before
inserting or starting TAKClientConnection; if shutdown has begun, close
clientSocket and do not register it. Ensure stop() marks shutdown before
clearing active connections and also closes or cancels pending authentication
work.
🤖 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
`@core/takserver/src/commonTest/kotlin/org/meshtastic/core/takserver/TAKMeshIntegrationTest.kt`:
- Line 435: Update the test setup around FakeNodeRepository in
TAKMeshIntegrationTest so it supplies a present MyNodeInfo whose firmwareVersion
is null, rather than passing null to the repository constructor. Preserve the
existing outbound packet assertions and ensure the test exercises the production
path for a present node with unknown firmware.

In
`@core/takserver/src/jvmTest/kotlin/org/meshtastic/core/takserver/TAKServerJvmInteropTest.kt`:
- Around line 115-117: Update the handshake test around client.startHandshake()
to wrap the call in assertFailsWith<SSLException>, reflecting the expected mTLS
failure; keep the subsequent timeout and server connection-count assertions
unchanged.

---

Outside diff comments:
In
`@core/takserver/src/jvmAndroidMain/kotlin/org/meshtastic/core/takserver/TAKServerJvm.kt`:
- Around line 166-185: Update the connection-launch flow around
authenticateTlsClient and the connectionsLock registration to track pending
authentication jobs or sockets and serialize admission with stop(). Recheck the
running state while holding the same synchronization used by shutdown before
inserting or starting TAKClientConnection; if shutdown has begun, close
clientSocket and do not register it. Ensure stop() marks shutdown before
clearing active connections and also closes or cancels pending authentication
work.
🪄 Autofix

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: 2e85e75e-55b3-4ee9-bad6-541b75a081f2

📥 Commits

Reviewing files that changed from the base of the PR and between a885127 and a0e96b9.

📒 Files selected for processing (4)
  • core/takserver/src/commonMain/kotlin/org/meshtastic/core/takserver/TAKMeshIntegration.kt
  • core/takserver/src/commonTest/kotlin/org/meshtastic/core/takserver/TAKMeshIntegrationTest.kt
  • core/takserver/src/jvmAndroidMain/kotlin/org/meshtastic/core/takserver/TAKServerJvm.kt
  • core/takserver/src/jvmTest/kotlin/org/meshtastic/core/takserver/TAKServerJvmInteropTest.kt

@RCGV1
RCGV1 force-pushed the codex/fix/tak-v2-capability branch from a0e96b9 to 6b8db4d Compare August 9, 2026 16:25
@RCGV1 RCGV1 changed the title fix(tak): gate V2 packets and verify TLS clients fix(tak): gate V2 packets on known firmware Aug 9, 2026
@github-actions github-actions Bot added the bugfix PR tag label Aug 9, 2026
@RCGV1

RCGV1 commented Aug 9, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@jamesarich
jamesarich added this pull request to the merge queue Aug 11, 2026
Merged via the queue into meshtastic:main with commit 5855736 Aug 11, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix PR tag

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants