Annotation of wikisrc/guide/bluetooth.mdwn, revision 1.1
1.1 ! jdf 1: # Bluetooth on NetBSD
! 2:
! 3: ## Introduction
! 4:
! 5: Bluetooth is a digital radio protocol used for short range and low power
! 6: communications. NetBSD 4.0 introduced support for the Bluetooth protocol stack,
! 7: and some integration of service profiles into the NetBSD device framework.
! 8:
! 9: The lower layers of the Bluetooth protocol stack pertaining to actual radio
! 10: links between devices are handled inside the Bluetooth Controller, which
! 11: communicates with the Host computer using the *Host Controller Interface* (HCI)
! 12: protocol which can be accessed via a raw packet BTPROTO\_HCI socket interface.
! 13:
! 14: Most of the Bluetooth protocols or services layer atop the *Link Layer Control
! 15: and Adaptation Protocol (L2CAP)*, which can be accessed via a BTPROTO\_L2CAP
! 16: socket interface. This provides sequential packet connections to remote devices,
! 17: with up to 64k channels. When an L2CAP channel is opened, the protocol or
! 18: service that is required is identified by a *Protocol/Service Multiplexer (PSM)*
! 19: value.
! 20:
! 21: Service Discovery in the Bluetooth environment is provided for by the
! 22: [sdp(3)](http://netbsd.gw.com/cgi-bin/man-cgi?sdp+3+NetBSD-5.0.1+i386) library
! 23: functions and the
! 24: [sdpd(8)](http://netbsd.gw.com/cgi-bin/man-cgi?sdpd+8+NetBSD-5.0.1+i386) daemon,
! 25: which keeps a database of locally registered services and makes the information
! 26: available to remote devices performing queries. The
! 27: [sdpquery(1)](http://netbsd.gw.com/cgi-bin/man-cgi?sdpquery+1+NetBSD-5.0.1+i386)
! 28: tool can be used to query local and remote service databases.
! 29:
! 30: Security on Bluetooth links can be enabled by encryption and authentication
! 31: options to
! 32: [btconfig(8)](http://netbsd.gw.com/cgi-bin/man-cgi?btconfig+8+NetBSD-5.0.1+i386)
! 33: which apply to all baseband links that a controller makes, or encryption and
! 34: authentication can be enabled for individual RFCOMM and L2CAP links as required.
! 35: When authentication is requested, a PIN is presented by each side (generally
! 36: entered by the operator, some limited input devices have a fixed PIN). The
! 37: controller uses this PIN to generate a Link Key and reports this to the Host
! 38: which may be asked to produce it to authenticate subsequent connections. On
! 39: NetBSD, the
! 40: [bthcid(8)](http://netbsd.gw.com/cgi-bin/man-cgi?bthcid+8+NetBSD-5.0.1+i386)
! 41: daemon is responsible for storing link keys and responding to Link Key Requests,
! 42: and also provides an interface to allow unprivileged users to specify a PIN with
! 43: a PIN client, such as
! 44: [btpin(1)](http://netbsd.gw.com/cgi-bin/man-cgi?btpin+1+NetBSD-5.0.1+i386).
! 45:
! 46: ## Supported Hardware
! 47:
! 48: Because Bluetooth controllers normally use the standard HCI protocol as
! 49: specified in the *Bluetooth 2.0 Core* documentation to communicate with the
! 50: host, the NetBSD Bluetooth stack is compatible with most controllers, only
! 51: requiring an interface driver, with the following drivers available in NetBSD
! 52: 5.0:
! 53:
! 54: * [bcsp(4)](http://netbsd.gw.com/cgi-bin/man-cgi?bcsp+4+NetBSD-5.0.1+i386)
! 55: provides a
! 56: [tty(4)](http://netbsd.gw.com/cgi-bin/man-cgi?tty+4+NetBSD-5.0.1+i386) line
! 57: discipline to send and receive BlueCore Serial Protocol packets over a serial
! 58: line as described in the *BlueCore Serial Protocol (BCSP)* specification.
! 59: * [bt3c(4)](http://netbsd.gw.com/cgi-bin/man-cgi?bt3c+4+NetBSD-5.0.1+i386)
! 60: provides an interface to the 3Com Bluetooth PC Card, model 3CRWB6096-A.
! 61: * [btbc(4)](http://netbsd.gw.com/cgi-bin/man-cgi?btbc+4+NetBSD-5.0.1+i386)
! 62: provides support for the AnyCom BlueCard (LSE041, LSE039, LSE139) PCMCIA
! 63: devices.
! 64: * [btuart(4)](http://netbsd.gw.com/cgi-bin/man-cgi?btuart+4+NetBSD-5.0.1+i386)
! 65: provides a
! 66: [tty(4)](http://netbsd.gw.com/cgi-bin/man-cgi?tty+4+NetBSD-5.0.1+i386) line
! 67: discipline to send and receive Bluetooth packets over a serial line as
! 68: described in the *Bluetooth Host Controller Interface [Transport Layer]
! 69: specification, Vol 4 part A*.
! 70: * [sbt(4)](http://netbsd.gw.com/cgi-bin/man-cgi?sbt+4+NetBSD-5.0.1+i386)
! 71: provides support for Secure Digital IO Bluetooth adapters.
! 72: * [ubt(4)](http://netbsd.gw.com/cgi-bin/man-cgi?ubt+4+NetBSD-5.0.1+i386)
! 73: interfaces to all USB Bluetooth controllers conforming to the *HCI USB
! 74: Transport Layer* specification.
! 75:
! 76: If support for the NetBSD Bluetooth stack is enabled in the kernel,
! 77: autoconfiguration messages will show up in the
! 78: [dmesg(8)](http://netbsd.gw.com/cgi-bin/man-cgi/man?dmesg+8+NetBSD-current)
! 79: output, for example:
! 80:
! 81: bt3c0 at pcmcia0 function 0: <3COM, 3CRWB60-A, Bluetooth PC Card>
! 82:
! 83: ubt0 at uhub1 port 4 configuration 1 interface 0
! 84: ubt0: Cambridge Silicon Radio Bluetooth USB Adapter, rev 2.00/19.58, addr 4
! 85:
! 86: ubt1 at uhub1 port 2 configuration 1 interface 0
! 87: ubt1: Broadcom Belkin Bluetooth Device, rev 1.10/0.01, addr 5
! 88:
! 89: When support is not already compiled in, it can be added to the kernel
! 90: configuration file for any platform that supports USB and/or PCMCIA (see
! 91: [[Kernel Tuning|guide/tuning]]), using the following declarations, as required:
! 92:
! 93: # Bluetooth Controller and Device support
! 94:
! 95: pseudo-device bcsp # BlueCore Serial Protocol
! 96: pseudo-device btuart # Bluetooth HCI UART
! 97:
! 98: # Bluetooth PCMCIA Controllers
! 99: bt3c* at pcmcia? function ? # 3Com 3CRWB6096-A
! 100: btbc* at pcmcia? function ? # AnyCom BlueCard LSE041/039/139
! 101:
! 102: # Bluetooth SDIO Controllers
! 103: sbt* at sdmmc?
! 104:
! 105: # Bluetooth USB Controllers
! 106: ubt* at uhub? port ?
! 107:
! 108: # Bluetooth Device Hub
! 109: bthub* at bcsp?
! 110: bthub* at bt3c?
! 111: bthub* at btbc?
! 112: bthub* at btuart?
! 113: bthub* at sbt?
! 114: bthub* at ubt?
! 115:
! 116: # Bluetooth HID support
! 117: bthidev* at bthub?
! 118:
! 119: # Bluetooth Mouse
! 120: btms* at bthidev? reportid ?
! 121: wsmouse* at btms? mux 0
! 122:
! 123: # Bluetooth Keyboard
! 124: btkbd* at bthidev? reportid ?
! 125: wskbd* at btkbd? console ? mux 1
! 126:
! 127: # Bluetooth Audio support
! 128: btsco* at bthub?
! 129:
! 130:
! 131: Some older USB Bluetooth dongles based on the Broadcom BCM2033 chip require
! 132: firmware to be loaded before they can function, and these devices will be
! 133: attached to
! 134: [ugen(4)](http://netbsd.gw.com/cgi-bin/man-cgi?ugen+4+NetBSD-5.0.1+i386). Use
! 135: the `sysutils/bcmfw` package from the NetBSD Package Collection, to load
! 136: firmware and enable these.
! 137:
! 138: ## System Configuration
! 139:
! 140: To fully enable Bluetooth services on NetBSD, the following line should be added
! 141: to the `/etc/rc.conf` file.
! 142:
! 143: bluetooth=YES
! 144:
! 145: and either reboot, or execute the following command:
! 146:
! 147: # /etc/rc.d/bluetooth start
! 148:
! 149: *Note*: Configuration of Bluetooth controllers is done with the
! 150: [btconfig(8)](http://netbsd.gw.com/cgi-bin/man-cgi?btconfig+8+NetBSD-5.0.1+i386)
! 151: program, and the above argument enables only basic functionality, see the manual
! 152: page for other useful options.
! 153:
! 154: **Important**:
! 155: [bthcid(8)](http://netbsd.gw.com/cgi-bin/man-cgi?bthcid+8+NetBSD-5.0.1+i386)
! 156: *must* be running in order to make authenticated connections with remote
! 157: devices, and authentication may be requested by either device.
! 158:
! 159: ## Human Interface Devices
! 160:
! 161: Support for *Human Interface Devices (HIDs)*, which operate using the USB HID
! 162: protocol over a pair of L2CAP channels is provided by the
! 163: [bthidev(4)](http://netbsd.gw.com/cgi-bin/man-cgi?bthidev+4+NetBSD-5.0.1+i386)
! 164: driver. Currently, keyboards and mice are catered for, and attach to
! 165: [wscons(4)](http://netbsd.gw.com/cgi-bin/man-cgi?wscons+4+NetBSD-5.0.1+i386) as
! 166: normal.
! 167:
! 168: ### Mice
! 169:
! 170: Bluetooth Mice can be attached to the system with the
! 171: [btms(4)](http://netbsd.gw.com/cgi-bin/man-cgi?btms+4+NetBSD-5.0.1+i386) driver,
! 172: using
! 173: [btdevctl(8)](http://netbsd.gw.com/cgi-bin/man-cgi?btdevctl+8+NetBSD-5.0.1+i386).
! 174:
! 175: First, you must discover the BDADDR of the device. This may be printed on the
! 176: box, but the easiest way is to place the device into discoverable mode and
! 177: perform a device inquiry with the appropriate controller:
! 178:
! 179: # btconfig ubt0 inquiry
! 180: Device Discovery on ubt0 .... 1 response
! 181: 1: bdaddr 00:14:51:c1:b9:2d (unknown)
! 182: : name "Mighty Mouse"
! 183: : class: [0x002580] Peripheral Mouse <Limited Discoverable>
! 184: : page scan rep mode 0x01
! 185: : page scan period mode 0x02
! 186: : page scan mode 0x00
! 187: : clock offset 6944
! 188:
! 189: For ease of use, you may want to add the address to the `/etc/bluetooth/hosts`
! 190: file, so that you can refer to the mouse by alias:
! 191:
! 192: # echo "00:14:51:c1:b9:2d mouse" >>/etc/bluetooth/hosts
! 193:
! 194: Now, you can query the mouse, which will likely request authentication before it
! 195: accepts connections. The fixed PIN should be listed in the documentation, though
! 196: `0000` is often used. Set the PIN first using the
! 197: [btpin(1)](http://netbsd.gw.com/cgi-bin/man-cgi?btpin+1+NetBSD-5.0.1+i386)
! 198: program:
! 199:
! 200: # btpin -d ubt0 -a mouse -p 0000
! 201: # btdevctl -d ubt0 -a mouse -s HID
! 202: local bdaddr: 00:08:1b:8d:ba:6d
! 203: remote bdaddr: 00:14:51:c1:b9:2d
! 204: link mode: auth
! 205: device type: bthidev
! 206: control psm: 0x0011
! 207: interrupt psm: 0x0013
! 208: Collection page=Generic_Desktop usage=Mouse
! 209: Input id=2 size=1 count=1 page=Button usage=Button_1 Variable, logical range 0..1
! 210: Input id=2 size=1 count=1 page=Button usage=Button_2 Variable, logical range 0..1
! 211: Input id=2 size=1 count=1 page=Button usage=Button_3 Variable, logical range 0..1
! 212: Input id=2 size=1 count=1 page=Button usage=Button_4 Variable, logical range 0..1
! 213: Input id=2 size=4 count=1 page=0x0000 usage=0x0000 Const Variable, logical range 0..1
! 214: Collection page=Generic_Desktop usage=Pointer
! 215: Input id=2 size=8 count=1 page=Generic_Desktop usage=X Variable Relative, logical range -127..127
! 216: Input id=2 size=8 count=1 page=Generic_Desktop usage=Y Variable Relative, logical range -127..127
! 217: Input id=2 size=8 count=1 page=Consumer usage=AC_Pan Variable Relative, logical range -127..127
! 218: Input id=2 size=8 count=1 page=Generic_Desktop usage=Wheel Variable Relative, logical range -127..127
! 219: End collection
! 220: Input id=2 size=8 count=1 page=0x00ff usage=0x00c0 Variable, logical range -127..127
! 221: Feature id=71 size=8 count=1 page=0x0006 usage=0x0020 Variable NoPref Volatile, logical range 0..100
! 222: End collection
! 223:
! 224: This tells you that the mouse has responded to an SDP query, and the device
! 225: capabilities are shown. Note that authentication is enabled by default for
! 226: Bluetooth mice. You may now attach to the system:
! 227:
! 228: # btdevctl -d ubt0 -a mouse -s HID -A
! 229:
! 230: which should generate some messages on the system console:
! 231:
! 232: bthidev0 at bthub0 remote-bdaddr 00:14:51:c1:b9:2d link-mode auth
! 233: btms0 at bthidev1 reportid 2: 4 buttons, W and Z dirs.
! 234: wsmouse1 at btms0 mux 0
! 235: bthidev1: reportid 71 not configured
! 236: bthidev1: connected
! 237:
! 238: and the mouse should work.
! 239:
! 240: The device capabilities are cached by
! 241: [btdevctl(8)](http://netbsd.gw.com/cgi-bin/man-cgi?btdevctl+8+NetBSD-5.0.1+i386),
! 242: and to reattach the mouse at system startup, place an entry in
! 243: `/etc/bluetooth/btdevctl.conf`. The
! 244: [bthidev(4)](http://netbsd.gw.com/cgi-bin/man-cgi?bthidev+4+NetBSD-5.0.1+i386)
! 245: driver will attempt to connect once, though mice will usually be sleeping and
! 246: may require a tap on the shoulder to awaken, in which case they should initiate
! 247: the connection to the host computer.
! 248:
! 249: ### Keyboards
! 250:
! 251: Bluetooth Keyboards can be attached to the system with the
! 252: [btkbd(4)](http://netbsd.gw.com/cgi-bin/man-cgi?btkbd+4+NetBSD-5.0.1+i386)
! 253: driver, using
! 254: [btdevctl(8)](http://netbsd.gw.com/cgi-bin/man-cgi?btdevctl+8+NetBSD-5.0.1+i386).
! 255:
! 256: First, you must discover the BDADDR of the device. This may be printed on the
! 257: box, but the easiest way is to place the device into discoverable mode and
! 258: perform a device inquiry with the appropriate controller:
! 259:
! 260: # btconfig ubt0 inquiry
! 261: Device Discovery on ubt0 .... 1 response
! 262: 1: bdaddr 00:0a:95:45:a4:a0 (unknown)
! 263: : name "Apple Wireless Keyboard"
! 264: : class: [0x002540] Peripheral Keyboard <Limited Discoverable>
! 265: : page scan rep mode 0x01
! 266: : page scan period mode 0x00
! 267: : page scan mode 0x00
! 268: : clock offset 18604
! 269:
! 270: For ease of use, you may want to add the address to the `/etc/bluetooth/hosts`
! 271: file, so that you can refer to the keyboard by alias:
! 272:
! 273: # echo "00:0a:95:45:a4:a0 keyboard" >>/etc/bluetooth/hosts
! 274:
! 275: Now, you can query the keyboard, which will likely request authentication before
! 276: it accepts connections. The PIN will need to be entered on the keyboard, and we
! 277: can generate a random PIN, using the
! 278: [btpin(1)](http://netbsd.gw.com/cgi-bin/man-cgi?btpin+1+NetBSD-5.0.1+i386)
! 279: program.
! 280:
! 281: # btpin -d ubt0 -a keyboard -r -l 8
! 282: PIN: 18799632
! 283: # btdevctl -d ubt0 -a keyboard -s HID
! 284:
! 285: < ENTER PIN ON BLUETOOTH KEYBOARD NOW >
! 286:
! 287: local bdaddr: 00:08:1b:8d:ba:6d
! 288: remote bdaddr: 00:0a:95:45:a4:a0
! 289: link mode: encrypt
! 290: device type: bthidev
! 291: control psm: 0x0011
! 292: interrupt psm: 0x0013
! 293: Collection page=Generic_Desktop usage=Keyboard
! 294: Input id=1 size=1 count=1 page=Keyboard usage=Keyboard_LeftControl Variable, logical range 0..1
! 295: Input id=1 size=1 count=1 page=Keyboard usage=Keyboard_LeftShift Variable, logical range 0..1
! 296: Input id=1 size=1 count=1 page=Keyboard usage=Keyboard_LeftAlt Variable, logical range 0..1
! 297: Input id=1 size=1 count=1 page=Keyboard usage=Keyboard_Left_GUI Variable, logical range 0..1
! 298: Input id=1 size=1 count=1 page=Keyboard usage=Keyboard_RightControl Variable, logical range 0..1
! 299: Input id=1 size=1 count=1 page=Keyboard usage=Keyboard_RightShift Variable, logical range 0..1
! 300: Input id=1 size=1 count=1 page=Keyboard usage=Keyboard_RightAlt Variable, logical range 0..1
! 301: Input id=1 size=1 count=1 page=Keyboard usage=Keyboard_Right_GUI Variable, logical range 0..1
! 302: Input id=1 size=8 count=1 page=0x0000 usage=0x0000 Const, logical range 0..1
! 303: Output id=1 size=1 count=1 page=LEDs usage=Num_Lock Variable, logical range 0..1
! 304: Output id=1 size=1 count=1 page=LEDs usage=Caps_Lock Variable, logical range 0..1
! 305: Output id=1 size=1 count=1 page=LEDs usage=Scroll_Lock Variable, logical range 0..1
! 306: Output id=1 size=1 count=1 page=LEDs usage=Compose Variable, logical range 0..1
! 307: Output id=1 size=1 count=1 page=LEDs usage=Kana Variable, logical range 0..1
! 308: Output id=1 size=3 count=1 page=0x0000 usage=0x0000 Const, logical range 0..1
! 309: Input id=1 size=8 count=6 page=Keyboard usage=No_Event, logical range 0..255
! 310: Input id=1 size=1 count=1 page=Consumer usage=Eject Variable Relative, logical range 0..1
! 311: Input id=1 size=1 count=1 page=Consumer usage=Mute Variable Relative, logical range 0..1
! 312: Input id=1 size=1 count=1 page=Consumer usage=Volume_Up Variable, logical range 0..1
! 313: Input id=1 size=1 count=1 page=Consumer usage=Volume_Down Variable, logical range 0..1
! 314: Input id=1 size=1 count=4 page=0x0000 usage=0x0000 Const, logical range 0..1
! 315: End collection
! 316:
! 317:
! 318: This tells you that the keyboard has responded to an SDP query, and the device
! 319: capabilities are shown. Note that encryption is enabled by default, since
! 320: encrypted connection support is mandatory for Bluetooth keyboards. You may now
! 321: attach to the system:
! 322:
! 323: # btdevctl -d ubt0 -a keyboard -s HID -A
! 324:
! 325: which should generate some messages on the system console:
! 326:
! 327: bthidev1 at bthub0 remote-bdaddr 00:0a:95:45:a4:a0 link-mode encrypt
! 328: btkbd0 at bthidev0 reportid 1
! 329: wskbd1 at btkbd0 mux 1
! 330: wskbd1: connecting to wsdisplay0
! 331: bthidev1: connected
! 332:
! 333: and the keyboard should work.
! 334:
! 335: The device capabilities are cached by
! 336: [btdevctl(8)](http://netbsd.gw.com/cgi-bin/man-cgi?btdevctl+8+NetBSD-5.0.1+i386),
! 337: and to reattach the keyboard at system startup, place an entry in
! 338: `/etc/bluetooth/btdevctl.conf`. The
! 339: [bthidev(4)](http://netbsd.gw.com/cgi-bin/man-cgi?bthidev+4+NetBSD-5.0.1+i386)
! 340: driver will attempt to connect once when attached, but if the keyboard is not
! 341: available at that time, you may find that pressing a key will cause it to wake
! 342: up and initiate a connection to the last paired host.
! 343:
! 344: ## Personal Area Networking
! 345:
! 346: Personal Area Networking services over Bluetooth are provided by the
! 347: [btpand(8)](http://netbsd.gw.com/cgi-bin/man-cgi?btpand+8+NetBSD-5.0.1+i386)
! 348: daemon which can assume all roles from the PAN profile and connects remote
! 349: devices to the system through a
! 350: [tap(4)](http://netbsd.gw.com/cgi-bin/man-cgi?tap+4+NetBSD-5.0.1+i386) virtual
! 351: Ethernet interface.
! 352:
! 353: ### Personal Area Networking User
! 354:
! 355: The "Personal Area Networking User" role is the client that accesses Network
! 356: services on another device. For instance, in order to connect to the Internet
! 357: via a smart phone with the NAP profile, make sure that the phone is
! 358: discoverable, then:
! 359:
! 360: # btconfig ubt0 inquiry
! 361: Device Discovery from device: ubt0 .... 1 response
! 362: 1: bdaddr 00:17:83:30:bd:5e (unknown)
! 363: : name "HTC Touch"
! 364: : class: [0x5a020c] Smart Phone <Networking> <Capturing> <Object Transfer>
! 365: <Telephony>
! 366: : page scan rep mode 0x01
! 367: : clock offset 9769
! 368: : rssi -42
! 369:
! 370: # echo "00:17:83:30:bd:5e phone" >>/etc/bluetooth/hosts
! 371:
! 372: You will see that the phone should have the `<Networking>` flag set in the Class
! 373: of Device. Checking for the NAP service:
! 374:
! 375: # sdpquery -a phone search NAP
! 376: ServiceRecordHandle: 0x00010000
! 377: ServiceClassIDList:
! 378: Network Access Point
! 379: ProtocolDescriptorList:
! 380: L2CAP (PSM 0x000f)
! 381: BNEP (v1.0; IPv4, ARP, IPv6)
! 382: LanguageBaseAttributeIDList:
! 383: en.UTF-8 base 0x0100
! 384: BluetoothProfileDescriptorList:
! 385: Network Access Point, v1.0
! 386: ServiceName: "Network Access Point"
! 387: ServiceDescription: "Bluetooth NAP Service"
! 388: SecurityDescription: None
! 389: NetAccessType: 100Mb Ethernet
! 390: MaxNetAccessRate: 100000
! 391:
! 392: reveals that the NAP service is available and that it provides IPv4, ARP and IPv6 protocols.
! 393:
! 394: Most likely, the phone will request authentication before it allows connections
! 395: to the NAP service, so before you make the first connection you may need to
! 396: provide a PIN, which can be randomly generated. Then start
! 397: [btpand(8)](http://netbsd.gw.com/cgi-bin/man-cgi?btpand+8+NetBSD-5.0.1+i386):
! 398:
! 399: # btpin -d ubt0 -a phone -r -l 6
! 400: PIN: 862048
! 401: # btpand -d ubt0 -a phone -s NAP
! 402:
! 403: < ENTER PIN ON PHONE NOW >
! 404:
! 405: Searching for NAP service at 00:17:83:30:bd:5e
! 406: Found PSM 15 for service NAP
! 407: Opening connection to service 0x1116 at 00:17:83:30:bd:5e
! 408: Using interface tap0 with addr 00:10:60:e1:50:3d
! 409:
! 410: Finally, you will need to configure the
! 411: [tap(4)](http://netbsd.gw.com/cgi-bin/man-cgi?tap+4+NetBSD-5.0.1+i386)
! 412: interface, but the phone should have a DHCP server so
! 413: [dhcpcd(8)](http://netbsd.gw.com/cgi-bin/man-cgi?dhcpcd+8+NetBSD-5.0.1+i386)
! 414: will do that for you.
! 415:
! 416: # dhcpcd tap0
! 417:
! 418: Now you can surf the World Wide Web, but watch your data usage unless you have a
! 419: comprehensive data plan.
! 420:
! 421: ## Serial Connections
! 422:
! 423: Serial connections over Bluetooth are provided for by the RFCOMM protocol, which
! 424: provides up to 30 channels multiplexed over a single L2CAP channel. This
! 425: streamed data protocol can be accessed using the BTPROTO\_RFCOMM socket
! 426: interface, or via the
! 427: [rfcomm\_sppd(1)](http://netbsd.gw.com/cgi-bin/man-cgi?rfcomm_sppd+1+NetBSD-5.0.1+i386)
! 428: program.
! 429:
! 430: For instance, you can make a serial connection to the *Dial Up Networking (DUN)*
! 431: service of a mobile phone in order to connect to the Internet with PPP. First
! 432: you should discover the BDADDR of the phone, and add this to your
! 433: `/etc/bluetooth/hosts` for ease of use. Place the phone into Discoverable mode,
! 434: and perform an inquiry from the appropriate controller:
! 435:
! 436: # btconfig ubt0 inquiry
! 437: Device Discovery from device: ubt0 ..... 1 response
! 438: 1: bdaddr 00:16:bc:00:e8:48 (unknown)
! 439: : name "Nokia 6103"
! 440: : class: [0x520204] Cellular Phone <Networking> <Object Transfer> <Telephony>
! 441: : page scan rep mode 0x01
! 442: : page scan period mode 0x02
! 443: : page scan mode 0x00
! 444: : clock offset 30269
! 445:
! 446: # echo "00:16:bc:00:e8:48 phone" >>/etc/bluetooth/hosts
! 447:
! 448: Now, you can query the phone to confirm that it supports the DUN profile:
! 449:
! 450: # sdpquery -d ubt0 -a phone search DUN
! 451: ServiceRecordHandle: 0x00010003
! 452: ServiceClassIDList:
! 453: Dialup Networking
! 454: Generic Networking
! 455: ProtocolDescriptorList:
! 456: L2CAP
! 457: RFCOMM (channel 1)
! 458: BrowseGroupList:
! 459: Public Browse Root
! 460: LanguageBaseAttributeIDList:
! 461: en.UTF-8 base 0x0100
! 462: BluetoothProfileDescriptorList:
! 463: Dialup Networking, v1.0
! 464: ServiceName: "Dial-up networking"
! 465:
! 466: Most likely, the phone will request authentication before it allows connections
! 467: to the DUN service, so before you make the first connection you may need to
! 468: provide a PIN, which can be randomly generated. You can use `rfcomm_sppd` in
! 469: stdio mode to check that the connection is working ok, press `^C` to
! 470: disconnect and return to the shell, for example:
! 471:
! 472: # btpin -d ubt0 -a phone -r -l 6
! 473: PIN: 904046
! 474: # rfcomm_sppd -d ubt0 -a phone -s DUN
! 475:
! 476: < ENTER PIN ON PHONE NOW >
! 477:
! 478: rfcomm_sppd[24635]: Starting on stdio...
! 479: at
! 480: OK
! 481: ati
! 482: Nokia
! 483:
! 484: OK
! 485: ati3
! 486: Nokia 6103
! 487:
! 488: OK
! 489: at&v
! 490: ACTIVE PROFILE:
! 491: E1 Q0 V1 X5 &C1 &D2 &S0 &Y0
! 492: +CMEE=0 +CSTA=129 +CBST=0,0,1 +CRLP=61,61,48,6 +CR=0 +CRC=0 +CLIP=0,2
! 493: +CLIR=0,2 +CSNS=0 +CVHU=1 +DS=0,0,2048,32 +DR=0 +ILRR=0
! 494: +CHSN=0,0,0,0 +CHSR=0 +CPBS="SM"
! 495: S00:000 S01:000 S02:043 S03:013 S04:010 S05:008 S07:060 S08:002
! 496: S10:100 S12:050 S25:000
! 497:
! 498: OK
! 499: ^C
! 500: rfcomm_sppd[24635]: Completed on stdio
! 501:
! 502: To have [pppd(8)](http://netbsd.gw.com/cgi-bin/man-cgi?pppd+8+NetBSD-5.0.1+i386)
! 503: connect to the DUN service of your phone automatically when making outbound
! 504: connections, add the following line to the `/etc/ppp/options` file in place of
! 505: the normal tty declaration:
! 506:
! 507: pty "rfcomm_sppd -d ubt0 -a phone -s DUN -m encrypt"
! 508:
! 509: ## Audio
! 510:
! 511: Isochronous (SCO) Audio connections may be created on a baseband radio link
! 512: using either the BTPROTO\_SCO socket interface, or the
! 513: [btsco(4)](http://netbsd.gw.com/cgi-bin/man-cgi?btsco+4+NetBSD-5.0.1+i386) audio
! 514: device driver. While the specification says that up to three such links can be
! 515: made between devices, the current Bluetooth stack can only handle one with any
! 516: dignity.
! 517:
! 518: **Important**: When using SCO Audio with USB Bluetooth controllers, you will
! 519: need to enable isochronous data, and calculate the MTU that the device will use,
! 520: see [ubt(4)](http://netbsd.gw.com/cgi-bin/man-cgi?ubt+4+NetBSD-5.0.1+i386) and
! 521: [btconfig(8)](http://netbsd.gw.com/cgi-bin/man-cgi?btconfig+8+NetBSD-5.0.1+i386).
! 522:
! 523: *Note*: SCO Audio does not work properly with the
! 524: [bt3c(4)](http://netbsd.gw.com/cgi-bin/man-cgi?bt3c+4+NetBSD-5.0.1+i386) driver,
! 525: use a USB controller for best results.
! 526:
! 527: *Note*: SCO Audio will not work with
! 528: [ehci(4)](http://netbsd.gw.com/cgi-bin/man-cgi?ehci+4+NetBSD-5.0.1+i386) USB
! 529: controllers, since support for Isochronous data over EHCI is missing in NetBSD.
! 530:
! 531: ### SCO Audio Headsets
! 532:
! 533: Audio connections to Bluetooth Headsets are possible using the
! 534: [btsco(4)](http://netbsd.gw.com/cgi-bin/man-cgi?btsco+4+NetBSD-5.0.1+i386) audio
! 535: driver, and the
! 536: [bthset(1)](http://netbsd.gw.com/cgi-bin/man-cgi?bthset+1+NetBSD-5.0.1+i386)
! 537: program. First, you need to discover the BDADDR of the headset, and will
! 538: probably wish to make an alias in your `/etc/bluetooth/hosts` file for ease of
! 539: use. Place the headset into discoverable mode and perform an inquiry with the
! 540: appropriate controller:
! 541:
! 542: # btconfig ubt0 inquiry
! 543: Device Discovery from device: ubt0 ..... 1 response
! 544: 1: bdaddr 00:07:a4:23:10:83 (unknown)
! 545: : name "JABRA 250"
! 546: : class: [0x200404] Wearable Headset <Audio>
! 547: : page scan rep mode 0x01
! 548: : page scan period mode 0x00
! 549: : page scan mode 0x00
! 550: : clock offset 147
! 551:
! 552: # echo "00:07:a4:23:10:83 headset" >>/etc/bluetooth/hosts
! 553:
! 554: You will need to pair with the headset the first time you connect, the fixed PIN
! 555: should be listed in the manual (often, `0000` is used).
! 556: [btdevctl(8)](http://netbsd.gw.com/cgi-bin/man-cgi?btdevctl+8+NetBSD-5.0.1+i386)
! 557: will query the device and attach the
! 558: [btsco(4)](http://netbsd.gw.com/cgi-bin/man-cgi?btsco+4+NetBSD-5.0.1+i386) audio
! 559: driver.
! 560:
! 561: # btpin -d ubt0 -a headset -p 0000
! 562: # btdevctl -d ubt0 -a headset -s HSET -A
! 563: local bdaddr: 00:08:1b:8d:ba:6d
! 564: remote bdaddr: 00:07:a4:23:10:83
! 565: link mode: none
! 566: device type: btsco
! 567: mode: connect
! 568: channel: 1
! 569:
! 570: which should generate some messages on the system console:
! 571:
! 572: btsco0 at bthub0 remote-bdaddr 00:07:a4:23:10:83 channel 1
! 573: audio1 at btsco0: full duplex
! 574:
! 575: In order to use the audio device, you will need to open a control connection
! 576: with
! 577: [bthset(1)](http://netbsd.gw.com/cgi-bin/man-cgi?bthset+1+NetBSD-5.0.1+i386)
! 578: which conveys volume information to the mixer device.
! 579:
! 580: # bthset -m /dev/mixer1 -v
! 581: Headset Info:
! 582: mixer: /dev/mixer1
! 583: laddr: 00:08:1b:8d:ba:6d
! 584: raddr: 00:07:a4:23:10:83
! 585: channel: 1
! 586: vgs.dev: 0, vgm.dev: 1
! 587:
! 588: and you should now be able to transfer 8khz samples to and from `/dev/audio1`
! 589: using any program that supports audio, such as
! 590: [audioplay(1)](http://netbsd.gw.com/cgi-bin/man-cgi?audioplay+1+NetBSD-5.0.1+i386)
! 591: or
! 592: [audiorecord(1)](http://netbsd.gw.com/cgi-bin/man-cgi?audiorecord+1+NetBSD-5.0.1+i386).
! 593: Adjusting the mixer values should work when playing though you may find that
! 594: when opening a connection, the headset will reset the volume to the last known
! 595: settings.
! 596:
! 597: # audiorecord -d /dev/audio1 voice.au
! 598: < TALK NONSENSE NOW >
! 599: ^C
! 600: # audioplay -d /dev/audio voice.au
! 601: < THATS REALLY WHAT YOU SOUND LIKE >
! 602: # audioplay -d /dev/audio1 voice.au
! 603: < IN THE HEADSET >
! 604:
! 605: The device capabilities are cached by
! 606: [btdevctl(8)](http://netbsd.gw.com/cgi-bin/man-cgi?btdevctl+8+NetBSD-5.0.1+i386),
! 607: and to reattach the
! 608: [btsco(4)](http://netbsd.gw.com/cgi-bin/man-cgi?btsco+4+NetBSD-5.0.1+i386)
! 609: driver at system startup, add an entry to `/etc/bluetooth/btdevctl.conf`.
! 610:
! 611: ### SCO Audio Handsfree
! 612:
! 613: Audio connections to Bluetooth mobile phones using the Handsfree profile are
! 614: possible with the `comms/bthfp` program from the NetBSD Package Collection.
! 615:
! 616: First, you need to discover the BDADDR of the phone, and will probably wish to
! 617: make an alias in your `/etc/bluetooth/hosts` file for ease of use. Place the
! 618: phone into discoverable mode and perform an inquiry with the appropriate
! 619: controller:
! 620:
! 621: # btconfig ubt0 inquiry
! 622: Device Discovery from device: ubt0 ..... 1 response
! 623: 1: bdaddr 00:16:bc:00:e8:48 (unknown)
! 624: : name "Nokia 6103"
! 625: : class: [0x520204] Cellular Phone <Networking;gt; <Object Transfer;gt; <Telephony;gt;
! 626: : page scan rep mode 0x01
! 627: : page scan period mode 0x02
! 628: : page scan mode 0x00
! 629: : clock offset 10131
! 630:
! 631: # echo "00:16:bc:00:e8:48 phone" >>/etc/bluetooth/hosts
! 632:
! 633: Now, you should be able to query the phone to confirm that it supports the
! 634: Handsfree profile:
! 635:
! 636: # sdpquery -d ubt0 -a phone search HF
! 637: ServiceRecordHandle: 0x00010006
! 638: ServiceClassIDList:
! 639: Handsfree Audio Gateway
! 640: Generic Audio
! 641: ProtocolDescriptorList:
! 642: L2CAP
! 643: RFCOMM (channel 13)
! 644: BrowseGroupList:
! 645: Public Browse Root
! 646: LanguageBaseAttributeIDList:
! 647: en.UTF-8 base 0x0100
! 648: BluetoothProfileDescriptorList:
! 649: Handsfree, v1.5
! 650: ServiceName: "Voice Gateway"
! 651: Network: Ability to reject a call
! 652: SupportedFeatures:
! 653: 3 Way Calling
! 654: Echo Cancellation/Noise Reduction
! 655: Voice Recognition
! 656: In-band Ring Tone
! 657:
! 658: and you will be able to use the bthfp program to access the Handsfree profile.
! 659: The first time you connect, you may need to use a PIN to pair with the phone,
! 660: which can be generated randomly by
! 661: [btpin(1)](http://netbsd.gw.com/cgi-bin/man-cgi?btpin+1+NetBSD-5.0.1+i386):
! 662:
! 663: # btpin -d ubt0 -a phone -r -l 6
! 664: PIN: 349163
! 665: # bthfp -d ubt0 -a phone -v
! 666:
! 667: < ENTER PIN ON PHONE NOW >
! 668: Handsfree channel: 13
! 669: Press ? for commands
! 670: Connecting.. ok
! 671: < AT+BRSF=20
! 672: > +BRSF: 47
! 673: Features: [0x002f] <3 way calling> <EC/NR> <Voice Recognition> <In-band ringtone> <reject ability>
! 674: > OK
! 675: < AT+CIND=?
! 676: > +CIND: ("call",(0,1)),("service",(0,1)),("call_setup",(0-3)),("callsetup",(0-3))
! 677: > OK
! 678: < AT+CIND?
! 679: > +CIND: 0,1,0,0
! 680: > OK
! 681: < AT+CMER=3,0,0,1
! 682: > OK
! 683: < AT+CLIP=1
! 684: > OK
! 685: Service Level established
! 686:
! 687: When the phone rings, just press `a` to answer, and audio should be routed
! 688: through the `/dev/audio` device. Note that you will need a microphone connected
! 689: in order to speak to the remote party.
! 690:
! 691: ## Object Exchange
! 692:
! 693: NetBSD does not currently have any native OBEX capability, see the
! 694: `comms/obexapp` or `comms/obexftp` packages from the NetBSD Package Collection.
! 695:
! 696: ## Troubleshooting
! 697:
! 698: When nothing seems to be happening, it may be useful to try the hcidump program
! 699: from the `sysutils/netbt-hcidump` package in the NetBSD Package Collection. This
! 700: has the capability to dump packets entering and leaving Bluetooth controllers on
! 701: NetBSD, which is greatly helpful in pinpointing problems.
! 702:
CVSweb for NetBSD wikisrc <wikimaster@NetBSD.org> software: FreeBSD-CVSweb