Skip to content

[Question] How to use Bluedroid instead of NimBLE in Arduino IDE (v3.3.0)? #11822

@TenC0110

Description

@TenC0110

Board

ESP32-S3 Dev Board

Device Description

ESP32-S3 Dev Board

Hardware Configuration

Nothing

Version

v3.3.0

Type

Question

IDE Name

Arduino IDE

Operating System

Window 11

Flash frequency

80MHz

PSRAM enabled

yes

Upload speed

921600

Description

Problem
After updating to Arduino-ESP32 v3.3.0, the default BLE stack is NimBLE.
My code uses Bluedroid-specific APIs (e.g. startExtScan), so it no longer compiles.
In v3.2.1 this worked fine.

Question
In Arduino IDE, is there a way to switch the BLE host stack from NimBLE back to Bluedroid?
For example, using build_opt.h, platform.txt, or some other configuration?

What I tried

  • Added -DCONFIG_BT_BLUEDROID_ENABLED=1 -DCONFIG_BT_NIMBLE_ENABLED=0 in build_opt.h → did not work.
  • Edited platform.txt extra_flags → still NimBLE is forced.
  • I know PlatformIO or ESP-IDF as component can solve this, but I want to stay with Arduino IDE if possible.

Environment

  • Arduino IDE 2.x
  • Arduino-ESP32 v3.3.0
  • Board: ESP32-S3
  • OS: Windows

Sketch

/*
   BLE5 extended scan example for esp32 C3 and S3
   with this code it is simple to scan legacy (BLE4) compatible advertising,
   and BLE5 extended advertising. New coded added in BLEScan is not changing old behavior,
   which can be used with old esp32, but is adding functionality to use on C3/S3.
   With this new API advertised device wont be stored in API, it is now user responsibility

   author: chegewara
*/
#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>
#include <BLEUtils.h>
#include <BLEScan.h>
#include <BLEAdvertisedDevice.h>

uint32_t scanTime = 100;  //In 10ms (1000ms)
BLEScan *pBLEScan;

class MyBLEExtAdvertisingCallbacks : public BLEExtAdvertisingCallbacks {
  void onResult(esp_ble_gap_ext_adv_report_t report) {
    if (report.event_type & ESP_BLE_GAP_SET_EXT_ADV_PROP_LEGACY) {
      // here we can receive regular advertising data from BLE4.x devices
      Serial.println("BLE4.2");
    } else {
      // here we will get extended advertising data that are advertised over data channel by BLE5 devices
      Serial.printf("Ext advertise: data_le: %d, data_status: %d \n", report.adv_data_len, report.data_status);
    }
  }
};

void setup() {
  Serial.begin(115200);
  Serial.println("Scanning...");

  BLEDevice::init("");
  pBLEScan = BLEDevice::getScan();  //create new scan
  pBLEScan->setExtendedScanCallback(new MyBLEExtAdvertisingCallbacks());
  pBLEScan->setExtScanParams();         // use with pre-defined/default values, overloaded function allows to pass parameters
  delay(1000);                          // it is just for simplicity this example, to let ble stack to set extended scan params
  pBLEScan->startExtScan(scanTime, 3);  // scan duration in n * 10ms, period - repeat after n seconds (period >= duration)
}

void loop() {
  // put your main code here, to run repeatedly:
  delay(2000);
}
#endif  // SOC_BLE_50_SUPPORTED

Debug Message

C:\Users\Lighten\AppData\Local\Temp\.arduinoIDE-unsaved2025812-27280-vj6jdv.ulxd\BLE5_extended_scan\BLE5_extended_scan.ino:11:2: error: #error "NimBLE does not support extended scan yet. Try using Bluedroid."
   11 | #error "NimBLE does not support extended scan yet. Try using Bluedroid."
      |  ^~~~~
exit status 1

Compilation error: #error "NimBLE does not support extended scan yet. Try using Bluedroid."

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions