Android 蓝牙AVRCP功能的实现_第1页
Android 蓝牙AVRCP功能的实现_第2页
Android 蓝牙AVRCP功能的实现_第3页
Android 蓝牙AVRCP功能的实现_第4页
Android 蓝牙AVRCP功能的实现_第5页
已阅读5页,还剩11页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、Android 蓝牙AVRCP功能的实现作者:Macro LiuAVRCP的按按键定义:sdkemmulatoorkeyymapsAVRCPP.klkey 2000 MEEDIA_PPLAY_PPAUSE WAAKEkey 2011 MEEDIA_PPLAY_PPAUSE WAAKEkey 1666 MEEDIA_SSTOP WAAKEkey 1633 MEEDIA_NNEXT WAAKEkey 1655 MEEDIA_PPREVIOOUS WAAKEkey 1688 MEEDIA_RREWINDD WAAKEkey 2088 MEEDIA_FFAST_FFORWARRD WAAKEBCM(b

2、rooadcomm)宏定义需要打打开:BOARD_HHAVE_BBLUETOOOTH_BBCM := trueeBT音频控制的的代码externaalbluuetootthbluuezauudioccontrool.c(1) 按键的的MAPstatic strucct const char *namee;uint8_t avrrcp;uint166_t uiinput; key_mmap = PLAAY,PLAY_OP,KEY_PPLAYCDD , STOOP,STOP_OP,KEY_SSTOPCDD , PAUUSE,PAUSEE_OP,KEY_PPAUSECCD , FORRWARD,FO

3、RWAARD_OPP,KEY_NNEXTSOONG , BACCKWARDD,BACKWWARD_OOP,KEY_PPREVIOOUSSONNG , REWWIND,REWINND_OP,KEY_RREWINDD , FASST FORRWARD,FAST_FORWAARD_OPP,KEY_FFASTFOORWARDD , NULLL ;(2) 按键处处理static void handlle_pannel_paassthrrough(strucct conntrol *conttrol, for (ii = 0; key_mapii.namme != NULL; i+) uint88_t k

4、eey_quiirks;if (operaands00 & 00 x7F) != key_mapii.avrrcp)conttinue;DBG(AVRCPP: %s %s, key_e, staatus);key_qquirkss = coontroll-keyy_quirrkskeey_mappi.aavrcp;if (kkey_quuirks & QUIIRK_NOO_RELEEASE) if (!presssed) DBGG(AVRRCP: IIgnoriing reeleasee);breeak;DBG(AVRCCP: trreatinng keyy presss

5、as presss + reeleasee);sendd_key(contrrol-uuinputt, keyy_mapi.uiinput, 1);sendd_key(contrrol-uuinputt, keyy_mapi.uiinput, 0);breaak;send_key(ccontrool-uiinput, key_mapii.uinnput, presssed);breakk;HCIDUMPP数据分析以Sony耳机机DRC-BBT15为例例#adb shhell#hcidummp X左键: ACL ddata: handlle 12 flagss 0 x022 dlenn 12 L

6、2CCAP(d): cidd 0 x00042 leen 8 psm 00 00000: 30 111 0e 000 48 7c 4c 00 0.H|L. HCI CCommannd: Exxit Snniff MMode (0 x02|0 x00004) pllen 2 0000: 0c 00 . HCI EEvent: Max Slotss Channge (00 x1b) plen 3 0000: 0c 00 05 . HCI EEvent: Modee Channge (00 x14) plen 6 0000: 00 00c 00 00 000 00 . HCI EEvent: Com

7、mmand SStatuss (0 x00f) pllen 4 0000: 0c 01 04 088 . ACL ddata: handlle 12 flagss 0 x022 dlenn 12 L2CCAP(d): cidd 0 x00042 leen 8 psm 00 00000: 40 111 0e 000 48 7c cc 00 .H|? HCI EEvent: Numbber off Comppletedd Packkets (0 x13) plenn 5 0000: 01 00c 00 02 000 .播放/暂停: ACL ddata: handlle 12 flagss 0 x0

8、22 dlenn 12 L2CCAP(d): cidd 0 x00042 leen 8 psm 00 00000: 50 111 0e 000 48 7c 4b 00 PP.H|K. ACL ddata: handlle 12 flagss 0 x022 dlenn 12 L2CCAP(d): cidd 0 x00042 leen 8 psm 00 00000: 60 111 0e 000 48 7c cb 00 .H|? HCI EEvent: Numbber off Comppletedd Packkets (0 x13) plenn 5 0000: 01 00c 00 02 000 .右

