Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(NimBLE) Example for L2CAP COC Communication (IDFGH-7474) #9044

Closed
mickeyl opened this issue May 28, 2022 · 6 comments
Closed

(NimBLE) Example for L2CAP COC Communication (IDFGH-7474) #9044

mickeyl opened this issue May 28, 2022 · 6 comments
Assignees
Labels
Resolution: NA Issue resolution is unavailable Status: Done Issue is done internally Type: Feature Request Feature request for IDF

Comments

@mickeyl
Copy link
Contributor

mickeyl commented May 28, 2022

(I'm on an ESP32-C3)

I'd like to see an example for using an ESP32C3 via BLE L2CAP connection oriented channel.

I've augmented the standard blehr configuration with

CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM=1

and enhanced the sample with

rc = l2cap_create_server(0x235, 500, _l2cap_evt_handler, NULL);
assert(rc == 0);

but apparently the l2cap event handler callback does not get called.

Is anything else necessary to get l2cap channel communication working?

@mickeyl mickeyl added the Type: Feature Request Feature request for IDF label May 28, 2022
@espressif-bot espressif-bot added the Status: Opened Issue is new label May 28, 2022
@github-actions github-actions bot changed the title (NimBLE) Example for L2CAP COC Communication (NimBLE) Example for L2CAP COC Communication (IDFGH-7474) May 28, 2022
@IshaESP
Copy link
Contributor

IshaESP commented Nov 7, 2022

Hi @mickeyl, we have added an example for this under the name - ble_l2cap_coc.

@mickeyl
Copy link
Contributor Author

mickeyl commented Nov 7, 2022

@IshaESP Great, thanks a lot, I will have a look! I have since implemented my first bits and they seem to work fine and stable although I have problems with memory management (IMHO the NIMBLE memory pool functions are not very well documented), so I'm looking forward to checking out your example.

@mickeyl
Copy link
Contributor Author

mickeyl commented Nov 22, 2022

I wonder why you don't never release any mbuf instances (e.g., in BLE_L2CAP_EVENT_COC_DATA_RECEIVED). If I do that, I quickly run out of memory.

@rahult-github
Copy link
Collaborator

Hi @mickeyl ,

mbuf mangement ( allocation / free ) is taken care of by the underlying stack. If an application needs to use the data received from stack via events , it is advisable to make a copy of it and store if it needs to be used later on. Once the control goes back to stack ( say after the event posting functionality is over), then stack would taking the decision of freeing up the mbuf that was allocated by it.

@mickeyl
Copy link
Contributor Author

mickeyl commented Nov 24, 2022

@rahult-github Very interesting. Like I said, this doesn't go with my findings. If remove e.g. the os_mbuf_free_chain in https://github.com/mickeyl/esp-nimble-cpp/blob/25d23f92270d007ce0635f71cd81b3881658f113/src/NimBLEL2CAPService.cpp#L131, I get out-of-memory within short time. But anyways, if that's an issue, then it's another issue. Thanks for the example code, I'll close this here.

@mickeyl mickeyl closed this as completed Nov 24, 2022
@espressif-bot espressif-bot added Resolution: NA Issue resolution is unavailable Status: Done Issue is done internally and removed Status: Opened Issue is new labels Jan 9, 2023
@nebkat
Copy link
Contributor

nebkat commented Mar 15, 2024

Could we get a similar example for Bluedroid LE, or does it function using the Bluetooth Classic L2CAP API?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: NA Issue resolution is unavailable Status: Done Issue is done internally Type: Feature Request Feature request for IDF
Projects
None yet
Development

No branches or pull requests

5 participants