# 'startAdvertising' is not a member of 'BLEDevice

**URL:** <https://forum.arduino.cc/t/startadvertising-is-not-a-member-of-bledevice/1086837>\
**Category:** Programming\
**Created:** [February 6, 2023, 12:24pm UTC](https://forum.arduino.cc/t/startadvertising-is-not-a-member-of-bledevice/1086837 "2023-02-06T12:24:39Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![ptillisch](https://avatars.discourse-cdn.com/v4/letter/p/ad7895/32.png) [@ptillisch](https://forum.arduino.cc/u/ptillisch)\
**Post date:** [February 7, 2023, 2:58pm UTC](https://forum.arduino.cc/t/startadvertising-is-not-a-member-of-bledevice/1086837/5 "2023-02-07T14:58:50Z")

</div>

There is a valuable clue in the output you shared previously:

> <https://github.com/arduino-libraries/ArduinoBLE/issues/285#issuecomment-1413282293>
>
> Hello, I'm having some problems with the new version (1.3.2), if I use version 1….3.1, I don't have any problem.
> But when I compile with the new version I get this error log
> 
> \`\`\`text
> In file included from c:\\Users\\fimartin\\Documents\\Arduino\\libraries\\ArduinoBLE\\src\\utility\\HCIVirtualTransport.cpp:22:0:
> c:\\Users\\fimartin\\Documents\\Arduino\\libraries\\ArduinoBLE\\src\\utility\\HCIVirtualTransport.h:27:36: fatal error: freertos/stream\_buffer.h: No such file or directory
> compilation terminated.
> Se encontraron varias bibliotecas para "BLEDevice.h"
> Usado: C:\\Users\\fimartin\\Documents\\Arduino\\libraries\\ArduinoBLE
> No utilizado: C:\\Users\\fimartin\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.6\\libraries\\BLE
> exit status 1
> 
> Compilation error: exit status 1
> \`\`\`
> 
> Can you tell me what I am doing wrong?
> I even updated version after version to tried solve it, but I couldn't fix it this way.

> ```plaintext
> Se encontraron varias bibliotecas para "BLEDevice.h"
> Usado: C:\Users\fimartin\Documents\Arduino\libraries\ArduinoBLE
> No utilizado: C:\Users\fimartin\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.6\libraries\BLE
> 
> ```

Arduino IDE has a "library discovery" system. For each `#include` directive in the program being compiled, the IDE first checks to see if the file is present in the include search path. If not, it then searches through the root source folder of each of the installed libraries to look for a file of that name.

Sometimes multiple libraries contain a file matching the `#include` directive. In this case, Arduino IDE must decide which of the libraries to use. It has a sophisticated algorithm for picking the best library so it usually makes the right decision, but not always.

It appears in this case where Arduino IDE made the wrong decision when discovering the library for the `#include <BLEDevice.h>` directive. From what I can tell, your sketch is meant to use the " **ESP32 BLE Arduino**" library that is bundled with the ESP32 boards platform here:

```plaintext
C:\Users\fimartin\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.6\libraries\BLE

```

But Arduino IDE chose the " **ArduinoBLE**" library instead.

If this is the problem, then the solution will be to influence the library discovery system to pick the intended library.

As I mentioned before, files from the include search path are always given priority by the library discovery system. Once a library is "discovered", its path is added to the include search path. So if we can cause the " **ESP32 BLE Arduino**" library to be discovered before Arduino IDE does discovery for the ambiguous `BLEDevice.h` file, then it not discover the " **ArduinoBLE**" library. This is accomplished by placing an `#include` directive for a file unique to the " **ESP32 BLE Arduino**" library above the ambiguous `#include` directive.

The file `BLE2902.h` looks promising for this purpose since it is not present in the " **ArduinoBLE**" library and is also unlikely to be present in other libraries since it is fairly unique. Since you already have an `#include` directive in your sketch for that file, it is only a matter of moving that `#include` directive up in the sketch to a line above the `#include` directive for `BLEDevice.h`.

So change this part of your sketch:

```cpp
#include <BLEDevice.h>
#include <BLEUtils.h>
#include <BLEServer.h>
#include <BLE2902.h>

```

to this:

```cpp
#include <BLE2902.h>
#include <BLEDevice.h>
#include <BLEUtils.h>
#include <BLEServer.h>

```

After that, I still get an error when compiling your sketch:

```plaintext
C:\Users\per\AppData\Local\Temp\.arduinoIDE-unsaved202317-14556-f87ec9.adb5o\sketch_feb7a\sketch_feb7a.ino: In function 'void setup()':
C:\Users\per\AppData\Local\Temp\.arduinoIDE-unsaved202317-14556-f87ec9.adb5o\sketch_feb7a\sketch_feb7a.ino:167:19: error: 'nameAndModel' was not declared in this scope
   BLEDevice::init(nameAndModel.c_str());
                   ^ ~~~~~~~~~~~

```

but I suspect this is a bug in the sketch code rather than a problem with the libraries. So I think you will be able to solve it.

---

_[View the full topic](https://forum.arduino.cc/t/startadvertising-is-not-a-member-of-bledevice/1086837)._