9、键: ACL ddata: handlle 12 flagss 0 x022 dlenn 12 L2CCAP(d): cidd 0 x00042 leen 8 psm 00 00000: 70 111 0e 000 48 7c 46 00 pp.H|F. ACL ddata: handlle 12 flagss 0 x022 dlenn 12 L2CCAP(d): cidd 0 x00042 leen 8 psm 00 00000: 80 111 0e 000 48 7c c6 00 .H|? HCI EEvent: Numbber off Comppletedd Packkets (0 x1

10、3) plenn 5 0000: 01 00c 00 02 000 . HCI EEvent: Max Slotss Channge (00 x1b) plen 3 0000: 0c 00 01 . HCI EEvent: Modee Channge (00 x14) plen 6 0000: 00 00c 00 02 c8 00 .?然后将conttrol.cc的日志打印出来来:按一次”“播放放/暂停键”:D/ACRVPP ( 237): - handdle_paanel_ppassthhroughh -D/ACRVPP ( 237): opeerandss0 = 46 对应PAAUSE_O

11、OPD/ACRVPP ( 237): keyy_quirrks = 0, prressedd = 1按按键按下D/ACRVPP ( 237): conntrol-uinpput = ffffffffe,ssend_kkey = 201对应应MEDIAA_PLAYY_PAUSSED/ACRVPP ( 237): - handdle_paanel_ppassthhroughh -D/ACRVPP ( 237): opeerandss0 = c6 (= 0 xx46 0 x80 表示按键释释放了)D/ACRVPP ( 237): keyy_quirrks = 0, prressedd = 0按按键释

12、放D/ACRVPP ( 237): conntrol-uinpput = ffffffffe,ssend_kkey = 201 对对应MEDIIA_PLAAY_PAUUSE再按一次”“播播放/暂停键键”:D/ACRVPP ( 237): - handdle_paanel_ppassthhroughh -D/ACRVPP ( 237): opeerandss0 = 44 对应PLLAY_OPPD/ACRVPP ( 237): keyy_quirrks = 0, prressedd = 1 按键按按下D/ACRVPP ( 237): conntrol-uinpput = ffffffffe,sse

13、nd_kkey = 200 对应MEDDIA_PLLAY_PAAUSED/ACRVPP ( 237): - handdle_paanel_ppassthhroughh -D/ACRVPP ( 237): opeerandss0 = c4D/ACRVPP ( 237): keyy_quirrks = 0, prressedd = 0 按键释放放D/ACRVPP ( 237): conntrol-uinpput = ffffffffe,ssend_kkey = 200 对对应MEDIIA_PLAAY_PAUUSEnext keey:D/ACRVPP ( 237): - handdle_paanel

14、_ppassthhroughh -D/ACRVPP ( 237): opeerandss0 = 4b对应应FORWAARD_OPPD/ACRVPP ( 237): keyy_quirrks = 0, prressedd = 1D/ACRVPP ( 237): conntrol-uinpput = ffffffffe,ssend_kkey = 163 对对应MEDIIA_NEXXTD/ACRVPP ( 237): - handdle_paanel_ppassthhroughh -D/ACRVPP ( 237): opeerandss0 = cbD/ACRVPP ( 237): keyy_quir

15、rks = 0, prressedd = 0D/ACRVPP ( 237): conntrol-uinpput = ffffffffe,ssend_kkey = 163prev keey:D/ACRVPP ( 237): - handdle_paanel_ppassthhroughh -D/ACRVPP ( 237): opeerandss0 = 4c 对应BACCKWARDD_OPD/ACRVPP ( 237): keyy_quirrks = 0, prressedd = 1D/ACRVPP ( 237): conntrol-uinpput = ffffffffe,ssend_kkey =

16、165 对对应D/ACRVPP ( 237): - handdle_paanel_ppassthhroughh -D/ACRVPP ( 237): opeerandss0 = ccD/ACRVPP ( 237): keyy_quirrks = 0, prressedd = 0D/ACRVPP ( 237): conntrol-uinpput = ffffffffe,ssend_kkey = 165 MEDIAA_PREVVIOUS从上面可以看到到bluettooth的的协议栈bllueZ是没没有问题的将 frameeworkssbaseelibssuiEEventHHub.cppp的LOGG打

17、开,只能能看到了coontroll.c的日志志,EvenntHub的getEvvent完全全不响应观察所有logg日志发现,openDevice里也没有装载AVRCP.kl初步判断eveent有问题题event分析析:$ adb sshell# cd /pproc/bbus/innput# cat ddeviceescat devvices# cat ddeviceescat devvicesI: Bus=0019 Vendoor=00001 Prooduct=0001 Versiion=00001 参考s3c-keyypad.ccN: Namee=s3cc-keyppad inputt_de

18、v-namee = DEEVICE_NAME;P: Physs=s3c-keyypad/iinput00 inpput_deev-phhys = s3c-keyypad/iinput00;S: Sysffs=/deevicess/virttual/iinput/inputt0 virrtual的的?U: Uniqq=H: Handdlers=eventt0B: EV=33B: KEY=40004400 0I: Bus=0019 Vendoor=00001 Prooduct=0001 Versiion=01100参考vpadd_butttons.ccN: Namee=s3cc-einttkey

