android bluetooth蓝牙移植,androidbluetooth
前段时间移植神念系统需要使用到bluetooth功能,现将移植过程中碰到的问题简要列一下,备忘而已。
1、内核增加配置
make menuconfig -> Networking support -> Bluetooth subsystem support -->
进行选择BT选项,至少选择如下几项:
CONFIG_BT=y
CONFIG_BT_RFCOMM=y
#
# Bluetooth device drivers
#
CONFIG_BT_HCIBTUSB=y
ONFIG_BT_HCIBFUSB=y
其它的根据平台特性增减
此内核是否配置成功,可以在代码 system\bluetooth\bluedroid下的bluetooth.c文件
中加打印:
init_rfkill() 函数
如果没有配置ok的话则:
snprintf(path, sizeof(path), "/sys/class/rfkill/rfkill%d/type", id);
fd = open(path, O_RDONLY);
if (fd < 0) {
LOGW("open(%s) failed: %s (%d)\n", path, strerror(errno), errno);
return -1;
}
会打开文件失败的。
2、android系统配置
build\target\board\generic下面的generic.mk增加:
BOARD_HAVE_BLUETOOTH := true
这个是由于编译相关蓝牙代码时需要这个宏,请看:\system\bluetooth\android.mk
ifeq ($(BOARD_HAVE_BLUETOOTH),true)
include $(all-subdir-makefiles)
endif
在 external\bluetooth 也同样存在此宏起作用
3、启动项修改 init.rc
system\core\rootdir下init.rc文件增加:
service hciattach /system/bin/hciattach -n -s 115200 /dev/ttyS2 bcm2035 115200
user bluetooth
group bluetooth net_bt_admin
disabled
oneshot
<