2

The usual way to access L2CAP is to create an L2CAP socket and simply call connect() on it to connect to the bluetooth device you want to access. This usually works completely fine. However, I'm trying to do this on an ARM device with Linux kernel 3.0 and there appears to be a nasty bug where you can't have multiple L2CAP connections without all of the data coming down which ever channel was created last. (ie if I connect to 2 bluetooth sensors with 2 l2cap sockets, all the notifications for both devices come through the socket open last and nothing comes on the socket open first.) However, if I set the filters right on the HCI socket I can see that the ACL data is coming through with the proper connection handles so I could get the data properly over there.

So... I'd like to change my code to utilize just the HCI socket.

My problem is, I'm not sure how (or even if it's possible). There's a "create logical link command" in HCI that seems like it would create an L2CAP connection, but the arguments make no sense to me. After I make an HCI connection over LE I get back a "connection complete event" that gives me a 2 octet "Connection_Handle". The "create logical link command" takes a 1 octet "Physical_Link_Handle" though.

4

2 回答 2

1

“创建逻辑链路命令”用于 AMP 控制器,与 L2CAP 无关。使用 LE,您可以通过固定通道自动建立“连接”,并且可以简单地将 ATT 命令作为 CID 4 上的 ACL 数据包发送。ACL 数据包使用从 HCI LE 连接事件返回的连接句柄。

(由#bluez IRC 频道上的某个人回答;我不记得是谁了)

于 2013-10-30T13:39:37.547 回答
0

在 BLE 中,无论何时建立连接,L2CAP 都可以使用。

你不需要connect或其他任何东西。一旦您收到 LE 连接完成事件,您就可以开始了,您可以开始通过 L2CAP 进行通信。

您提到的其他命令和数据不是 LE,它们仅适用于 BR/EDR。

于 2014-10-09T15:11:37.710 回答