Skip to content

Conversation

@mixa3607
Copy link
Contributor

@mixa3607 mixa3607 commented Dec 11, 2025

Traceroute command:

  • fix id generation (was always FF)
  • add backward and snr info
  • fix response matching

dest arg parser:

  • allow int and hex formats
image

@CLAassistant
Copy link

CLAassistant commented Dec 11, 2025

CLA assistant check
All committers have signed the CLA.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

{
var p1 = (uint)Random.Shared.Next();
var p2 = (uint)Random.Shared.Next();
var id = unchecked(p1 + p2);
Copy link
Contributor

Choose a reason for hiding this comment

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

Obviously outside of the scope of this PR, but I've thought about consolidating the ID generation into a base factory or helper of some variety.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

move it to PacketUtils.GenerateRandomPacketId. In this MR, I did not change the code of other components (e.g. PositionMessageFactory)

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 fixes critical issues in the traceroute command implementation and enhances the destination argument parser to accept multiple input formats. The traceroute fixes include correcting ID generation (previously producing only 0xFF values), improving response matching logic, and adding backward route and SNR information display. The argument parser improvements enable users to specify node addresses in hexadecimal (with ! or 0x prefix) or decimal integer formats.

Key Changes

  • Fixed traceroute packet ID generation and added Priority.Reliable flag
  • Enhanced response matching to verify RequestId and Portnum for proper traceroute responses
  • Added backward route and SNR display with proper role inversion for received traceroute data

Reviewed changes

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

Show a summary per file
File Description
Meshtastic/Data/MessageFactories/TraceRouteMessageFactory.cs Modified ID generation from problematic formula to sum of two random values; added Priority field
Meshtastic.Cli/Utilities/ArgumentParsers.cs New parser for node IDs supporting hex (! and 0x prefix) and decimal formats
Meshtastic.Test/Utilities/ArgumentParsersTests.cs Test suite for new ArgumentParsers with various format test cases
Meshtastic.Cli/Program.cs Integrated new NodeIdParser for --dest option
Meshtastic.Cli/Display/ProtobufPrinter.cs Refactored route display to show both toward/backward routes with SNR info
Meshtastic.Cli/CommandHandlers/TraceRouteCommandHandler.cs Improved response matching using RequestId and Portnum validation

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


var nodeStr = result.Tokens[0].Value.ToLowerInvariant();

var hexMatch = Regex.Match(nodeStr, "^(!|0x)(?<num>([a-f|0-9][a-f|0-9]){1,4})$");
Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

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

The regex pattern requires hex strings to have an even number of characters (pairs) with the pattern ([a-f|0-9][a-f|0-9]){1,4}, which means it only accepts 2, 4, 6, or 8 hex digits. This rejects valid hex values with odd-length strings like "0xabc" or "!f". Consider changing the pattern to [a-f0-9]{1,8} to accept any hex string from 1 to 8 characters, which would properly parse all valid uint32 hex values.

Suggested change
var hexMatch = Regex.Match(nodeStr, "^(!|0x)(?<num>([a-f|0-9][a-f|0-9]){1,4})$");
var hexMatch = Regex.Match(nodeStr, "^(!|0x)(?<num>[a-f0-9]{1,8})$");

Copilot uses AI. Check for mistakes.

var nodeStr = result.Tokens[0].Value.ToLowerInvariant();

var hexMatch = Regex.Match(nodeStr, "^(!|0x)(?<num>([a-f|0-9][a-f|0-9]){1,4})$");
Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

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

The regex pattern uses pipe characters inside a character class incorrectly. The pattern [a-f|0-9] will match 'a' through 'f', the literal pipe character '|', or '0' through '9'. This should be [a-f0-9] or [0-9a-f] instead to match hexadecimal digits without including the pipe character as a valid match.

Suggested change
var hexMatch = Regex.Match(nodeStr, "^(!|0x)(?<num>([a-f|0-9][a-f|0-9]){1,4})$");
var hexMatch = Regex.Match(nodeStr, "^(!|0x)(?<num>([a-f0-9][a-f0-9]){1,4})$");

Copilot uses AI. Check for mistakes.
@thebentern thebentern merged commit df9c494 into meshtastic:master Dec 11, 2025
4 checks passed
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