-
Notifications
You must be signed in to change notification settings - Fork 66
Migration from 2.* to 3.*
lathoub edited this page Feb 12, 2021
·
2 revisions
Version 3 of this library is not backward compatible with the API from version 2. This due to a change in the API for error and exception handling, the new API for exception handling provides more detailed feedback about the on hand issue.
AppleMIDI.setHandleError
is retired and replaced with AppleMIDI.setHandleException
void OnAppleMidiError(const APPLEMIDI_NAMESPACE::ssrc_t& ssrc, int32_t err)
becomes void OnAppleMidiException(const APPLEMIDI_NAMESPACE::ssrc_t& ssrc, const APPLEMIDI_NAMESPACE::Exception& e, const int32_t value )
(note the addition of the value parameter, providing more detail about the Exception e)
Here is a complete Exception handler:
...
AppleMIDI.setHandleException(OnAppleMidiException);
...
void OnAppleMidiException(const APPLEMIDI_NAMESPACE::ssrc_t& ssrc, const APPLEMIDI_NAMESPACE::Exception& e, const int32_t value ) {
switch (e)
{
case APPLEMIDI_NAMESPACE::Exception::BufferFullException:
DBG(F("*** BufferFullException"));
break;
case APPLEMIDI_NAMESPACE::Exception::ParseException:
DBG(F("*** ParseException"));
break;
case APPLEMIDI_NAMESPACE::Exception::TooManyParticipantsException:
DBG(F("*** TooManyParticipantsException"));
break;
case APPLEMIDI_NAMESPACE::Exception::UnexpectedInviteException:
DBG(F("*** UnexpectedInviteException"));
break;
case APPLEMIDI_NAMESPACE::Exception::ParticipantNotFoundException:
DBG(F("*** ParticipantNotFoundException"), value);
break;
case APPLEMIDI_NAMESPACE::Exception::ComputerNotInDirectory:
DBG(F("*** ComputerNotInDirectory"), value);
break;
case APPLEMIDI_NAMESPACE::Exception::NotAcceptingAnyone:
DBG(F("*** NotAcceptingAnyone"), value);
break;
case APPLEMIDI_NAMESPACE::Exception::ListenerTimeOutException:
DBG(F("*** ListenerTimeOutException"));
break;
case APPLEMIDI_NAMESPACE::Exception::MaxAttemptsException:
DBG(F("*** MaxAttemptsException"));
break;
case APPLEMIDI_NAMESPACE::Exception::NoResponseFromConnectionRequestException:
DBG(F("***:yyy did't respond to the connection request. Check the address and port, and any firewall or router settings. (time)"));
break;
case APPLEMIDI_NAMESPACE::Exception::SendPacketsDropped:
DBG(F("*** SendPacketsDropped"), value);
break;
case APPLEMIDI_NAMESPACE::Exception::ReceivedPacketsDropped:
DBG(F("*** ReceivedPacketsDropped"), value);
break;
}
}
More on AppleMIDI Callbacks