Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BleClient Custom settings #62

Open
wants to merge 32 commits into
base: CustomSettings
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
26eeb92
Update BLEMIDI_Client_ESP32.h
RobertoHE Jun 2, 2022
c69bb30
Change Define Template
RobertoHE Jun 6, 2022
3fc460e
Merge pull request #2 from RobertoHE/patch-1
RobertoHE Jun 6, 2022
53e0139
Debug Verbose
RobertoHE Jun 21, 2022
39c1647
Increased readability in onResult
RobertoHE Jun 21, 2022
24dce9a
Changed #define for Struct in Config
RobertoHE Jun 21, 2022
fe3412b
Minor Syntax correction
RobertoHE Jun 21, 2022
f31f8db
Code Example changed for new settings struct
RobertoHE Jun 27, 2022
24f4add
Intro explanation modified
RobertoHE Jun 27, 2022
81462be
Add Notification and Response parameters to Config
RobertoHE Nov 21, 2022
3e83235
Update build-arduino.sh
RobertoHE Nov 22, 2022
27ee609
Update build-arduino.sh
RobertoHE Nov 22, 2022
03523e5
Update build-arduino.sh
RobertoHE Nov 22, 2022
f9b7922
Update build-arduino.sh
RobertoHE Nov 23, 2022
03365fc
Update CustomerBufferSize.ino
RobertoHE Nov 23, 2022
a294fc6
Update build-arduino.sh
RobertoHE Nov 28, 2022
2e2cb86
Update build-arduino.sh
RobertoHE Nov 28, 2022
37eb60b
Update build-arduino.sh
RobertoHE Nov 28, 2022
0afc91c
Update build-arduino.sh
RobertoHE Nov 28, 2022
06dc8d0
Update build-arduino.sh
RobertoHE Nov 28, 2022
186cc21
Update build-arduino.sh
RobertoHE Nov 28, 2022
c3ecb07
Update build-arduino.sh
RobertoHE Nov 28, 2022
99c2151
Update build-arduino.sh
RobertoHE Nov 28, 2022
fe4a021
Update build-arduino.sh
RobertoHE Nov 28, 2022
f871a35
Update build-arduino.sh
RobertoHE Nov 28, 2022
c7121d0
Update MidiBle.ino
RobertoHE Nov 28, 2022
2aa2183
Update MidiBle_Client.ino
RobertoHE Nov 28, 2022
7fdaffc
Update SysEx_Receive.ino
RobertoHE Nov 28, 2022
06a1b8f
Update SysEx_Send.ino
RobertoHE Nov 28, 2022
25a78fa
Added all configurations options to example
RobertoHE Nov 29, 2022
a1ec137
*/ syntax correction in example
RobertoHE Nov 29, 2022
38fea5d
Add lines to avoid warning about unused var
RobertoHE Dec 28, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions ci/build-arduino.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@ shopt -s globstar
# Make sure we are inside the github workspace
cd $GITHUB_WORKSPACE
# Create directories
mkdir $HOME/Arduino
mkdir $HOME/Arduino/libraries
mkdir $HOME/Arduino -p
mkdir $HOME/Arduino/libraries -p
# Install Arduino IDE
export PATH=$PATH:$GITHUB_WORKSPACE/bin
curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh
arduino-cli config init
arduino-cli config set library.enable_unsafe_install true
# arduino-cli core update-index --additional-urls https://arduino.esp8266.com/stable/package_esp8266com_index.json
arduino-cli core update-index --additional-urls https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
#arduino-cli core update-index --additional-urls https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
sed -i 's+\[\]+\[https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json\]+g' /home/runner/.arduino15/arduino-cli.yaml
arduino-cli core update-index

# Install Arduino AVR core
Expand All @@ -24,13 +25,13 @@ arduino-cli core install arduino:samd
arduino-cli core install esp32:esp32

# List the boards
arduino-cli board list
arduino-cli board listall

# Link Arduino library
ln -s $GITHUB_WORKSPACE $HOME/Arduino/libraries/CI_Test_Library

arduino-cli lib install "MIDI library"
arduino-cli lib install ArduinoBLE
#arduino-cli lib install ArduinoBLE
arduino-cli lib install NimBLE-Arduino

