2020-07-21 21:42:56

by Barry Byford

[permalink] [raw]
Subject: Networking - NetworkServer1

I am trying to get Bluetooth networking to happen between a couple of
Raspberry Pi's running the latest Raspberry Pi OS and BlueZ 5.50

$ uname -a
Linux raspberry 4.19.118-v7+ #1311 SMP Mon Apr 27 14:21:24 BST 2020
armv7l GNU/Linux
$ bluetoothctl --version
bluetoothctl: 5.50

I have been able to use the Network1 interface to Connect to my
Android phone using Bluetooth tethering.

However, when I use the NetworkServer1 interface to register a profile
I have not had success in getting two devices to communicate. I have
paired and trusted the two devices. This allows the Bluetooth to
connect but not for the networking interface to be created as can be
seen in the logs:

e.g. bluetoothd: BNEP server cannot be added

A search for that error message didn't seem to turn up anything actionable.

```
> ACL Data RX: Handle 11 flags 0x02 dlen 44 #50 [hci0] 21:54:01.130545
Channel: 64 len 40 [PSM 15 mode 0] {chan 0}
BNEP: Control (0x01|0)
Filter MultAddr Set (0x05)
Length: 0x0024
ff:ff:ff:ff:ff:ff - ff:ff:ff:ff:ff:ff
33:33:00:00:00:01 - 33:33:00:00:00:01
01:00:5e:00:00:01 - 01:00:5e:00:00:01
< ACL Data TX: Handle 11 flags 0x00 dlen 8
#51 [hci0] 21:54:01.131140
Channel: 64 len 4 [PSM 15 mode 0] {chan 0}
BNEP: Control (0x01|0)
Filter MultAddr Rsp (0x06)
Rsp msg: Operation Successful(0x0000)
> ACL Data RX: Handle 11 flags 0x02 dlen 56 #52 [hci0] 21:54:01.131800
Channel: 64 len 52 [PSM 15 mode 0] {chan 0}
BNEP: Control (0x01|0)
Filter MultAddr Set (0x05)
Length: 0x0030
ff:ff:ff:ff:ff:ff - ff:ff:ff:ff:ff:ff
33:33:00:00:00:01 - 33:33:00:00:00:01
01:00:5e:00:00:01 - 01:00:5e:00:00:01
33:33:ff:d1:14:7e - 33:33:ff:d1:14:7e
< ACL Data TX: Handle 11 flags 0x00 dlen 8
#53 [hci0] 21:54:01.131912
Channel: 64 len 4 [PSM 15 mode 0] {chan 0}
BNEP: Control (0x01|0)
Filter MultAddr Rsp (0x06)
Rsp msg: Operation Successful(0x0000)
> HCI Event: Number of Completed Packets (0x13) plen 5 #54 [hci0] 21:54:01.132894
Num handles: 1
Handle: 11
Count: 2
> HCI Event: Number of Completed Packets (0x13) plen 5 #55 [hci0] 21:54:01.135075
Num handles: 1
Handle: 11
Count: 2
= bluetoothd: bnep: Can't add bnep0 to the bridge tether: No such
device(19) 21:54:01.138304
= bluetoothd: BNEP server cannot be added
21:54:01.138429
> ACL Data RX: Handle 11 flags 0x02 dlen 89 #56 [hci0] 21:54:01.158957
Channel: 64 len 85 [PSM 15 mode 0] {chan 0}
BNEP: Compressed Ethernet DestOnly (0x04|0)
dst 33:33:00:00:00:16 [proto 0x86dd]
60 00 00 00 00 24 00 01 00 00 00 00 00 00 00 00 `....$..........
00 00 00 00 00 00 00 00 ff 02 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 16 3a 00 05 02 00 00 01 00 ........:.......
8f 00 5a 3b 00 00 00 01 04 00 00 00 ff 02 00 00 ..Z;............
00 00 00 00 00 00 00 01 ff d1 14 7e ...........~
> ACL Data RX: Handle 11 flags 0x02 dlen 68 #57 [hci0] 21:54:01.265654
Channel: 64 len 64 [PSM 15 mode 0] {chan 0}
BNEP: Control (0x01|0)
Filter MultAddr Set (0x05)
Length: 0x003c
ff:ff:ff:ff:ff:ff - ff:ff:ff:ff:ff:ff
33:33:00:00:00:01 - 33:33:00:00:00:01
01:00:5e:00:00:01 - 01:00:5e:00:00:01
33:33:ff:d1:14:7e - 33:33:ff:d1:14:7e
33:33:00:00:00:fb - 33:33:00:00:00:fb
```
The client seems to be created correctly.

I have been searching around and I cannot find any working solutions
being reported for GN or PANU using the tools that are currently
available.

There is this thread but it seems to have ended without conclusion
https://marc.info/?l=linux-bluetooth&m=149129850001348&w=2

I have added org.bluez.Network1 and org.bluez.NetworkServer1 to my
/etc/dbus-1/system.d/bluetooth.conf for both server and client.

Are there any other configuration files that need editing?

Any help or guidance gratefully received. Pointers to a tutorial or
the steps required would be good also as there appears to be some step
I'm missing.

Thanks,
Barry


2020-07-21 23:41:10

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: Networking - NetworkServer1

Hi Barry,

On Tue, Jul 21, 2020 at 2:45 PM Barry Byford <[email protected]> wrote:
>
> I am trying to get Bluetooth networking to happen between a couple of
> Raspberry Pi's running the latest Raspberry Pi OS and BlueZ 5.50
>
> $ uname -a
> Linux raspberry 4.19.118-v7+ #1311 SMP Mon Apr 27 14:21:24 BST 2020
> armv7l GNU/Linux
> $ bluetoothctl --version
> bluetoothctl: 5.50
>
> I have been able to use the Network1 interface to Connect to my
> Android phone using Bluetooth tethering.
>
> However, when I use the NetworkServer1 interface to register a profile
> I have not had success in getting two devices to communicate. I have
> paired and trusted the two devices. This allows the Bluetooth to
> connect but not for the networking interface to be created as can be
> seen in the logs:
>
> e.g. bluetoothd: BNEP server cannot be added
>
> A search for that error message didn't seem to turn up anything actionable.
>
> ```
> > ACL Data RX: Handle 11 flags 0x02 dlen 44 #50 [hci0] 21:54:01.130545
> Channel: 64 len 40 [PSM 15 mode 0] {chan 0}
> BNEP: Control (0x01|0)
> Filter MultAddr Set (0x05)
> Length: 0x0024
> ff:ff:ff:ff:ff:ff - ff:ff:ff:ff:ff:ff
> 33:33:00:00:00:01 - 33:33:00:00:00:01
> 01:00:5e:00:00:01 - 01:00:5e:00:00:01
> < ACL Data TX: Handle 11 flags 0x00 dlen 8
> #51 [hci0] 21:54:01.131140
> Channel: 64 len 4 [PSM 15 mode 0] {chan 0}
> BNEP: Control (0x01|0)
> Filter MultAddr Rsp (0x06)
> Rsp msg: Operation Successful(0x0000)
> > ACL Data RX: Handle 11 flags 0x02 dlen 56 #52 [hci0] 21:54:01.131800
> Channel: 64 len 52 [PSM 15 mode 0] {chan 0}
> BNEP: Control (0x01|0)
> Filter MultAddr Set (0x05)
> Length: 0x0030
> ff:ff:ff:ff:ff:ff - ff:ff:ff:ff:ff:ff
> 33:33:00:00:00:01 - 33:33:00:00:00:01
> 01:00:5e:00:00:01 - 01:00:5e:00:00:01
> 33:33:ff:d1:14:7e - 33:33:ff:d1:14:7e
> < ACL Data TX: Handle 11 flags 0x00 dlen 8
> #53 [hci0] 21:54:01.131912
> Channel: 64 len 4 [PSM 15 mode 0] {chan 0}
> BNEP: Control (0x01|0)
> Filter MultAddr Rsp (0x06)
> Rsp msg: Operation Successful(0x0000)
> > HCI Event: Number of Completed Packets (0x13) plen 5 #54 [hci0] 21:54:01.132894
> Num handles: 1
> Handle: 11
> Count: 2
> > HCI Event: Number of Completed Packets (0x13) plen 5 #55 [hci0] 21:54:01.135075
> Num handles: 1
> Handle: 11
> Count: 2
> = bluetoothd: bnep: Can't add bnep0 to the bridge tether: No such
> device(19) 21:54:01.138304

