esp-nimble-cpp icon indicating copy to clipboard operation
esp-nimble-cpp copied to clipboard

Autofragmentation characteristic transfers

Open mickeyl opened this issue 3 years ago • 1 comments

Due to L2CAP not really working yet, I'm looking to transfer larger stream of data (i.e. up to 4KB) via consecutive READs (and WRITEs for the response) to a characteristic and then deliver the whole payload to my upper layers.

What's the best way to do this using esp-nimble-cpp? Do you perhaps have classes ready that can assist me with this task?

mickeyl avatar Jun 01 '22 12:06 mickeyl

I don't have any specific classes for this but it could be done quite simply with the existing framework.

There are multiple ways to handle this but packetizing would seem the easiest. For speed you would want to limit the packet sizes to the MTU size - 3. Calculate from there how many packets you'll need to send and specify the number of packets remaining at the beginning of each packet sent. The peer device could then construct the data as each packet arrives, stripping the header of course.

The only tricky part may be timing of write calls, you may want to user write with response for this to make it easy, it would be slower though.

h2zero avatar Jun 01 '22 14:06 h2zero

With more experience I no longer think that autofragmenting characteristics would be appropriate in this library. This should either be handled by a specific instance of GATT callbacks or (better) an L2CAP channel should be used.

Closing this.

mickeyl avatar Apr 28 '23 14:04 mickeyl