]> www.wagner.pp.ru Git - sites/home_page.git/blob - software/unix/btdev.html
Changed all links to 45.free.net to wagner.pp.ru
[sites/home_page.git] / software / unix / btdev.html
1 <html><head><title>Bluetooth address resolution project for Linux</title></head>
2 <meta name="description" content="Proposal and some example
3 implementations of project for managing bluetooth devices name
4 resolution database"  
5 <body>
6
7
8 <h1>Bluetooth address resolution project for Linux</h1>
9 <h2>Rationale</h2>
10 <a href="http://bluez.sf.net/">Official Linux Bluetooth stack</a> doesn't
11 include any system-wide way to cache descriptive bluetooth device names
12 and use them instead of numeric addresses.
13 <p>
14 Caching of names in the computer seems to be neccesary, because most
15 devices are able to operate in non-discoverable mode, and this mode is
16 preferrable due to security reason.
17 </p><p>
18 Bluetooth protocol includes &quot;pairing&quot; stage when same secret
19 (typically numeric PIN-code) should be entered on both devices. Since
20 then it is stored (at least in cell phones) along with address of paired
21 devices, and connections may be made even if device is not discoverable.
22 </p><p>
23 Evidently, computer should be able to store PIN codes too. Problem is
24 that entering PIN code for some personal device such as cell-phone is
25 evidently end-user action, whereas exchange of PINs is kernel-level
26 activity.
27 </p><p>
28 Bluez project provides example implementation of PIN helper program,
29 which requests PIN from user interactively. Unfortunately, this
30 implementation doesn't work on reasonable secure Linux system, because
31 it requires daemon process to make connection to user X server.
32 </p><p>
33 There is also dbus-based pin-helper which is better, but doesn't suit my
34 requirements too.
35 </p><p>
36 This also has some usability problems:
37 </p><ul>
38 <li>Suppose your bluetooth adapter is plugged into headless linux server
39 on home network. You can execute any bluetooth-related utility via ssh,
40 but there is no local X server to ask PIN on.
41 </li><li>Suppose you have several computers at you home, and only one have
42 bluetooth adapter plugged in. Suppose it is your girlfriend who is
43 sitting at that computer. Would she like if <b>she</b> would be asked to enter
44 PIN when <b>you</b> are operating with your favorite bluetooth gadget?
45 </li><li>Last, but not least - why should <b>you</b> remember some cryptic
46 code when you have a <b>computer</b>. If such silly gadget as cell phone
47 can remember them for you, why not computer? 
48 </li></ul>
49
50 <h2>Architecture</h2>
51 As user have to manage his own personal appliances himself, database
52 should be stored in user's home directory. It can be simple text file
53 like <tt>/etc/password</tt> which lists device name, device address,
54 most interesting channels and pin code. It is strictly personal data,
55 so file would probably have 0600 permissions.
56 <p>
57 PIN helper utility should scan all user home directories (or all
58 interactively logged in user's directories) and search for appropriate
59 address in their <tt>.btdev</tt> files. It is running as root, so it
60 would be able to access these files anyway. If eventually, Bluez would
61 use some privilege separation, we can chgrp these files to primary group
62 of the system user pin helper run as.
63 </p><p>
64 There should be utility (or several ones - command line, GUI etc) to
65 pair your computer with bluetooth device. It should use hcitool scan
66 command to find out devices you want to pair with, ask your to enter
67 PIN, write it to .btdev file and perform some operation which requires
68 actual connection, such as <tt>sdptool browse</tt> to check if all is correct.  
69 </p><p>
70
71 </p><h2>File format </h2>
72
73 Since bluetooth addresses are colon-separated, we cannot use colons as
74 field separators in .btdev So, let's use vertical bar. People don't
75 typically put it into device names.
76 <p>
77 Traditional hash-mark comments should be allowed.
78 </p><p>
79 Field list:
80 </p><ol>
81 <li>Device nickame, as displayed by <tt>hcitool scan</tt>
82 </li><li>Device address 
83 </b></li><li>PIN code
84 </li><li>various channels. Now following list of channels is used:
85 IRME_SYNC, DUN, OPUSH and FTRN (file transfer)
86 </li></ol>
87
88 <h2>library</h2>
89
90 Here is <a href="http://www.wagner.pp.ru/~vitus/software/unix/btdev.tcl">Tcl library</a> to scan .btdev files.
91
92 It provides following commands:
93
94 <pre> ::btdev::byname <i>name</i>
95 </pre>
96 Returns tcl list of device parameters listed above searching by device
97 name. If device is not found, returns empty list
98 <pre> ::btdev::byaddr <i>bt-addr</i>
99  </pre>
100 Does the same, but using bluetooth address as key
101 <pre>::btdev::channelbyname name service
102 </pre>
103 Returns two-element list with bt address as first element and channel as
104 second element for device with given name and given service type.
105
106 <h2>Utilities</h2>
107 <ul>
108 <li><a href="http://www.wagner.pp.ru/~vitus/software/btdev-pin">Pin helper</a>
109 </li><li><a href="http://www.wagner.pp.ru/~vitus/software/unix/btpair">Command-line Pairing utility</a>
110 </li><li><a href="http://www.wagner.pp.ru/~vitus/software/unix/obexls">Directory lister using FTRN</a> - simple wrapper
111 around obexftp utility which lists directory on the bluetooth device
112 using pathname like Device:directory
113 </li><li><a href="http://www.wagner.pp.ru/~vitus/software/unix/obexget">File transfer utility</a> wrapper around obexftp,
114 which allows to retrieve files from device using wildcards
115 </li></ul>
116
117 </body></html>