8

I have tried following this tutorial: How to enable PAN on Raspberry

When I try this command:

sudo pand –connect xx:xx:xx:xx:xx:xx -n 

I get the error:

pand[4035]: Bluetooth PAN daemon version 4.99 
pand[4035]: Connecting to xx:xx:xx:xx:xx:xx
pand[4035]: Connect to xx:xx:xx:xx:xx:xx failed. Connection refused(111)

I have tried the following so my iPod is trusted by my Raspberry Pi.

> sudo bluez-test-device trust xx:xx:xx:xx:xx:xx yes

Any help on this topic would be greatly appreciated.

1
  • Have you considered the 'Bluetooth Device Manager' in Menu->Preferences? Try Devices->select device and right click->Setup->Connect group network.
    – alkopop79
    Sep 14, 2016 at 17:48

1 Answer 1

22

Here's how you can setup a bluetooth pan on Raspbian.

This answer uses systemd/networkd but you could do something similar with an interfaces file and dnsmasq if you wanted.

Run:

sudo apt-get install bluez-tools

Create the following files:

/etc/systemd/network/pan0.netdev

[NetDev]
Name=pan0
Kind=bridge

/etc/systemd/network/pan0.network

[Match]
Name=pan0

[Network]
Address=172.20.1.1/24
DHCPServer=yes

/etc/systemd/system/bt-agent.service

[Unit]
Description=Bluetooth Auth Agent

[Service]
ExecStart=/usr/bin/bt-agent -c NoInputNoOutput
Type=simple

[Install]
WantedBy=multi-user.target

/etc/systemd/system/bt-network.service

[Unit]
Description=Bluetooth NEP PAN
After=pan0.network

[Service]
ExecStart=/usr/bin/bt-network -s nap pan0
Type=simple

[Install]
WantedBy=multi-user.target

Then run

sudo systemctl enable systemd-networkd
sudo systemctl enable bt-agent
sudo systemctl enable bt-network
sudo systemctl start systemd-networkd
sudo systemctl start bt-agent
sudo systemctl start bt-network

Finally to pair, run:

sudo bt-adapter --set Discoverable 1

Then, on the other device pair it and connect the network. Hopefully everything should just work after that.

Also note: currently, if you are running Raspbian Stretch, you will need an updated btuart script to workaround the issue here.

4
  • I didn't need to use the updated btuart script as my bluetooth address wasn't 'weird' on my RPi 3 using Stretch
    – hfmanson
    Nov 16, 2018 at 9:45
  • Thanks for this. I'm having some trouble getting the PAN to work over Mini UART, though. Posted a new question here: raspberrypi.stackexchange.com/questions/99997/… Jun 27, 2019 at 10:25
  • hi trying to make this work on RPi4. Run all those commands. paired the devices. i now want to connect to my web server hosted on rpi. what do.can i type into my browser to do that?
    – user11286
    Jul 6, 2020 at 7:58
  • As far as I understand, this is to share the Internet Connection the Pi has, no the other way around. The DHCP is set on Pi, not on the other device. I wanna do the reverse, connect to a PAN server, like my mobile.
    – digfish
    Aug 5, 2023 at 11:49

Not the answer you're looking for? Browse other questions tagged or ask your own question.