8
8
9
9
BEGIN_BLEMIDI_NAMESPACE
10
10
11
+ template <class _Settings >
11
12
class BLEMIDI_ESP32
12
13
{
13
14
private:
14
15
BLEServer *_server = nullptr ;
15
16
BLEAdvertising *_advertising = nullptr ;
16
17
BLECharacteristic *_characteristic = nullptr ;
17
18
18
- BLEMIDI_Transport<class BLEMIDI_ESP32 , DefaultSettings > *_bleMidiTransport = nullptr ;
19
+ BLEMIDI_Transport<class BLEMIDI_ESP32 <_Settings>, _Settings > *_bleMidiTransport = nullptr ;
19
20
20
- friend class MyServerCallbacks ;
21
- friend class MyCharacteristicCallbacks ;
21
+ template < class > friend class MyServerCallbacks ;
22
+ template < class > friend class MyCharacteristicCallbacks ;
22
23
23
24
protected:
24
25
QueueHandle_t mRxQueue ;
@@ -28,7 +29,7 @@ class BLEMIDI_ESP32
28
29
{
29
30
}
30
31
31
- bool begin (const char *, BLEMIDI_Transport<class BLEMIDI_ESP32 , DefaultSettings > *);
32
+ bool begin (const char *, BLEMIDI_Transport<class BLEMIDI_ESP32 <_Settings>, _Settings > *);
32
33
33
34
void end ()
34
35
{
@@ -74,16 +75,17 @@ class BLEMIDI_ESP32
74
75
}
75
76
};
76
77
78
+ template <class _Settings >
77
79
class MyServerCallbacks : public BLEServerCallbacks
78
80
{
79
81
public:
80
- MyServerCallbacks (BLEMIDI_ESP32 *bluetoothEsp32)
82
+ MyServerCallbacks (BLEMIDI_ESP32<_Settings> *bluetoothEsp32)
81
83
: _bluetoothEsp32(bluetoothEsp32)
82
84
{
83
85
}
84
86
85
87
protected:
86
- BLEMIDI_ESP32 *_bluetoothEsp32 = nullptr ;
88
+ BLEMIDI_ESP32<_Settings> *_bluetoothEsp32 = nullptr ;
87
89
88
90
void onConnect (BLEServer *)
89
91
{
@@ -100,16 +102,17 @@ class MyServerCallbacks : public BLEServerCallbacks
100
102
}
101
103
};
102
104
105
+ template <class _Settings >
103
106
class MyCharacteristicCallbacks : public BLECharacteristicCallbacks
104
107
{
105
108
public:
106
- MyCharacteristicCallbacks (BLEMIDI_ESP32 *bluetoothEsp32)
109
+ MyCharacteristicCallbacks (BLEMIDI_ESP32<_Settings> *bluetoothEsp32)
107
110
: _bluetoothEsp32(bluetoothEsp32)
108
111
{
109
112
}
110
113
111
114
protected:
112
- BLEMIDI_ESP32 *_bluetoothEsp32 = nullptr ;
115
+ BLEMIDI_ESP32<_Settings> *_bluetoothEsp32 = nullptr ;
113
116
114
117
void onWrite (BLECharacteristic *characteristic)
115
118
{
@@ -121,7 +124,8 @@ class MyCharacteristicCallbacks : public BLECharacteristicCallbacks
121
124
}
122
125
};
123
126
124
- bool BLEMIDI_ESP32::begin (const char *deviceName, BLEMIDI_Transport<class BLEMIDI_ESP32 , DefaultSettings> *bleMidiTransport)
127
+ template <class _Settings >
128
+ bool BLEMIDI_ESP32<_Settings>::begin(const char *deviceName, BLEMIDI_Transport<class BLEMIDI_ESP32 <_Settings>, _Settings> *bleMidiTransport)
125
129
{
126
130
_bleMidiTransport = bleMidiTransport;
127
131
@@ -132,7 +136,7 @@ bool BLEMIDI_ESP32::begin(const char *deviceName, BLEMIDI_Transport<class BLEMID
132
136
mRxQueue = xQueueCreate (_Settings::MaxBufferSize, sizeof (uint8_t ));
133
137
134
138
_server = BLEDevice::createServer ();
135
- _server->setCallbacks (new MyServerCallbacks (this ));
139
+ _server->setCallbacks (new MyServerCallbacks<_Settings> (this ));
136
140
137
141
// Create the BLE Service
138
142
auto service = _server->createService (BLEUUID (SERVICE_UUID));
@@ -147,7 +151,7 @@ bool BLEMIDI_ESP32::begin(const char *deviceName, BLEMIDI_Transport<class BLEMID
147
151
// Add CCCD 0x2902 to allow notify
148
152
_characteristic->addDescriptor (new BLE2902 ());
149
153
150
- _characteristic->setCallbacks (new MyCharacteristicCallbacks (this ));
154
+ _characteristic->setCallbacks (new MyCharacteristicCallbacks<_Settings> (this ));
151
155
152
156
auto _security = new BLESecurity ();
153
157
_security->setAuthenticationMode (ESP_LE_AUTH_BOND);
@@ -166,9 +170,9 @@ bool BLEMIDI_ESP32::begin(const char *deviceName, BLEMIDI_Transport<class BLEMID
166
170
167
171
/* ! \brief Create an instance for ESP32 named <DeviceName>
168
172
*/
169
- #define BLEMIDI_CREATE_CUSTOM_INSTANCE (DeviceName, Name, CustomSettings ) \
170
- BLEMIDI_NAMESPACE::BLEMIDI_Transport<BLEMIDI_NAMESPACE::BLEMIDI_ESP32, CustomSettings > BLE##Name(DeviceName); \
171
- MIDI_NAMESPACE::MidiInterface<BLEMIDI_NAMESPACE::BLEMIDI_Transport<BLEMIDI_NAMESPACE::BLEMIDI_ESP32, CustomSettings >, BLEMIDI_NAMESPACE::MySettings> Name ((BLEMIDI_NAMESPACE::BLEMIDI_Transport<BLEMIDI_NAMESPACE::BLEMIDI_ESP32, CustomSettings > &)BLE##Name);
173
+ #define BLEMIDI_CREATE_CUSTOM_INSTANCE (DeviceName, Name, _Settings ) \
174
+ BLEMIDI_NAMESPACE::BLEMIDI_Transport<BLEMIDI_NAMESPACE::BLEMIDI_ESP32<_Settings>, _Settings > BLE##Name(DeviceName); \
175
+ MIDI_NAMESPACE::MidiInterface<BLEMIDI_NAMESPACE::BLEMIDI_Transport<BLEMIDI_NAMESPACE::BLEMIDI_ESP32<_Settings>, _Settings >, BLEMIDI_NAMESPACE::MySettings> Name ((BLEMIDI_NAMESPACE::BLEMIDI_Transport<BLEMIDI_NAMESPACE::BLEMIDI_ESP32<_Settings>, _Settings > &)BLE##Name);
172
176
173
177
/* ! \brief Create an instance for ESP32 named <DeviceName>
174
178
*/
0 commit comments