In search of a convenient way to connect to the pi without a connected Lan or even Wifi, the Bluetooth Personal Area Network functionality looked ideal for my use case. Minimal cabling, more wireless fun experimenting and learning with DietPi.
However following the first handful of googled guides I’ve tried where without success. But that could just be me.
After two weeks and many attempts starting from a fresh image I’ve come to a working setup.
This using a GitHub repository from 2017, with some minor modifications. So i thought i should share it here.
DietPi version: 9.3.0
My board: Orange Pi Zero 3
Many thanks for the Bluetooth fix still needed on this image, to get Bluetooth functioning:
I hope this fix will make it into a next image of the Orange Pi Zero 3 soon if it has not already.
Log of my current setup, all done under root user:
dietpi-config => Bluetooth on
Applying the fix for my SBC in the above link.
reboot
Following outline of:
With slight modifications:
apt install python3-dbus python3-systemd iptables bridge-utils rfkill
wget -O /usr/local/sbin/bt-pan https://github.com/Re4son/Kali-Pi/raw/master/Menus/RAS-AP/bt-pan
wget -O /usr/local/sbin/pan https://github.com/Re4son/Kali-Pi/raw/master/Menus/RAS-AP/pan
wget -O /usr/local/sbin/BT-AP https://github.com/Re4son/Kali-Pi/raw/master/Menus/RAS-AP/BT-AP
wget -O /etc/systemd/network/pan.netdev https://github.com/Re4son/Kali-Pi/raw/master/Menus/RAS-AP/pan.netdev
wget -O /etc/systemd/network/pan.network https://github.com/Re4son/Kali-Pi/raw/master/Menus/RAS-AP/pan.network
wget -O /etc/systemd/system/pan.service https://github.com/Re4son/Kali-Pi/raw/master/Menus/RAS-AP/pan.service
chmod +x /usr/local/sbin/bt-pan
chmod +x /usr/local/sbin/pan
chmod +x /usr/local/sbin/BT-AP
Modify bt-pan for use with python3:
nano /usr/local/sbin/bt-pan
#!/usr/bin/env python3
remove “iter” part from “.iteritems”
remove “view” part from “.viewitems”
Modify pan.netdev:
nano /etc/systemd/network/pan.netdev
[NetDev]
Name=pan
Kind=bridge
Modify pan.network, choose your preferred fixed ip while on the PAN:
nano /etc/systemd/network/pan.network
[Match]
Name=pan
[Network]
Address=192.168.192.1/24
DHCPServer=yes
IPMasquerade=ipv4
[Link]
ActivationPolicy=always-up
Modify pan.service, the added sprd-bluetooth.service might be Orange Pi Zero 3 board specific:
nano /etc/systemd/system/pan.service
[Unit]
Description=Bluetooth Personal Area Network
After=bluetooth.service systemd-networkd.service sprd-bluetooth.service
Requires=systemd-networkd.service
PartOf=bluetooth.service
[Service]
Type=notify
ExecStartPre=/bin/sleep 10
ExecStart=/usr/local/sbin/pan
[Install]
WantedBy=bluetooth.target
Unblock if needed:
rfkill list
rfkill unblock 1
rfkill unblock 2
Pair and trust the pi with the other device:
bluetoothctl
agent on
power on
discoverable on
discoverable-timeout 0
scan on
pair xx:xx:xx:xx:xx:xx
trust xx:xx:xx:xx:xx:xx
scan off
info xx:xx:xx:xx:xx:xx
quit
Set Bluetooth to auto enable if not already set:
nano /etc/bluetooth/main.conf
DiscoverableTimeout = 0
Experimental = true
KernelExperimental = true
AutoEnable=true
systemctl daemon-reload
systemctl restart systemd-networkd
systemctl start pan
systemctl enable pan
Starting up the SBC and after ±1:15 connecting to the PAN on Windows or android is then possible.
I do not fully understand all the inner workings yet of the used code, some parts seem to use some deprecated or older packaged/methods.
So there seems to be room for further improvement; more minimal code, possibly less used packages or use of more recent packages/methods.
Ideally i would love to see a robust version of a feature like this implemented in the dietpi-config.
Then optionally enabling this after Bluetooth on, and configure it like configuring ethernet or wireless networking in the DietPi style config menu’s.
What are your thoughts and or working set up’s for connecting to your SBC’s via a Bluetooth PAN?