Bug#359003: [Pkg-bluetooth-maintainers] Bug#359003: udev script missing (?)

Rainer Dorsch rdorsch at web.de
Fri Dec 8 15:11:30 CET 2006


Hi Filippo,

(I added the bug on cc, that people have a chance to find my setup using 
google)

I added an udev rule and an udev script for bluetooth usb dongles on my 
system. The rule and script are pasted at the end of the mail. 

I think it is not yet enough to be a starting point for bluetooth usb dongles 
in the Debian bluez packages. 

Essentially, what I want to do is:

When an usb dongle is plugged:
-> bring up the bnep0 interface
-> ifplugd triggers
-> get an IP address using dhclient

ifplugd and dhclient work well, I have a three minor issues with the bnep0 
interface:

1) The udev script is only called for "add" actions not for "remove" actions. 
Why?

2) I have a sleep statement in the udev script. Not sure why it is needed (and 
I would like to get rid of it, because it is a source of a race condition)
        sleep 2
        /etc/init.d/bluetooth restart

Without the sleep statement, I see in syslog

Dec  8 13:22:18 topsi kernel: usb 1-2: new full speed USB device using 
uhci_hcd and address 6
Dec  8 13:22:19 topsi kernel: usb 1-2: configuration #1 chosen from 1 choice
Dec  8 13:22:19 topsi hcid[5171]: HCI dev 0 registered
Dec  8 13:22:19 topsi hcid[5171]: Register path:/org/bluez/hci0 fallback:0
Dec  8 13:22:19 topsi hcid[5171]: HCI dev 0 up
Dec  8 13:22:19 topsi hcid[5171]: Device hci0 has been added
Dec  8 13:22:19 topsi hcid[5171]: Starting security manager 0
Dec  8 13:22:19 topsi hcid[5171]: Device hci0 has been activated
Dec  8 13:22:19 topsi sdpd[5173]: terminating...
Dec  8 13:22:19 topsi hcid[5171]: Unregister path:/org/bluez/hci0
Dec  8 13:22:19 topsi hcid[5171]: Unregister path:/org/bluez
Dec  8 13:22:19 topsi hcid[5171]: Exit
Dec  8 13:22:20 topsi hcid[5351]: Bluetooth HCI daemon
Dec  8 13:22:20 topsi sdpd[5353]: Bluetooth SDP daemon
Dec  8 13:22:20 topsi pand[5354]: Bluetooth PAN daemon version 3.7
Dec  8 13:22:20 topsi pand[5354]: Inquiring
Dec  8 13:22:20 topsi hcid[5351]: Register path:/org/bluez fallback:1
Dec  8 13:22:20 topsi hcid[5351]: HCI dev 0 registered
Dec  8 13:22:20 topsi hcid[5351]: Register path:/org/bluez/hci0 fallback:0
Dec  8 13:22:20 topsi hcid[5351]: HCI dev 0 already up
Dec  8 13:22:20 topsi hcid[5351]: Device hci0 has been added
Dec  8 13:22:20 topsi hcid[5351]: Starting security manager 0
Dec  8 13:22:20 topsi hcid[5351]: Device hci0 has been activated
Dec  8 13:22:21 topsi pand[5354]: Inquiry failed. Device or resource busy(16)

With the sleep statement everything works fine:
Dec  8 13:24:08 topsi kernel: usb 1-2: new full speed USB device using 
uhci_hcd and address 9
Dec  8 13:24:08 topsi kernel: usb 1-2: configuration #1 chosen from 1 choice
Dec  8 13:24:08 topsi hcid[5415]: HCI dev 0 registered
Dec  8 13:24:08 topsi hcid[5415]: Register path:/org/bluez/hci0 fallback:0
Dec  8 13:24:08 topsi hcid[5415]: HCI dev 0 up
Dec  8 13:24:08 topsi hcid[5415]: Device hci0 has been added
Dec  8 13:24:08 topsi hcid[5415]: Starting security manager 0
Dec  8 13:24:09 topsi hcid[5415]: Device hci0 has been activated
Dec  8 13:24:11 topsi sdpd[5417]: terminating...
Dec  8 13:24:11 topsi hcid[5415]: Unregister path:/org/bluez/hci0
Dec  8 13:24:11 topsi hcid[5415]: Unregister path:/org/bluez
Dec  8 13:24:11 topsi hcid[5415]: Exit
Dec  8 13:24:12 topsi hcid[5457]: Bluetooth HCI daemon
Dec  8 13:24:12 topsi sdpd[5459]: Bluetooth SDP daemon
Dec  8 13:24:12 topsi pand[5460]: Bluetooth PAN daemon version 3.7
Dec  8 13:24:12 topsi pand[5460]: Inquiring
Dec  8 13:24:12 topsi pand[5460]: Searching for NAP on 00:04:61:82:24:9F
Dec  8 13:24:12 topsi hcid[5457]: Register path:/org/bluez fallback:1
Dec  8 13:24:12 topsi hcid[5457]: HCI dev 0 registered
Dec  8 13:24:12 topsi hcid[5457]: Register path:/org/bluez/hci0 fallback:0
Dec  8 13:24:12 topsi hcid[5457]: HCI dev 0 already up
Dec  8 13:24:12 topsi hcid[5457]: Device hci0 has been added
Dec  8 13:24:12 topsi hcid[5457]: Starting security manager 0
Dec  8 13:24:12 topsi hcid[5457]: Device hci0 has been activated
Dec  8 13:24:12 topsi pand[5460]: Connecting to 00:04:61:82:24:9F
Dec  8 13:24:12 topsi hcid[5457]: link_key_request (sba=00:04:61:81:10:DA, 
dba=00:04:61:82:24:9F)
Dec  8 13:24:12 topsi pand[5460]: bnep0 connected

