|
ESPHome 2026.11.0b6
|
Decoder for the BLE-MIDI packet format (Apple/MMA "Bluetooth Low Energy MIDI" specification, section 3). More...
#include <midi_parser.h>
Public Member Functions | |
| MidiParser (uint8_t *sysex_buffer, uint16_t sysex_capacity) | |
sysex_buffer reassembles SysEx messages; one longer than sysex_capacity bytes is reported incomplete. | |
| uint16_t | sysex_capacity () const |
| void | reset () |
| Drop all parser state. | |
| void | feed (const uint8_t *data, size_t length, MidiMessageHandler handler, void *ctx) |
| Feed one BLE notification payload. | |
Static Public Member Functions | |
| static uint8_t | expected_data_bytes (uint8_t status) |
| Number of data bytes that follow a status byte other than SysEx. | |
Protected Member Functions | |
| void | emit_ (MessageType type, const uint8_t *data, uint16_t length, MidiMessageHandler handler, void *ctx) |
| void | emit_current_ (MidiMessageHandler handler, void *ctx) |
| void | take_data_ (const uint8_t *byte, MidiMessageHandler handler, void *ctx) |
| void | end_sysex_ (bool complete, MidiMessageHandler handler, void *ctx) |
| void | sysex_push_ (uint8_t byte) |
Protected Attributes | |
| uint8_t *const | sysex_buffer_ |
| const uint16_t | sysex_capacity_ |
| uint16_t | sysex_length_ {0} |
| bool | sysex_active_ {false} |
| bool | sysex_overflow_ {false} |
| uint8_t | running_status_ {0} |
| uint8_t | current_message_ [3] {} |
| uint8_t | current_length_ {0} |
| uint8_t | current_expected_ {0} |
Decoder for the BLE-MIDI packet format (Apple/MMA "Bluetooth Low Energy MIDI" specification, section 3).
Packet layout: [header] [timestamp] [MIDI 0] ... ([timestamp] [MIDI n])*
A timestamp byte precedes every status byte, except where running status applies. SysEx messages may span several BLE packets and may be interrupted by real-time messages (0xF8-0xFF).
Timestamps are used for jitter reconstruction by MIDI hosts and are ignored here.
This class holds no BLE or ESPHome state so that it can be exercised in isolation.
Definition at line 74 of file midi_parser.h.
|
inline |
sysex_buffer reassembles SysEx messages; one longer than sysex_capacity bytes is reported incomplete.
Definition at line 77 of file midi_parser.h.
|
inlineprotected |
Definition at line 94 of file midi_parser.h.
|
protected |
Definition at line 77 of file midi_parser.cpp.
|
protected |
Definition at line 70 of file midi_parser.cpp.
|
static |
Number of data bytes that follow a status byte other than SysEx.
Definition at line 33 of file midi_parser.cpp.
| void esphome::ble_midi::MidiParser::feed | ( | const uint8_t * | data, |
| size_t | length, | ||
| MidiMessageHandler | handler, | ||
| void * | ctx ) |
Feed one BLE notification payload.
Undecodable bytes are reported as MessageType::UNKNOWN so the caller can log them.
Definition at line 107 of file midi_parser.cpp.
| void esphome::ble_midi::MidiParser::reset | ( | ) |
Drop all parser state.
Call on disconnect so running status and partial messages do not leak into the next session.
Definition at line 54 of file midi_parser.cpp.
|
inline |
Definition at line 80 of file midi_parser.h.
|
protected |
Definition at line 61 of file midi_parser.cpp.
|
protected |
Definition at line 91 of file midi_parser.cpp.
|
protected |
Definition at line 116 of file midi_parser.h.
|
protected |
Definition at line 115 of file midi_parser.h.
|
protected |
Definition at line 114 of file midi_parser.h.
|
protected |
Definition at line 111 of file midi_parser.h.
|
protected |
Definition at line 106 of file midi_parser.h.
|
protected |
Definition at line 103 of file midi_parser.h.
|
protected |
Definition at line 104 of file midi_parser.h.
|
protected |
Definition at line 105 of file midi_parser.h.
|
protected |
Definition at line 107 of file midi_parser.h.