added default initialisation

This commit is contained in:
lathoub 2019-08-17 17:31:21 +02:00
parent 0787571f5f
commit 8a0619c498
2 changed files with 12 additions and 20 deletions

View File

@ -6,26 +6,22 @@
#include <BLEServer.h> #include <BLEServer.h>
#include <BLE2902.h> #include <BLE2902.h>
BEGIN_BLEMIDI_NAMESPACE
#define SERVICE_UUID "03b80e5a-ede8-4b33-a751-6ce34ec4c700" #define SERVICE_UUID "03b80e5a-ede8-4b33-a751-6ce34ec4c700"
#define CHARACTERISTIC_UUID "7772e5db-3868-4112-a1a9-f2669d106bf3" #define CHARACTERISTIC_UUID "7772e5db-3868-4112-a1a9-f2669d106bf3"
BEGIN_BLEMIDI_NAMESPACE
class BluetoothEsp32 class BluetoothEsp32
{ {
private: private:
BLEServer* _server; BLEServer* _server = nullptr;
BLEAdvertising* _advertising; BLEAdvertising* _advertising = nullptr;
BLECharacteristic* _characteristic; BLECharacteristic* _characteristic = nullptr;
BleMidiTransport<class BluetoothEsp32>* _bleMidiTransport; BleMidiTransport<class BluetoothEsp32>* _bleMidiTransport = nullptr;
public: public:
BluetoothEsp32() BluetoothEsp32()
: _server(NULL),
_advertising(NULL),
_characteristic(NULL),
_bleMidiTransport(NULL)
{ {
} }
@ -66,7 +62,7 @@ public:
} }
protected: protected:
BluetoothEsp32* _bluetoothEsp32; BluetoothEsp32* _bluetoothEsp32 = nullptr;
void onConnect(BLEServer* server) { void onConnect(BLEServer* server) {
_bluetoothEsp32->connected(); _bluetoothEsp32->connected();
@ -84,7 +80,7 @@ public:
} }
protected: protected:
BluetoothEsp32* _bluetoothEsp32; BluetoothEsp32* _bluetoothEsp32 = nullptr;
void onWrite(BLECharacteristic * characteristic) { void onWrite(BLECharacteristic * characteristic) {
std::string rxValue = characteristic->getValue(); std::string rxValue = characteristic->getValue();

View File

@ -18,16 +18,14 @@ private:
midi::RingBuffer<byte, 44> mRxBuffer; midi::RingBuffer<byte, 44> mRxBuffer;
byte mTxBuffer[44]; byte mTxBuffer[44];
unsigned mTxIndex; unsigned mTxIndex = 0;
bool _connected;
private: private:
BleClass& mBleClass; BleClass& mBleClass;
public: public:
inline BleMidiTransport(BleClass& inBleClass) inline BleMidiTransport(BleClass& inBleClass)
: mBleClass(inBleClass), mTxIndex(0) : mBleClass(inBleClass)
{ {
} }
@ -117,17 +115,15 @@ protected:
public: public:
// callbacks // callbacks
void(*_connectedCallback)() = NULL; void(*_connectedCallback)() = nullptr;
void(*_disconnectedCallback)() = NULL; void(*_disconnectedCallback)() = nullptr;
public: public:
void onConnected(void(*fptr)()) { void onConnected(void(*fptr)()) {
_connected = true;
_connectedCallback = fptr; _connectedCallback = fptr;
} }
void onDisconnected(void(*fptr)()) { void onDisconnected(void(*fptr)()) {
_connected = false;
_disconnectedCallback = fptr; _disconnectedCallback = fptr;
} }