Skip to content

Commit 09a1f26

Browse files
authored
Merge pull request #62 from RobertoHE/CustomSettings
BleClient Custom settings
2 parents 6d168da + 38fea5d commit 09a1f26

File tree

8 files changed

+332
-301
lines changed

8 files changed

+332
-301
lines changed

ci/build-arduino.sh

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,16 @@ shopt -s globstar
66
# Make sure we are inside the github workspace
77
cd $GITHUB_WORKSPACE
88
# Create directories
9-
mkdir $HOME/Arduino
10-
mkdir $HOME/Arduino/libraries
9+
mkdir $HOME/Arduino -p
10+
mkdir $HOME/Arduino/libraries -p
1111
# Install Arduino IDE
1212
export PATH=$PATH:$GITHUB_WORKSPACE/bin
1313
curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh
1414
arduino-cli config init
1515
arduino-cli config set library.enable_unsafe_install true
1616
# arduino-cli core update-index --additional-urls https://arduino.esp8266.com/stable/package_esp8266com_index.json
17-
arduino-cli core update-index --additional-urls https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
17+
#arduino-cli core update-index --additional-urls https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
18+
sed -i 's+\[\]+\[https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json\]+g' /home/runner/.arduino15/arduino-cli.yaml
1819
arduino-cli core update-index
1920

2021
# Install Arduino AVR core
@@ -24,13 +25,13 @@ arduino-cli core install arduino:samd
2425
arduino-cli core install esp32:esp32
2526

2627
# List the boards
27-
arduino-cli board list
28+
arduino-cli board listall
2829

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

3233
arduino-cli lib install "MIDI library"
33-
arduino-cli lib install ArduinoBLE
34+
#arduino-cli lib install ArduinoBLE
3435
arduino-cli lib install NimBLE-Arduino
3536

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

52+
dR=$(pwd)
53+
5154
# Compile all *.ino files for the Arduino Uno
5255
for f in **/*.ino ; do
53-
arduino-cli compile -b arduino:esp32:??? $f
56+
echo "Project: $f"
57+
d=$(dirname $(readlink -f $f))
58+
echo $d
59+
cd $d
60+
arduino-cli compile -b esp32:esp32:esp32 *.ino --clean
61+
cd $dR
5462
done

examples/CustomerBufferSize/CustomerBufferSize.ino

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,67 @@
11
#include <BLEMIDI_Transport.h>
22

3+
static uint32_t customPasskeyRequest()
4+
{
5+
// FILL WITH YOUR CUSTOM AUTH METHOD CODE or PASSKEY
6+
// FOR EXAMPLE:
7+
uint32_t passkey = 123456;
8+
9+
// Serial.println("Client Passkey Request");
10+
11+
/** return the passkey to send to the server */
12+
return passkey;
13+
};
14+
315
struct CustomBufferSizeSettings : public BLEMIDI_NAMESPACE::DefaultSettings {
16+
//See all options and them explanation in the library.
17+
18+
/*
19+
##### BLE DEVICE NAME #####
20+
*/
21+
//static constexpr char *name = "BleMidiClient";
22+
/*
23+
###### TX POWER #####
24+
*/
25+
//static const esp_power_level_t clientTXPwr = ESP_PWR_LVL_P9;
26+
/*
27+
###### SECURITY #####
28+
*/
29+
//static const uint8_t clientSecurityCapabilities = BLE_HS_IO_NO_INPUT_OUTPUT;
30+
//static const bool clientBond = true;
31+
//static const bool clientMITM = false;
32+
//static const bool clientPair = true;
33+
//static constexpr PasskeyRequestCallback userOnPassKeyRequest = customPasskeyRequest;
34+
/*
35+
###### BLE COMMUNICATION PARAMS ######
36+
*/
37+
//static const uint16_t commMinInterval = 6; // 7.5ms
38+
//static const uint16_t commMaxInterval = 35; // 40ms
39+
//static const uint16_t commLatency = 0; //
40+
//static const uint16_t commTimeOut = 200; // 2000ms
41+
/*
42+
###### BLE FORCE NEW CONNECTION ######
43+
*/
44+
//static const bool forceNewConnection = false;
45+
/*
46+
###### BLE SUBSCRIPTION: NOTIFICATION & RESPONSE ######
47+
*/
48+
//static const bool notification = true;
49+
//static const bool response = true;
50+
/*
51+
###### AND THE OTHER SETTINGS OF MIDI LIBRARY ######
52+
*/
453
static const size_t MaxBufferSize = 16;
54+
555
};
656

757
#include <hardware/BLEMIDI_ESP32_NimBLE.h>
858
//#include <hardware/BLEMIDI_ESP32.h>
959
//#include <hardware/BLEMIDI_ArduinoBLE.h>
1060

61+
#ifndef LED_BUILTIN
62+
#define LED_BUILTIN 2
63+
#endif
64+
1165
BLEMIDI_CREATE_CUSTOM_INSTANCE("Esp32-NimBLE-MIDI", MIDI, CustomBufferSizeSettings);
1266

1367
unsigned long t0 = millis();
@@ -61,4 +115,4 @@ void loop()
61115

62116
MIDI.sendNoteOn (60, 100, 1); // note 60, velocity 100 on channel 1
63117
}
64-
}
118+
}

examples/MidiBle/MidiBle.ino

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
#include <hardware/BLEMIDI_ESP32.h>
55
//#include <hardware/BLEMIDI_ArduinoBLE.h>
66

