Chinaunix首页 | 论坛 | 博客
  • 博客访问: 246962
  • 博文数量: 26
  • 博客积分: 1425
  • 博客等级: 上尉
  • 技术积分: 270
  • 用 户 组: 普通用户
  • 注册时间: 2010-09-14 23:54
文章存档

2010年(26)

我的朋友

分类: 嵌入式

2010-09-27 20:54:09


一、Bluez编译配置支持
   
    在BoardConfig.mk中添加:
    BOARD_HAVE_BLUETOOTH := true。
   
二、启动hciattach
 
    BlueZ核心子系统使用hciattach守护进程添加指定的硬件串口驱动。
    修改init.rc来启动hciattach:
    service hciattach /system/bin/hciattch -n -s 115200 /dev/ttyS2 bcm2035 115200
            user bluetooth
            group bluetooth net_bt_admin
            disabled
    
     同时也要启动dbus daemon,因为bluez需要dbus与其它进程通讯的。
 
三、Bluez控制流程
 
     class bluetoothsetting是UI的入口,通过按button scan进入搜索状态,
     applicaton层调用bluetoothdevice, 接着就是bluetoothservice的调用,
     bluetoothservice调用native方法,到此全部的java程序结束了。
     下面的调用都是JNI, cpp实现的。android_server_bluetoothservice.cpp里面实现了native
     方法,最终通过dbus封装,调用 HCID deamon 的function DiscoverDevice。
     Bluetooth的启动流程是:
        1.  打开蓝牙电源,通过rfkill来enable;(system/bluetooth/bluedroid/bluetooth.c)
        2.  启动service hciattch -n -s 115200 /dev/ttyS2 bcm2035 115200;
        3.  检测HCI是否成功(接受HCIDEVUP socket来判断或hciconfig hci0 up);
        4.  hcid deamon start up。
 
 
四、Bluetooth结构
 
    1、JAVA层
       frameworks/base/core/java/android/bluetooth/
       包含了bluetooth的JAVA类。
 
    2、JNI层
       frameworks/base/core/jni/android_bluetooth_开头的文件
       定义了bluez通过JNI到上层的接口。
       frameworks/base/core/jni/android_server_bluetoothservice.cpp
       调用硬件适配层的接口system/bluetooth/bluedroid/bluetooth.c
 
    3、bluez库
       external/bluez/
       这是bluez用户空间的库,开源的bluetooth代码,包括很多协议,生成libbluetooth.so。
 
    4、硬件适配层
       system/bluetooth/bluedroid/bluetooth.c
       包含了对硬件操作的接口
       system/bluetooth/data/*
       一些配置文件,复制到/etc/bluetooth/。
       还有其他一些测试代码和工具。
      
   
 
 
 
 

 
阅读(7474) | 评论(2) | 转发(1) |
给主人留下些什么吧!~~

frogoscar2012-03-01 23:00:47

博主您好,您也研究过freescale的i.MX?
我现在在做Android的bluetooth的porting, 板子是i.MX6 sabre lite。能告知您的联系吗? 我想请教点问题。
我的邮箱是 frogoscar@163.com
enming.xie@utbm.fr

Thank you very much!

2011-10-24 11:14:45

你好,我想请教您一个问题,android现在已经封装了bluetooth api了,但是现在我要实现一个功能需要用到hci_RSSI_read(),但是应该采用什么样的方法去绕过api直接调用hci啊?