Skip to content

Conversation

@noahredon
Copy link

@noahredon noahredon commented Oct 22, 2025

This PR introduces a new module, mavproxy_router, that enables selective routing of MAVLink messages between MAVProxy links.
It allows fine-grained control over which messages are forwarded, based on target address, system/component IDs, and message names.

Motivation

In MAVProxy, messages received by the master link are forwarded to all outputs by default, while messages from outputs are only sent to masters. This behavior can be too broad for complex routing scenarios, motivating the need for selective routing rules.
This module allows defining custom routing rules, reducing traffic and improving isolation between nodes.

Features

Hierarchical rule-based routing

Filters can be applied by:

  • Address (link name)
  • System ID (sysid)
  • Component ID (compid)
  • Message name

Rules can be combined to precisely control message flow.

Runtime configuration

Comprehensive CLI interface to manage routing rules:

  • router help
  • router create / router delete / router clear
  • router dir / router load / router save
  • router show / router check
  • router add / router remove / router set
  • router start / router stop

Rules can be modified dynamically while MAVProxy is running.

Persistent configuration

Routing configurations can be stored and reloaded from JSON files (see router_config/example.json).

Integration with MAVProxy core

Hooked into:

  • Master callback (mavproxy_link.py, function master_callback)
  • Slave process (mavproxy.py, function process_mavlink)

Error handling and validation

  • Invalid rules or malformed JSON trigger explicit error messages (via STATUSTEXT or CLI feedback).
  • Prevents invalid routing loops or misconfigured filters.

Optional argument support

New CLI arguments to control router behavior from startup (e.g. specifying a config file or directory).

Example

Example configuration:

{
    "192.168.2.1:14550": {
        "1": {
            "191": "HEARTBEAT",
            "other": ["ATTITUDE", "GLOBAL_POSITION_INT"]
        },
        "other": "all/STATUSTEXT"
    },
    "other": {
        "other": null
    }
}

Implementation Details

  • New file: MAVProxy/modules/mavproxy_router.py
  • Modified files:
    • .gitignore (temporary adjustment reverted)
    • MAVProxy/modules/mavproxy_link.py: integration into master callback
    • MAVProxy/mavproxy.py: integration into slave process and CLI argument parsing

Testing

  • Tested locally with multiple MAVLink endpoints (UDP and serial).
  • Verified routing behavior and rule hierarchy.
  • Confirmed no interference with default MAVProxy forwarding when the module is disabled.

@noahredon
Copy link
Author

Hi all,
I had previously opened another PR for this module but decided to close it to reorganize the commits and improve the description.
Thanks for your time and review!

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.

1 participant