Well it looks like the bridge (tether) does not exist so we can't add
the bnep interface, perhaps the idea is not to have it attached to any
bridge in case of GN, PAN and just bring the interface up when an
empty string is given as bridge.

> = bluetoothd: BNEP server cannot be added
> 21:54:01.138429
> > ACL Data RX: Handle 11 flags 0x02 dlen 89 #56 [hci0] 21:54:01.158957
> Channel: 64 len 85 [PSM 15 mode 0] {chan 0}
> BNEP: Compressed Ethernet DestOnly (0x04|0)
> dst 33:33:00:00:00:16 [proto 0x86dd]
> 60 00 00 00 00 24 00 01 00 00 00 00 00 00 00 00 `....$..........
> 00 00 00 00 00 00 00 00 ff 02 00 00 00 00 00 00 ................
> 00 00 00 00 00 00 00 16 3a 00 05 02 00 00 01 00 ........:.......
> 8f 00 5a 3b 00 00 00 01 04 00 00 00 ff 02 00 00 ..Z;............
> 00 00 00 00 00 00 00 01 ff d1 14 7e ...........~
> > ACL Data RX: Handle 11 flags 0x02 dlen 68 #57 [hci0] 21:54:01.265654
> Channel: 64 len 64 [PSM 15 mode 0] {chan 0}
> BNEP: Control (0x01|0)
> Filter MultAddr Set (0x05)
> Length: 0x003c
> ff:ff:ff:ff:ff:ff - ff:ff:ff:ff:ff:ff
> 33:33:00:00:00:01 - 33:33:00:00:00:01
> 01:00:5e:00:00:01 - 01:00:5e:00:00:01
> 33:33:ff:d1:14:7e - 33:33:ff:d1:14:7e
> 33:33:00:00:00:fb - 33:33:00:00:00:fb
> ```
> The client seems to be created correctly.
>
> I have been searching around and I cannot find any working solutions
> being reported for GN or PANU using the tools that are currently
> available.
>
> There is this thread but it seems to have ended without conclusion
> https://marc.info/?l=linux-bluetooth&m=149129850001348&w=2
>
> I have added org.bluez.Network1 and org.bluez.NetworkServer1 to my
> /etc/dbus-1/system.d/bluetooth.conf for both server and client.
>
> Are there any other configuration files that need editing?
>
> Any help or guidance gratefully received. Pointers to a tutorial or
> the steps required would be good also as there appears to be some step
> I'm missing.
>
> Thanks,
> Barry



