User Tools

Site Tools


Sidebar

Launch of Linino.org

wiki:lininobluetooth

How to configure a Bluetooth with CSR usb dongle

Bluetooth is a wireless technology standard for exchanging data over short distances (using short-wavelength UHF radio waves in the ISM band from 2.4 to 2.485 GHz). Linux distributions using the Linux kernel 2.4.6 and later implement the Open Source bluetooth stack BlueZ.

Bluez is the Bluetooth stack for Linux kernel-based family of operating systems. Its goal is to program an implementation of the Bluetooth wireless standards specifications for Linux. In addition to the basic stack, the bluez-utils and bluez-firmware packages contain low level utilities such as dfutool which can interrogate the Bluetooth adapter chipset to determine whether its firmware can be upgraded.

The CSR family USB dongle supported by BlueZ stack and by LininoOS distribution.

In this HOW-to will configure Bluetooth CSR family USB Dongle in order to allow the bluetooth 4.0 LE (low energy) technology on Linino board. In detail, it was used the Bluetooth CSR family USB Dongle based on CSR8510 chip. The CSR8510 is a fully qualified Bluetooth v3.0 system that will also offer support for Bluetooth v4.0. It has a full-speed USB 2.0 interface and allows PC, netbook and notebook designers to develop products with the latest in both high-speed and low energy technology.

Installation

Space needed: ~1.3 MB

opkg update
opkg install kmod-bluetooth bluez-libs bluez-utils kmod-usb-core kmod-usb-uhci kmod-usb2 usbutils

Configuration

bluez-tools automatically installs dbus as dependency package but it is not enabled by default in order to have benefits of dbus you need to enable both dbus and bluez-utils services to start on boot:

/etc/init.d/dbus enable
/etc/init.d/bluez-utils enable
/etc/init.d/dbus start
/etc/init.d/bluez-utils start

Restart the LininoOS.

Use BlueZ

There are few basic commands to test if you bluetooth device is properly detected and working ok.

Print name and basic information about all the Bluetooth devices installed in the system:

hciconfig -a

The result should be:

root@linino:~# hciconfig -a
hci0:	Type: USB
	BD Address: 00:1A:7D:DA:71:05 ACL MTU: 310:10 SCO MTU: 64:8
	**UP RUNNING PSCAN ISCAN** 
	RX bytes:6971 acl:10 sco:0 events:172 errors:0
	TX bytes:1283 acl:8 sco:0 commands:97 errors:0
	Features: 0xff 0xff 0x8f 0xfe 0xdb 0xff 0x5b 0x87
	Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3 
	Link policy: RSWITCH HOLD SNIFF PARK 
	Link mode: SLAVE ACCEPT 
	Name: 'linino'
	Class: 0x000100
	Service Classes: Unspecified
	Device Class: Computer, Uncategorized
	HCI Ver:  (0x6) HCI Rev: 0x22bb LMP Ver:  (0x6) LMP Subver: 0x22bb

If the device were to be down, you have to take it up with this command:

hciconfig hci0 up

If the command returns error trying to disconnect and re-insert the USB dongle, and retry the command.

To scan for remote devices:

hcitool scan

To ping the devices discoverad identified:

l2ping <bdaddr>

To provides a list of the features of the Bluetooth devices to be handled; this includes ports, protocol, communication channels, and so forth.

sdptool browse 

to configure the behavior of Linino bluetooth, you have to edit the configuration file: /etc/bluetooth/hcid.conf

#
# HCI daemon configuration file.
#
 
# HCId options
options {
	# Automatically initialize new devices
	autoinit yes;
 
	# Security Manager mode
	#   none - Security manager disabled
	#   auto - Use local PIN for incoming connections
	#   user - Always ask user for a PIN
	#
	security auto;
 
	# Pairing mode
	#   none  - Pairing disabled
	#   multi - Allow pairing with already paired devices
	#   once  - Pair once and deny successive attempts
	pairing multi;
 
	# Default PIN code for incoming connections
	passkey "BlueZ";
}
 
# Default settings for HCI devices
device {
	# Local device name
	#   %d - device id
	#   %h - host name
	name "%h";
 
	# Local device class
	class 0x000100;
 
	# Default packet type
	#pkt_type DH1,DM1,HV1;
 
	# Inquiry and Page scan
	iscan enable; pscan enable;
 
	# Default link mode
	#   none   - no specific policy 
	#   accept - always accept incoming connections
	#   master - become master on incoming connections,
	#            deny role switch on outgoing connections
	lm accept;
 
	# Default link policy
	#   none    - no specific policy
	#   rswitch - allow role switch
	#   hold    - allow hold mode
	#   sniff   - allow sniff mode
	#   park    - allow park mode
	lp rswitch,hold,sniff,park;
}

To attach a serial UART to the Bluetooth stack as HCI transport interface, you use:

hciattach /dev/ttyX csr 115200

Troubleshooting and issues

If bluetooth device doesn't inicialize correctly and doesn't show up while running hcitool dev command try reinitializing bluetooth stack:

hciconfig hci0 reset
hciconfig hci0 up
/etc/init.d/bluez-utils restart
/var/www/wiki.linino.org/data/pages/wiki/lininobluetooth.txt · Last modified: 2014/10/31 07:39 by adriano

2014 © dog hunter llc and the Linino Community. Linino.org is a dog hunter sponsored community project. Credits