2009-07-28 08:37:55

by Andrej Rosano

[permalink] [raw]
Subject: Renaming hci interfaces with udev

Hi,
I would like to change the default name of bluetooth interfaces (hci0, hci1, ...)
using udev rules.

While with wlan usb dongles it works with the line:
KERNEL=="wlan*", NAME="foo0"
the analogous for the bt:
KERNEL=="hci*", NAME="foo0"
doesn't work, while
KERNEL=="hci*", RUN+="/usr/bin/touch /tmp/foo"
works.

I'm using kernel 2.6.30.1, udev 125 and bluez 4.46.

Regards,
Andrej

--
Andrej Rosano <[email protected]>
0x7B470744 E5DF 7810 AD63 A215 2D0E AF56 53C7 A2CB 7B47 0744


2009-07-28 12:22:27

by Marcel Holtmann

[permalink] [raw]
Subject: Re: Renaming hci interfaces with udev

Hi Andrej,

> > > I would like to change the default name of bluetooth interfaces (hci0, hci1, ...)
> > > using udev rules.
> >
> > Could I ask why you want to do that?
>
> I have more than one bt dongle connected to the box and I would like to assign always
> the same bluetooth name (the one set with hciconfig hciX name ...), ex:
>
> the one with BD_ADDR=xx:yy:zz:00:00:01 -> foo
> the one with BD_ADDR=xx:yy:zz:00:00:02 -> bar
> ...
>
>
> If one could use the udev persistent rules like with ethernet interfaces:
>
> ACTION=="add", KERNEL=="hci*", ATTR{address}=="xx:yy:zz:00:00:01", NAME="hci0"
> ACTION=="add", KERNEL=="hci*", ATTR{address}=="xx:yy:zz:00:00:02", NAME="hci1"
> ...
>
> and then set the appropriate bluetooth name:
>
> hciconfig hci0 name foo
> hciconfig hci1 name bar
> ...
>
> Currently I am using a script to do that.

and actually bluetoothd is doing that for you no matter what the device
name is. You just have to set the name once using the D-Bus interface.

Regards

Marcel



2009-07-28 12:05:07

by Andrej Rosano

[permalink] [raw]
Subject: Re: Renaming hci interfaces with udev

On Tue, Jul 28, 2009 at 12:34:38PM +0100, Bastien Nocera wrote:
> On Tue, 2009-07-28 at 10:37 +0200, Andrej Rosano wrote:
> > Hi,
> > I would like to change the default name of bluetooth interfaces (hci0, hci1, ...)
> > using udev rules.
>
> Could I ask why you want to do that?

I have more than one bt dongle connected to the box and I would like to assign always
the same bluetooth name (the one set with hciconfig hciX name ...), ex:

the one with BD_ADDR=xx:yy:zz:00:00:01 -> foo
the one with BD_ADDR=xx:yy:zz:00:00:02 -> bar
...


If one could use the udev persistent rules like with ethernet interfaces:

ACTION=="add", KERNEL=="hci*", ATTR{address}=="xx:yy:zz:00:00:01", NAME="hci0"
ACTION=="add", KERNEL=="hci*", ATTR{address}=="xx:yy:zz:00:00:02", NAME="hci1"
...

and then set the appropriate bluetooth name:

hciconfig hci0 name foo
hciconfig hci1 name bar
...

Currently I am using a script to do that.

Regards,
Andrej

--
Andrej Rosano <[email protected]>
0x7B470744 E5DF 7810 AD63 A215 2D0E AF56 53C7 A2CB 7B47 0744

2009-07-28 11:34:38

by Bastien Nocera

[permalink] [raw]
Subject: Re: Renaming hci interfaces with udev

On Tue, 2009-07-28 at 10:37 +0200, Andrej Rosano wrote:
> Hi,
> I would like to change the default name of bluetooth interfaces (hci0, hci1, ...)
> using udev rules.

Could I ask why you want to do that?


2009-07-28 11:31:35

by Marcel Holtmann

[permalink] [raw]
Subject: Re: Renaming hci interfaces with udev

Hi Andrej,

> I would like to change the default name of bluetooth interfaces (hci0, hci1, ...)
> using udev rules.
>
> While with wlan usb dongles it works with the line:
> KERNEL=="wlan*", NAME="foo0"
> the analogous for the bt:
> KERNEL=="hci*", NAME="foo0"
> doesn't work, while
> KERNEL=="hci*", RUN+="/usr/bin/touch /tmp/foo"
> works.
>
> I'm using kernel 2.6.30.1, udev 125 and bluez 4.46.

we don't support renaming HCI devices. However feel free to send a
kernel patch to enable it.

Regards

Marcel