Skip to content

feat(NimBLE): Add support for NimBLE #11424

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

Draft
wants to merge 5 commits into
base: release/v3.3.x
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cores/esp32/esp32-hal-bt.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include "esp32-hal-bt.h"

#if SOC_BT_SUPPORTED
#if defined(CONFIG_BT_BLUEDROID_ENABLED) && __has_include("esp_bt.h")
#if (defined(CONFIG_BLUEDROID_ENABLED) || defined(CONFIG_NIMBLE_ENABLED)) && __has_include("esp_bt.h")

#if CONFIG_IDF_TARGET_ESP32
bool btInUse() {
Expand Down Expand Up @@ -116,7 +116,7 @@ bool btStop() {
return false;
}

#else // CONFIG_BT_ENABLED
#else // !__has_include("esp_bt.h") || !(defined(CONFIG_BLUEDROID_ENABLED) || defined(CONFIG_NIMBLE_ENABLED))
bool btStarted() {
return false;
}
Expand All @@ -129,6 +129,6 @@ bool btStop() {
return false;
}

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

#endif /* SOC_BT_SUPPORTED */
8 changes: 6 additions & 2 deletions libraries/BLE/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# ESP32 BLE for Arduino
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.

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

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!)
Some parts of the NimBLE implementation are based on the work of h2zero, which can be found here: https://github.com/h2zero/NimBLE-Arduino

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!)

Documentation for using the library can be found here: https://github.com/nkolban/esp32-snippets/tree/master/Documentation

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.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@

author: chegewara
*/
#ifndef SOC_BLE_50_SUPPORTED
#warning "This SoC does not support BLE5. Try using ESP32-C3, or ESP32-S3"
#ifndef CONFIG_BLUEDROID_ENABLED
#error "NimBLE does not support extended scan yet. Try using Bluedroid."
#elif !defined(SOC_BLE_50_SUPPORTED)
#error "This SoC does not support BLE5. Try using ESP32-C3, or ESP32-S3"
#else

