rename hardware files, move headers to config file

This commit is contained in:
lathoub 2020-09-27 14:32:33 +02:00
parent 20ff691133
commit 9193101fab
8 changed files with 38 additions and 28 deletions

View File

@ -1,8 +1,5 @@
#include <BLE-MIDI.h>
//#include <hardware/MIDI_ESP32_NimBLE.h>
#include <hardware/MIDI_ESP32.h>
//#include <hardware/MIDI_nRF52.h>
//#include <hardware/MIDI_ArduinoBLE.h>
#include <BLE-MIDI_Config.h>
BLEMIDI_CREATE_DEFAULT_INSTANCE()

View File

@ -1 +1 @@
#include "BLE-MIDI.h"
#include "BLE-MIDI.h"

View File

@ -277,4 +277,3 @@ struct MySettings : public MIDI_NAMESPACE::DefaultSettings
{
static const bool Use1ByteParsing = false;
};

14
src/BLE-MIDI_Config.h Normal file
View File

@ -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

View File

@ -8,14 +8,14 @@
BEGIN_BLEMIDI_NAMESPACE
class BLEMIDI
class BLEMIDI_ESP32
{
private:
BLEServer* _server = nullptr;
BLEAdvertising* _advertising = nullptr;
BLECharacteristic* _characteristic = nullptr;
BLEMIDITransport<class BLEMIDI>* _bleMidiTransport = nullptr;
BLEMIDITransport<class BLEMIDI_ESP32>* _bleMidiTransport = nullptr;
friend class MyServerCallbacks;
friend class MyCharacteristicCallbacks;
@ -24,11 +24,11 @@ protected:
QueueHandle_t mRxQueue;
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)
{
@ -69,12 +69,12 @@ protected:
class MyServerCallbacks: public BLEServerCallbacks {
public:
MyServerCallbacks(BLEMIDI* bluetoothEsp32)
MyServerCallbacks(BLEMIDI_ESP32* bluetoothEsp32)
: _bluetoothEsp32(bluetoothEsp32) {
}
protected:
BLEMIDI* _bluetoothEsp32 = nullptr;
BLEMIDI_ESP32* _bluetoothEsp32 = nullptr;
void onConnect(BLEServer*) {
if (_bluetoothEsp32)
@ -89,12 +89,12 @@ protected:
class MyCharacteristicCallbacks: public BLECharacteristicCallbacks {
public:
MyCharacteristicCallbacks(BLEMIDI* bluetoothEsp32)
MyCharacteristicCallbacks(BLEMIDI_ESP32* bluetoothEsp32)
: _bluetoothEsp32(bluetoothEsp32 ) {
}
protected:
BLEMIDI* _bluetoothEsp32 = nullptr;
BLEMIDI_ESP32* _bluetoothEsp32 = nullptr;
void onWrite(BLECharacteristic * characteristic) {
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;
@ -151,8 +151,8 @@ bool BLEMIDI::begin(const char* deviceName, BLEMIDITransport<class BLEMIDI>* ble
/*! \brief Create an instance for ESP32 named <DeviceName>
*/
#define BLEMIDI_CREATE_INSTANCE(DeviceName, Name) \
BLEMIDI_NAMESPACE::BLEMIDITransport<BLEMIDI_NAMESPACE::BLEMIDI> BLE##Name(DeviceName); \
MIDI_NAMESPACE::MidiInterface<BLEMIDI_NAMESPACE::BLEMIDITransport<BLEMIDI_NAMESPACE::BLEMIDI>, MySettings> Name((BLEMIDI_NAMESPACE::BLEMIDITransport<BLEMIDI_NAMESPACE::BLEMIDI> &)BLE##Name);
BLEMIDI_NAMESPACE::BLEMIDITransport<BLEMIDI_NAMESPACE::BLEMIDI_ESP32> BLE##Name(DeviceName); \
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
*/

View File

@ -5,14 +5,14 @@
BEGIN_BLEMIDI_NAMESPACE
class BLEMIDI
class BLEMIDI_ESP32_NimBLE
{
private:
BLEServer* _server = nullptr;
BLEAdvertising* _advertising = nullptr;
BLECharacteristic* _characteristic = nullptr;
BLEMIDITransport<class BLEMIDI>* _bleMidiTransport = nullptr;
BLEMIDITransport<class BLEMIDI_ESP32_NimBLE>* _bleMidiTransport = nullptr;
friend class MyServerCallbacks;
friend class MyCharacteristicCallbacks;
@ -21,11 +21,11 @@ protected:
QueueHandle_t mRxQueue;
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)
{
@ -66,12 +66,12 @@ protected:
class MyServerCallbacks: public BLEServerCallbacks {
public:
MyServerCallbacks(BLEMIDI* bluetoothEsp32)
MyServerCallbacks(BLEMIDI_ESP32_NimBLE* bluetoothEsp32)
: _bluetoothEsp32(bluetoothEsp32) {
}
protected:
BLEMIDI* _bluetoothEsp32 = nullptr;
BLEMIDI_ESP32_NimBLE* _bluetoothEsp32 = nullptr;
void onConnect(BLEServer*) {
if (_bluetoothEsp32)
@ -86,12 +86,12 @@ protected:
class MyCharacteristicCallbacks: public BLECharacteristicCallbacks {
public:
MyCharacteristicCallbacks(BLEMIDI* bluetoothEsp32)
MyCharacteristicCallbacks(BLEMIDI_ESP32_NimBLE* bluetoothEsp32)
: _bluetoothEsp32(bluetoothEsp32 ) {
}
protected:
BLEMIDI* _bluetoothEsp32 = nullptr;
BLEMIDI_ESP32_NimBLE* _bluetoothEsp32 = nullptr;
void onWrite(BLECharacteristic * characteristic) {
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;
@ -146,8 +146,8 @@ bool BLEMIDI::begin(const char* deviceName, BLEMIDITransport<class BLEMIDI>* ble
/*! \brief Create an instance for ESP32 named <DeviceName>
*/
#define BLEMIDI_CREATE_INSTANCE(DeviceName, Name) \
BLEMIDI_NAMESPACE::BLEMIDITransport<BLEMIDI_NAMESPACE::BLEMIDI> BLE##Name(DeviceName); \
MIDI_NAMESPACE::MidiInterface<BLEMIDI_NAMESPACE::BLEMIDITransport<BLEMIDI_NAMESPACE::BLEMIDI>, MySettings> Name((BLEMIDI_NAMESPACE::BLEMIDITransport<BLEMIDI_NAMESPACE::BLEMIDI> &)BLE##Name);
BLEMIDI_NAMESPACE::BLEMIDITransport<BLEMIDI_NAMESPACE::BLEMIDI_ESP32_NimBLE> BLE##Name(DeviceName); \
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
*/