1 .\" $NetBSD: bluetooth.4,v 1.16 2009/09/25 19:47:09 plunky Exp $
3 .\" Copyright (c) 2006 Itronix Inc.
4 .\" All rights reserved.
6 .\" Written by Iain Hibbert for Itronix Inc.
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
11 .\" 1. Redistributions of source code must retain the above copyright
12 .\" notice, this list of conditions and the following disclaimer.
13 .\" 2. Redistributions in binary form must reproduce the above copyright
14 .\" notice, this list of conditions and the following disclaimer in the
15 .\" documentation and/or other materials provided with the distribution.
16 .\" 3. The name of Itronix Inc. may not be used to endorse
17 .\" or promote products derived from this software without specific
18 .\" prior written permission.
20 .\" THIS SOFTWARE IS PROVIDED BY ITRONIX INC. ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22 .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ITRONIX INC. BE LIABLE FOR ANY
24 .\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 .\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26 .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
27 .\" ON ANY THEORY OF LIABILITY, WHETHER IN
28 .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 .\" POSSIBILITY OF SUCH DAMAGE.
33 .Dd September 24, 2009
38 .Nd Bluetooth Protocol Family
49 Bluetooth Protocol Family sockets all use a
51 structure which contains a Bluetooth Device Address (BDADDR).
52 This consists of a six byte string in least significant byte
54 .Bd -literal -offset indent
57 sa_family_t bt_family;
64 The local address used by the socket can be set with
67 Protocols included are:
70 This gives raw access to the Host Controller Interface of local devices
71 using the HCI protocol as described in the Bluetooth Core Specification.
72 Any user may open an HCI socket but there are limitations on what
73 unprivileged users can send and receive.
74 The local address specified by
76 may be used to select the device that the socket will receive packets from.
79 is specified then the socket will receive packets from all
80 devices on the system.
82 may be used to create connections such that packets sent with
84 will be delivered to the specified device, otherwise
92 fields in the sockaddr_bt structure are ignored by HCI protocol code
93 and should be set to zero.
97 .It Dv SO_HCI_EVT_FILTER Op Ar struct hci_filter
98 This filter controls which events will be received at the socket.
101 for available events.
102 By default, Command_Complete and Command_Status
103 events only are enabled.
104 .It Dv SO_HCI_PKT_FILTER Op Ar struct hci_filter
105 This filter controls the type of packets that will be received at the
107 By default, Event packets only are enabled.
108 .It Dv SO_HCI_DIRECTION Op Ar int
109 When set, this enables control messages on packets received at the socket
110 indicating the direction of travel of the packet.
117 .It Dv net.bluetooth.hci.sendspace
118 Default send buffer size for HCI sockets.
119 .It Dv net.bluetooth.hci.recvspace
120 Default receive buffer size for HCI sockets
121 .It Dv net.bluetooth.hci.acl_expiry
122 If set, this is the time in seconds after which unused ACL data connections
124 If zero, connections will not be closed.
125 .It Dv net.bluetooth.hci.memo_expiry
126 Time, in seconds, that the system will keep records of Bluetooth devices
127 in the vicinity after an Inquiry Response packet has been received.
128 This information is used for routing purposes.
129 .It Dv net.bluetooth.hci.eventq_max
130 The maximum number of packets on the low level Event queue.
131 .It Dv net.bluetooth.hci.aclrxq_max
132 The maximum number of packets on the low level ACL queue.
133 .It Dv net.bluetooth.hci.scorxq_max
134 The maximum number of packets on the low level SCO queue.
137 L2CAP sockets give sequential packet access over channels to other Bluetooth
138 devices and make use of the
142 structure to select the Protocol/Sevice Multiplexer to specify when making
144 If the special value of
148 call is made, the next available PSM from the dynamic range above 0x1001
149 will be selected and may be discovered using the
153 L2CAP socket options:
155 .It Dv SO_L2CAP_IMTU Op Ar uint16_t
157 .It Dv SO_L2CAP_OMTU Op Ar uint16_t
158 Outgoing MTU (read-only)
159 .It Dv SO_L2CAP_LM Op Ar int
161 The following bits may be set:
163 .Bl -tag -compact -width ".Dv L2CAP_LM_ENCRYPT"
165 Request authentication
167 .It Dv L2CAP_LM_ENCRYPT
170 .It Dv L2CAP_LM_SECURE
172 .Pq encryption, plus change link key .
175 Link mode settings will be applied to the baseband link during L2CAP
176 connection establishment.
177 If the L2CAP connection is already established,
179 may be returned, and it is not possible to guarantee that data already queued
181 will not be delivered.
182 If the mode change fails, the L2CAP connection will be aborted.
189 .It Dv net.bluetooth.l2cap.sendspace
190 Default send buffer size for L2CAP sockets.
191 .It Dv net.bluetooth.l2cap.recvspace
192 Default receive buffer size for L2CAP sockets.
193 .It Dv net.bluetooth.l2cap.rtx
194 Response Timeout eXpiry for L2CAP signals.
195 .It Dv net.bluetooth.l2cap.ertx
196 Extended Response Timeout eXpiry for L2CAP signals.
198 .It Cm BTPROTO_RFCOMM
199 RFCOMM sockets provide streamed data over Bluetooth connection and make use of the
206 The channel number must be between 1 and 30 inclusive except that if the
208 .Dv RFCOMM_CHANNEL_ANY
211 call is made, the first unused channel for the relevant bdaddr will be
212 allocated and may be discovered using the
215 If no PSM is specified, a default value of
217 (0x0003) will be used.
219 RFCOMM socket options:
221 .It Dv SO_RFCOMM_MTU Op Ar uint16_t
222 Maximum Frame Size to use for this link.
223 .It Dv SO_RFCOMM_LM Op Ar int
225 The following bits may be set at any time:
227 .Bl -tag -compact -width ".Dv RFCOMM_LM_ENCRYPT"
228 .It Dv RFCOMM_LM_AUTH
229 Request authentication
231 .It Dv RFCOMM_LM_ENCRYPT
234 .It Dv RFCOMM_LM_SECURE
236 .Pq encryption, plus change link key .
239 Link mode settings will be applied to the baseband link during RFCOMM
240 connection establishment.
241 If the RFCOMM connection is already established,
243 may be returned, and it is not possible to guarantee that data already queued
245 will not be delivered.
246 If the mode change fails, the RFCOMM connection will be aborted.
253 .It Dv net.bluetooth.rfcomm.sendspace
254 Default send buffer size for RFCOMM sockets.
255 .It Dv net.bluetooth.rfcomm.recvspace
256 Default receive buffer size for RFCOMM sockets.
257 .It Dv net.bluetooth.rfcomm.default_mtu
258 Maximum Frame Size (N1)
259 .It Dv net.bluetooth.ack_timeout
260 Acknowledgement Timer (T1)
261 .It Dv net.bluetooth.mcc_timeout
262 Response Timer for Multiplexer Control Channel (T2)
265 SCO sockets provide sequential packet access to time sensitive data
266 channels over Bluetooth connections, typically used for audio data.
270 .It Dv SO_SCO_MTU Op Ar uint16_t
271 Maximum packet size for use on this link.
272 This is read-only and will be set by the protocol code when a connection is made.
273 Currently, due to limitations in the
275 driver, the SCO protocol code will only accept packets with
277 .It Dv SO_SCO_HANDLE Op Ar uint16_t
278 Connection handle for this link.
279 This is read-only and provided for informational purposes only.
286 .It Dv net.bluetooth.sco.sendspace
287 Default send buffer size for SCO sockets.
288 .It Dv net.bluetooth.sco.recvspace
289 Default receive buffer size for SCO sockets.
295 calls may be used to manipulate Bluetooth devices.
301 All of the requests take a
303 structure defined as follows as their parameter and unless otherwise
306 field to identify the device.
309 char btr_name[HCI_DEVNAME_SIZE]; /* device name */
313 bdaddr_t btri_bdaddr; /* device bdaddr */
314 uint16_t btri_flags; /* flags */
315 uint16_t btri_num_cmd; /* # of free cmd buffers */
316 uint16_t btri_num_acl; /* # of free ACL buffers */
317 uint16_t btri_num_sco; /* # of free SCO buffers */
318 uint16_t btri_acl_mtu; /* ACL mtu */
319 uint16_t btri_sco_mtu; /* SCO mtu */
320 uint16_t btri_link_policy; /* Link Policy */
321 uint16_t btri_packet_type; /* Packet Type */
323 struct bt_stats btrs; /* unit stats */
327 #define btr_flags btru.btri.btri_flags
328 #define btr_bdaddr btru.btri.btri_bdaddr
329 #define btr_num_cmd btru.btri.btri_num_cmd
330 #define btr_num_acl btru.btri.btri_num_acl
331 #define btr_num_sco btru.btri.btri_num_sco
332 #define btr_acl_mtu btru.btri.btri_acl_mtu
333 #define btr_sco_mtu btru.btri.btri_sco_mtu
334 #define btr_link_policy btru.btri.btri_link_policy
335 #define btr_packet_type btru.btri.btri_packet_type
336 #define btr_stats btru.btrs
339 #define BTF_UP (1\*[Lt]\*[Lt]0) /* unit is up */
340 #define BTF_RUNNING (1\*[Lt]\*[Lt]1) /* unit is running */
341 #define BTF_XMIT_CMD (1\*[Lt]\*[Lt]2) /* transmitting CMD packets */
342 #define BTF_XMIT_ACL (1\*[Lt]\*[Lt]3) /* transmitting ACL packets */
343 #define BTF_XMIT_SCO (1\*[Lt]\*[Lt]4) /* transmitting SCO packets */
344 #define BTF_INIT_BDADDR (1\*[Lt]\*[Lt]5) /* waiting for bdaddr */
345 #define BTF_INIT_BUFFER_SIZE (1\*[Lt]\*[Lt]6) /* waiting for buffer size */
346 #define BTF_INIT_FEATURES (1\*[Lt]\*[Lt]7) /* waiting for features */
347 #define BTF_NOOP_ON_RESET (1\*[Lt]\*[Lt]8) /* wait for No-op on reset */
348 #define BTF_INIT_COMMANDS (1\*[Lt]\*[Lt]9) /* waiting for supported commands */
349 #define BTF_MASTER (1\*[Lt]\*[Lt]10) /* request Master role */
365 .Bl -tag -width SIOCGBTPOLICY
367 Get Bluetooth device Info.
368 Given the device name, fill in the
369 btreq structure including the address field for use with socket addressing
372 Get Bluetooth device Info from Address.
373 Given the device address, fill in the
374 btreq structure including the name field.
376 Next Bluetooth device Info.
377 If name field is empty, the first device will be returned.
378 Otherwise, the next device will be returned.
379 Thus, you can cycle through all devices in the system.
381 Set Bluetooth device Flags.
382 Not all flags are settable.
384 Set Bluetooth device Link Policy.
385 Link Policy bits are defined in
387 though you can only set bits that the device supports.
389 Set Bluetooth device Packet Types.
390 You can only set packet types that the device supports.
392 Read device statistics.
394 Read device statistics, and zero them.
397 Only the super-user may change device configurations.
409 The Bluetooth Protocol Stack was written for
413 under the sponsorship of Itronix, Inc.