From 56386ace3c41a206ace8377584d80935bf177271 Mon Sep 17 00:00:00 2001 From: lathoub <4082369+lathoub@users.noreply.github.com> Date: Sun, 11 Oct 2020 11:44:25 +0200 Subject: [PATCH] Update README.md --- README.md | 41 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 65c68ca..323b9d8 100644 --- a/README.md +++ b/README.md @@ -14,20 +14,55 @@ When manually installing this library, you have to manually download [Arduino MI #include #include ... -BLEMIDI_CREATE_DEFAULT_ESP32_INSTANCE(); +BLEMIDI_CREATE_DEFAULT_INSTANCE() ... void setup() { - MIDI.begin(1); + MIDI.begin(); ... void loop() { MIDI.read(); ``` -will create a instance named `bleMIDI` and listens to incoming MIDI on channel 1. +will create a instance named `BLEMIDI` and listens to incoming MIDI. + +### using NimBLE for ESP32 with a custom name and turns LED on when its connected + +```cpp +#include +#include +... +BLEMIDI_CREATE_INSTANCE("CustomName", MIDI) +... +void setup() +{ + pinMode(LED_BUILTIN, OUTPUT); + digitalWrite(LED_BUILTIN, LOW); + + BLEMIDI.setHandleConnected(OnConnected); + BLEMIDI.setHandleDisconnected(OnDisconnected); + + MIDI.begin(); +... +void loop() +{ + MIDI.read(); +... +void OnConnected() { + digitalWrite(LED_BUILTIN, HIGH); +} + +void OnDisconnected() { + digitalWrite(LED_BUILTIN, LOW); +} + +``` +will create a instance named `BLEMIDI` and listens to incoming MIDI. ## Tested boards/modules - ESP32 +- ESP32 NimBLE +- Arduino NANO 33 BLE ## Other Transport protocols: The libraries below the same calling mechanism (API), making it easy to interchange the transport layer.