Home > front end >  CoreBluetooth bidirectional communication(tcp-similar approach)
CoreBluetooth bidirectional communication(tcp-similar approach)

Time:08-19

What is the best way to provide bidirecational communication using CoreBluetooth framework? I want to use BLE stack protocal as tcp-similar(only as a way for sending data) and then add upper layes: as tls, http, grpc etc.

We have 2 ways(I guess):

  1. Via characteristics (but here we have restriction in 526 bytes strings and I'm not sure at all that we have complete bidirectional communication here) As example I have doubt about possibility to set communication via characteristics as simple tcp exchange.
  2. Via L2CAP channels(in my mind it's just a 2 output/input streams for bidirectional communication) that complelty suits to tcp-similar approach.

Which way is the best and why? Maybe examples are present anywhere?

CodePudding user response:

Using "write without response" "notifications" is almost the same in terms of performance compared to l2cap coc. In the end it is just a different header if you look at the raw BLE packets over the air that will be the difference (a few bytes might differ in the overhead, but nothing of importance if you have the LE Data Length extension enabled). One difference though is that you have the flow control mechanism for l2cap coc that you don't have for gatt.

My suggestion is to try both and pick the API that you like the most.

  • Related