19、iinput-namee = pddev-nname, gpioo_keyss_deviice_= s3cc-einttkey,P: Physs=gpioo-keyss/inpuut0 inputt-phyys = gpio-keys/inputt0S: Sysffs=/deevicess/plattform/s3c-einntkey/inputt/inpuut1 为什么这里里是plattform目目录?U: Uniqq=H: Handdlers=eventt1B: EV=33B: KEY=1000000 0 00 0I: Bus=0018 Vendoor=00000

20、Prooduct=0000 Versiion=00000 参考amrii_ts.ccN: Namee=amrri_ts ammri_tss_drivver.naame = amrii_tsP: Physs= 没有有定义S: Sysffs=/deevicess/plattform/s3c24400-i2c.0/ii2c-0/00-00333/inpuut/inpput2 为什么这这里是plaatformm目录?U: Uniqq=H: Handdlers=eventt2B: EV=bbB: KEY=400 00 0 0 0 0 4400008800 400 0 0 100000B: ABS=265

21、00000 0I: Bus=0000 Vendoor=00000 Prooduct=0000 Versiion=00000N: Namee=ecoompasss_dataaP: Physs=S: Sysffs=/deevicess/virttual/iinput/inputt3U: Uniqq=H: Handdlers=eventt3B: EV=99B: ABS=307bff从上面可以看到到,完全没有AVVRCP的eevent。解决办法:Kernel$ make menucconfiggCONFIG_INPUTT_UINPPUT解决后的状况:$ adb sshell# cd /pproc/bb

22、us/innput# cat ddevicees显示增加了一个个eventtI: Bus=0005 Vendoor=00000 Prooduct=0000 Versiion=00000N: Namee=AVRRCPP: Physs=S: Sysffs=/deevicess/virttual/iinput/inputt4U: Uniqq=H: Handdlers=eventt4B: EV=11000077B: KEY=103000 168 0 0 00 0 0B: REL=0看openDeevice的的信息:D/EventtHub( 84): EveentHubb:reaadNotiify nf

23、fd: 877D/EventtHub( 84): Opeening devicce: /ddev/innput/eevent44D/EventtHub( 84): Gettting keys.D/EventtHub( 84): Gettting absollute ccontroollerss.D/EventtHub( 84): keyylayouutFileename = /syystem/usr/kkeylayyout/AAVRCP.kl I/EventtHub( 84): Neww keybboard: deviice-iid=0 x110003 devnaame=AAVRCP prop

24、pName=hw.kkeyboaards.665539.devnaame kkeylayyout=/systtem/ussr/keyylayouut/AVRRCP.kllI/EventtHub( 84): Neww deviice: ppath=/dev/iinput/eventt4 namme=AVRRCP idd=0 x100003 (of 0 xx4) inndex=44 fd=1196 cllassess=0 x1D/EventtHub( 84): Addding ddevicee /devv/inpuut/eveent4 00 x3618800 att 4, iid = 33, cl

25、aasses = 0 x11D/EventtHub( 84): Repportinng devvice oopenedd: id=0 x100003, nname=/dev/iinput/eventt4按键时也可以看看到EvenntHub的的信息了:Log如下:D/ACRVPP ( 236): - handdle_paanel_ppassthhroughh -D/ACRVPP ( 236): opeerandss0 = 46D/ACRVPP ( 236): keyy_quirrks = 0, prressedd = 1D/ACRVPP ( 236): conntrol-uinpput = 14

26、,seend_keey = 2201 conntrol.c发出2001号键,按按键按下了D/EventtHub( 84): /deev/inpput/evvent4 got: t0=9337, t11=5829930, ttype=11, codde=2011, v=11 表示从从eventt4得到2001号键 MMEDIA_PLAY_PAUSEED/EventtHub( 84): ievv.codee=201 keyCoode=855 flaggs=0 x0000000001 errr=0D/EventtHub( 84): /deev/inpput/evvent4 got: t0=9337,

27、 t11=6002241, ttype=00, codde=0, v=0D/AudiooHardwware( 61): AuddioStrreamOuutALSAA:settParammeterss() rooutingg=0D/ACRVPP ( 236): - handdle_paanel_ppassthhroughh -D/ACRVPP ( 236): opeerandss0 = c6D/ACRVPP ( 236): keyy_quirrks = 0, prressedd = 0D/ACRVPP ( 236): conntrol-uinpput = 14,seend_keey = cc9D

28、/EventtHub( 84): /deev/inpput/evvent4 got: t0=9337, t11=6643391, ttype=11, codde=2011, v=00 contrrol.c发发出201号号键,按键释释放了D/EventtHub( 84): ievv.codee=201 keyCoode=855 flaggs=0 x0000000001 errr=0D/EventtHub( 84): /deev/inpput/evvent4 got: t0=9337, t11=6644406, ttype=00, codde=0, v=0D/A2DP ( 61): a2ddp_stoopD/A2DP ( 61): bluuetootth_stoopE/BluettoothEEventLLoop.cc

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论