Then ifplugd and dhclient come up:

Dec  8 13:24:13 topsi ifplugd.agent[5469]: Invoking ifplugd for bnep0
Dec  8 13:24:13 topsi ifplugd(bnep0)[5479]: ifplugd 0.28 initializing.
Dec  8 13:24:13 topsi ifplugd(bnep0)[5479]: Using interface 
bnep0/00:04:61:81:10:DA
Dec  8 13:24:13 topsi ifplugd(bnep0)[5479]: Using detection mode: IFF_RUNNING
Dec  8 13:24:13 topsi ifplugd(bnep0)[5479]: Initialization complete, link beat 
detected.
Dec  8 13:24:13 topsi dhclient: Internet Software Consortium DHCP Client 
2.0pl5

3) At startup the bluetooth network does not come up. I need to replug the usb 
dongle to get it working.


This is the rule file:

topsi:~# cat /etc/udev/bluez-usb-support.rules
# USB adapters
SUBSYSTEM=="usb", BUS=="usb", ENV{MANF_ID}="$sysfs{idVendor}", 
ENV{PROD_ID}="$sysfs{idProduct}"

#topsi:/sys/bus/usb/devices/usb1/1-2# cat idProduct
#0001
#topsi:/sys/bus/usb/devices/usb1/1-2# cat idVendor
#0a12
#topsi:/sys/bus/usb/devices/usb1/1-2#

# Epox BT-DG02A
BUS=="usb", SYSFS{idProduct}=="0001", SYSFS{idVendor}=="0a12", 
SYSFS{bInterfaceNumber}=="00", RUN+="bluetooth_usb"

topsi:~#

Register the udev script:

topsi:/etc/udev/rules.d# ls -l z60_bluez-usb-support.rules
lrwxrwxrwx 1 root root 26 2006-12-07 09:05 z60_bluez-usb-support.rules 
-> ../bluez-usb-support.rules
topsi:/etc/udev/rules.d#

The RUN scripts in /lib/udev

topsi:/etc/udev/rules.d# cat /lib/udev/bluetooth_usb
#!/bin/sh
#
# bluetooth_usb
#
# Bluetooth usb dongle startup
#

echo $* > /tmp/bluetooth_usb.log
echo MANF_ID: $MANF_ID >> /tmp/bluetooth_usb.log
echo ACTION: $ACTION >> /tmp/bluetooth_usb.log

start_bluetooth()
{
#       if [ ! -x /bin/setserial -o ! -x /usr/sbin/hciattach ]; then
#               logger "$0: setserial or hciattach not executable, cannot 
start $DEVNAME"
#               return 1
#       fi

#       IRQ=`/bin/setserial $DEVNAME | sed -e 's/.*IRQ: //'`
#       /bin/setserial $DEVNAME irq 0 ; /bin/setserial $DEVNAME irq $IRQ

        MANF_CARD_ID="${MANF_ID},${CARD_ID}"
        sleep 2
        /etc/init.d/bluetooth restart
}

stop_bluetooth()
{
#       [ -x /bin/fuser ] || return 1

#        /bin/fuser -k -HUP $DEVNAME > /dev/null
}

case "$ACTION" in
   add)
        start_bluetooth
        ;;
   remove)
        stop_bluetooth
        ;;
   *)
        logger "Unknown action received $0: $ACTION"
        ;;
esac
topsi:/etc/udev/rules.d#



Many thanks,
Rainer


Am Montag, 9. Oktober 2006 13:01 schrieben Sie:
> On Sun, Oct 08, 2006 at 12:27:12AM +0200, Rainer Dorsch wrote:
> > Hello,
> >
> > I just upgraded a sarge system to etch and since hotplug is gone in etch,
> > attaching my bluetooth usb dongle
>
> have a look at udev rules in /etc/udev, you might want to see
> bluez-pcmcia-support as it contains some udev rules and the
> bluetooth_serial script. You want to match your usb dongle via udev and
> then use a RUN target running your modified script.
>
> By the way, this seems a non-bug to me, can I close it or it needs more
> attention?
>
> thanks,
> filippo
> --
> Filippo Giunchedi - http://esaurito.net
> PGP key: 0x6B79D401
> random quote follows:
>
> The only way to get rid of a temptation is to yield to it.
> -- Oscar Wilde

-- 
Rainer Dorsch
Alzentalstr. 28
D-71083 Herrenberg
07032-919495
jabber: rdorsch at jabber.org
GPG Fingerprint: 5966 C54C 2B3C 42CC 1F4F  8F59 E3A8 C538 7519 141E
Full GPG key: http://pgp.mit.edu/




More information about the Pkg-bluetooth-maintainers mailing list