Skip to content

Add support for dynamic route metric switching in bt-tether plugin#407

Open
PapiJalopy wants to merge 4 commits intojayofelony:noaifrom
PapiJalopy:PapiJalopy-BT-metric-switching
Open

Add support for dynamic route metric switching in bt-tether plugin#407
PapiJalopy wants to merge 4 commits intojayofelony:noaifrom
PapiJalopy:PapiJalopy-BT-metric-switching

Conversation

@PapiJalopy
Copy link

@PapiJalopy PapiJalopy commented May 18, 2025

Description

Adds a new option to the bt-tether.py plugin that allows users to dynamically set the route metric for the Bluetooth connection using a prefer-bluetooth option in config.toml.

Added a prefer-bluetooth config option (defaults to false)

If prefer-bluetooth = true, Bluetooth is given a lower route metric to take priority over USB. Maintains the original behavior if the setting is not enabled. This allows choosing the preferred tethering interface without needing to manually edit metric priorities.

Allows users to SSH over USB while tethered via Bluetooth.

Added prefer-bluetooth selection to wizard

Fixed [main.plugins.bt-tether] formatting in cli.py, removed extra new line (\n) between the [main.plugins.bt-tether] header and its config options. TOML will think that it is the end of the section, so anything after it without a new header is treated as top-level.

Tested and working with both Bluetooth and USB interfaces active, system correctly prioritizes the selected route.

Motivation and Context

This change gives users more control in how their Pwnagotchi connects to the internet. Before this change, Bluetooth tethering always received a higher route metric, making USB the preferred interface when tethered by both Bluetooth and USB. Now a config.toml option lets you switch priorities without manual editing.

Addresses #405

  • I have raised an issue to propose this change (required)

How Has This Been Tested?

  • Enabled and disabled prefer-bluetooth in config.toml

  • Verified that the the correct metric is applied to the Bluetooth interface with "ip route; cat /etc/resolv.conf; ping -c 2 8.8.8.8; ping -c 2 google.com"

  • Made sure default behavior is not affected when the option is not enabled.

  • Double checked routing, DNS resolution, and SSH access over USB while Bluetooth tether is being used.

  • Tested cli.py script (modified the old cli.py with old TOML parser and format so I could test on my device, but changes are basically the same other than the key name format)

  • Tested on Raspberry Pi Zero 2W running latest release 2.9.5.3

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I've read the CONTRIBUTION guide
  • I have signed-off my commits with git commit -s

Adds a new option to the bt-tether.py plugin that allows users to dynamically set the route metric for the Bluetooth connection using a prefer-bluetooth option in config.toml.

Added a prefer-bluetooth config option (defaults to false)

If prefer-bluetooth = true, Bluetooth is given a lower route metric to take priority over USB.

Maintains the original behavior if the setting is not enabled

This allows choosing the preferred tethering interface without needing to manually edit metric priorities.

Allows users to SSH over USB while tethered via Bluetooth.

Tested and working with both Bluetooth and USB interfaces active, system correctly prioritizes the selected route.

Signed-off-by: Jalopy <169272449+PapiJalopy@users.noreply.github.com>
Add new config option for bt-tether 

Signed-off-by: Jalopy <169272449+PapiJalopy@users.noreply.github.com>
- Add prefer-bluetooth option selection in wizard

- Corrected formatting of [main.plugins.bt-tether] block in config.toml by removing extra "/n". TOML will think that it is the end of the section, so anything after it without a new header is treated as top-level.

Signed-off-by: Jalopy <169272449+PapiJalopy@users.noreply.github.com>
version and typo

Signed-off-by: Jalopy <169272449+PapiJalopy@users.noreply.github.com>
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