Skip to content

Add transport key to packet and utilities for mesh packet calcs#16

Merged
rightup merged 4 commits intodevfrom
feat/trans-code
Nov 22, 2025
Merged

Add transport key to packet and utilities for mesh packet calcs#16
rightup merged 4 commits intodevfrom
feat/trans-code

Conversation

@rightup
Copy link
Owner

@rightup rightup commented Nov 22, 2025

Add transport codes to the packet class and new functions to work out transport code with packet data.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds transport key functionality to the mesh packet system, enabling packet authentication using region-based transport codes. The implementation matches the C++ MeshCore firmware protocol, ensuring cross-platform compatibility.

Key Changes:

  • Introduced transport key generation and transport code calculation utilities
  • Extended packet structure to support optional 4-byte transport code fields for TRANSPORT_FLOOD and TRANSPORT_DIRECT route types
  • Added helper methods to identify packet routing characteristics

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.

File Description
src/pymc_core/protocol/transport_keys.py New module providing get_auto_key_for() to generate 128-bit keys from region names and calc_transport_code() to compute HMAC-based transport codes for packet authentication
src/pymc_core/protocol/packet.py Extended Packet class with transport_codes attribute, updated serialization/deserialization to conditionally include 4-byte transport codes, added routing helper methods (has_transport_codes(), is_route_flood(), is_route_direct()), and updated documentation to reflect transport code support

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

return key_hash[:16] # First 16 bytes (128 bits)


def calc_transport_code(key: bytes, packet) -> int:
Copy link

Copilot AI Nov 22, 2025

Choose a reason for hiding this comment

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

The packet parameter is missing a type annotation. Based on usage in the function body (calling packet.get_payload_type() and packet.get_payload()), it should be typed as Packet from the .packet module. This would improve type safety and IDE support.

Suggestion: Add type annotation like packet: "Packet" or import Packet and use packet: Packet.

Copilot uses AI. Check for mistakes.
rightup and others added 3 commits November 22, 2025 22:26
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI commented Nov 22, 2025

@rightup I've opened a new pull request, #17, to work on those changes. Once the pull request is ready, I'll request review from you.

@rightup rightup merged commit dde62c6 into dev Nov 22, 2025
@rightup rightup deleted the feat/trans-code branch November 22, 2025 22:29
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.

3 participants