Skip to content

Conversation

@mickeyl
Copy link
Contributor

@mickeyl mickeyl commented Apr 23, 2025

L2CAP is the underlying technology powering GATT.
BLE 5 exposes L2CAP COC (Connection Oriented Channels) allowing a streaming API that leads to much higher throughputs than you can achieve with updating GATT characteristics.

The patch follows the established infrastructure very closely. The main components are:

  • NimBLEL2CAPChannel, encapsulating an L2CAP COC.
  • NimBLEL2CAPServer, encapsulating the L2CAP service.
  • Examples/L2CAP, containing a client and a server application.

Apart from these, only minor adjustments to the existing code was necessary.

NOTE: The example programs point out a potential problem in the l2cap stack, probably deep inside Nimble, but we have to investigate that. If you are sending too many data, the stack silently drops it.

NOTE2: I forked the repository over two years ago and unfortunately didn't sync afterwards, so I had to do more merge work than expected to catch up with your changes. I hope everything is correct, but in order to reduce coming diffs, it's probably a good idea to pull this now.

This obsoletes #116

@mickeyl
Copy link
Contributor Author

mickeyl commented Apr 23, 2025

Hmm… it fails to compile with ESP-IDF 4.4, probably due to the older C++ standard:

NimBLEL2CAPChannel.h:77:33: error: use of deleted function 'std::atomic<bool>::atomic(const std::atomic<bool>&)'
     std::atomic<bool> stalled = false;
                                 ^~~~~
In file included from /__w/esp-nimble-cpp/esp-nimble-cpp/components/esp-nimble-cpp/src/NimBLEL2CAPChannel.h:14,
                 from /__w/esp-nimble-cpp/esp-nimble-cpp/components/esp-nimble-cpp/src/NimBLEL2CAPChannel.cpp:4:
/opt/esp/tools/riscv32-esp-elf/esp-2021r2-patch5-8.4.0/riscv32-esp-elf/riscv32-esp-elf/include/c++/8.4.0/atomic:71:5: note: declared here
     atomic(const atomic&) = delete;
     ^~~~~~

How are we going to fix this correctly?

Copy link
Owner

@h2zero h2zero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good and thank you for updating this, couple little things to clean up the build.

mickeyl added a commit to mickeyl/esp-nimble-cpp that referenced this pull request Apr 24, 2025
@h2zero h2zero self-requested a review April 24, 2025 13:09
@h2zero
Copy link
Owner

h2zero commented Apr 24, 2025

Thanks @mickeyl, something weird is happening with this PR, it's not triggering the CI or showing the update. Could you squash these commits and force push? Hopefully that triggers the CI.

@mickeyl
Copy link
Contributor Author

mickeyl commented Apr 28, 2025

@h2zero For some versions it still fails ­– this time because of some bogus use of min. I don't think this is inside my code and apparently you're doing some #undef min sorcery in your headers… perhaps I need to replicate that?

Copy link
Owner

@h2zero h2zero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just missed one.

L2CAP is the underlying technology powering GATT.
BLE 5 exposes L2CAP COC (Connection Oriented Channels)
allowing a streaming API that leads to much higher throughputs
than you can achieve with updating GATT characteristics.

The patch follows the established infrastructure very closely.
The main components are:

- `NimBLEL2CAPChannel`, encapsulating an L2CAP COC.
- `NimBLEL2CAPServer`, encapsulating the L2CAP service.
- `Examples/L2CAP`, containing a client and a server application.

Apart from these, only minor adjustments to the existing code was
necessary.
@h2zero
Copy link
Owner

h2zero commented Apr 28, 2025

Awesome, thanks @mickeyl

@h2zero h2zero merged commit e55ad90 into h2zero:master Apr 28, 2025
59 checks passed
@mickeyl
Copy link
Contributor Author

mickeyl commented Apr 29, 2025

@h2zero Excellent, glad that this pull request made it. I can now reduce the diff and concentrate on stabilizing the code and probably exposing the (suspected) bugs in the Nimble l2cap infrastructure. Thanks for maintaining this package, I really appreciate that. Expect further pull requests for the l2cap infrastructure coming over the course of this year.

@mickeyl mickeyl mentioned this pull request Apr 29, 2025
@h2zero
Copy link
Owner

h2zero commented Apr 29, 2025

Awesome, thank you @mickeyl, looking forward to future PR's 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants