working on nRF52
This commit is contained in:
parent
3c789b0b5f
commit
75e994c95d
|
|
@ -6,7 +6,6 @@
|
||||||
|
|
||||||
#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_ArduinoBLE.h>
|
//#include <hardware/BLEMIDI_ArduinoBLE.h>
|
||||||
|
|
||||||
BLEMIDI_CREATE_CUSTOM_INSTANCE("Esp32-NimBLE-MIDI", MIDI, CustomBufferSizeSettings);
|
BLEMIDI_CREATE_CUSTOM_INSTANCE("Esp32-NimBLE-MIDI", MIDI, CustomBufferSizeSettings);
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
//#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_ArduinoBLE.h>
|
//#include <hardware/BLEMIDI_ArduinoBLE.h>
|
||||||
|
|
||||||
BLEMIDI_CREATE_DEFAULT_INSTANCE()
|
BLEMIDI_CREATE_DEFAULT_INSTANCE()
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,6 @@
|
||||||
|
|
||||||
//#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_ArduinoBLE.h>
|
//#include <hardware/BLEMIDI_ArduinoBLE.h>
|
||||||
|
|
||||||
BLEMIDI_CREATE_CUSTOM_INSTANCE("Esp32-BLE-MIDI", MIDI, CustomBufferSizeSettings); // Connect to first server found
|
BLEMIDI_CREATE_CUSTOM_INSTANCE("Esp32-BLE-MIDI", MIDI, CustomBufferSizeSettings); // Connect to first server found
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
//#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_ArduinoBLE.h>
|
//#include <hardware/BLEMIDI_ArduinoBLE.h>
|
||||||
|
|
||||||
BLEMIDI_CREATE_INSTANCE("CustomName", MIDI)
|
BLEMIDI_CREATE_INSTANCE("CustomName", MIDI)
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
#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_ArduinoBLE.h>
|
//#include <hardware/BLEMIDI_ArduinoBLE.h>
|
||||||
|
|
||||||
byte sysex4[] = { 0xF0, 0x43, 0x20, 0xF7 };
|
byte sysex4[] = { 0xF0, 0x43, 0x20, 0xF7 };
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
// I N D E V E L O P M E N T
|
// I N D E V E L O P M E N T
|
||||||
|
|
||||||
//#include <bluefruit.h>
|
#include <bluefruit.h>
|
||||||
|
|
||||||
BEGIN_BLEMIDI_NAMESPACE
|
BEGIN_BLEMIDI_NAMESPACE
|
||||||
|
|
||||||
|
|
@ -10,13 +10,13 @@ template <class _Settings>
|
||||||
class BLEMIDI_nRF52
|
class BLEMIDI_nRF52
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
// BLEDis bledis;
|
BLEDis bledis;
|
||||||
// BLEMidi blemidi;
|
// BLEMidi blemidi;
|
||||||
|
|
||||||
BLEMIDI_NAMESPACE::BLEMIDI_Transport<class BLEMIDI_nRF52<_Settings>, _Settings>* _bleMidiTransport;
|
BLEMIDI_NAMESPACE::BLEMIDI_Transport<class BLEMIDI_nRF52<_Settings>, _Settings>* _bleMidiTransport;
|
||||||
|
|
||||||
template <class> friend class MyServerCallbacks;
|
// template <class> friend class MyServerCallbacks;
|
||||||
template <class> friend class MyCharacteristicCallbacks;
|
// template <class> friend class MyCharacteristicCallbacks;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BLEMIDI_nRF52()
|
BLEMIDI_nRF52()
|
||||||
|
|
@ -62,6 +62,23 @@ protected:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void connect_callback(uint16_t conn_handle)
|
||||||
|
{
|
||||||
|
Serial.println("Connected");
|
||||||
|
|
||||||
|
// Get the reference to current connection
|
||||||
|
BLEConnection* connection = Bluefruit.Connection(conn_handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
void disconnect_callback(uint16_t conn_handle, uint8_t reason)
|
||||||
|
{
|
||||||
|
(void) conn_handle;
|
||||||
|
(void) reason;
|
||||||
|
|
||||||
|
Serial.println();
|
||||||
|
Serial.print("Disconnected, reason = 0x"); Serial.println(reason, HEX);
|
||||||
|
}
|
||||||
|
|
||||||
template <class _Settings>
|
template <class _Settings>
|
||||||
bool BLEMIDI_nRF52<_Settings>::begin(const char* deviceName, BLEMIDI_NAMESPACE::BLEMIDI_Transport<class BLEMIDI_nRF52<_Settings>, _Settings>* bleMidiTransport)
|
bool BLEMIDI_nRF52<_Settings>::begin(const char* deviceName, BLEMIDI_NAMESPACE::BLEMIDI_Transport<class BLEMIDI_nRF52<_Settings>, _Settings>* bleMidiTransport)
|
||||||
{
|
{
|
||||||
|
|
@ -70,34 +87,39 @@ bool BLEMIDI_nRF52<_Settings>::begin(const char* deviceName, BLEMIDI_NAMESPACE::
|
||||||
// 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);
|
||||||
|
|
||||||
|
Bluefruit.Periph.setConnectCallback(connect_callback);
|
||||||
|
Bluefruit.Periph.setDisconnectCallback(disconnect_callback);
|
||||||
|
|
||||||
// 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);
|
||||||
|
|
||||||
|
// blemidi.write((uint8_t)0);
|
||||||
|
|
||||||
// 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
|
||||||
|
|
@ -108,10 +130,10 @@ bool BLEMIDI_nRF52<_Settings>::begin(const char* deviceName, BLEMIDI_NAMESPACE::
|
||||||
* 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;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue