-
Notifications
You must be signed in to change notification settings - Fork 19
bluetooth
This tutorials provide Bluetooth information for Microchip bluetooth devices.
This tool is used to attach a serial UART to the Bluetooth stack as HCI transport interface.
- usage
hciattach [-n] [-p] [-b] [-t timeout] [-s initial_speed] <tty> <type | id> [speed] [flow|noflow] [bdaddr]
hciattach -l
- options
-b Send break.
-n Don't detach from controlling terminal.
-p Print the PID when detaching.
-t timeout Specify an initialization timeout. (Default is 5 seconds.)
-s speed Specify an initial speed instead of the hardware default.
-l List all available configurations.
-r Set the HCI device into raw mode (the kernel and bluetoothd will ignore it).
tty This specifies the serial device to attach. A leading /dev can be omitted. Examples: /dev/ttyS1 ttyS2
type|id
[TYPE]
type description
any Unspecified HCI_UART interface, no vendor specific options
ericsson Ericsson based modules
digi Digianswer based cards
xircom Xircom PCMCIA cards: Credit Card Adapter and Real Port Adapter
csr CSR Casira serial adapter or BrainBoxes serial dongle (BL642)
bboxes BrainBoxes PCMCIA card (BL620)
swave Silicon Wave kits
bcsp Serial adapters using CSR chips with BCSP serial protocol
[ID]
0x0105, 0x080a Xircom PCMCIA cards: Credit Card Adapter and Real Port Adapter
0x0160, 0x0002 BrainBoxes PCMCIA card (BL620)
speed The speed specifies the UART speed to use. Baudrates higher than 115.200bps require vendor specific initializations that are not implemented for all types of devices. In general the following speeds are supported:
[9600, 19200, 38400, 57600, 115200, 230400, 460800, 921600]
Supported vendor devices are automatically initialised to their respective best settings.
flow If the keyword flow is appended to the list of options then hardware flow control is forced on the serial link ( CRTSCTS ). All above mentioned device types have flow set by default. To force no flow control use noflow instead.
bdaddr The bdaddr specifies the Bluetooth Address to use. Some devices (like the STLC2500) do not store the Bluetooth address in hardware memory. Instead it must be uploaded during the initialization process. If this argument is specified, then the address will be used to initialize the device. Otherwise, a default address will be used.
It is used to configure the Bluetooth devices.
- usage
hciconfig
hciconfig [-a] hciX [command]
- commands
up Open and initialize HCI device
down Close HCI device
reset Reset HCI device
rstat Reset statistic counters
auth Enable Authentication
noauth Disable Authentication
encrypt Enable Encryption
noencrypt Disable Encryption
piscan Enable Page and Inquiry scan
noscan Disable scan
iscan Enable Inquiry scan
pscan Enable Page scan
ptype [type] Get/Set default packet type
lm [mode] Get/Set default link mode
lp [policy] Get/Set default link policy
name [name] Get/Set local name
class [class] Get/Set class of device
voice [voice] Get/Set voice setting
iac [iac] Get/Set inquiry access code
inqtpl [level] Get/Set inquiry transmit power level
inqmode [mode] Get/Set inquiry mode
inqdata [data] Get/Set inquiry data
inqtype [type] Get/Set inquiry scan type
inqparms [win:int] Get/Set inquiry scan window and interval
pageparms [win:int] Get/Set page scan window and interval
pageto [to] Get/Set page timeout
afhmode [mode] Get/Set AFH mode
sspmode [mode] Get/Set Simple Pairing Mode
aclmtu <mtu:pkt> Set ACL MTU and number of packets
scomtu <mtu:pkt> Set SCO MTU and number of packets
putkey <bdaddr> Store link key on the device
delkey <bdaddr> Delete link key from the device
oobdata Display local OOB data
commands Display supported commands
features Display device features
version Display version information
revision Display revision information
Issue the following command without parameters or commands. Each Bluetooth adapter that BlueZ recognizes is displayed with his several information for example, Bluetooth Address, whether Bluetooth is enabled or disabled and whether discoverable or connectable.
# hciconfig
The up and down commands to this tool can be used to enable and disable the Bluetooth adapter.
# hciconfig hci0 up
# hciconfig hci0 down
The inquiry and page scan settings for the Bluetooth adapter determine whether the adapter is detectable and whether connectable, which means it will accept incoming connection requests, respectively.
The following summarizes which commands to use when configuring there two options.
- Inquiry scan: on, Page scan:on --> command: piscan, detectable and connectable
- Inquiry scan: off, Page scan:on --> command: pscan, only connectable
- Inquiry scan: on, Page scan: off --> command: iscan, only detectable
- Inquiry scan: off, Page scan: off --> command: noscan, neither detectable nor connectable
For example, the following disables both inqury and page scan for the Bluetooth adapter.
# hciconfig hci0 noscan
For more information use the help or manpages with the following commands.
# hciconfig -h
# man hciconfig
hcitool is used to configure Bluetooth connections and send some special command to Bluetooth devices. If no command is given, or if the option -h is used, hcitool prints some usage information and exits. This tool has two main uses. The first is to search for and detect nearby Bluetooth devices and the second is to test and show information about low-level Bluetooth connections.
- usage
hcitool [options] <command> [command parameters]
- options
-i dev: HCI device
- commands
dev Display local devices
inq Inquire remote devices
scan Scan for remote devices
name Get name from remote device
info Get information from remote device
spinq Start periodic inquiry
epinq Exit periodic inquiry
cmd Submit arbitrary HCI commands
con Display active connections
cc Create connection to remote device
dc Disconnect from remote device
sr Switch master/slave role
cpt Change connection packet type
rssi Display connection RSSI
lq Display link quality
tpl Display transmit power level
afh Display AFH channel map
lp Set/display link policy settings
lst Set/display link supervision timeout
auth Request authentication
enc Set connection encryption
key Change connection link key
clkoff Read clock offset
clock Read local or remote clock
To scan nearby Bluetooth devices, issue the following command. It will search for Bluetooth devices and display their addresses and user-friendly names.
# hcitool scan
The following shows how to connect to the remote device with the Bluetooth Address, 00:11:22:33:44:55 for instance.
# hcitool cc 00:11:22:33:44:55
hcitool con
can the be used to show information about connecting to the device.
l2ping sends a L2CAP echo request to the Bluetooth MAC address bd_addr given in doted hex notation.
- usage
l2ping [-i device] [-s size] [-c count] [-t timeout] [-d delay] [-f] [-r] [-v] <bdaddr>
-f Flood ping (delay = 0)
-r Reverse ping
-v Verify request and response payload
It's used to analysis Bluetooth HCI packets.
- usage
hcidump [option...] [filter]
- options
-i, --device=hci_dev HCI device
-l, --snap-len=len Snap len (in bytes)
-p, --psm=psm Default PSM
-m, --manufacturer=compid Default manufacturer-ㅗㄷ
-w, --save-dump=file Save dump to a file
-r, --read-dump=file Read dump from a file
-s, --send-dump=host Send dump to a host
-n, --recv-dump=host Receive dump on a host
-d, --wait-dump=host Wait on a host and send
-t, --ts Display time stamps
-a, --ascii Dump data in ascii
-x, --hex Dump data in hex
-X, --ext Dump data in hex and ascii
-R, --raw Dump raw data
-C, --cmtp=psm PSM for CMTP
-H, --hcrp=psm PSM for HCRP
-O, --obex=channel Channel for OBEX
-P, --ppp=channel Channel for PPP
-D, --pppdump=file Extract PPP traffic
-A, --audio=file Extract SCO audio data
-B, --btsnoop Use BTSnoop file format
-V, --verbose Verbose decoding
-Y, --novendor No vendor commands or events
-N, --noappend No appending to existing files
-4, --ipv4 Use IPv4 as transport
-6 --ipv6 Use IPv6 as transport
-h, --help Give this help list
--usage Give a short usage message
The sdptool is to control and interrogate SDP servers. This tool mainly has two uses: searching and browsing the Service Discovery Protocol (SDP) services advertised by remote devices. This is very useful for checking what Bluetooth services are implemented by remote devices. The second is for basic configuration of the SDP services offered by the local adapter.
- usage
sdptool [options] {command} [command parameters ...]
- options and commands
Options:
-h Display help
-i Specify source interface
Commands:
search Search for a service
browse Browse all available services
records Request all records
add Add local service
del Delete local service
get Get local service
setattr Set/Add attribute to a SDP record
setseq Set/Add attribute sequence to a SDP record
sdptool browse [addr]
retrieves a list of services provided by the Bluetooth device with address addr. Specially, the local SDP services are displayed in case the option, [addr] is local.
# sdptool browse local
Browsing FF:FF:FF:00:00:00 ...
Service Name: SIM Access Server
Service RecHandle: 0x10000
Service Class ID List:
"SIM Access" (0x112d)
"Generic Telephony" (0x1204)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 8
Profile Descriptor List:
"SIM Access" (0x112d)
Version: 0x0101
Service Name: Headset Audio Gateway
Service RecHandle: 0x10001
Service Class ID List:
"Headset Audio Gateway" (0x1112)
"Generic Audio" (0x1203)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 12
Profile Descriptor List:
"Headset" (0x1108)
Version: 0x0102
Service Name: Hands-Free Audio Gateway
Service RecHandle: 0x10002
Service Class ID List:
"Handsfree Audio Gateway" (0x111f)
"Generic Audio" (0x1203)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 13
Profile Descriptor List:
"Handsfree" (0x111e)
Version: 0x0105
The following shows how to browse SDP from the remote with Bluetooth Address, 70:F3:95:26:0D:B5 for example.
# sdptool browse 70:F3:95:26:0D:B5
Browsing 70:F3:95:26:0D:B5 ...
Service Name: SIM Access Server
Service RecHandle: 0x10000
Service Class ID List:
"SIM Access" (0x112d)
"Generic Telephony" (0x1204)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 8
Profile Descriptor List:
"SIM Access" (0x112d)
Version: 0x0101
Service Name: Headset Audio Gateway
Service RecHandle: 0x10001
Service Class ID List:
"Headset Audio Gateway" (0x1112)
"Generic Audio" (0x1203)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 12
Profile Descriptor List:
"Headset" (0x1108)
Version: 0x0102
Service Name: Hands-Free Audio Gateway
Service RecHandle: 0x10002
Service Class ID List:
"Handsfree Audio Gateway" (0x111f)
"Generic Audio" (0x1203)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 13
Profile Descriptor List:
"Handsfree" (0x111e)
Version: 0x0105
sdptool search
can be used to search nearby devices for a specific service. The service to search for can be specified either as a UUID or as a string. The following shows how to search Serial Port(SP) with the string and UUID.
sdptool search SP
sdptool search 0x1101
sdptool add <name>
can be used to advertise a set of predefined services, which are standardized Bluetooth profiles.. It can not be used to add an arbitrary service which BlueZ doesn't define.
sdptool del <handle>
deletes service record with the handle. For example, the service record with the handle, 0x100000 can be deleted from the SDP server and not advertised anymore.
sdptool del 0x10000
The baud rate can be adjusted with the vendor specific command provided by Atmel wilc3000. In addition, enabling and disabling the flow control is done by issuing the vendor specific command as well.
This chapter introduces how to change the baud rate and also control flow control.
Download the wilc3000 firmware by issuing the following command:
git clone https://github.com/linux4wilc/firmware.git
The default baud rate of bt_firmware.bin is 115200 without flow control packaged in the release package. Users may want to change the baud rate and flow control. The following shows how to change them using vendor specific HCI command in Linux platform, for example, SAMA5D3 Xplained board.
- Changing baud rate to 921600 without flow control
The size of parameters are 5 bytes. The fist 4 bytes are baud rate and 1 byte is for flow control. The hexadecimal value of 921600 is 0xE1000 and we send LSB first, so 00 10 0E 00 are correct byte order. Set last 1 byte to 00 for no flow control.
# hciattach ttyS3 any 115200 noflow
# hciconfig hci0 up
# hcitool cmd 0x3F 0x0053 00 10 0E 00 00
# stty -F /dev/ttyS3 921600
# stty -F /dev/ttyS3 –a
- Changing baud rate to 921600 with flow control
Same as above except that set flow control to 1.
# hciattach ttyS3 any 115200 noflow
# hciconfig hci0 up
# hcitool cmd 0x3F 0x0053 00 10 0E 00 01
# stty -F /dev/ttyS3 921600 crtscts
# stty -F /dev/ttyS3 –a
If the BD address is not stored on the BT controller's side, the host can change BD address using vendor specific commands. For instance, 11:22:33:44:55:66 is the BD address you want, do the following commands.
# hciattach ttyS3 any 115200 noflow
# hciconfig hci0 up
# hcitool cmd 0x3F 0x0054 66 55 44 33 22 11
# hcitool cmd 0x03 0x0003
# hciconfig hci0 down
# hciconfig hci0 up
# hciconfig -a