5
5
6
6
BEGIN_BLEMIDI_NAMESPACE
7
7
8
- template <int Size >
8
+ template <class _Settings >
9
9
class BLEMIDI_ESP32_NimBLE
10
10
{
11
11
private:
12
12
BLEServer *_server = nullptr ;
13
13
BLEAdvertising *_advertising = nullptr ;
14
14
BLECharacteristic *_characteristic = nullptr ;
15
15
16
- BLEMIDI_Transport<class BLEMIDI_ESP32_NimBLE <Size >, Size > *_bleMidiTransport = nullptr ;
16
+ BLEMIDI_Transport<class BLEMIDI_ESP32_NimBLE <_Settings >, _Settings > *_bleMidiTransport = nullptr ;
17
17
18
- template <int > friend class MyServerCallbacks ;
19
- template <int > friend class MyCharacteristicCallbacks ;
18
+ template <class > friend class MyServerCallbacks ;
19
+ template <class > friend class MyCharacteristicCallbacks ;
20
20
21
21
protected:
22
22
QueueHandle_t mRxQueue ;
@@ -26,7 +26,7 @@ class BLEMIDI_ESP32_NimBLE
26
26
{
27
27
}
28
28
29
- bool begin (const char *, BLEMIDI_Transport<class BLEMIDI_ESP32_NimBLE <Size >, Size > *);
29
+ bool begin (const char *, BLEMIDI_Transport<class BLEMIDI_ESP32_NimBLE <_Settings >, _Settings > *);
30
30
31
31
void end ()
32
32
{
@@ -70,17 +70,17 @@ class BLEMIDI_ESP32_NimBLE
70
70
}
71
71
};
72
72
73
- template <int Size >
73
+ template <class _Settings >
74
74
class MyServerCallbacks : public BLEServerCallbacks
75
75
{
76
76
public:
77
- MyServerCallbacks (BLEMIDI_ESP32_NimBLE<Size > *bluetoothEsp32)
77
+ MyServerCallbacks (BLEMIDI_ESP32_NimBLE<_Settings > *bluetoothEsp32)
78
78
: _bluetoothEsp32(bluetoothEsp32)
79
79
{
80
80
}
81
81
82
82
protected:
83
- BLEMIDI_ESP32_NimBLE<Size > *_bluetoothEsp32 = nullptr ;
83
+ BLEMIDI_ESP32_NimBLE<_Settings > *_bluetoothEsp32 = nullptr ;
84
84
85
85
void onConnect (BLEServer *)
86
86
{
@@ -95,17 +95,17 @@ class MyServerCallbacks : public BLEServerCallbacks
95
95
}
96
96
};
97
97
98
- template <int Size >
98
+ template <class _Settings >
99
99
class MyCharacteristicCallbacks : public BLECharacteristicCallbacks
100
100
{
101
101
public:
102
- MyCharacteristicCallbacks (BLEMIDI_ESP32_NimBLE<Size > *bluetoothEsp32)
102
+ MyCharacteristicCallbacks (BLEMIDI_ESP32_NimBLE<_Settings > *bluetoothEsp32)
103
103
: _bluetoothEsp32(bluetoothEsp32)
104
104
{
105
105
}
106
106
107
107
protected:
108
- BLEMIDI_ESP32_NimBLE<Size > *_bluetoothEsp32 = nullptr ;
108
+ BLEMIDI_ESP32_NimBLE<_Settings > *_bluetoothEsp32 = nullptr ;
109
109
110
110
void onWrite (BLECharacteristic *characteristic)
111
111
{
@@ -117,19 +117,19 @@ class MyCharacteristicCallbacks : public BLECharacteristicCallbacks
117
117
}
118
118
};
119
119
120
- template <int Size >
121
- bool BLEMIDI_ESP32_NimBLE<Size >::begin(const char *deviceName, BLEMIDI_Transport<class BLEMIDI_ESP32_NimBLE <Size >, Size > *bleMidiTransport)
120
+ template <class _Settings >
121
+ bool BLEMIDI_ESP32_NimBLE<_Settings >::begin(const char *deviceName, BLEMIDI_Transport<class BLEMIDI_ESP32_NimBLE <_Settings >, _Settings > *bleMidiTransport)
122
122
{
123
123
_bleMidiTransport = bleMidiTransport;
124
124
125
125
BLEDevice::init (deviceName);
126
126
127
127
// To communicate between the 2 cores.
128
128
// Core_0 runs here, core_1 runs the BLE stack
129
- mRxQueue = xQueueCreate (Size , sizeof (uint8_t )); // TODO DefaultSettings::MaxBufferSize
129
+ mRxQueue = xQueueCreate (_Settings::MaxBufferSize , sizeof (uint8_t ));
130
130
131
131
_server = BLEDevice::createServer ();
132
- _server->setCallbacks (new MyServerCallbacks<Size >(this ));
132
+ _server->setCallbacks (new MyServerCallbacks<_Settings >(this ));
133
133
_server->advertiseOnDisconnect (true );
134
134
135
135
// Create the BLE Service
@@ -143,7 +143,7 @@ bool BLEMIDI_ESP32_NimBLE<Size>::begin(const char *deviceName, BLEMIDI_Transport
143
143
NIMBLE_PROPERTY::NOTIFY |
144
144
NIMBLE_PROPERTY::WRITE_NR);
145
145
146
- _characteristic->setCallbacks (new MyCharacteristicCallbacks<Size >(this ));
146
+ _characteristic->setCallbacks (new MyCharacteristicCallbacks<_Settings >(this ));
147
147
148
148
auto _security = new NimBLESecurity ();
149
149
_security->setAuthenticationMode (ESP_LE_AUTH_BOND);
@@ -162,9 +162,9 @@ bool BLEMIDI_ESP32_NimBLE<Size>::begin(const char *deviceName, BLEMIDI_Transport
162
162
163
163
/* ! \brief Create an instance for ESP32 named <DeviceName>
164
164
*/
165
- #define BLEMIDI_CREATE_CUSTOM_INSTANCE (DeviceName, Name, Size ) \
166
- BLEMIDI_NAMESPACE::BLEMIDI_Transport<BLEMIDI_NAMESPACE::BLEMIDI_ESP32_NimBLE<Size >, Size > BLE##Name(DeviceName); \
167
- MIDI_NAMESPACE::MidiInterface<BLEMIDI_NAMESPACE::BLEMIDI_Transport<BLEMIDI_NAMESPACE::BLEMIDI_ESP32_NimBLE<Size >, Size >, BLEMIDI_NAMESPACE::MySettings> Name ((BLEMIDI_NAMESPACE::BLEMIDI_Transport<BLEMIDI_NAMESPACE::BLEMIDI_ESP32_NimBLE<Size >, Size > &)BLE##Name);
165
+ #define BLEMIDI_CREATE_CUSTOM_INSTANCE (DeviceName, Name, _Settings ) \
166
+ BLEMIDI_NAMESPACE::BLEMIDI_Transport<BLEMIDI_NAMESPACE::BLEMIDI_ESP32_NimBLE<_Settings >, _Settings > BLE##Name(DeviceName); \
167
+ MIDI_NAMESPACE::MidiInterface<BLEMIDI_NAMESPACE::BLEMIDI_Transport<BLEMIDI_NAMESPACE::BLEMIDI_ESP32_NimBLE<_Settings >, _Settings >, BLEMIDI_NAMESPACE::MySettings> Name ((BLEMIDI_NAMESPACE::BLEMIDI_Transport<BLEMIDI_NAMESPACE::BLEMIDI_ESP32_NimBLE<_Settings >, _Settings > &)BLE##Name);
168
168
169
169
/* ! \brief Create an instance for ESP32 named <DeviceName>
170
170
*/
0 commit comments