# Compile all *.ino files for the Arduino Uno
Expand All @@ -48,7 +49,14 @@ arduino-cli lib install NimBLE-Arduino
# arduino-cli compile -b arduino:esp8266:??? $f
# done

dR=$(pwd)

# Compile all *.ino files for the Arduino Uno
for f in **/*.ino ; do
arduino-cli compile -b arduino:esp32:??? $f
echo "Project: $f"
d=$(dirname $(readlink -f $f))
echo $d
cd $d
arduino-cli compile -b esp32:esp32:esp32 *.ino --clean
cd $dR
done
56 changes: 55 additions & 1 deletion examples/CustomerBufferSize/CustomerBufferSize.ino
Original file line number Diff line number Diff line change
@@ -1,13 +1,67 @@
#include <BLEMIDI_Transport.h>

static uint32_t customPasskeyRequest()
{
// FILL WITH YOUR CUSTOM AUTH METHOD CODE or PASSKEY
// FOR EXAMPLE:
uint32_t passkey = 123456;

// Serial.println("Client Passkey Request");

/** return the passkey to send to the server */
return passkey;
};

struct CustomBufferSizeSettings : public BLEMIDI_NAMESPACE::DefaultSettings {
//See all options and them explanation in the library.

/*
##### BLE DEVICE NAME #####
*/
//static constexpr char *name = "BleMidiClient";
/*
###### TX POWER #####
*/
//static const esp_power_level_t clientTXPwr = ESP_PWR_LVL_P9;
/*
###### SECURITY #####
*/
//static const uint8_t clientSecurityCapabilities = BLE_HS_IO_NO_INPUT_OUTPUT;
//static const bool clientBond = true;
//static const bool clientMITM = false;
//static const bool clientPair = true;
//static constexpr PasskeyRequestCallback userOnPassKeyRequest = customPasskeyRequest;
/*
###### BLE COMMUNICATION PARAMS ######
*/
//static const uint16_t commMinInterval = 6; // 7.5ms
//static const uint16_t commMaxInterval = 35; // 40ms
//static const uint16_t commLatency = 0; //
//static const uint16_t commTimeOut = 200; // 2000ms
/*
###### BLE FORCE NEW CONNECTION ######
*/
//static const bool forceNewConnection = false;
/*
###### BLE SUBSCRIPTION: NOTIFICATION & RESPONSE ######
*/
//static const bool notification = true;
//static const bool response = true;
/*
###### AND THE OTHER SETTINGS OF MIDI LIBRARY ######
*/
static const size_t MaxBufferSize = 16;

};

#include <hardware/BLEMIDI_ESP32_NimBLE.h>
//#include <hardware/BLEMIDI_ESP32.h>
//#include <hardware/BLEMIDI_ArduinoBLE.h>

#ifndef LED_BUILTIN
#define LED_BUILTIN 2
#endif

BLEMIDI_CREATE_CUSTOM_INSTANCE("Esp32-NimBLE-MIDI", MIDI, CustomBufferSizeSettings);

unsigned long t0 = millis();
Expand Down Expand Up @@ -61,4 +115,4 @@ void loop()

MIDI.sendNoteOn (60, 100, 1); // note 60, velocity 100 on channel 1
}
}
}
4 changes: 4 additions & 0 deletions examples/MidiBle/MidiBle.ino
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
#include <hardware/BLEMIDI_ESP32.h>
//#include <hardware/BLEMIDI_ArduinoBLE.h>

#ifndef LED_BUILTIN
#define LED_BUILTIN 2
#endif

BLEMIDI_CREATE_DEFAULT_INSTANCE()

unsigned long t0 = millis();
Expand Down
31 changes: 18 additions & 13 deletions examples/MidiBle_Client/MidiBle_Client.ino
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
* the name of the server or the BLE address of the server. If you want to connect
* to the first MIDI server BLE found by the device, you just have to set the name field empty ("").
*
* FOR ADVANCED USERS: Other advanced BLE configurations can be changed in hardware/BLEMIDI_Client_ESP32.h
* #defines in the head of the file (IMPORTANT: Only the first user defines must be modified). These configurations
* are related to security (password, pairing and securityCallback()), communication params, the device name
* and other stuffs. Modify defines at your own risk.
* FOR ADVANCED USERS: Other advanced BLE configurations can be changed with a struct that heritate
* from BLEMIDI_NAMESPACE::DefaultSettingsClient. These configurations are related to
* security (password, pairing and securityCallback()), communication params, the device name
* and other stuffs. Modify those settings at your own risk.
*
*
*
Expand All @@ -28,21 +28,26 @@
#include <Arduino.h>
#include <BLEMIDI_Transport.h>

