From 9193101fab5e998bfc0f6a32a648183fabbe97b5 Mon Sep 17 00:00:00 2001 From: lathoub <4082369+lathoub@users.noreply.github.com> Date: Sun, 27 Sep 2020 14:32:33 +0200 Subject: [PATCH] rename hardware files, move headers to config file --- examples/MidiBle/MidiBle.ino | 5 +---- src/BLE-MIDI.cpp | 2 +- src/BLE-MIDI.h | 1 - src/BLE-MIDI_Config.h | 14 ++++++++++++ ...MIDI_ArduinoBLE.h => BLEMIDI_ArduinoBLE.h} | 0 .../{MIDI_ESP32.h => BLEMIDI_ESP32.h} | 22 +++++++++---------- ..._ESP32_NimBLE.h => BLEMIDI_ESP32_NimBLE.h} | 22 +++++++++---------- .../{MIDI_nRF52.h => BLEMIDI_nRF52.h} | 0 8 files changed, 38 insertions(+), 28 deletions(-) create mode 100644 src/BLE-MIDI_Config.h rename src/hardware/{MIDI_ArduinoBLE.h => BLEMIDI_ArduinoBLE.h} (100%) rename src/hardware/{MIDI_ESP32.h => BLEMIDI_ESP32.h} (85%) rename src/hardware/{MIDI_ESP32_NimBLE.h => BLEMIDI_ESP32_NimBLE.h} (82%) rename src/hardware/{MIDI_nRF52.h => BLEMIDI_nRF52.h} (100%) diff --git a/examples/MidiBle/MidiBle.ino b/examples/MidiBle/MidiBle.ino index 6da41cc..28d3557 100644 --- a/examples/MidiBle/MidiBle.ino +++ b/examples/MidiBle/MidiBle.ino @@ -1,8 +1,5 @@ #include -//#include -#include -//#include -//#include +#include BLEMIDI_CREATE_DEFAULT_INSTANCE() diff --git a/src/BLE-MIDI.cpp b/src/BLE-MIDI.cpp index 3ba251c..258e5f5 100755 --- a/src/BLE-MIDI.cpp +++ b/src/BLE-MIDI.cpp @@ -1 +1 @@ -#include "BLE-MIDI.h" +#include "BLE-MIDI.h" \ No newline at end of file diff --git a/src/BLE-MIDI.h b/src/BLE-MIDI.h index c987115..421d401 100755 --- a/src/BLE-MIDI.h +++ b/src/BLE-MIDI.h @@ -277,4 +277,3 @@ struct MySettings : public MIDI_NAMESPACE::DefaultSettings { static const bool Use1ByteParsing = false; }; - diff --git a/src/BLE-MIDI_Config.h b/src/BLE-MIDI_Config.h new file mode 100644 index 0000000..6efaf53 --- /dev/null +++ b/src/BLE-MIDI_Config.h @@ -0,0 +1,14 @@ +#pragma once + +#ifdef ARDUINO_ARCH_ESP32 +//#include +#include +#endif + +#ifdef AAA +#include +#endif + +#ifdef __AVR__ +#include +#endif diff --git a/src/hardware/MIDI_ArduinoBLE.h b/src/hardware/BLEMIDI_ArduinoBLE.h similarity index 100% rename from src/hardware/MIDI_ArduinoBLE.h rename to src/hardware/BLEMIDI_ArduinoBLE.h diff --git a/src/hardware/MIDI_ESP32.h b/src/hardware/BLEMIDI_ESP32.h similarity index 85% rename from src/hardware/MIDI_ESP32.h rename to src/hardware/BLEMIDI_ESP32.h index 0cb32b1..df9201b 100644 --- a/src/hardware/MIDI_ESP32.h +++ b/src/hardware/BLEMIDI_ESP32.h @@ -8,14 +8,14 @@ BEGIN_BLEMIDI_NAMESPACE -class BLEMIDI +class BLEMIDI_ESP32 { private: BLEServer* _server = nullptr; BLEAdvertising* _advertising = nullptr; BLECharacteristic* _characteristic = nullptr; - BLEMIDITransport* _bleMidiTransport = nullptr; + BLEMIDITransport* _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*); + bool begin(const char*, BLEMIDITransport*); 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* bleMidiTransport) +bool BLEMIDI_ESP32::begin(const char* deviceName, BLEMIDITransport* bleMidiTransport) { _bleMidiTransport = bleMidiTransport; @@ -151,8 +151,8 @@ bool BLEMIDI::begin(const char* deviceName, BLEMIDITransport* ble /*! \brief Create an instance for ESP32 named */ #define BLEMIDI_CREATE_INSTANCE(DeviceName, Name) \ -BLEMIDI_NAMESPACE::BLEMIDITransport BLE##Name(DeviceName); \ -MIDI_NAMESPACE::MidiInterface, MySettings> Name((BLEMIDI_NAMESPACE::BLEMIDITransport &)BLE##Name); +BLEMIDI_NAMESPACE::BLEMIDITransport BLE##Name(DeviceName); \ +MIDI_NAMESPACE::MidiInterface, MySettings> Name((BLEMIDI_NAMESPACE::BLEMIDITransport &)BLE##Name); /*! \brief Create a default instance for ESP32 named BLE-MIDI */ diff --git a/src/hardware/MIDI_ESP32_NimBLE.h b/src/hardware/BLEMIDI_ESP32_NimBLE.h similarity index 82% rename from src/hardware/MIDI_ESP32_NimBLE.h rename to src/hardware/BLEMIDI_ESP32_NimBLE.h index 14d1feb..2c2887b 100644 --- a/src/hardware/MIDI_ESP32_NimBLE.h +++ b/src/hardware/BLEMIDI_ESP32_NimBLE.h @@ -5,14 +5,14 @@ BEGIN_BLEMIDI_NAMESPACE -class BLEMIDI +class BLEMIDI_ESP32_NimBLE { private: BLEServer* _server = nullptr; BLEAdvertising* _advertising = nullptr; BLECharacteristic* _characteristic = nullptr; - BLEMIDITransport* _bleMidiTransport = nullptr; + BLEMIDITransport* _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*); + bool begin(const char*, BLEMIDITransport*); 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* bleMidiTransport) +bool BLEMIDI_ESP32_NimBLE::begin(const char* deviceName, BLEMIDITransport* bleMidiTransport) { _bleMidiTransport = bleMidiTransport; @@ -146,8 +146,8 @@ bool BLEMIDI::begin(const char* deviceName, BLEMIDITransport* ble /*! \brief Create an instance for ESP32 named */ #define BLEMIDI_CREATE_INSTANCE(DeviceName, Name) \ -BLEMIDI_NAMESPACE::BLEMIDITransport BLE##Name(DeviceName); \ -MIDI_NAMESPACE::MidiInterface, MySettings> Name((BLEMIDI_NAMESPACE::BLEMIDITransport &)BLE##Name); +BLEMIDI_NAMESPACE::BLEMIDITransport BLE##Name(DeviceName); \ +MIDI_NAMESPACE::MidiInterface, MySettings> Name((BLEMIDI_NAMESPACE::BLEMIDITransport &)BLE##Name); /*! \brief Create a default instance for ESP32 named BLE-MIDI */ diff --git a/src/hardware/MIDI_nRF52.h b/src/hardware/BLEMIDI_nRF52.h similarity index 100% rename from src/hardware/MIDI_nRF52.h rename to src/hardware/BLEMIDI_nRF52.h