Linux – Unable to connect to PAN bluetooth access point

bluetoothlinuxnetworking

I'm currently trying to implement a PAN connection over bluetooth between two boards.

The first board is a Raspberry Pi Zero and the second a custom one based on Atmel Sama5d2.
Boards are respectively running Linux 4.9.75+ and Linux 4.9.30 and using BlueZ v5.43 and BlueZ v5.46.

I'm able to connect to my phone's tethered bluetooth connection with both boards using bt-panscript.

Here is the trace of a connection to my phone's tethered connection

# bt-pan --debug client 60:45:CB:2F:C6:4C --wait
DEBUG:root:Using local device (addr: B8:27:EB:20:54:45): /org/bluez/hci0
DEBUG:root:Using remote device (addr: 60:45:CB:2F:C6:4C): /org/bluez/hci0/dev_60_45_CB_2F_C6_4C
DEBUG:root:Connected to network (dev_remote: /org/bluez/hci0/dev_60_45_CB_2F_C6_4C, addr: 60:45:CB:2F:C6:4C) uuid 'nap' with iface: bnep0

Here is what I have done so far (using rpi as client and custom board as server) :

Boards are paired

Server side

[bluetooth]# paired-devices
Device B8:27:EB:20:54:45 raspberrypi[/code]

Client side

[bluetooth]# paired-devices
Device 00:16:A4:0A:15:13 BlueZ 5.46

Setup bridge interface on server side

#brctl addbr bnep0
#brctl setfd bnep0 0
#brctl stp bnep0 off
#ip addr add 10.5.0.5/255.255.0.0 dev bnep0
#ip link set bnep0 up

Launch bt-pan script as server on server side

#bt-pan --debug server bnep0
DEBUG:root:Using local device (addr: 00:16:A4:0A:15:13): /org/bluez/hci0
DEBUG:root:Registered uuid 'nap' with bridge/dev: bnep0 / 00:16:A4:0A:15:13

Launch bt-pan script as client on client side

# bt-pan --debug client 00:16:A4:0A:15:13 --wait
DEBUG:root:Using local device (addr: B8:27:EB:20:54:45): /org/bluez/hci0
DEBUG:root:Using remote device (addr: 00:16:A4:0A:15:13): /org/bluez/hci0/dev_00_16_A4_0A_15_13
Traceback (most recent call last):
  File "/usr/bin/bt-pan", line 238, in <module>
    if __name__ == '__main__': sys.exit(main())
  File "/usr/bin/bt-pan", line 210, in main
    try: iface = net.Connect(opts.uuid)
  File "/usr/lib/python3/dist-packages/dbus/proxies.py", line 145, in __call__
    **keywords)
  File "/usr/lib/python3/dist-packages/dbus/connection.py", line 651, in call_blocking
    message, timeout)
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.UnknownMethod: Method "Connect" with signature "s" on interface "org.bluez.Network1" doesn't exist

From what I understand, it seems that my bluetooth device doesn't export the method Connect for interface org.bluez.Network1

Does anybody knows why the network profile is not supported?
Is there a workaround to solve this error ?

Best Answer

I finally found out what the problem was.

There were two issues about what I have done :

1. I shall pair AFTER enabling PAN on server side

The PAN profile is created by the bt-pan script so if the PAN profile didn't exist when pairing was done, the client is not aware that the remote device has a PAN profile resulting in an error saying there is no Connect method on the remote interface.

2. Client shall be trusted on server side

The server only accept connection of trusted devices. If the server launched the pairing, the client is automatically trusted, however, if the pairing was initiated by the client, the client is not in the list of trusted devices on server side so it will not be accepted on connection, resulting in a Input/Output error.

The server can either trust the client after it launched the pairing or it can launch the pairing itself.

Related Question