rename BLEMIDI to BLEMIDI_Transport & cleanup
- rename BLEMIDI to BLEMIDI_Transport (avoid class name collision) - cleanup
This commit is contained in:
parent
5f8a38a5b8
commit
f274037f81
|
|
@ -13,7 +13,7 @@ When manually installing this library, you have to manually download [Arduino MI
|
||||||
## Usage
|
## Usage
|
||||||
### Basic / Default
|
### Basic / Default
|
||||||
```cpp
|
```cpp
|
||||||
#include <BLEMIDI.h>
|
#include <BLEMIDI_Transport.h>
|
||||||
#include <hardware/BLEMIDI_ESP32.h>
|
#include <hardware/BLEMIDI_ESP32.h>
|
||||||
...
|
...
|
||||||
BLEMIDI_CREATE_DEFAULT_ESP32_INSTANCE();
|
BLEMIDI_CREATE_DEFAULT_ESP32_INSTANCE();
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#include <BLEMIDI.h>
|
#include <BLEMIDI_Transport.h>
|
||||||
|
|
||||||
#include <hardware/BLEMIDI_ESP32_NimBLE.h>
|
#include <hardware/BLEMIDI_ESP32_NimBLE.h>
|
||||||
//#include <hardware/BLEMIDI_ESP32.h>
|
//#include <hardware/BLEMIDI_ESP32.h>
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,16 @@
|
||||||
#include <BLEMIDI.h>
|
#include <BLEMIDI_Transport.h>
|
||||||
|
|
||||||
#include <hardware/BLEMIDI_ESP32_NimBLE.h>
|
//#include <hardware/BLEMIDI_ESP32_NimBLE.h>
|
||||||
//#include <hardware/BLEMIDI_ESP32.h>
|
#include <hardware/BLEMIDI_ESP32.h>
|
||||||
//#include <hardware/BLEMIDI_nRF52.h>
|
//#include <hardware/BLEMIDI_nRF52.h>
|
||||||
//#include <hardware/BLEMIDI_ArduinoBLE.h>
|
//#include <hardware/BLEMIDI_ArduinoBLE.h>
|
||||||
|
|
||||||
BLEMIDI_CREATE_DEFAULT_INSTANCE()
|
BLEMIDI_CREATE_INSTANCE("CustomName", MIDI)
|
||||||
|
|
||||||
bool isConnected = false;
|
bool isConnected = false;
|
||||||
|
|
||||||
|
//#define LOGGING
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#include <BLEMIDI.h>
|
#include <BLEMIDI_Transport.h>
|
||||||
|
|
||||||
#include <hardware/BLEMIDI_ESP32_NimBLE.h>
|
#include <hardware/BLEMIDI_ESP32_NimBLE.h>
|
||||||
//#include <hardware/BLEMIDI_ESP32.h>
|
//#include <hardware/BLEMIDI_ESP32.h>
|
||||||
|
|
@ -84,4 +84,4 @@ void OnConnected() {
|
||||||
void OnDisconnected() {
|
void OnDisconnected() {
|
||||||
isConnected = false;
|
isConnected = false;
|
||||||
digitalWrite(LED_BUILTIN, LOW);
|
digitalWrite(LED_BUILTIN, LOW);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
29
keywords.txt
29
keywords.txt
|
|
@ -5,37 +5,14 @@
|
||||||
#######################################
|
#######################################
|
||||||
# Datatypes (KEYWORD1)
|
# Datatypes (KEYWORD1)
|
||||||
#######################################
|
#######################################
|
||||||
BLEMIDI.h KEYWORD1
|
BLEMIDI_Transport.h KEYWORD1
|
||||||
BLEMIDI KEYWORD1
|
BLEMIDI KEYWORD1
|
||||||
|
|
||||||
#######################################
|
#######################################
|
||||||
# Methods and Functions (KEYWORD2)
|
# Methods and Functions (KEYWORD2)
|
||||||
#######################################
|
#######################################
|
||||||
|
setHandleConnected KEYWORD2
|
||||||
run KEYWORD2
|
setHandleDisconnected KEYWORD2
|
||||||
noteOn KEYWORD2
|
|
||||||
noteOff KEYWORD2
|
|
||||||
afterTouchPoly KEYWORD2
|
|
||||||
controlChange KEYWORD2
|
|
||||||
programChange KEYWORD2
|
|
||||||
afterTouchChannel KEYWORD2
|
|
||||||
pitchBend KEYWORD2
|
|
||||||
systemExclusive KEYWORD2
|
|
||||||
timeCodeQuarterFrame KEYWORD2
|
|
||||||
songPosition KEYWORD2
|
|
||||||
songSelect KEYWORD2
|
|
||||||
tuneRequest KEYWORD2
|
|
||||||
clock KEYWORD2
|
|
||||||
start KEYWORD2
|
|
||||||
Continue KEYWORD2
|
|
||||||
stop KEYWORD2
|
|
||||||
activeSensing KEYWORD2
|
|
||||||
systemReset KEYWORD2
|
|
||||||
timeCodeQuarterFrame KEYWORD2
|
|
||||||
sysEx KEYWORD2
|
|
||||||
afterTouch KEYWORD2
|
|
||||||
polyPressure KEYWORD2
|
|
||||||
tick KEYWORD2
|
|
||||||
|
|
||||||
#######################################
|
#######################################
|
||||||
# Instances (KEYWORD3)
|
# Instances (KEYWORD3)
|
||||||
|
|
|
||||||
|
|
@ -7,5 +7,5 @@ paragraph=MIDI over Bluetooth Low Energy (BLE-MIDI) 1.0 for Arduino
|
||||||
category=Communication
|
category=Communication
|
||||||
url=https://github.com/lathoub/Arduino-BLE-MIDI
|
url=https://github.com/lathoub/Arduino-BLE-MIDI
|
||||||
architectures=esp32,samd,megaavr,mbed,nrf52
|
architectures=esp32,samd,megaavr,mbed,nrf52
|
||||||
includes=BLEMIDI.h
|
includes=BLEMIDI_Transport.h
|
||||||
depends=MIDI Library, NimBLE-Arduino, ArduinoBLE
|
depends=MIDI Library, NimBLE-Arduino, ArduinoBLE
|
||||||
|
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
#include "BLEMIDI.h"
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#ifdef ARDUINO_ARCH_ESP32
|
|
||||||
#include <hardware/BLEMIDI_ESP32_NimBLE.h>
|
|
||||||
//#include <hardware/BLEMIDI_ESP32.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <hardware/BLEMIDI_nRF52.h>
|
|
||||||
#ifdef BLEMIDI_nRF52
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef ArduinoBLE
|
|
||||||
#include <hardware/BLEMIDI_ArduinoBLE.h>
|
|
||||||
#endif
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
#include "BLEMIDI_Transport.h"
|
||||||
|
|
@ -1,11 +1,10 @@
|
||||||
/*!
|
/*!
|
||||||
* @file BLEMIDI.h
|
* @file BLEMIDI_Transport.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <MIDI.h>
|
#include <MIDI.h>
|
||||||
using namespace MIDI_NAMESPACE;
|
|
||||||
|
|
||||||
#include "BLEMIDI_Settings.h"
|
#include "BLEMIDI_Settings.h"
|
||||||
#include "BLEMIDI_Defs.h"
|
#include "BLEMIDI_Defs.h"
|
||||||
|
|
@ -14,7 +13,7 @@ using namespace MIDI_NAMESPACE;
|
||||||
BEGIN_BLEMIDI_NAMESPACE
|
BEGIN_BLEMIDI_NAMESPACE
|
||||||
|
|
||||||
template<class T, class _Settings = DefaultSettings>
|
template<class T, class _Settings = DefaultSettings>
|
||||||
class BLEMIDITransport
|
class BLEMIDI_Transport
|
||||||
{
|
{
|
||||||
typedef _Settings Settings;
|
typedef _Settings Settings;
|
||||||
|
|
||||||
|
|
@ -33,7 +32,7 @@ private:
|
||||||
T mBleClass;
|
T mBleClass;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BLEMIDITransport(const char* deviceName)
|
BLEMIDI_Transport(const char* deviceName)
|
||||||
{
|
{
|
||||||
strncpy(mDeviceName, deviceName, sizeof(mDeviceName));
|
strncpy(mDeviceName, deviceName, sizeof(mDeviceName));
|
||||||
|
|
||||||
|
|
@ -49,7 +48,7 @@ public:
|
||||||
mBleClass.begin(mDeviceName, this);
|
mBleClass.begin(mDeviceName, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool beginTransmission(MidiType type)
|
bool beginTransmission(MIDI_NAMESPACE::MidiType type)
|
||||||
{
|
{
|
||||||
getMidiTimestamp(&mTxBuffer[0], &mTxBuffer[1]);
|
getMidiTimestamp(&mTxBuffer[0], &mTxBuffer[1]);
|
||||||
mTxIndex = 2;
|
mTxIndex = 2;
|
||||||
|
|
@ -288,9 +287,10 @@ public:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
END_BLEMIDI_NAMESPACE
|
|
||||||
|
|
||||||
struct MySettings : public MIDI_NAMESPACE::DefaultSettings
|
struct MySettings : public MIDI_NAMESPACE::DefaultSettings
|
||||||
{
|
{
|
||||||
static const bool Use1ByteParsing = false;
|
static const bool Use1ByteParsing = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
END_BLEMIDI_NAMESPACE
|
||||||
|
|
||||||
|
|
@ -63,7 +63,7 @@ private:
|
||||||
class BLEMIDI_ArduinoBLE
|
class BLEMIDI_ArduinoBLE
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
static BLEMIDITransport<class BLEMIDI_ArduinoBLE>* _bleMidiTransport;
|
static BLEMIDI_Transport<class BLEMIDI_ArduinoBLE>* _bleMidiTransport;
|
||||||
static BLEDevice* _central;
|
static BLEDevice* _central;
|
||||||
|
|
||||||
Fifo<byte, 64> mRxBuffer;
|
Fifo<byte, 64> mRxBuffer;
|
||||||
|
|
@ -73,7 +73,7 @@ public:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool begin(const char*, BLEMIDITransport<class BLEMIDI_ArduinoBLE>*);
|
bool begin(const char*, BLEMIDI_Transport<class BLEMIDI_ArduinoBLE>*);
|
||||||
|
|
||||||
void write(uint8_t* buffer, size_t length)
|
void write(uint8_t* buffer, size_t length)
|
||||||
{
|
{
|
||||||
|
|
@ -177,10 +177,10 @@ protected:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
BLEMIDITransport<class BLEMIDI_ArduinoBLE>* BLEMIDI_ArduinoBLE::_bleMidiTransport = nullptr;
|
BLEMIDI_Transport<class BLEMIDI_ArduinoBLE>* BLEMIDI_ArduinoBLE::_bleMidiTransport = nullptr;
|
||||||
BLEDevice* BLEMIDI_ArduinoBLE::_central = nullptr;
|
BLEDevice* BLEMIDI_ArduinoBLE::_central = nullptr;
|
||||||
|
|
||||||
bool BLEMIDI_ArduinoBLE::begin(const char* deviceName, BLEMIDITransport<class BLEMIDI_ArduinoBLE>* bleMidiTransport)
|
bool BLEMIDI_ArduinoBLE::begin(const char* deviceName, BLEMIDI_Transport<class BLEMIDI_ArduinoBLE>* bleMidiTransport)
|
||||||
{
|
{
|
||||||
_bleMidiTransport = bleMidiTransport;
|
_bleMidiTransport = bleMidiTransport;
|
||||||
|
|
||||||
|
|
@ -214,10 +214,10 @@ bool BLEMIDI_ArduinoBLE::begin(const char* deviceName, BLEMIDITransport<class BL
|
||||||
/*! \brief Create an instance for nRF52 named <DeviceName>
|
/*! \brief Create an instance for nRF52 named <DeviceName>
|
||||||
*/
|
*/
|
||||||
#define BLEMIDI_CREATE_INSTANCE(DeviceName, Name) \
|
#define BLEMIDI_CREATE_INSTANCE(DeviceName, Name) \
|
||||||
BLEMIDI_NAMESPACE::BLEMIDITransport<BLEMIDI_NAMESPACE::BLEMIDI_ArduinoBLE> BLE##Name(DeviceName); \
|
BLEMIDI_NAMESPACE::BLEMIDI_Transport<BLEMIDI_NAMESPACE::BLEMIDI_ArduinoBLE> BLE##Name(DeviceName); \
|
||||||
MIDI_NAMESPACE::MidiInterface<BLEMIDI_NAMESPACE::BLEMIDITransport<BLEMIDI_NAMESPACE::BLEMIDI_ArduinoBLE>, MySettings> Name((BLEMIDI_NAMESPACE::BLEMIDITransport<BLEMIDI_NAMESPACE::BLEMIDI_ArduinoBLE> &)BLE##Name);
|
MIDI_NAMESPACE::MidiInterface<BLEMIDI_NAMESPACE::BLEMIDI_Transport<BLEMIDI_NAMESPACE::BLEMIDI_ArduinoBLE>, BLEMIDI_NAMESPACE::MySettings> Name((BLEMIDI_NAMESPACE::BLEMIDI_Transport<BLEMIDI_NAMESPACE::BLEMIDI_ArduinoBLE> &)BLE##Name);
|
||||||
|
|
||||||
/*! \brief Create a default instance for nRF52 named BLE-MIDI
|
/*! \brief Create a default instance for nRF52 (Nano 33 BLE) named BLE-MIDI
|
||||||
*/
|
*/
|
||||||
#define BLEMIDI_CREATE_DEFAULT_INSTANCE() \
|
#define BLEMIDI_CREATE_DEFAULT_INSTANCE() \
|
||||||
BLEMIDI_CREATE_INSTANCE("BLE-MIDI", MIDI)
|
BLEMIDI_CREATE_INSTANCE("BLE-MIDI", MIDI)
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ private:
|
||||||
BLEAdvertising* _advertising = nullptr;
|
BLEAdvertising* _advertising = nullptr;
|
||||||
BLECharacteristic* _characteristic = nullptr;
|
BLECharacteristic* _characteristic = nullptr;
|
||||||
|
|
||||||
BLEMIDITransport<class BLEMIDI_ESP32>* _bleMidiTransport = nullptr;
|
BLEMIDI_Transport<class BLEMIDI_ESP32>* _bleMidiTransport = nullptr;
|
||||||
|
|
||||||
friend class MyServerCallbacks;
|
friend class MyServerCallbacks;
|
||||||
friend class MyCharacteristicCallbacks;
|
friend class MyCharacteristicCallbacks;
|
||||||
|
|
@ -28,7 +28,7 @@ public:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool begin(const char*, BLEMIDITransport<class BLEMIDI_ESP32>*);
|
bool begin(const char*, BLEMIDI_Transport<class BLEMIDI_ESP32>*);
|
||||||
|
|
||||||
void write(uint8_t* buffer, size_t length)
|
void write(uint8_t* buffer, size_t length)
|
||||||
{
|
{
|
||||||
|
|
@ -104,7 +104,7 @@ protected:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
bool BLEMIDI_ESP32::begin(const char* deviceName, BLEMIDITransport<class BLEMIDI_ESP32>* bleMidiTransport)
|
bool BLEMIDI_ESP32::begin(const char* deviceName, BLEMIDI_Transport<class BLEMIDI_ESP32>* bleMidiTransport)
|
||||||
{
|
{
|
||||||
_bleMidiTransport = bleMidiTransport;
|
_bleMidiTransport = bleMidiTransport;
|
||||||
|
|
||||||
|
|
@ -151,8 +151,8 @@ bool BLEMIDI_ESP32::begin(const char* deviceName, BLEMIDITransport<class BLEMIDI
|
||||||
/*! \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_ESP32> BLE##Name(DeviceName); \
|
BLEMIDI_NAMESPACE::BLEMIDI_Transport<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);
|
MIDI_NAMESPACE::MidiInterface<BLEMIDI_NAMESPACE::BLEMIDI_Transport<BLEMIDI_NAMESPACE::BLEMIDI_ESP32>, BLEMIDI_NAMESPACE::MySettings> Name((BLEMIDI_NAMESPACE::BLEMIDI_Transport<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
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ private:
|
||||||
BLEAdvertising* _advertising = nullptr;
|
BLEAdvertising* _advertising = nullptr;
|
||||||
BLECharacteristic* _characteristic = nullptr;
|
BLECharacteristic* _characteristic = nullptr;
|
||||||
|
|
||||||
BLEMIDITransport<class BLEMIDI_ESP32_NimBLE>* _bleMidiTransport = nullptr;
|
BLEMIDI_Transport<class BLEMIDI_ESP32_NimBLE>* _bleMidiTransport = nullptr;
|
||||||
|
|
||||||
friend class MyServerCallbacks;
|
friend class MyServerCallbacks;
|
||||||
friend class MyCharacteristicCallbacks;
|
friend class MyCharacteristicCallbacks;
|
||||||
|
|
@ -25,7 +25,7 @@ public:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool begin(const char*, BLEMIDITransport<class BLEMIDI_ESP32_NimBLE>*);
|
bool begin(const char*, BLEMIDI_Transport<class BLEMIDI_ESP32_NimBLE>*);
|
||||||
|
|
||||||
void write(uint8_t* buffer, size_t length)
|
void write(uint8_t* buffer, size_t length)
|
||||||
{
|
{
|
||||||
|
|
@ -102,7 +102,7 @@ protected:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
bool BLEMIDI_ESP32_NimBLE::begin(const char* deviceName, BLEMIDITransport<class BLEMIDI_ESP32_NimBLE>* bleMidiTransport)
|
bool BLEMIDI_ESP32_NimBLE::begin(const char* deviceName, BLEMIDI_Transport<class BLEMIDI_ESP32_NimBLE>* bleMidiTransport)
|
||||||
{
|
{
|
||||||
_bleMidiTransport = bleMidiTransport;
|
_bleMidiTransport = bleMidiTransport;
|
||||||
|
|
||||||
|
|
@ -147,12 +147,12 @@ bool BLEMIDI_ESP32_NimBLE::begin(const char* deviceName, BLEMIDITransport<class
|
||||||
/*! \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_ESP32_NimBLE> BLE##Name(DeviceName); \
|
BLEMIDI_NAMESPACE::BLEMIDI_Transport<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);
|
MIDI_NAMESPACE::MidiInterface<BLEMIDI_NAMESPACE::BLEMIDI_Transport<BLEMIDI_NAMESPACE::BLEMIDI_ESP32_NimBLE>, BLEMIDI_NAMESPACE::MySettings> Name((BLEMIDI_NAMESPACE::BLEMIDI_Transport<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
|
||||||
*/
|
*/
|
||||||
#define BLEMIDI_CREATE_DEFAULT_INSTANCE() \
|
#define BLEMIDI_CREATE_DEFAULT_INSTANCE() \
|
||||||
BLEMIDI_CREATE_INSTANCE("BLE-MIDI", MIDI)
|
BLEMIDI_CREATE_INSTANCE("Esp32-BLE-MIDI", MIDI)
|
||||||
|
|
||||||
END_BLEMIDI_NAMESPACE
|
END_BLEMIDI_NAMESPACE
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,18 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <bluefruit.h>
|
// I N D E V E L O P M E N T
|
||||||
|
|
||||||
|
//#include <bluefruit.h>
|
||||||
|
|
||||||
BEGIN_BLEMIDI_NAMESPACE
|
BEGIN_BLEMIDI_NAMESPACE
|
||||||
|
|
||||||
class BLEMIDI_nRF52
|
class BLEMIDI_nRF52
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
BLEDis bledis;
|
// BLEDis bledis;
|
||||||
BLEMidi blemidi;
|
// BLEMidi blemidi;
|
||||||
|
|
||||||
BLEMIDITransport<class BLEMIDI_nRF52>* _bleMidiTransport;
|
BLEMIDI_NAMESPACE::BLEMIDI_Transport<class BLEMIDI_nRF52>* _bleMidiTransport;
|
||||||
|
|
||||||
friend class MyServerCallbacks;
|
friend class MyServerCallbacks;
|
||||||
friend class MyCharacteristicCallbacks;
|
friend class MyCharacteristicCallbacks;
|
||||||
|
|
@ -20,7 +22,7 @@ public:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool begin(const char*, BLEMIDITransport<class BLEMIDI_nRF52>*);
|
bool begin(const char*, BLEMIDI_NAMESPACE::BLEMIDI_Transport<class BLEMIDI_nRF52>*);
|
||||||
|
|
||||||
void write(uint8_t* buffer, size_t length)
|
void write(uint8_t* buffer, size_t length)
|
||||||
{
|
{
|
||||||
|
|
@ -54,41 +56,41 @@ protected:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
bool BLEMIDI_nRF52::begin(const char* deviceName, BLEMIDITransport<class BLEMIDI_nRF52>* bleMidiTransport)
|
bool BLEMIDI_nRF52::begin(const char* deviceName, BLEMIDI_NAMESPACE::BLEMIDI_Transport<class BLEMIDI_nRF52>* bleMidiTransport)
|
||||||
{
|
{
|
||||||
_bleMidiTransport = bleMidiTransport;
|
_bleMidiTransport = bleMidiTransport;
|
||||||
|
|
||||||
// Config the peripheral connection with maximum bandwidth
|
// Config the peripheral connection with maximum bandwidth
|
||||||
// more SRAM required by SoftDevice
|
// more SRAM required by SoftDevice
|
||||||
// Note: All config***() function must be called before begin()
|
// Note: All config***() function must be called before begin()
|
||||||
Bluefruit.configPrphBandwidth(BANDWIDTH_MAX);
|
// Bluefruit.configPrphBandwidth(BANDWIDTH_MAX);
|
||||||
|
|
||||||
Bluefruit.begin();
|
// Bluefruit.begin();
|
||||||
Bluefruit.setName(deviceName);
|
// Bluefruit.setName(deviceName);
|
||||||
Bluefruit.setTxPower(4); // Check bluefruit.h for supported values
|
// Bluefruit.setTxPower(4); // Check bluefruit.h for supported values
|
||||||
|
|
||||||
// Setup the on board blue LED to be enabled on CONNECT
|
// Setup the on board blue LED to be enabled on CONNECT
|
||||||
Bluefruit.autoConnLed(true);
|
// Bluefruit.autoConnLed(true);
|
||||||
|
|
||||||
// Configure and Start Device Information Service
|
// Configure and Start Device Information Service
|
||||||
bledis.setManufacturer("Adafruit Industries");
|
// bledis.setManufacturer("Adafruit Industries");
|
||||||
bledis.setModel("Bluefruit Feather52");
|
// bledis.setModel("Bluefruit Feather52");
|
||||||
bledis.begin();
|
// bledis.begin();
|
||||||
|
|
||||||
// Start advertising ----------------------------
|
// Start advertising ----------------------------
|
||||||
|
|
||||||
// Set General Discoverable Mode flag
|
// Set General Discoverable Mode flag
|
||||||
Bluefruit.Advertising.addFlags(BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE);
|
// Bluefruit.Advertising.addFlags(BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE);
|
||||||
|
|
||||||
// Advertise TX Power
|
// Advertise TX Power
|
||||||
Bluefruit.Advertising.addTxPower();
|
// Bluefruit.Advertising.addTxPower();
|
||||||
|
|
||||||
// Advertise BLE MIDI Service
|
// Advertise BLE MIDI Service
|
||||||
Bluefruit.Advertising.addService(blemidi);
|
// Bluefruit.Advertising.addService(blemidi);
|
||||||
|
|
||||||
// Secondary Scan Response packet (optional)
|
// Secondary Scan Response packet (optional)
|
||||||
// Since there is no room for 'Name' in Advertising packet
|
// Since there is no room for 'Name' in Advertising packet
|
||||||
Bluefruit.ScanResponse.addName();
|
// Bluefruit.ScanResponse.addName();
|
||||||
|
|
||||||
/* Start Advertising
|
/* Start Advertising
|
||||||
* - Enable auto advertising if disconnected
|
* - Enable auto advertising if disconnected
|
||||||
|
|
@ -99,10 +101,10 @@ bool BLEMIDI_nRF52::begin(const char* deviceName, BLEMIDITransport<class BLEMIDI
|
||||||
* For recommended advertising interval
|
* For recommended advertising interval
|
||||||
* https://developer.apple.com/library/content/qa/qa1931/_index.html
|
* https://developer.apple.com/library/content/qa/qa1931/_index.html
|
||||||
*/
|
*/
|
||||||
Bluefruit.Advertising.restartOnDisconnect(true);
|
// Bluefruit.Advertising.restartOnDisconnect(true);
|
||||||
Bluefruit.Advertising.setInterval(32, 244); // in unit of 0.625 ms
|
// Bluefruit.Advertising.setInterval(32, 244); // in unit of 0.625 ms
|
||||||
Bluefruit.Advertising.setFastTimeout(30); // number of seconds in fast mode
|
// Bluefruit.Advertising.setFastTimeout(30); // number of seconds in fast mode
|
||||||
Bluefruit.Advertising.start(0); // 0 = Don't stop advertising after n seconds
|
// Bluefruit.Advertising.start(0); // 0 = Don't stop advertising after n seconds
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -110,12 +112,12 @@ bool BLEMIDI_nRF52::begin(const char* deviceName, BLEMIDITransport<class BLEMIDI
|
||||||
/*! \brief Create an instance for nRF52 named <DeviceName>
|
/*! \brief Create an instance for nRF52 named <DeviceName>
|
||||||
*/
|
*/
|
||||||
#define BLEMIDI_CREATE_INSTANCE(DeviceName, Name) \
|
#define BLEMIDI_CREATE_INSTANCE(DeviceName, Name) \
|
||||||
BLEMIDI_NAMESPACE::BLEMIDITransport<BLEMIDI_NAMESPACE::BLEMIDI_nRF52> BLE##Name(DeviceName); \
|
BLEMIDI_NAMESPACE::BLEMIDI_Transport<BLEMIDI_NAMESPACE::BLEMIDI_nRF52> BLE##Name(DeviceName); \
|
||||||
MIDI_NAMESPACE::MidiInterface<BLEMIDI_NAMESPACE::BLEMIDITransport<BLEMIDI_NAMESPACE::BLEMIDI_nRF52>, MySettings> Name((BLEMIDI_NAMESPACE::BLEMIDITransport<BLEMIDI_NAMESPACE::BLEMIDI_nRF52> &)BLE##Name);
|
MIDI_NAMESPACE::MidiInterface<BLEMIDI_NAMESPACE::BLEMIDI_Transport<BLEMIDI_NAMESPACE::BLEMIDI_nRF52>, BLEMIDI_NAMESPACE::MySettings> Name((BLEMIDI_NAMESPACE::BLEMIDI_Transport<BLEMIDI_NAMESPACE::BLEMIDI_nRF52> &)BLE##Name);
|
||||||
|
|
||||||
/*! \brief Create a default instance for nRF52 named BLE-MIDI
|
/*! \brief Create a default instance for nRF52 named BLE-MIDI
|
||||||
*/
|
*/
|
||||||
#define BLEMIDI_CREATE_DEFAULT_INSTANCE() \
|
#define BLEMIDI_CREATE_DEFAULT_INSTANCE() \
|
||||||
BLEMIDI_CREATE_INSTANCE("BLE-MIDI", MIDI)
|
BLEMIDI_CREATE_INSTANCE("nRF85BLE-MIDI", MIDI)
|
||||||
|
|
||||||
END_BLEMIDI_NAMESPACE
|
END_BLEMIDI_NAMESPACE
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue