3

Here is stated that Android 8.0 supports LE Connection-Oriented Channels. However I don't see any reference of it in the Android API. The BluetoothAdapter class only has only methods for listening RFCOMM sockets (which runs on BT Classic only); and the BluetoothSocket class says: "The most common type of Bluetooth socket is RFCOMM, which is the type supported by the Android APIs."

How is possible to use LE CoC? Can someone help to clarify this confusion? Moreover is seems they are supported by the BLE stack that runs below the Java API, see here for example.

Šatov
  • 323
  • 3
  • 9
  • L2CAP CoC will be supported starting from Android Q. I'm not able to cite official sources about that – nsndvd Oct 25 '18 at 06:34

1 Answers1

1

LE L2CAP Connection Oriented Channel Support is a new introduced feature at core spec 4.1.

After reviewed the android 8.0 code(I did not test CoC feature since it need remote device also support CoC), from the code perspective you should able to use this feature at Android 8.0.

Let's assume you want to connect socket act as a client at Phone side, you do not need call RFCOMM socket but call L2CAP, use following socket API; Note that two items need mentioned: 1) Use the TYPE_L2CAP when init the socket structure. 2) Apply the CoC mask(0x20000) when set the socket port.

Here is the JNI link: JNI

Here is the stack link: stack

Under Here you will find the socket link to L2CAP connections.

Line #912 on this page indicate the CoC format.

Guo Xingmin
  • 1,013
  • 1
  • 7
  • 7
  • Thanks, I don't have a CoC device either; I will get one next week. I was trying to find a link between the BLE stack code and the Java API you mentioned but I failed; do you have any insight on that? – Šatov Nov 03 '17 at 09:16
  • You might find following links which may help you how the logic goes: – Guo Xingmin Nov 03 '17 at 09:31
  • @GuoXingmin am I getting it right that these APIs can only be accessed via NDK or reflection? – nsndvd Sep 14 '18 at 08:05
  • @GuoXingmin yes, I see that there are methods to get an instance of a BluetoothSocket with type=L2CAP, but they have the `@hide` annotation – nsndvd Sep 18 '18 at 08:29
  • e.g.: the `createL2capSocket` method in the `BluetoothDevice` class – nsndvd Sep 18 '18 at 08:55
  • Please see (and hopefully contradict) my question here https://stackoverflow.com/questions/51614736/how-can-i-instantiate-a-l2cap-socket-in-android – nsndvd Oct 10 '18 at 07:34