7+
#ifndef LED_BUILTIN
8+
#define LED_BUILTIN 2
9+
#endif
10+
711
BLEMIDI_CREATE_DEFAULT_INSTANCE()
812

913
unsigned long t0 = millis();

examples/MidiBle_Client/MidiBle_Client.ino

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
* the name of the server or the BLE address of the server. If you want to connect
1515
* to the first MIDI server BLE found by the device, you just have to set the name field empty ("").
1616
*
17-
* FOR ADVANCED USERS: Other advanced BLE configurations can be changed in hardware/BLEMIDI_Client_ESP32.h
18-
* #defines in the head of the file (IMPORTANT: Only the first user defines must be modified). These configurations
19-
* are related to security (password, pairing and securityCallback()), communication params, the device name
20-
* and other stuffs. Modify defines at your own risk.
17+
* FOR ADVANCED USERS: Other advanced BLE configurations can be changed with a struct that heritate
18+
* from BLEMIDI_NAMESPACE::DefaultSettingsClient. These configurations are related to
19+
* security (password, pairing and securityCallback()), communication params, the device name
20+
* and other stuffs. Modify those settings at your own risk.
2121
*
2222
*
2323
*
@@ -28,21 +28,26 @@
2828
#include <Arduino.h>
2929
#include <BLEMIDI_Transport.h>
3030

31-
struct CustomBufferSizeSettings : public BLEMIDI_NAMESPACE::DefaultSettings {
32-
static const size_t MaxBufferSize = 16;
33-
};
34-
3531
#include <hardware/BLEMIDI_Client_ESP32.h>
36-
3732
//#include <hardware/BLEMIDI_ESP32_NimBLE.h>
3833
//#include <hardware/BLEMIDI_ESP32.h>
3934
//#include <hardware/BLEMIDI_ArduinoBLE.h>
4035

41-
BLEMIDI_CREATE_CUSTOM_INSTANCE("Esp32-BLE-MIDI", MIDI, CustomBufferSizeSettings); // Connect to first server found
36+
#ifndef LED_BUILTIN
37+
#define LED_BUILTIN 2
38+
#endif
39+
40+
//See DefaultSettingsClient in hardware/BLEMIDI_Client_ESP32.h for more configurable settings
41+
// If you do not redefine a parameter, it will use the default value for these parameter
42+
struct CustomBufferSizeSettings : public BLEMIDI_NAMESPACE::DefaultSettingsClient {
43+
static const size_t MaxBufferSize = 16;
44+
};
45+
46+
BLEMIDI_CREATE_CUSTOM_INSTANCE("Esp32-BLE-MIDI", MIDI, CustomBufferSizeSettings); // Connect to a server named "Esp32-BLE-MIDI" and use CustomBufferSizeSettings as settings of client
4247

43-
//BLEMIDI_CREATE_INSTANCE("",MIDI) //Connect to the first server found
44-
//BLEMIDI_CREATE_INSTANCE("f2:c1:d9:36:e7:6b",MIDI) //Connect to a specific BLE address server
45-
//BLEMIDI_CREATE_INSTANCE("MyBLEserver",MIDI) //Connect to a specific name server
48+
//BLEMIDI_CREATE_INSTANCE("",MIDI) //Connect to the first server found, using default settings
49+
//BLEMIDI_CREATE_INSTANCE("f2:c1:d9:36:e7:6b",MIDI) //Connect to a specific BLE address server, using default settings
50+
//BLEMIDI_CREATE_INSTANCE("MyBLEserver",MIDI) //Connect to a specific name server, using default settings
4651

4752
#ifndef LED_BUILTIN
4853
#define LED_BUILTIN 2 //modify for match with yout board

examples/SysEx_Receive/SysEx_Receive.ino

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
#include <hardware/BLEMIDI_ESP32.h>
55
//#include <hardware/BLEMIDI_ArduinoBLE.h>
66

7+
#ifndef LED_BUILTIN
8+
#define LED_BUILTIN 2
9+
#endif
10+
711
BLEMIDI_CREATE_INSTANCE("CustomName", MIDI)
812

913
bool isConnected = false;

examples/SysEx_Send/SysEx_Send.ino

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
//#include <hardware/BLEMIDI_ESP32.h>
55
//#include <hardware/BLEMIDI_ArduinoBLE.h>
66

7+
#ifndef LED_BUILTIN
8+
#define LED_BUILTIN 2
9+
#endif
10+
711
byte sysex4[] = { 0xF0, 0x43, 0x20, 0xF7 };
812
byte sysex5[] = { 0xF0, 0x43, 0x20, 0x7E, 0xF7 };
913
byte sysex6[] = { 0xF0, 0x43, 0x20, 0x7E, 0x4C, 0xF7 };

src/BLEMIDI_Transport.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,10 +256,10 @@ class BLEMIDI_Transport
256256
byte headerByte = buffer[lPtr++];
257257

258258
auto timestampHigh = 0x3f & headerByte;
259-
259+
timestampHigh = timestampHigh; // <-- This line is for avoid Warning message due it is unused
260260
byte timestampByte = buffer[lPtr++];
261261
uint16_t timestamp = 0;
262-
262+
timestamp = timestamp; // <-- This line is for avoid Warning message due it is unused
263263
bool sysExContinuation = false;
264264
bool runningStatusContinuation = false;
265265

0 commit comments

Comments
 (0)