Control Surface main
MIDI Control Surface library for Arduino
Loading...
Searching...
No Matches
GenericBLEMIDI_Interface.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <AH/Error/Error.hpp>
4
5#include "BLEMIDI/BLEAPI.hpp"
6#include "MIDI_Interface.hpp"
7
8#include <chrono>
9
11
15template <class Backend>
17 public:
18 template <class... Args>
20 : backend {std::forward<Args>(args)...} {}
21
22 private:
23 // MIDI send implementations
24 template <class L, class F>
25 void sendImpl(L &lck, F add_to_buffer);
30 void sendNowImpl() override;
31
32 private:
33#if !DISABLE_PIPES
34 void handleStall() override { MIDI_Interface::handleStall(this); }
35#ifdef DEBUG_OUT
36 const char *getName() const override { return "ble"; }
37#endif
38#endif
39
40 public:
43
46 void begin() override;
48 void end();
52 void update() override { MIDI_Interface::updateIncoming(this); }
57 bool isConnected() const { return backend.isConnected(); }
58
60
61 public:
64
69
80 uint16_t getTimestamp() const;
81
83
84 private:
88 typename Backend::IncomingMIDIMessage incomingMessage;
89
90 public:
93
96 void setName(const char *name);
100 void setTimeout(std::chrono::milliseconds timeout) {
101 backend.setTimeout(timeout);
102 }
105
107
108 public:
110 Backend backend;
111};
112
114
115#include "GenericBLEMIDI_Interface.ipp"
Type definitions and callback interfaces for communication between the low-level BLE stacks and highe...
MIDIReadEvent
Values returned by the MIDI reading functions.
#define END_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
Bluetooth Low Energy MIDI Interface.
ChannelMessage getChannelMessage() const
Return the received channel voice message.
RealTimeMessage getRealTimeMessage() const
Return the received real-time message.
Backend::IncomingMIDIMessage incomingMessage
Incoming message that can be from retrieved using the getChannelMessage(), getSysCommonMessage(),...
void setTimeout(std::chrono::milliseconds timeout)
Set the timeout, the number of milliseconds to buffer the outgoing MIDI messages.
void sendImpl(L &lck, F add_to_buffer)
void sendChannelMessageImpl(ChannelMessage) override
Low-level function for sending a MIDI channel voice message.
void handleStall() override
Call back that should finish any MIDI messages that are in progress, and un-stall the pipe or MIDI so...
void update() override
Poll the backend (if necessary) and invoke the callbacks for any received MIDI messages,...
void sendNowImpl() override
Low-level function for sending any buffered outgoing MIDI messages.
SysCommonMessage getSysCommonMessage() const
Return the received system common message.
void sendRealTimeImpl(RealTimeMessage) override
Low-level function for sending a MIDI real-time message.
const char * getName() const override
Get the staller's name for debugging purposes.
Backend backend
Low-level BLE backend for sending and receiving MIDI over BLE packets.
void begin() override
Initialize the BLE hardware and start advertising as a MIDI over BLE peripheral.
bool isConnected() const
Returns true if a BLE central is currently connected.
void sendSysExImpl(SysExMessage) override
Low-level function for sending a system exclusive MIDI message.
BLESettings ble_settings
BLE backend configuration option.
void sendSysCommonImpl(SysCommonMessage) override
Low-level function for sending a MIDI system common message.
void setName(const char *name)
Set the BLE device name.
MIDIReadEvent read()
Try reading and parsing a single incoming MIDI message.
SysExMessage getSysExMessage() const
Return the received system exclusive message.
uint16_t getTimestamp() const
Get the BLE-MIDI timestamp of the latest MIDI message.
An abstract class for MIDI interfaces.
virtual void handleStall()=0
Call back that should finish any MIDI messages that are in progress, and un-stall the pipe or MIDI so...
static void updateIncoming(MIDIInterface_t *iface)
Read, parse and dispatch incoming MIDI messages on the given interface.
Configuration options for the low-level BLE code.
Definition BLEAPI.hpp:150