wiki:HowTo/Bluetooth/UsingCL

Version 4 (modified by harisk, 17 years ago) ( diff )

Using Bluetooth from the command line

pand

The daemon responsible for Personal Area Networks. Example:

Set infrastructure mode: node1-1 as the master and node1-2 as the slave:

node1-1:~# pand --listen -role NAP --master --autozap
node1-1:~# ifconfig bnep0 192.168.1.1
node1-1:~# ping 192.168.1.2
PING 192.168.1.2 (192.168.1.2): 56 data bytes
64 bytes from 192.168.1.2: icmp_seq=0 ttl=64 time=53.0 ms
node1-2:~# pand --connect 00:0A:3A:53:D4:82 --service NAP --autozap
node1-2:~# ifconfig bnep0 192.168.1.2
node1-2:~# ping 192.168.1.1
PING 192.168.1.1 (192.168.1.1): 56 data bytes
64 bytes from 192.168.1.1: icmp_seq=0 ttl=64 time=74.9 ms
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=39.6 ms

Useful link:

http://bluez.sourceforge.net/contrib/HOWTO-PAN

hciconfig and hcitool

hciconfig returns current status of the device or configures it:

root@node1-1:~# hciconfig hci0
hci0:   Type: USB
        BD Address: 00:0A:3A:59:9A:34 ACL MTU: 192:8 SCO MTU: 64:8
        UP RUNNING PSCAN 
        RX bytes:409 acl:0 sco:0 events:18 errors:0
        TX bytes:316 acl:0 sco:0 commands:17 errors:0

hcitool configures Bluetooth connections. For instance, to test link quality, RSSI, and transmit power used by the device 00:0A:3A:59:9A:34 on node1-1:

root@node1-2:~# hcitool lq 00:0A:3A:59:9A:34
Link quality: 255
root@node1-2:~# hcitool rssi 00:0A:3A:59:9A:34
RSSI return value: 5
root@node1-2:~# hcitool tpl 00:0A:3A:59:9A:34
Current transmit power level: -12

Interface settings are described in file:

/etc/bluetooth/hcid.conf

rfcomm

The device is treated as a serial port and this utility enables to connect devices, i.e. stuff like

  • set channel
  • bind to a particular MAC address

Affects file:

/etc/bluetooth/rfcomm.conf

Example:

The device on node1-2 has MAC address 00:0A:3A:53:D4:CD

node1-2:~# rfcomm -i hci0 listen 0 1 
Waiting for connection on channel 1
Connection from 00:0A:3A:53:D4:82 to /dev/rfcomm0
Press CTRL-C for hangup
node1-1:~# rfcomm -i hci0 connect 0 00:0A:3A:53:D4:CD 1
Connected /dev/rfcomm0 to 00:0A:3A:53:D4:CD on channel 1
Press CTRL-C for hangup

sdpd and sdptool

To Do.

Note: See TracWiki for help on using the wiki.