Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion pwnagotchi/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def is_valid_hostname(hostname):
"[Y/N] ")
if pwn_bluetooth.lower() in ('y', 'yes'):
f.write("[main.plugins.bt-tether]\n"
"enabled = true\n\n")
"enabled = true\n")
pwn_bluetooth_phone_name = input("What name uses your phone, check settings?\n\n")
if pwn_bluetooth_phone_name != "":
f.write(f"phone-name = \"{pwn_bluetooth_phone_name}\"\n")
Expand All @@ -237,6 +237,13 @@ def is_valid_hostname(hostname):
"MAC: ")
if pwn_bluetooth_mac != "":
f.write(f"mac = \"{pwn_bluetooth_mac}\"\n")
# add prefer-bluetooth option -- Jalopy added this
pwn_bluetooth_prefer = input("Do you want to prefer Bluetooth tether over USB tether for networking?\n\n"
"This changes the routing priority. (Y/N): ")
if pwn_bluetooth_prefer.lower() in ("y", "yes"):
f.write("prefer-bluetooth = true\n")
else:
f.write("prefer-bluetooth = false\n")
# set up display settings
pwn_display_enabled = input("Do you want to enable a display?\n\n"
"[Y/N]: ")
Expand Down
1 change: 1 addition & 0 deletions pwnagotchi/defaults.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ mac = ""
phone = "" # android or ios
ip = "" # optional, default : 192.168.44.2 if android or 172.20.10.2 if ios
dns = "8.8.8.8 1.1.1.1" # optional, default (google): "8.8.8.8 1.1.1.1". Consider using anonymous DNS like OpenNic :-)
prefer-bluetooth = false # optional, set to "true" to prefer Bluetooth tethering, set to "false" to prefer USB tethering

[main.plugins.fix_services]
enabled = true
Expand Down
10 changes: 6 additions & 4 deletions pwnagotchi/plugins/default/bt-tether.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@


class BTTether(plugins.Plugin):
__author__ = "Jayofelony, modified my fmatray"
__version__ = "1.4"
__author__ = "Jayofelony, modified by fmatray and Jalopy"
__version__ = "1.5"
__license__ = "GPL3"
__description__ = "A new BT-Tether plugin"

Expand Down Expand Up @@ -190,7 +190,9 @@ def on_config_changed(self, config):
dns = re.sub("[\s,;]+", " ", dns).strip() # DNS cleaning

try:
# Configure connection. Metric is set to 200 to prefer connection over USB
# Configure prefered connection. Metric is set dynamically via config option to prefer either Bluetooth or USB.
prefer_bt = self.options.get("prefer-bluetooth", False)
metric = "50" if prefer_bt else "200"
self.nmcli(
[
"connection", "modify", f"{self.phone_name}",
Expand All @@ -203,7 +205,7 @@ def on_config_changed(self, config):
"ipv4.dns", f"{dns}",
"ipv4.addresses", f"{address}/24",
"ipv4.gateway", f"{gateway}",
"ipv4.route-metric", "200",
"ipv4.route-metric", f"{metric}",
]
)
# Configure Device to autoconnect
Expand Down