Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 01 Nov 2005 16:00:10 -0800
From:      Maksim Yevmenkin <maksim.yevmenkin@savvis.net>
To:        Brooks Davis <brooks@one-eyed-alien.net>
Cc:        freebsd-bluetooth@freebsd.org, freebsd-rc@freebsd.org
Subject:   Re: [RFC] rc.d integration for the bluetooth subsystem
Message-ID:  <4368018A.8040403@savvis.net>
In-Reply-To: <20051101224554.GA20543@odin.ac.hmc.edu>
References:  <1129491219.1616.18.camel@localhost> <4353DBBC.2000508@savvis.net> <43541F79.6040008@ebs.gr> <43554BCE.7090309@savvis.net> <4355FD0C.2090702@ebs.gr> <4356D12F.7000006@savvis.net> <43576A9D.1050209@ebs.gr> <4357CEA5.1000308@savvis.net> <4357D9E2.6010701@ebs.gr> <4367E346.4080106@savvis.net> <20051101224554.GA20543@odin.ac.hmc.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
Brooks,

>> please find the first draft of bluetooth rc.d scripts located at
>>
>> http://people.freebsd.org/~emax/bluetooth-rc.diff.txt
>>
>> this patch adds
>>
>> 1) /etc/rc.d/bluetooth script that will be used to start and stop 
>> bluetooth devices. it will be called by devd(8) in response to
>> device arrival and departure events. the script also supports
>> _optional_ per device configuration. per device configuration is
>> stored in /etc/rc.conf.d/bluetooth.$dev file, where $dev is the
>> driver name of the device, i.e. ubt0, sio4, btccc1
>> 
>> 2) /etc/rc.conf.d/bluetooth.device.sample script. this is just an 
>> example. it should be copied to /etc/rc.conf.d/bluetooth.$dev and
>> then defaults can be adjusted. once again if there is no 
>> /etc/rc.conf.d/bluetooth.$dev script then reasonable defaults will
>> be used.
>> 
>> 3) required changes to /etc/Makefile, /etc/mtree/BSD.root.dist,
>> etc. to hook up new scripts to the build.
>> 
>> i'd appreciate any feedback you might have.
>> 
>> this work is inspired by the patches from Panagiotis Astithas.
> 
> This looks like a powerful framework, I may need to find some bluetooth
> devices to play with if you're going to make it relatively easy to

i will try to do my best :)

> configure them. :) I'm a bit dubious about the bluetooth.device.sample
> idea.  What if you used an /etc/defaults/bluetooth.device that you

this is *exactly* what i'm concern about too :) but i obviously do not 
understand rc.d subsystem very well. hence i sent this to freebsd-rc@ in 
a hope to find better solution.

> pulled in to set the defaults instead?  It could contain the current
> example code, but set all the variables do define the defaults.  I think
> that would be more in keeping with current practice.  Adding rc.conf.d
> to mtree is probably a good idea regardless though.

my original idea goes like this:

1) the system must support more then one bluetooth device connected at a 
time. this is _not_ a typical setup, but i'd rather not introduce any 
limitations;

2) it should be possible to configure each device in a slightly 
different manner. for example, i'd like to be able to assign unique 
device name to each device, etc.

3) each bluetooth device has few netgraph nodes associated with it (and 
only it), i.e. driver node, hci and l2cap. so i'd like to be able to 
set, say, hci and l2cap debug levels for one device, but not for another.

4) in the future, it may be desirable to run some services bound to 
specific device. such services should be started when device is 
connected and stopped when device is disconnected (note: this is not 
done yet).

again, i could not find the clean way to express configuration for 
multiple devices using just /etc/rc.conf. i'm _not_ saying it does not 
exists :) i thought of a couple other ways, i.e

- have all non-default parameters for a device in one line, i.e.

   ${dev}_bluetooth_config=".."

i did not like this one because hccontrol(8) and other bluetooth tools 
do not support more than one command at a time, i.e. its not possible to 
run "hccontrol -n ubt0hci cmd1 param1 cmd2 param2". changing 
hccontrol(8) to support this kind of syntax is somewhat tricky, because 
commands may have optional parameters.

- have all non-default parameters appear on a separate lines, i.e.

   ${dev}_bluetooth_local_name="..."
   ${dev}_bluetooth_hci_debug_level="..."

i did not like this one because it seemed like to much clutter in 
/etc/rc.conf. also variable names are far too long to my taste.

right now, there are few parameters for each device that can be tweaked. 
in the future more may be desired. i also wanted to make configuration 
as simple as possible. ideal case if the defaults work for 90+% of the time.

so, i started looking at /etc/rc.subr and specifically at 
load_rc_config(). the nice thing about it that it will automatically 
source /etc/defaults/rc.conf, /etc/rc.conf and then 
/etc/rc.conf.d/$_command (if exists). so the rest is quite simple:

1) /etc/rc.d/bluetooth has hardwired "reasonable" defaults. if there is 
only going to be one bluetooth device connected to the system then there 
is no need to create /etc/rc.conf.d/bluetooth.foo file. in fact, even if 
multiple devices are connected, but it is not required to configure them 
differently then it should work too.

2) if someone wants to tweak parameters then all he/she needs to do is 
to copy /etc/rc.conf.d/bluetooth.device.sample into 
/etc/rc.conf.d/bluetooth.ubt0 (ubt0 is a first bluetooth usb device) and 
edit it.

i liked having all device specific parameters in one file under 
/etc/rc.conf.d. it kinda looks flexible. on the other hand, it makes 
system more linux-like :) depending on your taste it may or may not be a 
good thing :)

may be i did not make it clear, but 
/etc/rc.conf.d/bluetooth.device.sample does _not_ contain defaults. it 
is just an _example_ of what can be put into etc/rc.conf.d/bluetooth.foo 
file. bluetooth.device.sample does not have to live in /etc/rc.conf.d 
and it does not have to be called bluetooth.device.sample. may be i 
should move it into /usr/share/examples/netgraph/bluetooth. may be i 
should rename it. or may be both.

thanks,
max



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4368018A.8040403>