-
-
Notifications
You must be signed in to change notification settings - Fork 33
Notification Method
When you construct the DFMiniMp3 instance in your sketch, you must provide a class that will be called when notifications happen that you may want to respond to. The example sketches provide simple implementations that you can build from.
This class you provide can be named anything that doesn't conflict with any other name in your sketch and included libraries. The name used below and in the example sketches are just a suggestion.
All members must be static methods as there is no instance of this class created.
If you get warnings or errors that an argument is not used in your implementation, you can use the [[maybe_unused]]
attribute to mark it as possibly unused like this.
static void OnError([[maybe_unused]] DfMp3& mp3, uint16_t errorCode)
This will be called if an error occurred.
Note: Most communications will be retried three times before falling through to call this. So if you get this notification, there is a significant issue that needs to be addressed. Often the device is not wired correctly. If your device mostly works then the wiring needs to be improved. It is also possible but rare, that the specific call you are making is not supported by your chip. If this is the case the error you will see is DfMp3_Error_RxTimeout
.
mp3 - The DfMp3 object instance the notification is being triggered from.
errorCode - The code returned will be one of the following.
DfMp3_Error_Busy = 1 - (see chip documentation) Usually the media was not found.
DfMp3_Error_Sleeping = 2 - (see chip documentation) The chip is in sleep mode.
DfMp3_Error_SerialWrongStack = 3 - (see chip documentation) The last command or request was not received correctly. Check wiring and GND connections.
DfMp3_Error_CheckSumNotMatch = 4 - (see chip documentation) Communications error on the hardware level. Check wiring and GND connections.
DfMp3_Error_FileIndexOut = 5 - (see chip documentation) File index out of bounds.
DfMp3_Error_FileMismatch = 6 - (see chip documentation) Can not find file.
DfMp3_Error_Advertise = 7 - (see chip documentation) In advertisement.
DfMp3_Error_SdReadFail = 8 - (see chip documentation) SD card failed
DfMp3_Error_FlashReadFail = 9 - (see chip documentation) Flash mem failed
DfMp3_Error_EnteredSleep = 10 - (see chip documentation) entered sleep
DfMp3_Error_RxTimeout - An expected response from the device timed out while waiting. Check wiring.
DfMp3_Error_PacketSize - The packet received from the device is the incorrect size.
DfMp3_Error_PacketHeader - The packet received from the device had an incorrect header.
DfMp3_Error_PacketChecksum - The packet received from the device had an incorrect checksum.
DfMp3_Error_General - Inconclusive problem happened.
A track has finished playing. There are cases where this will get called more than once for the same track. If you are using a repeating mode or random play, you will receive only one between the tracks and a double when it stops. If you play a single track, you should get called twice, one for the finish of the track, and another for the finish of the command. This is a nuance of the chip.
mp3 - The DfMp3 object instance the notification is being triggered from.
source - the source media the track was playing from. The value will be one of the following
DfMp3_PlaySources_Usb -
DfMp3_PlaySources_Sd -
DfMp3_PlaySources_Pc -
DfMp3_PlaySources_Flash -
track - The track number of the track that finished.
The source media is online and ready for use.
mp3 - The DfMp3 object instance the notification is being triggered from.
source - The value is a bit field with one or more of the following bits set
DfMp3_PlaySources_Usb -
DfMp3_PlaySources_Sd -
DfMp3_PlaySources_Pc -
DfMp3_PlaySources_Flash -
The source media was inserted.
mp3 - The DfMp3 object instance the notification is being triggered from.
source - The value is a bit field with one or more of the following bits set
DfMp3_PlaySources_Usb -
DfMp3_PlaySources_Sd -
DfMp3_PlaySources_Pc -
DfMp3_PlaySources_Flash -
The source media was removed.
mp3 - The DfMp3 object instance the notification is being triggered from.
source - The value is a bit field with one or more of the following bits set
DfMp3_PlaySources_Usb -
DfMp3_PlaySources_Sd -
DfMp3_PlaySources_Pc -
DfMp3_PlaySources_Flash -