struct CustomBufferSizeSettings : public BLEMIDI_NAMESPACE::DefaultSettings {
static const size_t MaxBufferSize = 16;
};

#include <hardware/BLEMIDI_Client_ESP32.h>

//#include <hardware/BLEMIDI_ESP32_NimBLE.h>
//#include <hardware/BLEMIDI_ESP32.h>
//#include <hardware/BLEMIDI_ArduinoBLE.h>

BLEMIDI_CREATE_CUSTOM_INSTANCE("Esp32-BLE-MIDI", MIDI, CustomBufferSizeSettings); // Connect to first server found
#ifndef LED_BUILTIN
#define LED_BUILTIN 2
#endif

//See DefaultSettingsClient in hardware/BLEMIDI_Client_ESP32.h for more configurable settings
// If you do not redefine a parameter, it will use the default value for these parameter
struct CustomBufferSizeSettings : public BLEMIDI_NAMESPACE::DefaultSettingsClient {
static const size_t MaxBufferSize = 16;
};

BLEMIDI_CREATE_CUSTOM_INSTANCE("Esp32-BLE-MIDI", MIDI, CustomBufferSizeSettings); // Connect to a server named "Esp32-BLE-MIDI" and use CustomBufferSizeSettings as settings of client

//BLEMIDI_CREATE_INSTANCE("",MIDI) //Connect to the first server found
//BLEMIDI_CREATE_INSTANCE("f2:c1:d9:36:e7:6b",MIDI) //Connect to a specific BLE address server
//BLEMIDI_CREATE_INSTANCE("MyBLEserver",MIDI) //Connect to a specific name server
//BLEMIDI_CREATE_INSTANCE("",MIDI) //Connect to the first server found, using default settings
//BLEMIDI_CREATE_INSTANCE("f2:c1:d9:36:e7:6b",MIDI) //Connect to a specific BLE address server, using default settings
//BLEMIDI_CREATE_INSTANCE("MyBLEserver",MIDI) //Connect to a specific name server, using default settings

#ifndef LED_BUILTIN
#define LED_BUILTIN 2 //modify for match with yout board
Expand Down
4 changes: 4 additions & 0 deletions examples/SysEx_Receive/SysEx_Receive.ino
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
#include <hardware/BLEMIDI_ESP32.h>
//#include <hardware/BLEMIDI_ArduinoBLE.h>

#ifndef LED_BUILTIN
#define LED_BUILTIN 2
#endif

BLEMIDI_CREATE_INSTANCE("CustomName", MIDI)

bool isConnected = false;
Expand Down
4 changes: 4 additions & 0 deletions examples/SysEx_Send/SysEx_Send.ino
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
//#include <hardware/BLEMIDI_ESP32.h>
//#include <hardware/BLEMIDI_ArduinoBLE.h>

#ifndef LED_BUILTIN
#define LED_BUILTIN 2
#endif

byte sysex4[] = { 0xF0, 0x43, 0x20, 0xF7 };
byte sysex5[] = { 0xF0, 0x43, 0x20, 0x7E, 0xF7 };
byte sysex6[] = { 0xF0, 0x43, 0x20, 0x7E, 0x4C, 0xF7 };
Expand Down
4 changes: 2 additions & 2 deletions src/BLEMIDI_Transport.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,10 @@ class BLEMIDI_Transport
byte headerByte = buffer[lPtr++];

auto timestampHigh = 0x3f & headerByte;

timestampHigh = timestampHigh; // <-- This line is for avoid Warning message due it is unused
byte timestampByte = buffer[lPtr++];
uint16_t timestamp = 0;

timestamp = timestamp; // <-- This line is for avoid Warning message due it is unused
bool sysExContinuation = false;
bool runningStatusContinuation = false;

Expand Down
Loading