分享

How to run Bluez

 joy_chen 2013-07-27
  1. http://www./kernel/bluetooth/how-to-run-BlueZ

    Enable Bluetooth support on the Kernel config as described in the previous section.

  2. Plug in a Bluetooth USB device. If the device is based on the STLC2500, enter the following command to attach the STLC2500 Bluetooth device to USB using HCI:

    target# hciattach /dev/ttyUSB0 stlc2500 115200

    The hciattach tool also loads the firmware required to set up STLC2500-based Bluetooth devices.

    Note: For the Linksys USBBT100 Bluetooth device, the hciattach command is not needed.

  3. Use hciconfig to bring up the associated USB device manually:

    target# hciconfig hci0 up

    The hciconfig command enables the device to handle other Bluetooth devices through its embedded discovery system.

The installed Bluez-utils package provides several useful command line tools. Each of these tools has a help feature, invoked with the -h option.

Some brief examples of using these tools are given below.

hcitool

Use hcitool to configure Bluetooth connections and send special commands to Bluetooth devices. For example, to discover the Bluetooth-enabled devices within range, use the scancommand:

target# hcitool scan

If the Bluetooth system has been configured correctly, hciconfig displays something similar to the following:

target# hcitool scan
Scanning…
00:16:CF:DC:B9:81 Nokia3660
00:15:4B:01:33:C5 BTGPS-321

The number "00:16:CF:DC:B9:81" is the MAC address of the associated Bluetooth device (a mobile Nokia in this instance). The software always uses the MAC address to reference a given device.

l2ping

When a device has been discovered, use l2ping to test the connection. For example, to ping the Nokia device described above, use the following command:

target# l2ping 00:16:CF:DC:B9:81

If Bluetooth is configured correctly, and if the handled device is Bluetooth enabled, l2ping responds with output similar to the following:

target# l2ping 00:16:CF:DC:B9:81
Ping: 00:16:CF:DC:B9:81 from 00:11:B1:07:BE:A7 (data size 44) ... 
4 bytes from 00:16:CF:DC:B9:81 id 0 time 42.71ms 
4 bytes from 00:16:CF:DC:B9:81 id 1 time 35.34ms
........
x sent, x received, 0% loss

sdptool

Another useful Bluetooth tool is sdptool, which provides the interface for performing SDP queries on Bluetooth devices, and administering a local sdpd daemon. sdptool provides a list of the features of the Bluetooth device to be handled. This includes ports, protocol, communication channels, and so forth. Use the browse option to get a general overview of the features of the Bluetooth device referenced by the given MAC address:

target# sdptool browse 00:16:CF:DC:B9:81

If there are no errors, this command produces the following output. The exact details are determined by the configuration of the device being queried.

target# sdptool browse 00:16:CF:DC:B9:81
Inquiring...
Browsing 00:16:CF:DC:B9:81    
Service Name:Fax     
Service RecHandle: 0x10000
Service Class ID List:
"Fax" (0x1111)
"Generic Telephony" (0x1204)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 1 
Profile Descriptor List:
"Fax" (0x1111)
Version: 0x0100
Service Name: Dial-up Networking  
Service RecHandle: 0x10001
Service Class ID List:
"Dialup Networking" (0x1103)
"Generic Networking" (0x1201)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 1
Profile Descriptor List:
"Dialup Networking" (0x1103)
Version: 0x0100
Service Name:Bluetooth Serial Port  
Service RecHandle: 0x10002
Service Class ID List:
"Serial Port" (0x1101)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 2
Language Base Attr List:
code_ISO639: 0x656e
encoding:    0x6a
base_offset: 0x100
Service Name:OBEX Object Push    
Service RecHandle: 0x10003
Service Class ID List:
"OBEX Object Push" (0x1105)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 9
"OBEX" (0x0008)
Profile Descriptor List:
"OBEX Object Push" (0x1105)
Version: 0x0100
Service Name: OBEX File Transfer  
Service RecHandle: 0x10005
Service Class ID List:
"OBEX File Transfer" (0x1106)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 10
"OBEX" (0x0008)
Profile Descriptor List:
"OBEX File Transfer" (0x1106)
Version: 0x0100
......

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多