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

ESP32-C6, issues with Bluetooth #1191

Open
Gob2003 opened this issue Apr 30, 2024 · 1 comment
Open

ESP32-C6, issues with Bluetooth #1191

Gob2003 opened this issue Apr 30, 2024 · 1 comment

Comments

@Gob2003
Copy link

Gob2003 commented Apr 30, 2024

Hello to all!

I am in a school project that requires Bluetooth and this is my project resumed shortly:
I am making my own MP3, of course, I will be using an ESP32 to make my project working. I tested my buttons, functional, the screen is also functional, but I can't make the Bluetooth working (BLE).

I tried those libraries: Esp32 BLE Arduino and ArduinoBLE.

The first step I did was to run an example just to see how it works, but I have this issue when using Esp32 BLE Arduino:

In file included from c:\Users\elvin\OneDrive\Documents\Arduino\libraries\ESP32_BLE_Arduino\src/BLERemoteDescriptor.h:18,
                 from c:\Users\elvin\OneDrive\Documents\Arduino\libraries\ESP32_BLE_Arduino\src/BLERemoteCharacteristic.h:18,
                 from c:\Users\elvin\OneDrive\Documents\Arduino\libraries\ESP32_BLE_Arduino\src/BLERemoteService.h:16,
                 from c:\Users\elvin\OneDrive\Documents\Arduino\libraries\ESP32_BLE_Arduino\src/BLEClient.h:19,
                 from c:\Users\elvin\OneDrive\Documents\Arduino\libraries\ESP32_BLE_Arduino\src/BLEUtils.h:16,
                 from C:\Users\elvin\AppData\Local\Temp\.arduinoIDE-unsaved2024330-13832-fd0ng1.jqiml\BLE_scan\BLE_scan.ino:7:
c:\Users\elvin\OneDrive\Documents\Arduino\libraries\ESP32_BLE_Arduino\src/FreeRTOS.h:61:35: error: 'ringbuf_type_t' has not been declared
   61 |         Ringbuffer(size_t length, ringbuf_type_t type = RINGBUF_TYPE_NOSPLIT);
      |                                   ^~~~~~~~~~~~~~
In file included from c:\Users\elvin\OneDrive\Documents\Arduino\libraries\ESP32_BLE_Arduino\src/BLECharacteristic.h:17,
                 from c:\Users\elvin\OneDrive\Documents\Arduino\libraries\ESP32_BLE_Arduino\src/BLEService.h:15,
                 from c:\Users\elvin\OneDrive\Documents\Arduino\libraries\ESP32_BLE_Arduino\src/BLEClient.h:20:
c:\Users\elvin\OneDrive\Documents\Arduino\libraries\ESP32_BLE_Arduino\src/BLEDescriptor.h:25:7: error: redefinition of 'class BLEDescriptor'
   25 | class BLEDescriptor {
      |       ^~~~~~~~~~~~~
In file included from c:\Users\elvin\OneDrive\Documents\Arduino\libraries\ArduinoBLE\src/BLECharacteristic.h:25,
                 from c:\Users\elvin\OneDrive\Documents\Arduino\libraries\ArduinoBLE\src/BLEService.h:23,
                 from c:\Users\elvin\OneDrive\Documents\Arduino\libraries\ArduinoBLE\src/BLEDevice.h:25,
                 from C:\Users\elvin\AppData\Local\Temp\.arduinoIDE-unsaved2024330-13832-fd0ng1.jqiml\BLE_scan\BLE_scan.ino:6:
c:\Users\elvin\OneDrive\Documents\Arduino\libraries\ArduinoBLE\src/BLEDescriptor.h:28:7: note: previous definition of 'class BLEDescriptor'
   28 | class BLEDescriptor {
      |       ^~~~~~~~~~~~~
c:\Users\elvin\OneDrive\Documents\Arduino\libraries\ESP32_BLE_Arduino\src/BLECharacteristic.h:53:7: error: redefinition of 'class BLECharacteristic'
   53 | class BLECharacteristic {
      |       ^~~~~~~~~~~~~~~~~
c:\Users\elvin\OneDrive\Documents\Arduino\libraries\ArduinoBLE\src/BLECharacteristic.h:45:7: note: previous definition of 'class BLECharacteristic'
   45 | class BLECharacteristic  {
      |       ^~~~~~~~~~~~~~~~~
c:\Users\elvin\OneDrive\Documents\Arduino\libraries\ESP32_BLE_Arduino\src/BLEService.h:49:7: error: redefinition of 'class BLEService'
   49 | class BLEService {
      |       ^~~~~~~~~~
c:\Users\elvin\OneDrive\Documents\Arduino\libraries\ArduinoBLE\src/BLEService.h:28:7: note: previous definition of 'class BLEService'
   28 | class BLEService {
      |       ^~~~~~~~~~
C:\Users\elvin\AppData\Local\Temp\.arduinoIDE-unsaved2024330-13832-fd0ng1.jqiml\BLE_scan\BLE_scan.ino: In function 'void setup()':
C:\Users\elvin\AppData\Local\Temp\.arduinoIDE-unsaved2024330-13832-fd0ng1.jqiml\BLE_scan\BLE_scan.ino:24:14: error: 'init' is not a member of 'BLEDevice'
   24 |   BLEDevice::init("");
      |              ^~~~
C:\Users\elvin\AppData\Local\Temp\.arduinoIDE-unsaved2024330-13832-fd0ng1.jqiml\BLE_scan\BLE_scan.ino:25:25: error: 'getScan' is not a member of 'BLEDevice'
   25 |   pBLEScan = BLEDevice::getScan(); //create new scan
      |                         ^~~~~~~
Multiple libraries were found for "BLEUtils.h"
  Used: C:\Users\elvin\OneDrive\Documents\Arduino\libraries\ESP32_BLE_Arduino
  Not used: C:\Users\elvin\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.0-rc1\libraries\BLE
Multiple libraries were found for "BLEDevice.h"
  Used: C:\Users\elvin\OneDrive\Documents\Arduino\libraries\ArduinoBLE
  Not used: C:\Users\elvin\OneDrive\Documents\Arduino\libraries\ESP32_BLE_Arduino
  Not used: C:\Users\elvin\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.0-rc1\libraries\BLE
exit status 1

Compilation error: 'init' is not a member of 'BLEDevice'

And here's the code:

/*
   Based on Neil Kolban example for IDF: https://github.com/nkolban/esp32-snippets/blob/master/cpp_utils/tests/BLE%20Tests/SampleScan.cpp
   Ported to Arduino ESP32 by Evandro Copercini
*/

#include <BLEDevice.h>
#include <BLEUtils.h>
#include <BLEScan.h>
#include <BLEAdvertisedDevice.h>

int scanTime = 5; //In seconds
BLEScan* pBLEScan;

class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks {
    void onResult(BLEAdvertisedDevice advertisedDevice) {
      Serial.printf("Advertised Device: %s \n", advertisedDevice.toString().c_str());
    }
};

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

  BLEDevice::init("");
  pBLEScan = BLEDevice::getScan(); //create new scan
  pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks());
  pBLEScan->setActiveScan(true); //active scan uses more power, but get results faster
  pBLEScan->setInterval(100);
  pBLEScan->setWindow(99);  // less or equal setInterval value
}

void loop() {
  // put your main code here, to run repeatedly:
  BLEScanResults foundDevices = pBLEScan->start(scanTime, false);
  Serial.print("Devices found: ");
  Serial.println(foundDevices.getCount());
  Serial.println("Scan done!");
  pBLEScan->clearResults();   // delete results fromBLEScan buffer to release memory
  delay(2000);
}

I am not sure what is wrong too... I require help please.

Kind regards.

@mustafadilmac
Copy link

just remove the libary from arduino ide which => "BLEUtils.h"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants