rename hardware files, move headers to config file
This commit is contained in:
parent
20ff691133
commit
9193101fab
|
|
@ -1,8 +1,5 @@
|
||||||
#include <BLE-MIDI.h>
|
#include <BLE-MIDI.h>
|
||||||
//#include <hardware/MIDI_ESP32_NimBLE.h>
|
#include <BLE-MIDI_Config.h>
|
||||||
#include <hardware/MIDI_ESP32.h>
|
|
||||||
//#include <hardware/MIDI_nRF52.h>
|
|
||||||
//#include <hardware/MIDI_ArduinoBLE.h>
|
|
||||||
|
|
||||||
BLEMIDI_CREATE_DEFAULT_INSTANCE()
|
BLEMIDI_CREATE_DEFAULT_INSTANCE()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
#include "BLE-MIDI.h"
|
#include "BLE-MIDI.h"
|
||||||
|
|
@ -277,4 +277,3 @@ struct MySettings : public MIDI_NAMESPACE::DefaultSettings
|
||||||
{
|
{
|
||||||
static const bool Use1ByteParsing = false;
|
static const bool Use1ByteParsing = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef ARDUINO_ARCH_ESP32
|
||||||
|
//#include <hardware/BLEMIDI_ESP32_NimBLE.h>
|
||||||
|
#include <hardware/BLEMIDI_ESP32.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef AAA
|
||||||
|
#include <hardware/BLEMIDI_nRF52.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __AVR__
|
||||||
|
#include <hardware/BLEMIDI_ArduinoBLE.h>
|
||||||
|
#endif
|
||||||
|
|
@ -8,14 +8,14 @@
|
||||||
|
|
||||||
BEGIN_BLEMIDI_NAMESPACE
|
BEGIN_BLEMIDI_NAMESPACE
|
||||||
|
|
||||||
class BLEMIDI
|
class BLEMIDI_ESP32
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
BLEServer* _server = nullptr;
|
BLEServer* _server = nullptr;
|
||||||
BLEAdvertising* _advertising = nullptr;
|
BLEAdvertising* _advertising = nullptr;
|
||||||
BLECharacteristic* _characteristic = nullptr;
|
BLECharacteristic* _characteristic = nullptr;
|
||||||
|
|
||||||
BLEMIDITransport<class BLEMIDI>* _bleMidiTransport = nullptr;
|
BLEMIDITransport<class BLEMIDI_ESP32>* _bleMidiTransport = nullptr;
|
||||||
|
|
||||||
friend class MyServerCallbacks;
|
friend class MyServerCallbacks;
|
||||||
friend class MyCharacteristicCallbacks;
|
friend class MyCharacteristicCallbacks;
|
||||||
|
|
@ -24,11 +24,11 @@ protected:
|
||||||
QueueHandle_t mRxQueue;
|
QueueHandle_t mRxQueue;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BLEMIDI()
|
BLEMIDI_ESP32()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool begin(const char*, BLEMIDITransport<class BLEMIDI>*);
|
bool begin(const char*, BLEMIDITransport<class BLEMIDI_ESP32>*);
|
||||||
|
|
||||||
void write(uint8_t* buffer, size_t length)
|
void write(uint8_t* buffer, size_t length)
|
||||||
{
|
{
|
||||||
|
|
@ -69,12 +69,12 @@ protected:
|
||||||
|
|
||||||
class MyServerCallbacks: public BLEServerCallbacks {
|
class MyServerCallbacks: public BLEServerCallbacks {
|
||||||
public:
|
public:
|
||||||
MyServerCallbacks(BLEMIDI* bluetoothEsp32)
|
MyServerCallbacks(BLEMIDI_ESP32* bluetoothEsp32)
|
||||||
: _bluetoothEsp32(bluetoothEsp32) {
|
: _bluetoothEsp32(bluetoothEsp32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
BLEMIDI* _bluetoothEsp32 = nullptr;
|
BLEMIDI_ESP32* _bluetoothEsp32 = nullptr;
|
||||||
|
|
||||||
void onConnect(BLEServer*) {
|
void onConnect(BLEServer*) {
|
||||||
if (_bluetoothEsp32)
|
if (_bluetoothEsp32)
|
||||||
|
|
@ -89,12 +89,12 @@ protected:
|
||||||
|
|
||||||
class MyCharacteristicCallbacks: public BLECharacteristicCallbacks {
|
class MyCharacteristicCallbacks: public BLECharacteristicCallbacks {
|
||||||
public:
|
public:
|
||||||
MyCharacteristicCallbacks(BLEMIDI* bluetoothEsp32)
|
MyCharacteristicCallbacks(BLEMIDI_ESP32* bluetoothEsp32)
|
||||||
: _bluetoothEsp32(bluetoothEsp32 ) {
|
: _bluetoothEsp32(bluetoothEsp32 ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
BLEMIDI* _bluetoothEsp32 = nullptr;
|
BLEMIDI_ESP32* _bluetoothEsp32 = nullptr;
|
||||||
|
|
||||||
void onWrite(BLECharacteristic * characteristic) {
|
void onWrite(BLECharacteristic * characteristic) {
|
||||||
std::string rxValue = characteristic->getValue();
|
std::string rxValue = characteristic->getValue();
|
||||||
|
|
@ -104,7 +104,7 @@ protected:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
bool BLEMIDI::begin(const char* deviceName, BLEMIDITransport<class BLEMIDI>* bleMidiTransport)
|
bool BLEMIDI_ESP32::begin(const char* deviceName, BLEMIDITransport<class BLEMIDI_ESP32>* bleMidiTransport)
|
||||||
{
|
{
|
||||||
_bleMidiTransport = bleMidiTransport;
|
_bleMidiTransport = bleMidiTransport;
|
||||||
|
|
||||||
|
|
@ -151,8 +151,8 @@ bool BLEMIDI::begin(const char* deviceName, BLEMIDITransport<class BLEMIDI>* ble
|
||||||
/*! \brief Create an instance for ESP32 named <DeviceName>
|
/*! \brief Create an instance for ESP32 named <DeviceName>
|
||||||
*/
|
*/
|
||||||
#define BLEMIDI_CREATE_INSTANCE(DeviceName, Name) \
|
#define BLEMIDI_CREATE_INSTANCE(DeviceName, Name) \
|
||||||
BLEMIDI_NAMESPACE::BLEMIDITransport<BLEMIDI_NAMESPACE::BLEMIDI> BLE##Name(DeviceName); \
|
BLEMIDI_NAMESPACE::BLEMIDITransport<BLEMIDI_NAMESPACE::BLEMIDI_ESP32> BLE##Name(DeviceName); \
|
||||||
MIDI_NAMESPACE::MidiInterface<BLEMIDI_NAMESPACE::BLEMIDITransport<BLEMIDI_NAMESPACE::BLEMIDI>, MySettings> Name((BLEMIDI_NAMESPACE::BLEMIDITransport<BLEMIDI_NAMESPACE::BLEMIDI> &)BLE##Name);
|
MIDI_NAMESPACE::MidiInterface<BLEMIDI_NAMESPACE::BLEMIDITransport<BLEMIDI_NAMESPACE::BLEMIDI_ESP32>, MySettings> Name((BLEMIDI_NAMESPACE::BLEMIDITransport<BLEMIDI_NAMESPACE::BLEMIDI_ESP32> &)BLE##Name);
|
||||||
|
|
||||||
/*! \brief Create a default instance for ESP32 named BLE-MIDI
|
/*! \brief Create a default instance for ESP32 named BLE-MIDI
|
||||||
*/
|
*/
|
||||||
|
|
@ -5,14 +5,14 @@
|
||||||
|
|
||||||
BEGIN_BLEMIDI_NAMESPACE
|
BEGIN_BLEMIDI_NAMESPACE
|
||||||
|
|
||||||
class BLEMIDI
|
class BLEMIDI_ESP32_NimBLE
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
BLEServer* _server = nullptr;
|
BLEServer* _server = nullptr;
|
||||||
BLEAdvertising* _advertising = nullptr;
|
BLEAdvertising* _advertising = nullptr;
|
||||||
BLECharacteristic* _characteristic = nullptr;
|
BLECharacteristic* _characteristic = nullptr;
|
||||||
|
|
||||||
BLEMIDITransport<class BLEMIDI>* _bleMidiTransport = nullptr;
|
BLEMIDITransport<class BLEMIDI_ESP32_NimBLE>* _bleMidiTransport = nullptr;
|
||||||
|
|
||||||
friend class MyServerCallbacks;
|
friend class MyServerCallbacks;
|
||||||
friend class MyCharacteristicCallbacks;
|
friend class MyCharacteristicCallbacks;
|
||||||
|
|
@ -21,11 +21,11 @@ protected:
|
||||||
QueueHandle_t mRxQueue;
|
QueueHandle_t mRxQueue;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BLEMIDI()
|
BLEMIDI_ESP32_NimBLE()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool begin(const char*, BLEMIDITransport<class BLEMIDI>*);
|
bool begin(const char*, BLEMIDITransport<class BLEMIDI_ESP32_NimBLE>*);
|
||||||
|
|
||||||
void write(uint8_t* buffer, size_t length)
|
void write(uint8_t* buffer, size_t length)
|
||||||
{
|
{
|
||||||
|
|
@ -66,12 +66,12 @@ protected:
|
||||||
|
|
||||||
class MyServerCallbacks: public BLEServerCallbacks {
|
class MyServerCallbacks: public BLEServerCallbacks {
|
||||||
public:
|
public:
|
||||||
MyServerCallbacks(BLEMIDI* bluetoothEsp32)
|
MyServerCallbacks(BLEMIDI_ESP32_NimBLE* bluetoothEsp32)
|
||||||
: _bluetoothEsp32(bluetoothEsp32) {
|
: _bluetoothEsp32(bluetoothEsp32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
BLEMIDI* _bluetoothEsp32 = nullptr;
|
BLEMIDI_ESP32_NimBLE* _bluetoothEsp32 = nullptr;
|
||||||
|
|
||||||
void onConnect(BLEServer*) {
|
void onConnect(BLEServer*) {
|
||||||
if (_bluetoothEsp32)
|
if (_bluetoothEsp32)
|
||||||
|
|
@ -86,12 +86,12 @@ protected:
|
||||||
|
|
||||||
class MyCharacteristicCallbacks: public BLECharacteristicCallbacks {
|
class MyCharacteristicCallbacks: public BLECharacteristicCallbacks {
|
||||||
public:
|
public:
|
||||||
MyCharacteristicCallbacks(BLEMIDI* bluetoothEsp32)
|
MyCharacteristicCallbacks(BLEMIDI_ESP32_NimBLE* bluetoothEsp32)
|
||||||
: _bluetoothEsp32(bluetoothEsp32 ) {
|
: _bluetoothEsp32(bluetoothEsp32 ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
BLEMIDI* _bluetoothEsp32 = nullptr;
|
BLEMIDI_ESP32_NimBLE* _bluetoothEsp32 = nullptr;
|
||||||
|
|
||||||
void onWrite(BLECharacteristic * characteristic) {
|
void onWrite(BLECharacteristic * characteristic) {
|
||||||
std::string rxValue = characteristic->getValue();
|
std::string rxValue = characteristic->getValue();
|
||||||
|
|
@ -101,7 +101,7 @@ protected:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
bool BLEMIDI::begin(const char* deviceName, BLEMIDITransport<class BLEMIDI>* bleMidiTransport)
|
bool BLEMIDI_ESP32_NimBLE::begin(const char* deviceName, BLEMIDITransport<class BLEMIDI_ESP32_NimBLE>* bleMidiTransport)
|
||||||
{
|
{
|
||||||
_bleMidiTransport = bleMidiTransport;
|
_bleMidiTransport = bleMidiTransport;
|
||||||
|
|
||||||
|
|
@ -146,8 +146,8 @@ bool BLEMIDI::begin(const char* deviceName, BLEMIDITransport<class BLEMIDI>* ble
|
||||||
/*! \brief Create an instance for ESP32 named <DeviceName>
|
/*! \brief Create an instance for ESP32 named <DeviceName>
|
||||||
*/
|
*/
|
||||||
#define BLEMIDI_CREATE_INSTANCE(DeviceName, Name) \
|
#define BLEMIDI_CREATE_INSTANCE(DeviceName, Name) \
|
||||||
BLEMIDI_NAMESPACE::BLEMIDITransport<BLEMIDI_NAMESPACE::BLEMIDI> BLE##Name(DeviceName); \
|
BLEMIDI_NAMESPACE::BLEMIDITransport<BLEMIDI_NAMESPACE::BLEMIDI_ESP32_NimBLE> BLE##Name(DeviceName); \
|
||||||
MIDI_NAMESPACE::MidiInterface<BLEMIDI_NAMESPACE::BLEMIDITransport<BLEMIDI_NAMESPACE::BLEMIDI>, MySettings> Name((BLEMIDI_NAMESPACE::BLEMIDITransport<BLEMIDI_NAMESPACE::BLEMIDI> &)BLE##Name);
|
MIDI_NAMESPACE::MidiInterface<BLEMIDI_NAMESPACE::BLEMIDITransport<BLEMIDI_NAMESPACE::BLEMIDI_ESP32_NimBLE>, MySettings> Name((BLEMIDI_NAMESPACE::BLEMIDITransport<BLEMIDI_NAMESPACE::BLEMIDI_ESP32_NimBLE> &)BLE##Name);
|
||||||
|
|
||||||
/*! \brief Create a default instance for ESP32 named BLE-MIDI
|
/*! \brief Create a default instance for ESP32 named BLE-MIDI
|
||||||
*/
|
*/
|
||||||
Loading…
Reference in New Issue