Use Bluetooth in the Android command line and Bluetooth in the android command line

Source: Internet
Author: User

Use Bluetooth in the Android command line and Bluetooth in the android command line

Note: This part only applies to broadcom series bluetooth chips, such as RK903 and AP6xxx Series

Switch to the root user using the su command

1. confirm that the RFKILL driver has been loaded.

Ls/sys/class/rfkill/rfkill0/

If the rfkill0 directory is not found, the Bluetooth driver is faulty.

Check whether the Bluetooth option in the kernel is checked.

Check the information starting with "[BT_RFKILL]" in the print information of the kernel.

2. Disable Bluetooth:

A. Disable Bluetooth on the Settings page.

B. Power off the bluetooth device:

Echo 0>/sys/class/rfkill/rfkill0/state

C. Disable the initthd and hciattach services:

Setprop ctl. stop restart thd

Setprop ctl. stop hciattach

D. For Android4.2, you also need to disable the com. android. bluetooth process.

Busybox killall com. android. bluetooth

3. After confirming that Bluetooth is disabled, manually power on the bluetooth device:

Echo 1>/sys/class/rfkill/rfkill0/state

4. Download the Bluetooth firmware.

Broadcomd chips use the following command:

RK30:

Brcm_patchram_plus -- patchram bychip -- baudrate 1500000 -- enable_lpm -- enable_hci/dev/ttyS0-d &

RK29:

Brcm_patchram_plus -- patchram bychip -- baudrate 1500000 -- enable_lpm -- enable_hci/dev/ttyS2-d &

If there is no problem with the Bluetooth hardware and driver, you can see the print after this step is completed:

E/effecth_brcm (402): Done setting line discpline

If this line of printing does not appear, it indicates that there is a problem with the Bluetooth hardware or software.

Realtek RTL8723AS command:

/System/bin/hciattach-n-s 115200/dev/ttyS0 rtk_h5

5. confirm that the hci0 interface has been created:

# Hciconfig-

Hci0: Type: BR/EDR Bus: UART

BD Address: 20: 00: 00: 00: 01: 09 acl mtu: 1021:7 sco mtu: 64: 1

DOWN

RX bytes: 485 acl: 0 sco: 0 events: 18 errors: 0

TX bytes: 95 acl: 0 sco: 0 commands: 18 errors: 0

Features: 0xff 0xff 0x8f 0xfe 0x9b 0xff 0x79 0x87

Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3

Link policy: RSWITCH HOLD SNIFF PARK

Link mode: SLAVE ACCEPT

6. Activate Bluetooth

# Hciconfig hci0 up

7. Confirm that Bluetooth is activated successfully.

# Hcitool dev

Devices:

Hci0 20: 00: 00: 00: 01: 09

8. After Bluetooth is activated, you can start scanning the surrounding Bluetooth devices.

# Hcitool scan

Scanning...

90: C1: 15: 0F: C2: 78 Xperia neo


Others:

1. Open detection, allowing peripheral devices to detect

# Hciconfig hciX piscan

2. Connect to Bluetooth

# Hcitool cc A0: E9: DB: 26: 36: 98

3. pairing

# Hcitool auth A0: E9: DB: 26: 36: 98


Conclusion: The principle is to disable bluedroid, enable BlueZ, and then use the hciconfig/hcitool Based on BluZ to perform a simple test. these tools are used to conduct post-matching experiments, but they are not functional. In fact, this step can basically ensure that the local Bluetooth device works properly,

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.