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.

有帮助吗?

解决方案 2

In BLE, whenever you establish a connection, the L2CAP is ready to be used.

You don't need to connect or anything else. Once you receive the LE Connection Complete Event, you are ready to go and you may start communicating through L2CAP.

The other commands and data you mention are not LE, they are only for BR/EDR.

其他提示

The "create logic link command" is for AMP controllers and has nothing to do with L2CAP. With LE you automatically have a "connection" through the fixed channels and can simply send ATT commands as ACL packets on CID 4. The ACL packets make use of the connection handle returned fro the HCI LE connection event.

(answer courtesy someone on the #bluez IRC channel; I don't recall who)

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top