Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Adaptation to new NimBLE lib methods. #102

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

Open
wants to merge 13 commits into
base: CustomSettings
Choose a base branch
from

Conversation

RobertoHE
Copy link
Contributor

I have updated the method names following the migration guide. You can find it here: https://github.com/h2zero/NimBLE-Arduino/blob/62180ab2bc9c9a8b41f9fb800ea7256e89628a3a/docs/1.x_to2.x_migration_guide.md?plain=1#L132

Please note that these changes have only been compiled without errors and have not been tested with hardware (I haven't any ESP32 now).

This pull request is intended as a hotfix. I will need additional time to update the other transport layers.

@lathoub , could you please review this pull request before it is merged?

Please, add other users to this theat that may be involved with the lib and what they may test with real hardware.

@samspencer5991
Copy link

Will check later this week and report back after hardware testing.

@samspencer5991
Copy link

@RobertoHE
I am getting compilation errors when trying to build. I am using the latest source from here (pulled from GH via PIO and also manually downloading the source and replacing it in the libdeps. This is building with the latest (v2.2.3) NimBLE version. Any thoughts:
image

@samspencer5991
Copy link

@RobertoHE just wondering if you can steer me in the right direction here please

@nforro
Copy link

nforro commented May 15, 2025

Apart from the changes here I also did these:

diff --git a/src/hardware/BLEMIDI_Client_ESP32.h b/src/hardware/BLEMIDI_Client_ESP32.h
index b16dd48..8f2c5dc 100644
--- a/src/hardware/BLEMIDI_Client_ESP32.h
+++ b/src/hardware/BLEMIDI_Client_ESP32.h
@@ -149,7 +149,7 @@ public:
     std::string nameTarget;
 
 protected:
-    void onResult(NimBLEAdvertisedDevice *advertisedDevice)
+    void onResult(const NimBLEAdvertisedDevice *advertisedDevice)
     {
         if (!enableConnection) // not begin() or end()
         {
diff --git a/src/hardware/BLEMIDI_ESP32_NimBLE.h b/src/hardware/BLEMIDI_ESP32_NimBLE.h
index 6914a00..9a4c3d1 100644
--- a/src/hardware/BLEMIDI_ESP32_NimBLE.h
+++ b/src/hardware/BLEMIDI_ESP32_NimBLE.h
@@ -82,13 +82,13 @@ public:
 protected:
     BLEMIDI_ESP32_NimBLE<_Settings> *_bluetoothEsp32 = nullptr;
 
-    void onConnect(BLEServer *)
+    void onConnect(BLEServer *, NimBLEConnInfo &)
     {
         if (_bluetoothEsp32)
             _bluetoothEsp32->connected();
     };
 
-    void onDisconnect(BLEServer *)
+    void onDisconnect(BLEServer *, NimBLEConnInfo &, int)
     {
         if (_bluetoothEsp32)
             _bluetoothEsp32->disconnected();
@@ -107,7 +107,7 @@ public:
 protected:
     BLEMIDI_ESP32_NimBLE<_Settings> *_bluetoothEsp32 = nullptr;
 
-    void onWrite(BLECharacteristic *characteristic)
+    void onWrite(BLECharacteristic *characteristic, NimBLEConnInfo &)
     {
         std::string rxValue = characteristic->getValue();
         if (rxValue.length() > 0)
@@ -173,6 +173,7 @@ bool BLEMIDI_ESP32_NimBLE<_Settings>::begin(const char *deviceName, BLEMIDI_Tran
     _advertising = _server->getAdvertising();
     _advertising->addServiceUUID(service->getUUID());
     _advertising->setAppearance(0x00);
+    _advertising->setName(deviceName);
     _advertising->start();
 
     return true;

Everything seems to be working fine (at least for my use case) on ESP32-C6.

@samspencer5991 I don't think those errors are related to these changes.

@RobertoHE
Copy link
Contributor Author

@samspencer5991 @nforro @lathoub @MicroMidi @jhsa. Please, check it.

@lathoub
Copy link
Owner

lathoub commented May 22, 2025

Thx @RobertoHE have other been able to test? @nforro @MicroMidi @samspencer5991

@jhsa
Copy link

jhsa commented May 23, 2025

Hi, I tried compiling the Sketch "MidiBle_Client.ino" for the ESP32-S3 board, but it does not compile. I am using IDE 2.3.5. Here is the error:

In file included from C:\Users\Joao\AppData\Local\Temp\.arduinoIDE-unsaved2025423-8740-17gekze.0ejj\MidiBle_Client\MidiBle_Client.ino:31:
c:\Users\Joao\Documents\Arduino\libraries\BLE-MIDI\src/hardware/BLEMIDI_Client_ESP32.h:178:1: error: expected class-name before '{' token
  178 | {
      | ^
c:\Users\Joao\Documents\Arduino\libraries\BLE-MIDI\src/hardware/BLEMIDI_Client_ESP32.h: In member function 'void bleMidi::AdvertisedDeviceCallbacks::onResult(NimBLEAdvertisedDevice*)':
c:\Users\Joao\Documents\Arduino\libraries\BLE-MIDI\src/hardware/BLEMIDI_Client_ESP32.h:197:125: error: no match for 'operator==' (operand types are 'const NimBLEAddress' and 'std::string' {aka 'std::__cxx11::basic_string<char>'})
  197 |                 if (!specificTarget || (advertisedDevice->getName() == nameTarget.c_str() || advertisedDevice->getAddress() == nameTarget))
      |                                                                                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^~ ~~~~~~~~~~
      |                                                                                                                          |     |
      |                                                                                                                          |     std::string {aka std::__cxx11::basic_string<char>}
      |                                                                                                                          const NimBLEAddress
In file included from C:/Users/Joao/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/xtensa-esp-elf/esp32s3/no-rtti/bits/c++allocator.h:33,
                 from C:/Users/Joao/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/bits/allocator.h:46,
                 from C:/Users/Joao/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/bits/alloc_traits.h:39,
                 from C:/Users/Joao/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/ext/alloc_traits.h:34,
                 from C:/Users/Joao/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/bits/hashtable_policy.h:39,
                 from C:/Users/Joao/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/bits/hashtable.h:35,
                 from C:/Users/Joao/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/bits/unordered_map.h:33,
                 from C:/Users/Joao/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/unordered_map:41,
                 from C:/Users/Joao/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/functional:63,
                 from C:\Users\Joao\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.2.0\cores\esp32/HardwareSerial.h:49,
                 from C:\Users\Joao\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.2.0\cores\esp32/Arduino.h:203,
                 from C:\Users\Joao\AppData\Local\Temp\.arduinoIDE-unsaved2025423-8740-17gekze.0ejj\MidiBle_Client\MidiBle_Client.ino:28:
C:/Users/Joao/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/bits/new_allocator.h:215:9: note: candidate: 'template<class _Up> constexpr bool std::operator==(const __new_allocator<char>&, const __new_allocator<_Tp>&)' (reversed)
  215 |         operator==(const __new_allocator&, const __new_allocator<_Up>&)
      |         ^~~~~~~~
C:/Users/Joao/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/bits/new_allocator.h:215:9: note:   template argument deduction/substitution failed:
c:\Users\Joao\Documents\Arduino\libraries\BLE-MIDI\src/hardware/BLEMIDI_Client_ESP32.h:197:128: note:   'const NimBLEAddress' is not derived from 'const std::__new_allocator<_Tp>'
  197 |                 if (!specificTarget || (advertisedDevice->getName() == nameTarget.c_str() || advertisedDevice->getAddress() == nameTarget))
      |                                                                                                                                ^~~~~~~~~~
In file included from C:/Users/Joao/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/bits/stl_algobase.h:64,
                 from C:/Users/Joao/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/bits/specfun.h:43,
                 from C:/Users/Joao/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/cmath:3898,
                 from C:/Users/Joao/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/math.h:36,
                 from C:\Users\Joao\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.2.0\cores\esp32/esp32-hal.h:30,
                 from C:\Users\Joao\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.2.0\cores\esp32/Arduino.h:45:
C:/Users/Joao/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/bits/stl_pair.h:1010:5: note: candidate: 'template<class _T1, class _T2, class _U1, class _U2> constexpr bool std::operator==(const pair<_T1, _T2>&, const pair<_U1, _U2>&)' (reversed)
 1010 |     operator==(const pair<_T1, _T2>& __x, const pair<_U1, _U2>& __y)
      |     ^~~~~~~~
C:/Users/Joao/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/bits/stl_pair.h:1010:5: note:   template argument deduction/substitution failed:
c:\Users\Joao\Documents\Arduino\libraries\BLE-MIDI\src/hardware/BLEMIDI_Client_ESP32.h:197:128: note:   'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::pair<_T1, _T2>'
  197 |                 if (!specificTarget || (advertisedDevice->getName() == nameTarget.c_str() || advertisedDevice->getAddress() == nameTarget))
      |                                                                                                                                ^~~~~~~~~~
In file included from C:/Users/Joao/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/bits/stl_algobase.h:67:
C:/Users/Joao/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/bits/stl_iterator.h:527:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const reverse_iterator<_IteratorL>&, const reverse_iterator<_IteratorR>&) requires requires{{std::operator==::__x->base() == std::operator==::__y->base()} -> decltype(auto) [requires std::convertible_to<<placeholder>, bool>];}' (reversed)
  527 |     operator==(const reverse_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
C:/Users/Joao/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/bits/stl_iterator.h:527:5: note:   template argument deduction/substitution failed:
c:\Users\Joao\Documents\Arduino\libraries\BLE-MIDI\src/hardware/BLEMIDI_Client_ESP32.h:197:128: note:   'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::reverse_iterator<_IteratorL>'
  197 |                 if (!specificTarget || (advertisedDevice->getName() == nameTarget.c_str() || advertisedDevice->getAddress() == nameTarget))
      |                                                                                                                                ^~~~~~~~~~
C:/Users/Joao/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/bits/stl_iterator.h:1667:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&) requires requires{{std::operator==::__x->base() == std::operator==::__y->base()} -> decltype(auto) [requires std::convertible_to<<placeholder>, bool>];}' (reversed)
 1667 |     operator==(const move_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
C:/Users/Joao/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/bits/stl_iterator.h:1667:5: note:   template argument deduction/substitution failed:
c:\Users\Joao\Documents\Arduino\libraries\BLE-MIDI\src/hardware/BLEMIDI_Client_ESP32.h:197:128: note:   'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::move_iterator<_IteratorL>'
  197 |                 if (!specificTarget || (advertisedDevice->getName() == nameTarget.c_str() || advertisedDevice->getAddress() == nameTarget))
      |                                                                                                                                ^~~~~~~~~~
In file included from C:/Users/Joao/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/functional:53:
C:/Users/Joao/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/tuple:2556:5: note: candidate: 'template<class ... _TElements, class ... _UElements> constexpr bool std::operator==(const tuple<_UTypes ...>&, const tuple<_Elements ...>&)' (reversed)
 2556 |     operator==(const tuple<_TElements...>& __t,
      |     ^~~~~~~~
C:/Users/Joao/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/tuple:2556:5: note:   template argument deduction/substitution failed:
c:\Users\Joao\Documents\Arduino\libraries\BLE-MIDI\src/hardware/BLEMIDI_Client_ESP32.h:197:128: note:   'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::tuple<_UTypes ...>'
  197 |                 if (!specificTarget || (advertisedDevice->getName() == nameTarget.c_str() || advertisedDevice->getAddress() == nameTarget))
      |                                                                                                                                ^~~~~~~~~~
In file included from C:/Users/Joao/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/functional:59:
C:/Users/Joao/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/bits/std_function.h:743:5: note: candidate: 'template<class _Res, class ... _Args> bool std::operator==(const function<_Res(_ArgTypes ...)>&, nullptr_t)' (reversed)
  743 |     operator==(const function<_Res(_Args...)>& __f, nullptr_t) noexcept
      |     ^~~~~~~~
C:/Users/Joao/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/bits/std_function.h:743:5: note:   template argument deduction/substitution failed:
c:\Users\Joao\Documents\Arduino\libraries\BLE-MIDI\src/hardware/BLEMIDI_Client_ESP32.h:197:128: note:   'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::function<_Res(_ArgTypes ...)>'
  197 |                 if (!specificTarget || (advertisedDevice->getName() == nameTarget.c_str() || advertisedDevice->getAddress() == nameTarget))
      |                                                                                                                                ^~~~~~~~~~
C:/Users/Joao/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/bits/allocator.h:235:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator==(const allocator<_Up>&, const allocator<_T2>&)' (reversed)
  235 |     operator==(const allocator<_T1>&, const allocator<_T2>&)
      |     ^~~~~~~~
C:/Users/Joao/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/bits/allocator.h:235:5: note:   template argument deduction/substitution failed:
c:\Users\Joao\Documents\Arduino\libraries\BLE-MIDI\src/hardware/BLEMIDI_Client_ESP32.h:197:128: note:   'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::allocator<_Up>'
  197 |                 if (!specificTarget || (advertisedDevice->getName() == nameTarget.c_str() || advertisedDevice->getAddress() == nameTarget))
      |                                                                                                                                ^~~~~~~~~~
In file included from C:/Users/Joao/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/bits/basic_string.h:47,
                 from C:/Users/Joao/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/string:54,
                 from c:\Users\Joao\Documents\Arduino\libraries\NimBLE-Arduino\src/NimBLEDevice.h:40,
                 from c:\Users\Joao\Documents\Arduino\libraries\BLE-MIDI\src/hardware/BLEMIDI_Client_ESP32.h:145:
C:/Users/Joao/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/string_view:609:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(basic_string_view<_CharT, _Traits>, type_identity_t<basic_string_view<_CharT, _Traits> >)' (reversed)
  609 |     operator==(basic_string_view<_CharT, _Traits> __x,
      |     ^~~~~~~~
C:/Users/Joao/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/string_view:609:5: note:   template argument deduction/substitution failed:
c:\Users\Joao\Documents\Arduino\libraries\BLE-MIDI\src/hardware/BLEMIDI_Client_ESP32.h:197:128: note:   'std::__cxx11::basic_string<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
  197 |                 if (!specificTarget || (advertisedDevice->getName() == nameTarget.c_str() || advertisedDevice->getAddress() == nameTarget))
      |                                                                                                                                ^~~~~~~~~~
C:/Users/Joao/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/bits/basic_string.h:3772:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> constexpr bool std::operator==(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)' (reversed)
 3772 |     operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~~~~~
C:/Users/Joao/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/bits/basic_string.h:3772:5: note:   template argument deduction/substitution failed:
c:\Users\Joao\Documents\Arduino\libraries\BLE-MIDI\src/hardware/BLEMIDI_Client_ESP32.h:197:128: note:   mismatched types 'const _CharT*' and 'NimBLEAddress'
  197 |                 if (!specificTarget || (advertisedDevice->getName() == nameTarget.c_str() || advertisedDevice->getAddress() == nameTarget))
      |                                                                                                                                ^~~~~~~~~~
In file included from c:\Users\Joao\Documents\Arduino\libraries\NimBLE-Arduino\src/NimBLEClient.h:30,
                 from c:\Users\Joao\Documents\Arduino\libraries\NimBLE-Arduino\src/NimBLEDevice.h:282:
c:\Users\Joao\Documents\Arduino\libraries\NimBLE-Arduino\src/NimBLEAddress.h:63:26: note: candidate: 'bool NimBLEAddress::operator==(const NimBLEAddress&) const'
   63 |     bool                 operator==(const NimBLEAddress& rhs) const;
      |                          ^~~~~~~~
c:\Users\Joao\Documents\Arduino\libraries\NimBLE-Arduino\src/NimBLEAddress.h:63:58: note:   no known conversion for argument 1 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'const NimBLEAddress&'
   63 |     bool                 operator==(const NimBLEAddress& rhs) const;
      |                                     ~~~~~~~~~~~~~~~~~~~~~^~~
C:/Users/Joao/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/bits/stl_iterator.h:586:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const reverse_iterator<_IteratorL>&, const reverse_iterator<_IteratorL>&) requires requires{{std::operator==::__x->base() == std::operator==::__y->base()} -> decltype(auto) [requires std::convertible_to<<placeholder>, bool>];}'
  586 |     operator==(const reverse_iterator<_Iterator>& __x,
      |     ^~~~~~~~
C:/Users/Joao/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/bits/stl_iterator.h:586:5: note:   template argument deduction/substitution failed:
c:\Users\Joao\Documents\Arduino\libraries\BLE-MIDI\src/hardware/BLEMIDI_Client_ESP32.h:197:128: note:   'const NimBLEAddress' is not derived from 'const std::reverse_iterator<_IteratorL>'
  197 |                 if (!specificTarget || (advertisedDevice->getName() == nameTarget.c_str() || advertisedDevice->getAddress() == nameTarget))
      |                                                                                                                                ^~~~~~~~~~
C:/Users/Joao/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/bits/stl_iterator.h:1737:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
 1737 |     operator==(const move_iterator<_Iterator>& __x,
      |     ^~~~~~~~
C:/Users/Joao/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/bits/stl_iterator.h:1737:5: note:   template argument deduction/substitution failed:
c:\Users\Joao\Documents\Arduino\libraries\BLE-MIDI\src/hardware/BLEMIDI_Client_ESP32.h:197:128: note:   'const NimBLEAddress' is not derived from 'const std::move_iterator<_IteratorL>'
  197 |                 if (!specificTarget || (advertisedDevice->getName() == nameTarget.c_str() || advertisedDevice->getAddress() == nameTarget))
      |                                                                                                                                ^~~~~~~~~~
C:/Users/Joao/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/bits/unordered_map.h:2144:5: note: candidate: 'template<class _Key1, class _Tp1, class _Hash1, class _Pred1, class _Alloc1> bool std::operator==(const unordered_map<_Key1, _Tp1, _Hash1, _Pred1, _Alloc1>&, const unordered_map<_Key1, _Tp1, _Hash1, _Pred1, _Alloc1>&)'
 2144 |     operator==(const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
      |     ^~~~~~~~
C:/Users/Joao/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/bits/unordered_map.h:2144:5: note:   template argument deduction/substitution failed:
c:\Users\Joao\Documents\Arduino\libraries\BLE-MIDI\src/hardware/BLEMIDI_Client_ESP32.h:197:128: note:   'const NimBLEAddress' is not derived from 'const std::unordered_map<_Key1, _Tp1, _Hash1, _Pred1, _Alloc1>'
  197 |                 if (!specificTarget || (advertisedDevice->getName() == nameTarget.c_str() || advertisedDevice->getAddress() == nameTarget))
      |                                                                                                                                ^~~~~~~~~~
C:/Users/Joao/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/bits/unordered_map.h:2158:5: note: candidate: 'template<class _Key1, class _Tp1, class _Hash1, class _Pred1, class _Alloc1> bool std::operator==(const unordered_multimap<_Key1, _Tp1, _Hash1, _Pred1, _Alloc1>&, const unordered_multimap<_Key1, _Tp1, _Hash1, _Pred1, _Alloc1>&)'
 2158 |     operator==(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
      |     ^~~~~~~~
C:/Users/Joao/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/bits/unordered_map.h:2158:5: note:   template argument deduction/substitution failed:
c:\Users\Joao\Documents\Arduino\libraries\BLE-MIDI\src/hardware/BLEMIDI_Client_ESP32.h:197:128: note:   'const NimBLEAddress' is not derived from 'const std::unordered_multimap<_Key1, _Tp1, _Hash1, _Pred1, _Alloc1>'
  197 |                 if (!specificTarget || (advertisedDevice->getName() == nameTarget.c_str() || advertisedDevice->getAddress() == nameTarget))
      |                                                                                                                                ^~~~~~~~~~
In file included from C:/Users/Joao/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/vector:66,
                 from C:/Users/Joao/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/functional:64:
C:/Users/Joao/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/bits/stl_vector.h:2050:5: note: candidate: 'template<class _Tp, class _Alloc> constexpr bool std::operator==(const vector<_Tp, _Alloc>&, const vector<_Tp, _Alloc>&)'
 2050 |     operator==(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
      |     ^~~~~~~~
C:/Users/Joao/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/bits/stl_vector.h:2050:5: note:   template argument deduction/substitution failed:
c:\Users\Joao\Documents\Arduino\libraries\BLE-MIDI\src/hardware/BLEMIDI_Client_ESP32.h:197:128: note:   'const NimBLEAddress' is not derived from 'const std::vector<_Tp, _Alloc>'
  197 |                 if (!specificTarget || (advertisedDevice->getName() == nameTarget.c_str() || advertisedDevice->getAddress() == nameTarget))
      |                                                                                                                                ^~~~~~~~~~
In file included from C:/Users/Joao/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/functional:65:
C:/Users/Joao/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/array:303:5: note: candidate: 'template<class _Tp, unsigned int _Nm> constexpr bool std::operator==(const array<_Tp, _Nm>&, const array<_Tp, _Nm>&)'
  303 |     operator==(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
      |     ^~~~~~~~
C:/Users/Joao/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/array:303:5: note:   template argument deduction/substitution failed:
c:\Users\Joao\Documents\Arduino\libraries\BLE-MIDI\src/hardware/BLEMIDI_Client_ESP32.h:197:128: note:   'const NimBLEAddress' is not derived from 'const std::array<_Tp, _Nm>'
  197 |                 if (!specificTarget || (advertisedDevice->getName() == nameTarget.c_str() || advertisedDevice->getAddress() == nameTarget))
      |                                                                                                                                ^~~~~~~~~~
In file included from C:/Users/Joao/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/bits/char_traits.h:42,
                 from C:/Users/Joao/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/string:42:
C:/Users/Joao/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/bits/postypes.h:192:5: note: candidate: 'template<class _StateT> bool std::operator==(const fpos<_StateT>&, const fpos<_StateT>&)'
  192 |     operator==(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs)
      |     ^~~~~~~~
C:/Users/Joao/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/bits/postypes.h:192:5: note:   template argument deduction/substitution failed:
c:\Users\Joao\Documents\Arduino\libraries\BLE-MIDI\src/hardware/BLEMIDI_Client_ESP32.h:197:128: note:   'const NimBLEAddress' is not derived from 'const std::fpos<_StateT>'
  197 |                 if (!specificTarget || (advertisedDevice->getName() == nameTarget.c_str() || advertisedDevice->getAddress() == nameTarget))
      |                                                                                                                                ^~~~~~~~~~
C:/Users/Joao/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/bits/basic_string.h:3755:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> constexpr bool std::operator==(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
 3755 |     operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~~~~~
C:/Users/Joao/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/bits/basic_string.h:3755:5: note:   template argument deduction/substitution failed:
c:\Users\Joao\Documents\Arduino\libraries\BLE-MIDI\src/hardware/BLEMIDI_Client_ESP32.h:197:128: note:   'const NimBLEAddress' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
  197 |                 if (!specificTarget || (advertisedDevice->getName() == nameTarget.c_str() || advertisedDevice->getAddress() == nameTarget))
      |                                                                                                                                ^~~~~~~~~~
C:/Users/Joao/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/bits/allocator.h:214:7: note: candidate: 'constexpr bool std::operator==(const allocator<char>&, const allocator<char>&)'
  214 |       operator==(const allocator&, const allocator&) _GLIBCXX_NOTHROW
      |       ^~~~~~~~
C:/Users/Joao/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/bits/allocator.h:214:18: note:   no known conversion for argument 1 from 'const NimBLEAddress' to 'const std::allocator<char>&'
  214 |       operator==(const allocator&, const allocator&) _GLIBCXX_NOTHROW
      |                  ^~~~~~~~~~~~~~~~
c:\Users\Joao\Documents\Arduino\libraries\BLE-MIDI\src/hardware/BLEMIDI_Client_ESP32.h: In member function 'void bleMidi::BLEMIDI_Client_ESP32::scan()':
c:\Users\Joao\Documents\Arduino\libraries\BLE-MIDI\src/hardware/BLEMIDI_Client_ESP32.h:499:19: error: 'class NimBLEScan' has no member named 'setAdvertisedDeviceCallbacks'
  499 |         pBLEScan->setAdvertisedDeviceCallbacks(&myAdvCB);
      |                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
c:\Users\Joao\Documents\Arduino\libraries\BLE-MIDI\src/hardware/BLEMIDI_Client_ESP32.h: In member function 'bool bleMidi::BLEMIDI_Client_ESP32::connect()':
c:\Users\Joao\Documents\Arduino\libraries\BLE-MIDI\src/hardware/BLEMIDI_Client_ESP32.h:547:23: error: 'getClientListSize' is not a member of 'NimBLEDevice'
  547 |     if (NimBLEDevice::getClientListSize() >= NIMBLE_MAX_CONNECTIONS)
      |                       ^~~~~~~~~~~~~~~~~
exit status 1

Compilation error: exit status 1

@RobertoHE
Copy link
Contributor Author

Do you use the branch or main repo?

@jhsa
Copy link

jhsa commented May 23, 2025

Do you use the branch or main repo?

Well, I have just reinstalled the library using the IDE itself. Shall I do it differently?

@jhsa
Copy link

jhsa commented May 23, 2025

I have just installed version 2.1.0 of the library using the arduino IDE, tried to compile the sketch "MidiBle.ino" for ESP32-S3 with "#include <hardware/BLEMIDI_ESP32_NimBLE.h>" selected and it did compile. I still don't know if it actually works. But at least it did compile.

@RobertoHE
Copy link
Contributor Author

You are using the main repo without request changes. You must use pull request code.

@jhsa
Copy link

jhsa commented May 23, 2025

You are using the main repo without request changes. You must use pull request code.

So, manual installation then.
Do you mind posting the link to it again please?
Also, I am still not very familiar with all this, do I have to install the other "Dependencies/libraries" inside the library this library folder?
Thanks

@RobertoHE
Copy link
Contributor Author

If you use Platformio, you can use something like this in platformio.ini:
lib_deps = ;https://github.com/lathoub/Arduino-BLE-MIDI ; <-- Main repro. NO ;https://github.com/RobertoHE/Arduino-BLE-MIDI ; <-- My main repo. NO https://github.com/RobertoHE/Arduino-BLE-MIDI.git#CustomSettings <-- My repro with PullRequest code YES

In Arduino IDE, you must select the PR code (for example, my repo and CustomSetting Branch ), download the code ( Code -> Download as zip), and install it manually in Arduino (copy files to the Arduino path and reload the IDE).
In both cases, you will find more info and step-by-step guides on internet.

@jhsa
Copy link

jhsa commented May 23, 2025

Ok, Thanks RobertoHE, I am trying to improve an old project and it wasn't compiling anymore. I think the ESP32 core changed and as far as I understand libraries will have to adapt to it, otherwise they won't work anymore, at least some of them. Will try this asap. It might take a couple days..

@RobertoHE
Copy link
Contributor Author

@lathoub. The Auto Test script has a little problem, if you try to compile Arduino-BLE lib and ESP-BLE libs on the same computer, because they have incompatible methods. If I only include the Hardware transport layer of ESP-BLE lib (<hardware/BLEMIDI_ESP32_NimBLE.h>, <hardware/BLEMIDI_ESP32.h> or<hardware/BLEMIDI_Client_ESP32.h> but no <hardware/BLEMIDI_ArduinoBLE.h>) The test runs OK, but the test doesn't cover the ArduinoBLE lib code.

Except for this one, I compile every code with every hardware layer manually, and everything compiles fine. I can't test them in functionality because I don't have hardware now, but I can suppose that they can work fine.

Additionally, I unified all configuration methods by hierarchy ( MIDI -> BLE_MIDI -> BLE_Transport Layer). You can configure MIDI and BLE with the same structure configuration. I refactored some example code to illustrate that.
I didn't study the other transport layer lib, but if they use some configurations (transmission power, security, or whatever), I advise you, @lathoub, to update them by adding those code lines functionalities of the BLE lib following the example of the client lib.

@RobertoHE
Copy link
Contributor Author

I think that the CustomSettings branch (configuration capabilities of MIDI and BLEMIDI) can merge as the master branch. In my opinion, this method of configuration transport layer and MIDI functionality is more flexible, adaptive, and easy to use than the master branch.
Some tests must be necessary to prove that this branch and master have the same methods, and they may be used in the same way without any additional changes in end-user codes.

@lathoub
Copy link
Owner

lathoub commented May 25, 2025

Great work, i will try on my end. @ all: please check as well

@jhsa
Copy link

jhsa commented May 29, 2025

In Arduino IDE, you must select the PR code (for example, my repo and CustomSetting Branch ), download the code ( Code -> Download as zip), and install it manually in Arduino (copy files to the Arduino path and reload the IDE). In both cases, you will find more info and step-by-step guides on internet.

I am testing your library on my older project and the devices is being recognized as "Unknown Device" by my android smartphone. Am I doing something wrong?
EDIT: The same happens when I try the "MidiBle.ino" sketch It is detected by the MIDI+BTLE tool on my android smartphone, but as Unknown device. It appears on the midi monitor as a blank space (no name), and it doesn't send or receive any midi messages.

#include <BLEMIDI_Transport.h>
#include <hardware/BLEMIDI_ESP32_NimBLE.h>

// BLE MIDI object
BLEMIDI_CREATE_INSTANCE("iL9_BLE", BLE_MIDI)

void setup {

BLE_MIDI.begin(MIDI_CHANNEL_OMNI);
    BLE_MIDI.setHandleProgramChange(BLE_ProgramChange);
    BLE_MIDI.setHandleControlChange(BLE_ControlChange);

}

@jhsa
Copy link

jhsa commented May 31, 2025

Tried also with a normal "ESP32 board "DOIT ESP32 DEVKIT V1" and am having the same behavior.
Selecting the default "#include <hardware/BLEMIDI_ESP32.h>" it doesn't compile.
Selecting "#include <hardware/BLEMIDI_ESP32_NimBLE.h>" it compiles but it appears as Unknown device on my phone, and the device name appears empty on the Midi Monitor device name setting. No Midi messages are transferred either way.
Sketch is the "MidiBle.ino".
Same behavior as with the ESP32-S3 board.
Are you guys testing this?? Is it working for you? Am I doing something wrong?

@nforro
Copy link

nforro commented May 31, 2025

@jhsa For the Unknown Device, see the last hunk of the diff I posted above - device name is not being advertised by default anymore.

Sorry, I haven't been able to test the code changes yet.

@jhsa
Copy link

jhsa commented May 31, 2025

@jhsa For the Unknown Device, see the last hunk of the diff I posted above - device name is not being advertised by default anymore.

Sorry, I haven't been able to test the code changes yet.

what file is that? Can't find it..
Sorry I am a beginner..

@nforro
Copy link

nforro commented Jun 1, 2025

@jsha src/hardware/BLEMIDI_ESP32_NimBLE.h:

// Start advertising
_advertising = _server->getAdvertising();
_advertising->addServiceUUID(service->getUUID());
_advertising->setAppearance(0x00);
_advertising->start();

You need to add _advertising->setName(deviceName); before _advertising->start();.

@RobertoHE
Copy link
Contributor Author

@jsha src/hardware/BLEMIDI_ESP32_NimBLE.h:

// Start advertising
_advertising = _server->getAdvertising();
_advertising->addServiceUUID(service->getUUID());
_advertising->setAppearance(0x00);
_advertising->start();

You need to add _advertising->setName(deviceName); before _advertising->start();.

Change added.
@nforro @jhsa

@RobertoHE
Copy link
Contributor Author

Tried also with a normal "ESP32 board "DOIT ESP32 DEVKIT V1" and am having the same behavior. Selecting the default "#include <hardware/BLEMIDI_ESP32.h>" it doesn't compile. Selecting "#include <hardware/BLEMIDI_ESP32_NimBLE.h>" it compiles but it appears as Unknown device on my phone, and the device name appears empty on the Midi Monitor device name setting. No Midi messages are transferred either way. Sketch is the "MidiBle.ino". Same behavior as with the ESP32-S3 board. Are you guys testing this?? Is it working for you? Am I doing something wrong?

Can you explain to me what setup you are using? (IDE, what library you are using, how you install it, in what version, etc.)
What error appears when you compile #include <hardware/BLEMIDI_ESP32.h>?
I am worried that no messages got transmitted. Can me with some information about your setup?

@jhsa
Copy link

jhsa commented Jun 1, 2025

Tried also with a normal "ESP32 board "DOIT ESP32 DEVKIT V1" and am having the same behavior. Selecting the default "#include <hardware/BLEMIDI_ESP32.h>" it doesn't compile. Selecting "#include <hardware/BLEMIDI_ESP32_NimBLE.h>" it compiles but it appears as Unknown device on my phone, and the device name appears empty on the Midi Monitor device name setting. No Midi messages are transferred either way. Sketch is the "MidiBle.ino". Same behavior as with the ESP32-S3 board. Are you guys testing this?? Is it working for you? Am I doing something wrong?

Can you explain to me what setup you are using? (IDE, what library you are using, how you install it, in what version, etc.) What error appears when you compile #include <hardware/BLEMIDI_ESP32.h>? I am worried that no messages got transmitted. Can me with some information about your setup?

Hi Thanks for your help. I have the latest Espressiff ESP32 core installed. I have downloaded the zip file from your repo at https://github.com/RobertoHE/Arduino-BLE-MIDI/tree/CustomSettings.
Then, after deleting the BLE-MIDI library I had installed, started the Arduino IDE 2.3.5 an clicked on Sketch/Include Library/Add .ZIP Library, pointed it to the file I downloaded from your repo, and let it install.
Next tried to compile the MidiBle.ino from the library examples using "#include <hardware/BLEMIDI_ESP32.h>".
The IDE shows the following compiling error:

In file included from C:\Users\Joao\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.2.0\libraries\BLE\src/BLECharacteristic.h:20,
                 from C:\Users\Joao\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.2.0\libraries\BLE\src/BLEService.h:18,
                 from C:\Users\Joao\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.2.0\libraries\BLE\src/BLEClient.h:23,
                 from C:\Users\Joao\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.2.0\libraries\BLE\src/BLEUtils.h:19,
                 from c:\Users\Joao\Documents\Arduino\libraries\BLE-MIDI\src/hardware/BLEMIDI_ESP32.h:5,
                 from C:\Users\Joao\AppData\Local\Temp\.arduinoIDE-unsaved202551-14036-jhin97.s6fl8\MidiBle\MidiBle.ino:4:
C:\Users\Joao\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.2.0\libraries\BLE\src/BLEDescriptor.h:28:7: error: redefinition of 'class BLEDescriptor'
   28 | class BLEDescriptor {
      |       ^~~~~~~~~~~~~
In file included from c:\Users\Joao\Documents\Arduino\libraries\ArduinoBLE\src/BLECharacteristic.h:25,
                 from c:\Users\Joao\Documents\Arduino\libraries\ArduinoBLE\src/BLEService.h:23,
                 from c:\Users\Joao\Documents\Arduino\libraries\ArduinoBLE\src/BLEDevice.h:25,
                 from c:\Users\Joao\Documents\Arduino\libraries\BLE-MIDI\src/hardware/BLEMIDI_ESP32.h:4:
c:\Users\Joao\Documents\Arduino\libraries\ArduinoBLE\src/BLEDescriptor.h:28:7: note: previous definition of 'class BLEDescriptor'
   28 | class BLEDescriptor {
      |       ^~~~~~~~~~~~~
C:\Users\Joao\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.2.0\libraries\BLE\src/BLECharacteristic.h:56:7: error: redefinition of 'class BLECharacteristic'
   56 | class BLECharacteristic {
      |       ^~~~~~~~~~~~~~~~~
c:\Users\Joao\Documents\Arduino\libraries\ArduinoBLE\src/BLECharacteristic.h:45:7: note: previous definition of 'class BLECharacteristic'
   45 | class BLECharacteristic  {
      |       ^~~~~~~~~~~~~~~~~
C:\Users\Joao\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.2.0\libraries\BLE\src/BLEService.h:51:7: error: redefinition of 'class BLEService'
   51 | class BLEService {
      |       ^~~~~~~~~~
c:\Users\Joao\Documents\Arduino\libraries\ArduinoBLE\src/BLEService.h:28:7: note: previous definition of 'class BLEService'
   28 | class BLEService {
      |       ^~~~~~~~~~
c:\Users\Joao\Documents\Arduino\libraries\BLE-MIDI\src/hardware/BLEMIDI_ESP32.h: In member function 'void bleMidi::BLEMIDI_ESP32<_Settings>::write(uint8_t*, size_t)':
c:\Users\Joao\Documents\Arduino\libraries\BLE-MIDI\src/hardware/BLEMIDI_ESP32.h:53:26: error: 'class BLECharacteristic' has no member named 'notify'
   53 |         _characteristic->notify();
      |                          ^~~~~~
c:\Users\Joao\Documents\Arduino\libraries\BLE-MIDI\src/hardware/BLEMIDI_ESP32.h: In member function 'void bleMidi::MyCharacteristicCallbacks<_Settings>::onWrite(BLECharacteristic*)':
c:\Users\Joao\Documents\Arduino\libraries\BLE-MIDI\src/hardware/BLEMIDI_ESP32.h:130:40: error: 'class BLECharacteristic' has no member named 'getValue'; did you mean 'setValue'?
  130 |         auto rxValue = characteristic->getValue();
      |                                        ^~~~~~~~
      |                                        setValue
c:\Users\Joao\Documents\Arduino\libraries\BLE-MIDI\src/hardware/BLEMIDI_ESP32.h: In member function 'bool bleMidi::BLEMIDI_ESP32<_Settings>::begin(const char*, bleMidi::BLEMIDI_Transport<bleMidi::BLEMIDI_ESP32<_Settings>, _Settings>*)':
c:\Users\Joao\Documents\Arduino\libraries\BLE-MIDI\src/hardware/BLEMIDI_ESP32.h:143:16: error: 'init' is not a member of 'BLEDevice'
  143 |     BLEDevice::init(deviceName);
      |                ^~~~
c:\Users\Joao\Documents\Arduino\libraries\BLE-MIDI\src/hardware/BLEMIDI_ESP32.h:149:26: error: 'createServer' is not a member of 'BLEDevice'
  149 |     _server = BLEDevice::createServer();
      |                          ^~~~~~~~~~~~
c:\Users\Joao\Documents\Arduino\libraries\BLE-MIDI\src/hardware/BLEMIDI_ESP32.h:156:32: error: 'class BLEService' has no member named 'createCharacteristic'; did you mean 'addCharacteristic'?
  156 |     _characteristic = service->createCharacteristic(
      |                                ^~~~~~~~~~~~~~~~~~~~
      |                                addCharacteristic
c:\Users\Joao\Documents\Arduino\libraries\BLE-MIDI\src/hardware/BLEMIDI_ESP32.h:158:28: error: 'PROPERTY_READ' is not a member of 'BLECharacteristic'
  158 |         BLECharacteristic::PROPERTY_READ |
      |                            ^~~~~~~~~~~~~
c:\Users\Joao\Documents\Arduino\libraries\BLE-MIDI\src/hardware/BLEMIDI_ESP32.h:159:32: error: 'PROPERTY_WRITE' is not a member of 'BLECharacteristic'
  159 |             BLECharacteristic::PROPERTY_WRITE |
      |                                ^~~~~~~~~~~~~~
c:\Users\Joao\Documents\Arduino\libraries\BLE-MIDI\src/hardware/BLEMIDI_ESP32.h:160:32: error: 'PROPERTY_NOTIFY' is not a member of 'BLECharacteristic'
  160 |             BLECharacteristic::PROPERTY_NOTIFY |
      |                                ^~~~~~~~~~~~~~~
c:\Users\Joao\Documents\Arduino\libraries\BLE-MIDI\src/hardware/BLEMIDI_ESP32.h:161:32: error: 'PROPERTY_WRITE_NR' is not a member of 'BLECharacteristic'
  161 |             BLECharacteristic::PROPERTY_WRITE_NR);
      |                                ^~~~~~~~~~~~~~~~~
c:\Users\Joao\Documents\Arduino\libraries\BLE-MIDI\src/hardware/BLEMIDI_ESP32.h:163:36: error: cannot convert 'BLE2902*' to 'BLEDescriptor&'
  163 |     _characteristic->addDescriptor(new BLE2902());
      |                                    ^~~~~~~~~~~~~
      |                                    |
      |                                    BLE2902*
c:\Users\Joao\Documents\Arduino\libraries\ArduinoBLE\src/BLECharacteristic.h:91:37: note:   initializing argument 1 of 'void BLECharacteristic::addDescriptor(BLEDescriptor&)'
   91 |   void addDescriptor(BLEDescriptor& descriptor);
      |                      ~~~~~~~~~~~~~~~^~~~~~~~~~
c:\Users\Joao\Documents\Arduino\libraries\BLE-MIDI\src/hardware/BLEMIDI_ESP32.h:165:22: error: 'class BLECharacteristic' has no member named 'setCallbacks'
  165 |     _characteristic->setCallbacks(new MyCharacteristicCallbacks<_Settings>(this));
      |                      ^~~~~~~~~~~~
c:\Users\Joao\Documents\Arduino\libraries\BLE-MIDI\src/hardware/BLEMIDI_ESP32.h:171:14: error: 'class BLEService' has no member named 'start'
  171 |     service->start();
      |              ^~~~~
c:\Users\Joao\Documents\Arduino\libraries\BLE-MIDI\src/hardware/BLEMIDI_ESP32.h:175:43: error: 'class BLEService' has no member named 'getUUID'
  175 |     _advertising->addServiceUUID(service->getUUID());
      |                                           ^~~~~~~
Multiple libraries were found for "BLEDevice.h"
  Used: C:\Users\Joao\Documents\Arduino\libraries\ArduinoBLE
  Not used: C:\Users\Joao\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.2.0\libraries\BLE
exit status 1

Compilation error: exit status 1

On the error message above there seems to be some references to some BLE library from the ESP core itself?? Perhaps there is some conflict?
If I compile the same code using "#include <hardware/BLEMIDI_ESP32_NimBLE.h>" instead, it does compile but it won't work and the device appears as unknown on my Samsung Smartphone and also older Huawei tablet.. Names are also empty. data is not shared, and the LED (pin 2) on the ESP32 board never turns On. Here are some pictures. I hope this info helps.

Screenshot_20250601_224054_Chrome

Screenshot_20250601_223657
Screenshot_20250601_223615

@jhsa
Copy link

jhsa commented Jun 1, 2025

@jsha src/hardware/BLEMIDI_ESP32_NimBLE.h:

// Start advertising
_advertising = _server->getAdvertising();
_advertising->addServiceUUID(service->getUUID());
_advertising->setAppearance(0x00);
_advertising->start();

You need to add _advertising->setName(deviceName); before _advertising->start();.

Change added. @nforro @jhsa

I have tried this, the sketch below compiles, the device name now appears, but I have no Midi data transfer. The ESP32 LED on Pin 2 should turn on when connected, and nothing happens..

#include <BLEMIDI_Transport.h>

#include <hardware/BLEMIDI_ESP32_NimBLE.h>
// #include <hardware/BLEMIDI_ESP32.h>
//#include <hardware/BLEMIDI_ArduinoBLE.h>

#ifndef LED_BUILTIN
#define LED_BUILTIN 2
#endif

BLEMIDI_CREATE_INSTANCE("iL9", MIDI)

unsigned long t0 = millis();
bool isConnected = false;

// -----------------------------------------------------------------------------
// When BLE connected, LED will turn on (indication that connection was successful)
// When receiving a NoteOn, LED will go out, on NoteOff, light comes back on.
// This is an easy and conveniant way to show that the connection is alive and working. 
// -----------------------------------------------------------------------------
void setup()
{
  MIDI.begin();

  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, LOW);

  BLEMIDI.setHandleConnected([]() {
    isConnected = true;
    digitalWrite(LED_BUILTIN, HIGH);
  });

  BLEMIDI.setHandleDisconnected([]() {
    isConnected = false;
    digitalWrite(LED_BUILTIN, LOW);
  });

  MIDI.setHandleNoteOn([](byte channel, byte note, byte velocity) {
    digitalWrite(LED_BUILTIN, LOW);
  });
  MIDI.setHandleNoteOff([](byte channel, byte note, byte velocity) {
    digitalWrite(LED_BUILTIN, HIGH);
  });
}

void loop()
{
  MIDI.read();

  if (isConnected && (millis() - t0) > 1000)
  {
    t0 = millis();

    MIDI.sendNoteOn (60, 100, 1); // note 60, velocity 100 on channel 1
  }
}

@jhsa
Copy link

jhsa commented Jun 1, 2025

Tried also with a normal "ESP32 board "DOIT ESP32 DEVKIT V1" and am having the same behavior. Selecting the default "#include <hardware/BLEMIDI_ESP32.h>" it doesn't compile. Selecting "#include <hardware/BLEMIDI_ESP32_NimBLE.h>" it compiles but it appears as Unknown device on my phone, and the device name appears empty on the Midi Monitor device name setting. No Midi messages are transferred either way. Sketch is the "MidiBle.ino". Same behavior as with the ESP32-S3 board. Are you guys testing this?? Is it working for you? Am I doing something wrong?

Can you explain to me what setup you are using? (IDE, what library you are using, how you install it, in what version, etc.) What error appears when you compile #include <hardware/BLEMIDI_ESP32.h>? I am worried that no messages got transmitted. Can me with some information about your setup?

I can see that you made changes to some files in your repo, I downloaded it again and installed it. Using "#include <hardware/BLEMIDI_ESP32.h>" still does not compile for DOIT ESP32 DEVKIT V1.

Now, the good news, "#include <hardware/BLEMIDI_ESP32_NimBLE.h>" is compiling, and working. I can see data transfer both ways on the DOIT ESP32 DEVKIT V1 board. Will now test on the ESP32-S3. Thank you.
Ahh, and the device name is also advertised and recognized by my Smartphone.

@jhsa
Copy link

jhsa commented Jun 2, 2025

Little update, when using the library on my older project that worked fine before, I am seeing some strange behavior when sending data. there is some data being sent twice, some data missing, when there are several midi messages bein sent when pressing a button, every press of the button is sending only different parts of the message when it should always send the complete different midi messages.
I need to do some more experiments and try to find out if the problem lays within the library or somewhere else. So I am going to use the MidiBle.ino example as a base, add a button or two and do some testing. Will report in a while..

@jhsa
Copy link

jhsa commented Jun 2, 2025

well, it looks like the problem is with the library, I try to send 2 control change messages and 2 Program Change messages when pressing a button, and the only message sent is the last Program Change "MIDI.sendProgramChange(115 , 16);" The others are somehow being ignored.

void loop()
{
  MIDI.read();
  check_switches();

  if (ShortPress[0]) {

    MIDI.sendControlChange(72, 100, 4);
    MIDI.sendControlChange(45, 54, 2);
    MIDI.sendProgramChange(125 , 11);
    MIDI.sendProgramChange(115 , 16);

  }

@jhsa
Copy link

jhsa commented Jun 2, 2025

If I do this, all values are sent..

void loop()
{
  MIDI.read();
  check_switches();

  if (ShortPress[0]) {

    MIDI.sendControlChange(72, 100, 4);
    delay(1);
    MIDI.sendControlChange(45, 54, 2);
    delay(1);
    MIDI.sendProgramChange(125 , 11);
    delay(1);
    MIDI.sendProgramChange(115 , 16);

  }

if I do this, only both Program Change messages are sent:

void loop()
{
  MIDI.read();
  check_switches();

  if (ShortPress[0]) {

    MIDI.sendControlChange(72, 100, 4);
    // delay(1);
    MIDI.sendControlChange(45, 54, 2);
    // delay(1);
    MIDI.sendProgramChange(125 , 11);
    // delay(1);
    MIDI.sendProgramChange(115 , 16);

delay(3);
  }

if I use delayMicroseconds(100); between messages, with each switch press, it alternates between missing CC message and sending one of the PC messages in double. Increasing the delay to 200 MicroSeconds, all messages seem to be correctly sent every time.
What do you guys think?
It looks like it needs a small delay between messages? This is not good, it will slow things down..
I might be saying something stupid but could it be that there is some buffer that is too small and needs time to clear before it sends the next message?

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

Successfully merging this pull request may close these issues.

5 participants