--
Luiz Augusto von Dentz

2020-07-22 08:36:31

by Barry Byford

[permalink] [raw]
Subject: Re: Networking - NetworkServer1

Hi Luiz,

Thanks for the quick response. Very much appreciated.

On Wed, 22 Jul 2020 at 00:27, Luiz Augusto von Dentz
<[email protected]> wrote:
> > = bluetoothd: bnep: Can't add bnep0 to the bridge tether: No such
> > device(19) 21:54:01.138304
>
> Well it looks like the bridge (tether) does not exist so we can't add
> the bnep interface, perhaps the idea is not to have it attached to any
> bridge in case of GN, PAN and just bring the interface up when an
> empty string is given as bridge.
>
An empty string also produced the error.

However, I created a bridge using the bridge utilities package
$ sudo apt install bridge-utils
$ sudo brctl addbr bluez

And then used
server.Register('panu', 'bluez')

This enabled the connection to be accepted from the client to happen
without error.

$ service bluetooth status
● bluetooth.service - Bluetooth service
Loaded: loaded (/lib/systemd/system/bluetooth.service; enabled;
vendor preset: enabled)
Active: active (running) since Tue 2020-07-21 09:27:49 BST; 24h ago
Docs: man:bluetoothd(8)
Main PID: 625 (bluetoothd)
Status: "Running"
Tasks: 1 (limit: 2200)
Memory: 3.3M
CGroup: /system.slice/bluetooth.service
└─625 /usr/lib/bluetooth/bluetoothd --experimental

Jul 22 07:27:43 raspberrypi bluetoothd[625]: bnep: bridge bluez:
interface bnep0 added



I think the bridge probably needs more refinement as there does not
appear to be a route between the two devices still.

Any pointers on that appreciated.

Thanks again for your help on this Luiz.

Regards,
Barry


$ brctl show
bridge name bridge id STP enabled interfaces
bluez 8000.b827eb2257e0 no bnep0

$ brctl showstp bluez
bluez
bridge id 8000.b827eb2257e0
designated root 8000.b827eb2257e0
root port 0 path cost 0
max age 20.00 bridge max age 20.00
hello time 2.00 bridge hello time 2.00
forward delay 15.00 bridge forward delay 15.00
ageing time 300.00
hello timer 0.00 tcn timer 0.00
topology change timer 0.00 gc timer 0.00
flags


bnep0 (1)
port id 8001 state disabled
designated root 8000.b827eb2257e0 path cost 100
designated bridge 8000.b827eb2257e0 message age timer 0.00
designated port 8001 forward delay timer 0.00
designated cost 0 hold timer 0.00
flags

$ ifconfig bluez
bluez: flags=4098<BROADCAST,MULTICAST> mtu 1500
ether b8:27:eb:22:57:e0 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

$ ifconfig bnep0
bnep0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 169.254.91.109 netmask 255.255.0.0 broadcast 169.254.255.255
inet6 fe80::ba27:ebff:fe22:57e0 prefixlen 64 scopeid 0x20<link>
inet6 fe80::64d6:60a1:4a0d:3e4 prefixlen 64 scopeid 0x20<link>
ether b8:27:eb:22:57:e0 txqueuelen 1000 (Ethernet)
RX packets 111 bytes 20669 (20.1 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 57 bytes 16084 (15.7 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

$ route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.1.254 0.0.0.0 UG 202 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 233 0 0 bnep0
192.168.1.0 0.0.0.0 255.255.255.0 U 202 0 0 eth0