Skip to content

Commit 6100cb5

Browse files
lucasssvazh2zero
andcommitted
feat(NimBLE): Add support for NimBLE
Co-authored-by: h2zero <ryan@nable-embedded.io>
1 parent 0f72681 commit 6100cb5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+9910
-3201
lines changed

cores/esp32/esp32-hal-bt.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include "esp32-hal-bt.h"
1616

1717
#if SOC_BT_SUPPORTED
18-
#if defined(CONFIG_BT_BLUEDROID_ENABLED) && __has_include("esp_bt.h")
18+
#if (defined(CONFIG_BLUEDROID_ENABLED) || defined(CONFIG_NIMBLE_ENABLED)) && __has_include("esp_bt.h")
1919

2020
#if CONFIG_IDF_TARGET_ESP32
2121
bool btInUse() {
@@ -116,7 +116,7 @@ bool btStop() {
116116
return false;
117117
}
118118

119-
#else // CONFIG_BT_ENABLED
119+
#else // !__has_include("esp_bt.h") || !(defined(CONFIG_BLUEDROID_ENABLED) || defined(CONFIG_NIMBLE_ENABLED))
120120
bool btStarted() {
121121
return false;
122122
}
@@ -129,6 +129,6 @@ bool btStop() {
129129
return false;
130130
}
131131

132-
#endif /* CONFIG_BT_ENABLED */
132+
#endif /* !__has_include("esp_bt.h") || !(defined(CONFIG_BLUEDROID_ENABLED) || defined(CONFIG_NIMBLE_ENABLED)) */
133133

134134
#endif /* SOC_BT_SUPPORTED */

cores/esp32/esp32-hal-misc.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@
2525
#include "esp_ota_ops.h"
2626
#endif //CONFIG_APP_ROLLBACK_ENABLE
2727
#include "esp_private/startup_internal.h"
28-
#if defined(CONFIG_BT_BLUEDROID_ENABLED) && SOC_BT_SUPPORTED && __has_include("esp_bt.h")
28+
#if (defined(CONFIG_BLUEDROID_ENABLED) || defined(CONFIG_NIMBLE_ENABLED)) && SOC_BT_SUPPORTED && __has_include("esp_bt.h")
2929
#include "esp_bt.h"
30-
#endif //CONFIG_BT_BLUEDROID_ENABLED
30+
#endif
3131
#include <sys/time.h>
3232
#include "soc/rtc.h"
3333
#if !defined(CONFIG_IDF_TARGET_ESP32C2) && !defined(CONFIG_IDF_TARGET_ESP32C6) && !defined(CONFIG_IDF_TARGET_ESP32H2) && !defined(CONFIG_IDF_TARGET_ESP32P4) && !defined(CONFIG_IDF_TARGET_ESP32C5)
@@ -245,7 +245,7 @@ bool verifyRollbackLater() {
245245
}
246246
#endif
247247

248-
#ifdef CONFIG_BT_BLUEDROID_ENABLED
248+
#if defined(CONFIG_BLUEDROID_ENABLED) || defined(CONFIG_NIMBLE_ENABLED)
249249
#if CONFIG_IDF_TARGET_ESP32
250250
//overwritten in esp32-hal-bt.c
251251
bool btInUse() __attribute__((weak));
@@ -307,7 +307,7 @@ void initArduino() {
307307
if (err) {
308308
log_e("Failed to initialize NVS! Error: %u", err);
309309
}
310-
#if defined(CONFIG_BT_BLUEDROID_ENABLED) && SOC_BT_SUPPORTED
310+
#if (defined(CONFIG_BLUEDROID_ENABLED) || defined(CONFIG_NIMBLE_ENABLED)) && SOC_BT_SUPPORTED
311311
if (!btInUse()) {
312312
esp_bt_controller_mem_release(ESP_BT_MODE_BTDM);
313313
}

libraries/BLE/README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
# ESP32 BLE for Arduino
22
The Arduino IDE provides an excellent library package manager where versions of libraries can be downloaded and installed. This Github project provides the repository for the ESP32 BLE support for Arduino.
33

4-
The original source of the project, **which is not maintained anymore**, can be found here: https://github.com/nkolban/esp32-snippets
4+
The original source of the Bluedroid project, **which is not maintained anymore**, can be found here: https://github.com/nkolban/esp32-snippets
55

6-
Issues and questions should be raised here: https://github.com/espressif/arduino-esp32/issues <br> (please don't use https://github.com/nkolban/esp32-snippets/issues!)
6+
Some parts of the NimBLE implementation are based on the work of h2zero, which can be found here: https://github.com/h2zero/NimBLE-Arduino
7+
8+
Issues and questions should be raised here: https://github.com/espressif/arduino-esp32/issues <br> (please don't use https://github.com/nkolban/esp32-snippets/issues or https://github.com/h2zero/NimBLE-Arduino/issues!)
79

810
Documentation for using the library can be found here: https://github.com/nkolban/esp32-snippets/tree/master/Documentation
11+
12+
For a more customizable and feature-rich implementation of the NimBLE stack, you can use the [NimBLE-Arduino](https://github.com/h2zero/NimBLE-Arduino) library.

libraries/BLE/examples/BLE5_extended_scan/BLE5_extended_scan.ino

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
88
author: chegewara
99
*/
10-
#ifndef SOC_BLE_50_SUPPORTED
11-
#warning "This SoC does not support BLE5. Try using ESP32-C3, or ESP32-S3"
10+
#ifndef CONFIG_BLUEDROID_ENABLED
11+
#error "NimBLE does not support extended scan yet. Try using Bluedroid."
12+
#elif !defined(SOC_BLE_50_SUPPORTED)
13+
#error "This SoC does not support BLE5. Try using ESP32-C3, or ESP32-S3"
1214
#else
1315

1416
#include <BLEDevice.h>
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"fqbn_append": "PartitionScheme=huge_app",
33
"requires": [
4-
"CONFIG_SOC_BLE_50_SUPPORTED=y"
4+
"CONFIG_SOC_BLE_50_SUPPORTED=y",
5+
"CONFIG_BLUEDROID_ENABLED=y"
56
]
67
}

libraries/BLE/examples/BLE5_multi_advertising/BLE5_multi_advertising.ino

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
author: chegewara
77
*/
88

9-
#ifndef CONFIG_BT_BLE_50_FEATURES_SUPPORTED
9+
#ifndef CONFIG_BLUEDROID_ENABLED
10+
#error "NimBLE does not support multi advertising yet. Try using Bluedroid."
11+
#elif !defined(CONFIG_BT_BLE_50_FEATURES_SUPPORTED)
1012
#error "This SoC does not support BLE5. Try using ESP32-C3, or ESP32-S3"
1113
#else
1214

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"fqbn_append": "PartitionScheme=huge_app",
33
"requires": [
4-
"CONFIG_SOC_BLE_50_SUPPORTED=y"
4+
"CONFIG_SOC_BLE_50_SUPPORTED=y",
5+
"CONFIG_BLUEDROID_ENABLED=y"
56
]
67
}

libraries/BLE/examples/BLE5_periodic_advertising/BLE5_periodic_advertising.ino

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
author: chegewara
66
*/
77

8-
#ifndef CONFIG_BT_BLE_50_FEATURES_SUPPORTED
8+
#ifndef CONFIG_BLUEDROID_ENABLED
9+
#error "NimBLE does not support periodic advertising yet. Try using Bluedroid."
10+
#elif !defined(CONFIG_BT_BLE_50_FEATURES_SUPPORTED)
911
#error "This SoC does not support BLE5. Try using ESP32-C3, or ESP32-S3"
1012
#else
1113
#include <BLEDevice.h>
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"fqbn_append": "PartitionScheme=huge_app",
33
"requires": [
4-
"CONFIG_SOC_BLE_50_SUPPORTED=y"
4+
"CONFIG_SOC_BLE_50_SUPPORTED=y",
5+
"CONFIG_BLUEDROID_ENABLED=y"
56
]
67
}

libraries/BLE/examples/BLE5_periodic_sync/BLE5_periodic_sync.ino

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
88
author: chegewara
99
*/
10-
#ifndef SOC_BLE_50_SUPPORTED
11-
#warning "This SoC does not support BLE5. Try using ESP32-C3, or ESP32-S3"
10+
#ifndef CONFIG_BLUEDROID_ENABLED
11+
#error "NimBLE does not support periodic sync yet. Try using Bluedroid."
12+
#elif !defined(SOC_BLE_50_SUPPORTED)
13+
#error "This SoC does not support BLE5. Try using ESP32-C3, or ESP32-S3"
1214
#else
1315
#include <BLEDevice.h>
1416
#include <BLEUtils.h>

0 commit comments

Comments
 (0)