admin管理员组

文章数量:1540701

2024年7月1日发(作者:)

Bluetooth(Android 4.1)问题汇总

1.在查问题之前,需先掌握这些东西:

捕捉 LOG

Kernel 的启动LOG, 在串口中会有输出, 蓝牙的 rfkill-rk 驱动, 其打印以字符

可搜索之;如果你用“adb shell”来查看 log,可先切换到 root 后,用“cat

/proc/kmsg”

打印kernel 的LOG。

Android 中关于蓝牙的 LOG,可通过如下命令打印:

logcat -s blue* Blue* Bt* bt* &

如果你的 Android 的 logcat 命令不支持星号通配符,请修改

system/core/liblog/logprint.c 文件,如下所示:

static android_LogPriority filterPriForTag(

AndroidLogFormat *p_format, const char *tag)

{

FilterInfo *p_curFilter;

for (p_curFilter = p_format->filters;

p_curFilter != NULL;

p_curFilter = p_curFilter->p_next)

{

if ((p_curFilter->mTag[strlen(p_curFilter->mTag)-1] == '*' &&

0 == strncmp(tag, p_curFilter->mTag, strlen(p_curFilter->mTag)-1)) ||

(0 == strcmp(tag, p_curFilter->mTag)))

{

if (p_curFilter->mPri == ANDROID_LOG_DEFAULT) {

return p_format->global_pri;

} else {

return p_curFilter->mPri;

}

}

}

return p_format->global_pri;

}

2.命令行启动蓝牙

通过su 命令切换到root 用户

1、 先确认 RFKILL 驱动已经加载

ls /sys/class/rfkill/rfkill0/

如果没有找到rfkill0 这个目录,说明蓝牙驱动有问题。

请检查kernel中的蓝牙选项是否有勾选了

请查看kernel的打印信息。

2、关闭蓝牙:

A. 在 Settings 界面中关闭蓝牙

B. 给蓝牙设备下电:

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

C. 关闭 bluetoothd 和hciattach 这两个service:

setprop bluetoothd

setprop hciattach

3、确定蓝牙已经关闭之后,手动给蓝牙上电:

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

4、下载蓝牙固件

Broadcomd 系列芯片使用命令:

brcm_patchram_plus --patchram bychip --baudrate 1500000 --enable_lpm

--enable_hci /dev/ttyS0 -d &

如果蓝牙硬件及驱动没有问题,那么在这步执行完成后可以看到打印:

E/bluetooth_brcm( 402): Done setting line discipline

如果没有出现这行打印,说明蓝牙硬件或软件方面存在问题。

Realtek RTL8723AS 使用命令:

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

5、确认 hci0 interface 已经创建:

# hciconfig -a

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、激活蓝牙

# hciconfig hci0 up

7、确认蓝牙激活成功

# hcitool dev

Devices:

hci0 20:00:00:00:01:09

8、 蓝牙激活成功后,可以开始扫描周围的蓝牙设备

# hcitool scan

Scanning ...

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

3. 蓝牙打开失败

可从如下步骤去查:

A. 软件配置是否正确?

先确定是否按第3 节的android, kernel 具体配置。

B. 从命令行启动蓝牙,观察出错的位置

E/bluetooth_brcm( 1615): Cannot open "/data/misc/bluetoothd/bt_addr": No

such file or

directory

D/bluetooth_brcm( 1615): bd_addr: 20:00:00:00:01:0B

D/bluetooth_brcm( 1615): Read default bdaddr of 20:00:00:00:01:0B

D/bluetooth_brcm( 1615): Get hcd file by BT chip!

D/bluetooth_brcm( 1615): hcd file: /system/etc/bluez/

D/bluetooth_brcm( 1615): /dev/ttyS0

--- a 发送 reset 指令 ---

E/bluetooth_brcm( 1615): writing

E/bluetooth_brcm( 1615): 01 03 0c 00

E/bluetooth_brcm( 1615): received 7

E/bluetooth_brcm( 1615): 04 0e 04 01 03 0c 00

E/bluetooth_brcm( 1615): writing

E/bluetooth_brcm( 1615): 01 2e fc 00

E/bluetooth_brcm( 1615): received 7

E/bluetooth_brcm( 1615): 04 0e 04 01 2e fc 00

--- b 读取蓝牙固件的内容并发送给蓝牙芯片 ---

......

--- c 发送 reset 指令 ---

E/bluetooth_brcm( 2072): writing

E/bluetooth_brcm( 2072): 01 03 0c 00

E/bluetooth_brcm( 2072): received 7

E/bluetooth_brcm( 2072): 04 0e 04 01 03 0c 00

--- d 复位完成后,设置波特率 ---

E/bluetooth_brcm( 2072): writing

E/bluetooth_brcm( 2072): 01 18 fc 06 00 00 60 e3 16 00

E/bluetooth_brcm( 2072): received 7

E/bluetooth_brcm( 2072): 04 0e 04 01 18 fc 00

E/bluetooth_brcm( 2072): Done setting baudrate

......

E/bluetooth_brcm( 1615): writing

E/bluetooth_brcm( 1615): 01 27 fc 0c 01 01 01 01 01 01 01 00 00 00 00 00

E/bluetooth_brcm( 1615): received 7

E/bluetooth_brcm( 1615): 04 0e 04 01 27 fc 00

E/bluetooth_brcm( 1615): Done setting line discpline

D/bluetooth_brcm( 1615): total used:3.605s

在a 出错:意味着与蓝牙芯片通过UART 通信失败,可能问题:

蓝牙实际没有上电,IO配置错误

UART接线有问题,UART 的状态不对,可测量UART 的 4个脚

在 b 出错:说明蓝牙芯片上电成功了,但 UART 通信存在问题,应检查 UART

在 c 出错:在RK29+BCM4329 中,由于UART 的 Rx/Tx 没有加上拉,要求在执

reset之前要先读取一个 byte:

read(uart_fd, buffer, 1);

在 d 出错:可能是 BT_WAKE 这个IO 的被设置成了 disable,导致蓝牙挂起,无

通讯;可测量该IO电平。

C. 如果查不出问题,此时应检查晶振的频偏及振幅是否满足要求。

4. 蓝牙设备配对失败

确认32.768k rtc clock 的精度与幅度

晶振:

32.768KHz 晶振,我们的推荐是 从 PMU 引出,RK29其峰峰值: 0.2 ~ 1.8 V

推荐频偏200ppm, 即 32762 ~ 32774,1ppm=1/10^6

如是RK903 模块,要求 26MHz 晶振,其频偏不能偏超过520Hz

5. 文件传输失败

确认文件的类型,是否Android 支持的类型:

如 果 需 要增 加 接 受 文 件 类 型 的 支 持 , 需 要 在

packages/apps/Bluetooth/src/com/android

/bluetooth/opp/ 的 ACCEPTABLE_SHARE_INBOUND_TYPES 数

组里增加相应的 data

style;

public static final String[] ACCEPTABLE_SHARE_INBOUND_TYPES = new String[]

{

"image/*",

"video/*",

"audio/*",

"text/x-vcard",

"text/plain",

"text/html",

"application/zip",

"application/-excel",

"application/msword",

"application/-powerpoint",

"application/pdf",

};

如果需要增加发送文件类型的支持,需要在里增加相应的

style:

本文标签: 蓝牙问题没有打印是否