【发布时间】:2018-12-29 23:44:04
【问题描述】:
经过一番折腾,我得到了一个 pybluez 脚本,可以连接到各种设备上的 AVRCP 配置文件,并读取响应。
代码sn-p:
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 是什么意思,除了第一个字节似乎是某种序列号这一事实。 我的问题有三个:
- 我不知道在哪里可以找到有效 operation_id 的列表。它是 规范中提到但除了一些随机的之外没有定义 示例。
- 规范引用了子单元类型和 ID,(这将是 48 在上面的例子中)再次没有定义它们 AFAICT。
- 没有提到前三个字节是什么。他们可能会 甚至成为 L2CAP 的一部分,与 AVRCP 没有直接关系,我不是 对 pybluez 足够熟悉。
上述任何一点的任何帮助都会有所帮助。 编辑:作为参考,AVRCP 规范的详细信息似乎在这里:https://www.bluetooth.org/docman/handlers/DownloadDoc.ashx?doc_id=119996
【问题讨论】:
-
我在这里找到了关于子单元类型和 ID 的一些详细信息:1394ta.org/wp-content/uploads/2015/07/2007001.pdf。 0x48 是“面板”(子单元类型=9)和 id=0。 9 编码在 7-3 位,id 编码在 2-0 位。
-
这提供了很多答案:github.com/bluekitchen/btstack/blob/master/src/classic/avrcp.h ...仍然不确定原始操作列表的定义位置。
标签: bluetooth pybluez avrcp l2cap