Connect to your raspberry pi (or linux computer) over Bluetooth PAN
  • Python 96.9%
  • Nix 3.1%
Find a file
2023-06-15 16:55:20 -04:00
.envrc add files 2023-06-15 15:56:43 -04:00
blue.py add files 2023-06-15 15:56:43 -04:00
example-config.toml add readme and example config 2023-06-15 16:13:39 -04:00
flake.lock add files 2023-06-15 15:56:43 -04:00
flake.nix add files 2023-06-15 15:56:43 -04:00
LICENSE add legal 2023-06-15 16:06:05 -04:00
Pipfile add files 2023-06-15 15:56:43 -04:00
Pipfile.lock add files 2023-06-15 15:56:43 -04:00
README.org add more instructions 2023-06-15 16:55:20 -04:00
requirements.txt add files 2023-06-15 15:56:43 -04:00

Readme

Rpi Bluetooth

rpi bluetooth allows you to pair your phone to your raspberry pi (or linux computer) to provide a PAN network. 1 I will have to find some way allowing it to run as non root user.

credits for the OG code goes to evilsocket, all i did here was lift the code and strip out pwnagotchi, it worked perfectly in the past so i copied it. 2

Setup and installation

git clone https://github.com/lost-rob0t/pi-ble-network.git
cd pi-ble-network
pipenv run blue.py -c config.toml

you can also install the requirements with pip if you dont use pipenv (you should use it)

pip install -r requirements.txt

Config

The configuration is just like pwnagotchi since. Here is an example config.

devices.android-phone.enabled = true          # the name of this entry is android-phone
devices.android-phone.search_order = 1         # in which order the devices should
                                                                      ## be searched. E.g. this is #1
devices.android-phone.mac = "mac"                 # you need to put your phones
                                                                      ## bt-mac here (settings > status)
devices.android-phone.ip = "192.168.44.2"     # this is the static ip of your pwnagotchi
                                                                      ## adjust this to your phones pan-network
                                                                      ## (run "ifconfig bt-pan" on your phone)
devices.android-phone.netmask = 24             # netmask of the PAN
devices.android-phone.interval = 1             # in minutes, how often should
                                                                      ## the device be searched
devices.android-phone.scantime = 10            # in seconds, how long should be searched
                                                                      ## on each interval
devices.android-phone.max_tries = 0           # how many times it should try to find the
                                                                      ## phone (0 = endless)
devices.android-phone.share_internet = true   # set to true if you want to have
                                                                      ## internet via bluetooth
devices.android-phone.priority = 1             # the device with the highest
                                                                      ## priority wins (1 = highest)

you can also add other phones by just adding another devices.<name> here

Running

Now i will need to find a better solution but for now just run it as root. 3

sudo blue.py --config example-config.toml

crontab

A easy way to have this run at boot is to use crontab you can also use systemd but crontab is easy

sudo crontab -e # we are editing root's crontab

Then inside the crontab put this line

@reboot /usr/bin/python <path to script> --config <path to config>

And when you reboot it will start the script

Troubleshooting

if for whatever reason it does not connect you can use bluetoothctl to pair and trust your device mac

bluetoothctl
discoverable on
scan on
pair <mac of your phone>
# enter yes for the pair prompts
trust <mac>
disconnect <mac>

it is important that you disconnect. if your phone prompts you to allow internet sharing, hit yes.

Footnotes