I've been trying to use a [Serial MP3 Player A](ioxhop.info MP3 Player A v1.1 Manual.pdf) for a project.
The manufacturer's library uses Software Serial, while I wish to use the Hardware Serial with an ESP32 board. So I was trying to adapt the library.
Never did anything like this before, so I guess I'm making some silly mistakes. but this is what I did and this is what I get...
I generally included HardwareSerial.h instead of SoftwareSerial.h, and in the original library I changed from:
In the RedMP3.h -
I now get an error: no matching function for call to 'HardwareSerial::HardwareSerial(uint8_t&, uint8_t&)'
I guess I'm getting the RedMP3.cpp code wrong cause I don't really understand the syntax. So would be happy for some advice.
The best thing would be to modify the library so it will work with any object of the Stream class (both HardwareSerial and SoftwareSerial inherit from Stream). So, you’d change the private variable ‘myMP3’ to be a Reference to a Stream object. This needs to be initialized in an initializer list for the MP3 class constructor. But, don’t include calling begin() on the reference within that constructor.
Your main .ino code should pass a Stream object reference to the MP3 constructor. In the setup() function, first call begin() on the Stream object (if required, not all classes that inherit from Stream include a begin() function) and then begin() on the MP3 object.
I was wondering what would be the "right" way to do it so it's generalized, and you sent me off to read about Stream which was really interesting and looks like the right way to go, but I feel this is next step. I tried doing something and there are too many things here I don't understand yet...
Thought I'll start with understanding the syntax of classes any get it to work with HW Serial before I get into more things I know nothing about (I have an idea, but still not sure I completely understand what you mean by "Reference to a Stream", "initializer", "constructor", or "reference" :)).