Bluetooth 解释AVRCP数据包

Bluetooth 解释AVRCP数据包,bluetooth,pybluez,avrcp,l2cap,Bluetooth,Pybluez,Avrcp,L2cap,经过一些研究,我得到了一个pybluez脚本,可以连接到各种设备上的AVRCP配置文件,并读取响应 代码段: addr="e2:8b:8e:89:6c:07" #S530 white port=23 if (port>0): print("Attempting to connect to L2CAP port ",port) socket=bluetooth.BluetoothSocket(bluetooth.L2CAP); socket.connect((add

经过一些研究,我得到了一个pybluez脚本,可以连接到各种设备上的AVRCP配置文件,并读取响应

代码段:

addr="e2:8b:8e:89:6c:07"  #S530 white
port=23
if (port>0):
    print("Attempting to connect to L2CAP port ",port)
    socket=bluetooth.BluetoothSocket(bluetooth.L2CAP);
    socket.connect((addr,port))
    print("Connected.")
    while True:
      print("Waiting on read:")
      data=socket.recv(1024)
      for b in data:
         print("%02x"%b,end=" ")
      print() 
    socket.close()
当我按下听筒上的按钮时得到的结果如下:

Attempting to connect to L2CAP port  23
Connected.
Waiting on read:
10 11 0e 01 48 00 00 19 58 10 00 00 01 03 
Waiting on read:
20 11 0e 00 48 7c 44 00 
Waiting on read:
30 11 0e 00 48 7c 46 00 
Waiting on read:
40 11 0e 00 48 7c 44 00 
在仔细阅读规范之后,看起来我看到了PASSTHROUGH命令,其中44是“PLAY”操作命令,46是“PAUSE”(我想) 我不知道10 11 0e是什么意思,除了第一个字节似乎是某种序列号。 我的问题有三个:

  • 我不知道在哪里可以找到有效操作ID的列表。它是 在规范中提到,但除了一些随机的 例子
  • 规范引用了子单元类型和Id(这将是 在上面的示例中为48),但不将其定义为AFAICT
  • 没有提到前导的三个字节是什么。他们可能 即使是L2CAP的一部分,与AVRCP没有直接关系,我也不是 对pybluez足够熟悉,可以说
  • 在上述任何一点上提供任何帮助都会有所帮助。
    编辑:此处显示AVRCP spect的详细信息供参考:

    真正的答案是规范文档假设您已阅读其他规范文档

    三个报头字节是AVCTP传输层的一部分:

    简言之:

    0: 7..4: Incrementing transaction id. 0x01 to 0x0f
       3..2: Packet type 00 = self contained packet
         1 : 0=request 1=response
         0 : 0=PID recognized 1: PID error
    1-2: 2 byte bigendian profile id (in this case 110e, AVRCP)
    
    其余部分在AVRCP概要文件中描述

    我不觉得文档非常清晰

    我提供了一个示例应用程序,它似乎适用于我能够测试的大多数AVRCP设备:


    我找到了一些关于子单元类型和id的详细信息,如下:。0x48是“面板”(子单元类型=9),id=0。9用位7-3编码,id用位2-0编码。这提供了很多答案:。。。仍然不确定原始操作列表是在哪里定义的。