Control Surface main
MIDI Control Surface library for Arduino
Loading...
Searching...
No Matches
PollingBLEMIDISender.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <Settings/NamespaceSettings.hpp>
4
5#include <chrono>
6
7#include "BLEAPI.hpp"
9
11
13template <class Derived>
15 public:
20
22 void begin();
23
25 struct ProtectedBuilder;
34
37
40 void updateMTU(uint16_t mtu);
42 uint16_t getMinMTU() const { return min_mtu; }
44 void forceMinMTU(uint16_t mtu);
45
48 void setTimeout(std::chrono::milliseconds timeout);
49
50 private:
52 void sendData(BLEDataView) = delete; // should be implemented by subclass
53
54 private:
59 unsigned long timeout {10};
61 unsigned long packet_start_time {0};
62
63 private:
65 uint16_t min_mtu {23};
69 uint16_t force_min_mtu {515};
70
71 public:
75};
76
78
79#include "PollingBLEMIDISender.ipp"
Type definitions and callback interfaces for communication between the low-level BLE stacks and highe...
#define END_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
Class for building MIDI over Bluetooth Low Energy packets.
Class that buffers MIDI BLE packets.
PollingBLEMIDISender()=default
BLEMIDIPacketBuilder packet
View of the data to send.
void sendData(BLEDataView)=delete
Actually perform the BLE notification with the given data.
uint16_t getMinMTU() const
Get the minimum MTU of all connected clients.
void setTimeout(std::chrono::milliseconds timeout)
Set the timeout, the number of milliseconds to buffer the outgoing MIDI messages.
void forceMinMTU(uint16_t mtu)
Force the MTU to an artificially small value (used for testing).
unsigned long timeout
Timeout before the sender thread sends a packet.
PollingBLEMIDISender(const PollingBLEMIDISender &)=delete
unsigned long packet_start_time
Time point when the packet was started.
uint16_t min_mtu
The minimum MTU of all connected clients.
ProtectedBuilder acquirePacket()
Acquire exclusive access to the buffer.
PollingBLEMIDISender & operator=(const PollingBLEMIDISender &)=delete
void begin()
Initialize.
void releasePacketAndNotify(ProtectedBuilder &lck)
Release exclusive access to the buffer and notify the sender thread that data is available.
void updateMTU(uint16_t mtu)
Set the maximum transmission unit of the Bluetooth link.
uint16_t force_min_mtu
Override the minimum MTU (0 means don't override, nonzero overrides if it's smaller than the minimum ...
void sendNow(ProtectedBuilder &lck)
Sends the data immediately without waiting for the timeout.
Non-owning, std::span-style read-only view of BLE data.
Definition BLEAPI.hpp:42