espressif / arduino-esp32

Arduino core for the ESP32
GNU Lesser General Public License v2.1
13.41k stars 7.37k forks source link

ESP32 Arduino BLE Refactoring #9878

Open SuGlider opened 3 months ago

SuGlider commented 3 months ago

Related area

BLE refactoring using NimBLE

Hardware specification

Any

Is your feature request related to a problem?

This is part of an effort to improve ESP32 Arduino.

Describe the solution you'd like

Starting point for a BLE refactoring Plan. Targets:

Suggestion:

Examples:

Describe alternatives you've considered

None.

Additional context

None.

I have checked existing list of Feature requests and the Contribution Guide

h2zero commented 3 months ago

ArduinoBLE already supports esp32. Only change to do here would be to configure BLE to be controller only and import the ArduinoBLE library, no Bluedroid or NimBLE required.

SuGlider commented 3 months ago

ArduinoBLE already supports esp32. Only change to do here would be to configure BLE to be controller only and import the ArduinoBLE library, no Bluedroid or NimBLE required.

Yes, it supports the ESP32-S3 module from the UNO R4 board and the boards that use Nina-W102 that has an ESP32 module. But those are used as WiFi/Bluetooth modem using AT commands.

The idea here is to implement the ArduinoBLE API as part of ESP32 Arduino BLE Library as direct ESP-IDF calls, instead of using a UART to send and receive AT commands.

h2zero commented 3 months ago

It also has the VHCI driver here: https://github.com/arduino-libraries/ArduinoBLE/blob/98ff550988912ffbaeb1d877970e9e05f1de0599/src/utility/HCIVirtualTransport.cpp#L138

Added in https://github.com/arduino-libraries/ArduinoBLE/pull/252

SuGlider commented 3 months ago

@h2zero - Thanks for the information!

It also has the VHCI driver here: https://github.com/arduino-libraries/ArduinoBLE/blob/98ff550988912ffbaeb1d877970e9e05f1de0599/src/utility/HCIVirtualTransport.cpp#L138

I see, this is way to implement it with internal channel AT commands. I'll try it.

Added in [arduino-libraries/ArduinoBLE#252](https://github.com/arduino-libraries/ArduinoBLE/pull/25

I like the table showing resource utilization after compiling the different libraries' respective scan example!

VojtechBartoska commented 1 month ago

related discussion: https://github.com/espressif/arduino-esp32/discussions/9836

VojtechBartoska commented 1 week ago

Hello @h2zero,

I am contacting you as a Project Manager of Arduino ESP32 project. Our Team have been recently investigating the refactoring of BLE in our core and we also investigated your NimBle-Arduino library.

As you know, we need to keep working solution also for Classic BT on ESP32 platform, but in general in case of implementing e.g. Matter, moving to NimBLE based implementation makes sense.

As you proposed before, we would like to open this approach of reusing parts of your library in the core and we would like to ask if it is okay for you and also if you would like to help us with your contribution?

We can share more details about our ideas of implementation and we will be more than happy to hear your thoughts regarding it. Rodrigo (@SuGlider) has his hands on this and has some suggestions already for BLE refactoting.

Thanks in advance

h2zero commented 1 week ago

@VojtechBartoska sure, let's chat about it.

SuGlider commented 4 days ago

@h2zero - I have to finish the Arduino Matter Library first and then we will talk here about the nimBLE refactoring. Thank you!