经过一番胡闹之后,我得到了一个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 在仔细阅读了规范之后,我似乎看到了传递命令,其中44个是"PLAY“操作命令,46个是”暂停“(我想),我不知道10110E是什么意思,只是第一个字节似乎是某种序列号。我的问题有三重:
在上述任何一点上提供任何帮助都是有帮助的。编辑:供参考,详细的AVRCP似乎在这里:id=119996
发布于 2018-07-23 08:07:45
真正的答案是,规范文档假定您已经阅读了其他规范文档。
这三个头字节是AVCTP传输层的一部分:0.pdf。
简言之:
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配置文件( id=119996 )中描述。
我不认为这些文档是惊人的清晰。
我提供了一个示例应用程序,它似乎适用于我能够测试的大多数AVRCP设备:
https://stackoverflow.com/questions/51463262
复制相似问题