#include <BLEDevice.h>
Expand Down
3 changes: 2 additions & 1 deletion libraries/BLE/examples/BLE5_extended_scan/ci.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"fqbn_append": "PartitionScheme=huge_app",
"requires": [
"CONFIG_SOC_BLE_50_SUPPORTED=y"
"CONFIG_SOC_BLE_50_SUPPORTED=y",
"CONFIG_BLUEDROID_ENABLED=y"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
author: chegewara
*/

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

Expand Down
3 changes: 2 additions & 1 deletion libraries/BLE/examples/BLE5_multi_advertising/ci.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"fqbn_append": "PartitionScheme=huge_app",
"requires": [
"CONFIG_SOC_BLE_50_SUPPORTED=y"
"CONFIG_SOC_BLE_50_SUPPORTED=y",
"CONFIG_BLUEDROID_ENABLED=y"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
author: chegewara
*/

#ifndef CONFIG_BT_BLE_50_FEATURES_SUPPORTED
#ifndef CONFIG_BLUEDROID_ENABLED
#error "NimBLE does not support periodic advertising yet. Try using Bluedroid."
#elif !defined(CONFIG_BT_BLE_50_FEATURES_SUPPORTED)
#error "This SoC does not support BLE5. Try using ESP32-C3, or ESP32-S3"
#else
#include <BLEDevice.h>
Expand Down
3 changes: 2 additions & 1 deletion libraries/BLE/examples/BLE5_periodic_advertising/ci.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"fqbn_append": "PartitionScheme=huge_app",
"requires": [
"CONFIG_SOC_BLE_50_SUPPORTED=y"
"CONFIG_SOC_BLE_50_SUPPORTED=y",
"CONFIG_BLUEDROID_ENABLED=y"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@

author: chegewara
*/
#ifndef SOC_BLE_50_SUPPORTED
#warning "This SoC does not support BLE5. Try using ESP32-C3, or ESP32-S3"
#ifndef CONFIG_BLUEDROID_ENABLED
#error "NimBLE does not support periodic sync yet. Try using Bluedroid."
#elif !defined(SOC_BLE_50_SUPPORTED)
#error "This SoC does not support BLE5. Try using ESP32-C3, or ESP32-S3"
#else
#include <BLEDevice.h>
#include <BLEUtils.h>
Expand Down
3 changes: 2 additions & 1 deletion libraries/BLE/examples/BLE5_periodic_sync/ci.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"fqbn_append": "PartitionScheme=huge_app",
"requires": [
"CONFIG_SOC_BLE_50_SUPPORTED=y"
"CONFIG_SOC_BLE_50_SUPPORTED=y",
"CONFIG_BLUEDROID_ENABLED=y"
]
}
2 changes: 1 addition & 1 deletion libraries/BLE/library.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name=BLE
version=3.2.0
author=Neil Kolban <[email protected]>
maintainer=Dariusz Krempa <[email protected]>
maintainer=lucasssvaz
sentence=BLE functions for ESP32
paragraph=This library provides an implementation Bluetooth Low Energy support for the ESP32 using the Arduino platform.
category=Communication
Expand Down
47 changes: 33 additions & 14 deletions libraries/BLE/src/BLE2901.cpp
Original file line number Diff line number Diff line change
@@ -1,29 +1,48 @@
/*
BLE2901.h
BLE2901.h

GATT Descriptor 0x2901 Characteristic User Description
GATT Descriptor 0x2901 Characteristic User Description

The value of this description is a user-readable string
describing the characteristic.
The value of this description is a user-readable string
describing the characteristic.

The Characteristic User Description descriptor
provides a textual user description for a characteristic
value.
If the Writable Auxiliary bit of the Characteristics
Properties is set then this descriptor is written. Only one
User Description descriptor exists in a characteristic
definition.
The Characteristic User Description descriptor
provides a textual user description for a characteristic
value.
If the Writable Auxiliary bit of the Characteristics
Properties is set then this descriptor is written. Only one
User Description descriptor exists in a characteristic
definition.
*/

#include "soc/soc_caps.h"
#if SOC_BLE_SUPPORTED

#include "sdkconfig.h"
#if defined(CONFIG_BLUEDROID_ENABLED)
#if defined(CONFIG_BLUEDROID_ENABLED) || defined(CONFIG_NIMBLE_ENABLED)

/***************************************************************************
* Common includes and definitions *
***************************************************************************/

#include "BLE2901.h"

BLE2901::BLE2901() : BLEDescriptor(BLEUUID((uint16_t)0x2901)) {} // BLE2901
#define BLE2901_UUID 0x2901

/***************************************************************************
* NimBLE includes and definitions *
***************************************************************************/

#if defined(CONFIG_NIMBLE_ENABLED)
#include "host/ble_att.h"
#define ESP_GATT_MAX_ATTR_LEN BLE_ATT_ATTR_MAX_LEN
#endif

/***************************************************************************
* Common functions *
***************************************************************************/

BLE2901::BLE2901() : BLEDescriptor(BLEUUID((uint16_t)BLE2901_UUID)) {}

/**
* @brief Set the Characteristic User Description
Expand All @@ -36,5 +55,5 @@ void BLE2901::setDescription(String userDesc) {
setValue(userDesc);
}

#endif
#endif /* CONFIG_BLUEDROID_ENABLED || CONFIG_NIMBLE_ENABLED */
#endif /* SOC_BLE_SUPPORTED */
39 changes: 25 additions & 14 deletions libraries/BLE/src/BLE2901.h
Original file line number Diff line number Diff line change
@@ -1,37 +1,48 @@
/*
BLE2901.h
BLE2901.h

GATT Descriptor 0x2901 Characteristic User Description
GATT Descriptor 0x2901 Characteristic User Description

The value of this description is a user-readable string
describing the characteristic.

The Characteristic User Description descriptor
provides a textual user description for a characteristic
value.
If the Writable Auxiliary bit of the Characteristics
Properties is set then this descriptor is written. Only one
User Description descriptor exists in a characteristic
definition.
The value of this description is a user-readable string
describing the characteristic.

The Characteristic User Description descriptor
provides a textual user description for a characteristic
value.
If the Writable Auxiliary bit of the Characteristics
Properties is set then this descriptor is written. Only one
User Description descriptor exists in a characteristic
definition.
*/

#ifndef COMPONENTS_CPP_UTILS_BLE2901_H_
#define COMPONENTS_CPP_UTILS_BLE2901_H_

#include "soc/soc_caps.h"
#if SOC_BLE_SUPPORTED

#include "sdkconfig.h"
#if defined(CONFIG_BLUEDROID_ENABLED)
#if defined(CONFIG_BLUEDROID_ENABLED) || defined(CONFIG_NIMBLE_ENABLED)

/***************************************************************************
* Common includes *
***************************************************************************/

#include "BLEDescriptor.h"

/**
* @brief GATT Descriptor 0x2901 Characteristic User Description
*/
class BLE2901 : public BLEDescriptor {
public:
/***************************************************************************
* Common public functions *
***************************************************************************/

BLE2901();
void setDescription(String desc);
}; // BLE2901

#endif /* CONFIG_BLUEDROID_ENABLED */
#endif /* CONFIG_BLUEDROID_ENABLED || CONFIG_NIMBLE_ENABLED */
#endif /* SOC_BLE_SUPPORTED */
#endif /* COMPONENTS_CPP_UTILS_BLE2901_H_ */
Loading
Loading