Skip to content

Commit 04babb8

Browse files
committed
Merge branch 'master' into CustomSettings
2 parents e09fa43 + 2e4b39f commit 04babb8

File tree

5 files changed

+25
-14
lines changed

5 files changed

+25
-14
lines changed

src/BLEMIDI_Transport.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ class BLEMIDI_Transport
183183
public:
184184
// callbacks
185185
void (*_connectedCallback)() = nullptr;
186+
void (*_connectedCallbackDeviceName)(char *) = nullptr;
186187
void (*_disconnectedCallback)() = nullptr;
187188
void (*_connectedCallbackDeviceName)(char *) = nullptr;
188189

@@ -198,6 +199,12 @@ class BLEMIDI_Transport
198199
_connectedCallback = fptr;
199200
return *this;
200201
}
202+
203+
BLEMIDI_Transport &setHandleConnected(void (*fptr)(char*))
204+
{
205+
_connectedCallbackDeviceName= fptr;
206+
return *this;
207+
}
201208

202209
BLEMIDI_Transport &setHandleConnected(void (*fptr)(char*))
203210
{

src/hardware/BLEMIDI_ArduinoBLE.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,17 @@
22

33
#include <ArduinoBLE.h>
44

5+
#define BLE_POLLING
6+
57
BEGIN_BLEMIDI_NAMESPACE
68

7-
template <typename T, short rawSize>
8-
class Fifo
9-
{
9+
BLEService midiService(SERVICE_UUID);
10+
11+
BLEStringCharacteristic midiChar(CHARACTERISTIC_UUID, // standard 16-bit characteristic UUID
12+
BLERead | BLEWrite | BLENotify | BLEWriteWithoutResponse, 16); // remote clients will be able to get notifications if this characteristic changes
13+
14+
template<typename T, int rawSize>
15+
class Fifo {
1016
public:
1117
const size_t size; // speculative feature, in case it's needed
1218

@@ -226,7 +232,7 @@ bool BLEMIDI_ArduinoBLE<_Settings>::begin(const char *deviceName, BLEMIDI_Transp
226232
/*! \brief Create an instance for ArduinoBLE <DeviceName>
227233
*/
228234
#define BLEMIDI_CREATE_INSTANCE(DeviceName, Name) \
229-
BLEMIDI_CREATE_CUSTOM_INSTANCE(DeviceName, Name, BLEMIDI_NAMESPACE::DefaultSettings)
235+
BLEMIDI_CREATE_CUSTOM_INSTANCE(DeviceName, Name, BLEMIDI_NAMESPACE::DefaultSettings);
230236

231237
/*! \brief Create a default instance for ArduinoBLE named BLE-MIDI
232238
*/

src/hardware/BLEMIDI_Client_ESP32.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,10 @@ class BLEMIDI_Client_ESP32
194194
BLEAdvertising *_advertising = nullptr;
195195
BLERemoteCharacteristic *_characteristic = nullptr;
196196
BLERemoteService *pSvc = nullptr;
197-
bool firstTimeSend = true; // First writeValue get sends like Write with reponse for clean security flags. After first time, all messages are send like WriteNoResponse for increase transmision speed.
198-
197+
bool firstTimeSend = true; //First writeValue get sends like Write with reponse for clean security flags. After first time, all messages are send like WriteNoResponse for increase transmision speed.
199198
char connectedDeviceName[24];
200-
201-
BLEMIDI_Transport<class BLEMIDI_Client_ESP32<_Settings>, _Settings> *_bleMidiTransport = nullptr;
199+
200+
BLEMIDI_Transport<class BLEMIDI_Client_ESP32> *_bleMidiTransport = nullptr;
202201

203202
bool specificTarget = false;
204203

@@ -270,13 +269,12 @@ class BLEMIDI_Client_ESP32
270269
if (_bleMidiTransport->_connectedCallback)
271270
_bleMidiTransport->_connectedCallback();
272271
firstTimeSend = true;
273-
272+
274273
if (_bleMidiTransport->_connectedCallbackDeviceName)
275274
{
276275
sprintf(connectedDeviceName, "%s", myAdvCB.advDevice.getName().c_str());
277276
_bleMidiTransport->_connectedCallbackDeviceName(connectedDeviceName);
278277
}
279-
280278
}
281279

282280
void disconnected()

src/hardware/BLEMIDI_ESP32.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
#include <BLEServer.h>
77
#include <BLE2902.h>
88

9+
// Note: error: redefinition of 'class BLEDescriptor' is a namespace collision on class BLEDescriptor between our ESp32 BLE and ArduinoBLE
10+
// Solution: remove ArduinoBLE
11+
912
BEGIN_BLEMIDI_NAMESPACE
1013

1114
template <class _Settings>
@@ -116,7 +119,7 @@ class MyCharacteristicCallbacks : public BLECharacteristicCallbacks
116119

117120
void onWrite(BLECharacteristic *characteristic)
118121
{
119-
std::string rxValue = characteristic->getValue();
122+
auto rxValue = characteristic->getValue();
120123
if (rxValue.length() > 0)
121124
{
122125
_bluetoothEsp32->receive((uint8_t *)(rxValue.c_str()), rxValue.length());

src/hardware/BLEMIDI_ESP32_NimBLE.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,6 @@ bool BLEMIDI_ESP32_NimBLE<_Settings>::begin(const char *deviceName, BLEMIDI_Tran
166166

167167
_characteristic->setCallbacks(new MyCharacteristicCallbacks<_Settings>(this));
168168

169-
// auto _security = new NimBLESecurity();
170-
// _security->setAuthenticationMode(ESP_LE_AUTH_BOND);
171-
172169
// Start the service
173170
service->start();
174171

0 commit comments

Comments
 (0)