NAP/GN with bluez-4
Hi!
Can't setup NAP-server with bluez-4 (versions 4.39, 4.47). Remote device can't discover any services. But when i trying to run 'simple-service' script from sources, i can see a "Serial Port" service on remote device. Service disappears when script canceled. As I understand at this point, all ok with connectivity and access rights.
I mean linux box must became an Access Point for phone, netbook, etc.
Logs:
...
bluetoothd[9949]: Loading builtin plugins
bluetoothd[9949]: Loading service plugin
bluetoothd[9949]: Loading hciops plugin
bluetoothd[9949]: Loading hal plugin
bluetoothd[9949]: Loading storage plugin
bluetoothd[9949]: Loading plugins /usr/lib/bluetooth/plugins bluetoothd[9949]: Loading network plugin
bluetoothd[9949]: Loading serial plugin
...
bluetoothd[9949]: network_server_probe: path /org/bluez/9949/hci0 bluetoothd[9949]: Adding record with handle 0x10002 bluetoothd[9949]: Record pattern UUID 0000000f-0000-1000-8000-00805f9 bluetoothd[9949]: Record pattern UUID 00000100-0000-1000-8000-00805f9 bluetoothd[9949]: Record pattern UUID 00001002-0000-1000-8000-00805f9 bluetoothd[9949]: Record pattern UUID 00001116-0000-1000-8000-00805f9 bluetoothd[9949]: Changing service classes to 0x020104 bluetoothd[9949]: register_server_record: got record id 0x10002 bluetoothd[9949]: Registered interface org.bluez.NetworkRouter on path /org/bluez/9949/hci0
h /org/bluez/9949/any
bluetoothd[9949]: Registered interface org.bluez.Service on path /org/bluez/9949/any
bluetoothd[9949]: /etc/bluetooth/network.conf: Key file does not have key 'Disable'
bluetoothd[9949]: Config options: InterfacePrefix=bnep0, PANU_Script=(null), GN_Script=(null), NAP_Script=(null), GN_Interface=pan1, NAP_Interface=pan2, Security=false bluetoothd[9949]: bridge pan1 created
...
bluetoothd[9949]: network_server_probe: path /org/bluez/9949/hci0 bluetoothd[9949]: Adding record with handle 0x10002 bluetoothd[9949]: Record pattern UUID 0000000f-0000-1000-8000-00805f9 bluetoothd[9949]: Record pattern UUID 00000100-0000-1000-8000-00805f9 bluetoothd[9949]: Record pattern UUID 00001002-0000-1000-8000-00805f9 bluetoothd[9949]: Record pattern UUID 00001116-0000-1000-8000-00805f9 bluetoothd[9949]: Changing service classes to 0x020104 bluetoothd[9949]: register_server_record: got record id 0x10002 bluetoothd[9949]: Registered interface org.bluez.NetworkRouter on path /org/bluez/9949/hci0
from dmesg:
[169632.490256] Bluetooth: Core ver 2.15 [169632.490308] Bluetooth: HCI device and connection manager initialized [169632.490310] Bluetooth: HCI socket layer initialized [169632.535120] Bluetooth: Generic Bluetooth USB driver ver 0.5 [170196.227526] Bluetooth: L2CAP ver 2.13 [170196.227529] Bluetooth: L2CAP socket layer initialized [170196.262160] Bluetooth: SCO (Voice Link) ver 0.6 [170196.262163] Bluetooth: SCO socket layer initialized [170196.290501] Bluetooth: BNEP (Ethernet Emulation) ver 1.3 [170196.290505] Bluetooth: BNEP filters: protocol multicast [170196.440134] Bluetooth: RFCOMM socket layer initialized [170196.440142] Bluetooth: RFCOMM TTY layer initialized [170196.440145] Bluetooth: RFCOMM ver 1.11
# ifconfig -a|grep 'pan|bnep' pan0 Link encap:Ethernet HWaddr 3a:cb:41:e4:19:97
(pan0 iface not disappears when bluetoothd stops. But it's ok when i set pan1 in config)
I can see both NAP/GN records with 'sdptool browse local'. After 'simple-service' script new record appears.
I dumped some bt traffic with 'hcidump' and saw a "serial port" record transmission. It seems, that somewhy bluez completely ignores any builtin records about network services.
I tried several userland tools (blueman, bluez-gnome) with no success. bluez-gnome has no support for local services. blueman has such broken support.
I tried to play a little with python and dbus (few 'simple-service' script modifications). No success here too.
Am I missed something?
Luiz Augusto von Dentz
maintainerHi,
Quoted 9 lines · On Wed, Aug 12, 2009 at 9:18 AM, [email protected]<[email protected]> wrote:
Hi!
Can't setup NAP-server with bluez-4 (versions 4.39, 4.47). Remote device can't discover any services. But when i trying to run 'simple-service' script from sources, i can see a "Serial Port" service on remote device. Service disappears when script canceled. As I understand at this point, all ok with connectivity and access rights.
I mean linux box must became an Access Point for phone, netbook, etc.
The service registration is done by network plugin, you can edit network.conf to configure which script/interface name to be used. Also check if they are enabled by calling org.bluez.NetworkRouter.GetProperties(), if not enabled enable it by calling org.bluez.NetworkRouter.SetProperty("Enabled", True). Another detail is that you should configure NAP bridge to be used since if you follow the spec it needs to enable dhcp server and configure the routes while GN is just a simple bridge.
Enabled is good for those applications that want to enable/disable data tethering over bluetooth, so it can really be changed without restarting bluetoothd.
Signature · 2 lines
Luiz Augusto von Dentz Engenheiro de Computação
Quoted 2 lines · Luiz Augusto von Dentz
The service registration is done by network plugin, you can edit network.conf to configure which script/interface name to be used. Also
All done here:
bluetoothd[10470]: Config options: InterfacePrefix=bnep0, PANU_Script=(null), GN_Script=(null), NAP_Script=(null), GN_Interface=pan1, NAP_Interface=pan2, Security=false bluetoothd[10470]: bridge pan1 created bluetoothd[10470]: HCI dev 0 registered bluetoothd[10470]: child 10472 forked bluetoothd[10470]: Entering main loop bluetoothd[10470]: child 10472 exited bluetoothd[10470]: HCI dev 0 up
Quoted 3 lines
check if they are enabled by calling
org.bluez.NetworkRouter.GetProperties(), if not enabled enable it by callingorg.bluez.NetworkRouter.SetProperty("Enabled", True). Another
Values, extracted from dbus with python script:
...
router = dbus.Interface(bus.get_object("org.bluez", manager.DefaultAdapter()),
"org.bluez.NetworkRouter")
...
print router.dbus_interface
props = router.GetProperties()
for pname in props.keys():
print pname,props[pname]
...
Output:
org.bluez.NetworkRouter
Enabled 1
Name BlueZ NAP service
Uuid 00001116-0000-1000-8000-00805f9b34fb
org.bluez.NetworkHub
Enabled 1
Name BlueZ GN service
Uuid 00001117-0000-1000-8000-00805f9b34fb
org.bluez.NetworkPeer
Enabled 1
Name BlueZ PANU service
Uuid 00001115-0000-1000-8000-00805f9b34fb
All enabled.
Quoted 3 lines
detail is that you should configure NAP bridge to be used since if you follow the spec it needs to enable dhcp server and configure the routes while GN is just a simple bridge.
I configured GN as pan1 and NAP as pan2. Only pan1 exists after bluetoothd started (why I can't see pan2?).
# ifconfig pan1 inet 10.7.7.1 netmask 255.255.255.0 up dhcp started on pan1
When I start discovery from my phone (or netbook) I can see in logs:
bluetoothd[11235]: adapter_get_device(00:0E:F6:01:00:98) And with 'monitor-bluetooth' script:
{Device.PropertyChanged} [/org/bluez/11235/hci0/dev_00_0E_F6_01_00_98] Connected = 1
{Device.PropertyChanged} [/org/bluez/11235/hci0/dev_00_0E_F6_01_00_98] Connected = 0
hcidump shows me a lot of traffic, but no any records about NAP/GN in a dump (as i understand, something similar to service xml record must present. With 'simple-service' script there is SrvRecHndl about serial service.). And, as result, no any services on 'bluez' blootooth device shown.
BTW: 2.6.30-gentoo-r4
# zcat /proc/config.gz|grep CONFIG_BT CONFIG_BT=m CONFIG_BT_L2CAP=m CONFIG_BT_SCO=m CONFIG_BT_RFCOMM=m CONFIG_BT_RFCOMM_TTY=y CONFIG_BT_BNEP=m CONFIG_BT_BNEP_MC_FILTER=y CONFIG_BT_BNEP_PROTO_FILTER=y CONFIG_BT_HIDP=m CONFIG_BT_HCIBTUSB=m CONFIG_BT_HCIUART=m CONFIG_BT_HCIUART_H4=y CONFIG_BT_HCIUART_BCSP=y CONFIG_BT_HCIUART_LL=y CONFIG_BT_HCIBCM203X=m CONFIG_BT_HCIBPA10X=m CONFIG_BT_HCIBFUSB=m CONFIG_BT_HCIVHCI=m # lsmod Module Size Used by rfcomm 36196 0 bridge 47816 0 bnep 11732 2 sco 9912 0 l2cap 22708 8 rfcomm,bnep btusb 11592 2 bluetooth 54084 9 rfcomm,bnep,sco,l2cap,btusb nvidia 7229892 26 fuse 53136 2 r8169 31896 0 e100 31420 0 intel_agp 26172 0 pl2303 16888 1 usbserial 29736 3 pl2303 processor 33864 0 i2c_i801 8420 0 thermal 12688 0 button 5092 0
Signature · 1 line
#include <regards.h>
Luiz Augusto von Dentz
maintainerHI,
Quoted 8 lines · Dmitry A. Yanko
router =
dbus.Interface(bus.get_object("org.bluez", manager.DefaultAdapter()), "org.bluez.NetworkRouter")
...
print router.dbus_interface
props =router.GetProperties()
for pname inprops.keys():
print pname,props[pname]
...
What does the command sdptool browse local gives to you? About the pan2 you should create it yourself, as I explained before we don't handle the routing/dhcp which is required for NAP, this can be the problem here but in the other hand there is probably a bug since enabled is set to true.
Signature · 2 lines
Luiz Augusto von Dentz Engenheiro de Computação
Quoted 5 lines · Luiz Augusto von Dentz
What does the command sdptool browse local gives to you? About the pan2 you should create it yourself, as I explained before we don't handle the routing/dhcp which is required for NAP, this can be the problem here but in the other hand there is probably a bug since enabled is set to true.
Look 'local.txt' file here: http://www.cross-road.org.ua/bttests/
hcidump output also available (with 'simple-service' script started, when remote device can see 1 service, and without, when no services shown at all). And also dump from windows box (NAP enabled), for comparison.
Signature · 1 line
#include <regards.h>
Luiz Augusto von Dentz
maintainerHi,
Quoted 9 lines · Dmitry A. Yanko
Look 'local.txt' file here: http://www.cross-road.org.ua/bttests/
hcidump output also available (with 'simple-service' script started, when remote device can see 1 service, and without, when no services shown at all). And also dump from windows box (NAP enabled), for comparison.--
#include <regards.h>
It seems the service is registered:
Service Name: BlueZ NAP service
Service Description: BlueZ PAN service
Service RecHandle: 0x10007
Service Class ID List:
"Network Access Point" (0x1116)
Protocol Descriptor List:
"L2CAP" (0x0100)
PSM: 15
"BNEP" (0x000f)
Version: 0x0100
SEQ16: 800 806Language Base Attr List:
code_ISO639: 0x656e
encoding: 0x6a
base_offset: 0x100
Profile Descriptor List:
"Network Access Point" (0x1116)
Version: 0x0100
The dump doesn't seems to contain it and I don't see any attempt to retrieve it, so I'm staring to believe it is the remote device fault, also this looks suspicious:
2009-08-12 13:33:29.014953 > ACL data: handle 1 flags 0x02 dlen 38
L2CAP(d): cid 0x0040 len 34 [psm 1]
SDP SSA Req: tid 0x0 len 0x1d
pat uuid-128 0350278f-3dca-4e62-831d-a41165ff906c
max 4088
aid(s) 0x0000 - 0xffff
cont 00
2009-08-12 13:33:29.015025 < ACL data: handle 1 flags 0x02 dlen 14
L2CAP(d): cid 0x0305 len 10 [psm 1]
SDP SSA Rsp: tid 0x0 len 0x5
count 2
cont 00This is the only time it attempt to retrieve a record which doesn't use bluetooth base, also note that there is no attempt to retrieve 0x1116 which would return NAP record so I don't think your device is really capable to use NAP service or it depend on the record from 0350278f-3dca-4e62-831d-a41165ff906c.
Signature · 2 lines
Luiz Augusto von Dentz Engenheiro de Computação