A streaming API would do nicely. Each time the current SysEx packet is about to fill up, call the SysEx handler with the partial buffer. Something like this:
Code:
static int sys_ex_length;
static char sys_ex_buffer[256];
static void onSysEx(uint8_t length, const uint8_t *data, bool complete) {
if (sys_ex_length + length < 256) {
memcpy(sys_ex_buffer + sys_ex_length, data, length);
sys_ex_length += length;
if (complete) {
sys_ex_buffer[sys_ex_length - 1] = '\0';
sys_ex_length = 0;
Serial.print("data = \""), Serial.print((const char *)(sys_ex_buffer + 1)), Serial.print("\""), Serial.println();
}
}
}
void setup() {
usbMIDI.setHandleSysEx(&OnSysEx);
}
This would let you use whatever size buffer you want. We might also want a way to configure the buffer size dynamically, when we know the max size our SysEx packets will ever be.