modules/router: add selective MAVLink routing module #1638
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
sysid)compid)Rules can be combined to precisely control message flow.
Runtime configuration
Comprehensive CLI interface to manage routing rules:
router helprouter create/router delete/router clearrouter dir/router load/router saverouter show/router checkrouter add/router remove/router setrouter start/router stopRules 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:
mavproxy_link.py, functionmaster_callback)mavproxy.py, functionprocess_mavlink)Error handling and validation
STATUSTEXTor CLI feedback).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
MAVProxy/modules/mavproxy_router.py.gitignore(temporary adjustment reverted)MAVProxy/modules/mavproxy_link.py: integration into master callbackMAVProxy/mavproxy.py: integration into slave process and CLI argument parsingTesting