String data = "";
do {
sendCMD("MF", NULL);
data = readAck(0); // assuming this returns what you want
} while (! data.startsWith("MF")); // https://www.arduino.cc/reference/en/language/variables/data-types/string/functions/startswith/
Note this might be an infinite loop and you can get stuck there
Thank you very much... It wont get stuck because sendCMD ("MF", NULL ); demands awser with MF at the start, but sometimes some other message gets captured idk why. Ussualy after 3 -5 attempts message with MF gets captured.
the spaces you see is likely due to data encoding (unicode / UTF16, ....) in the device. would be interesting to see exactly what's in memory by printing each byte of the filename
It there like a function for that?
I searched and didnt find anything useful.
I tryed with filename.Replace(" ", "");
But it doesn't work for some reason, if I declare string on my own like String filename = "A B C D E F G " and comment out the code for declaring filename out of data it works....
Also do while !data.startsWith("MF") doesn't work, but I solved this problem with turning auto query on playback start on the board ...
@0212995500229 Hey, it's you again! So you decided to stick with weird filenames instead of pure ASCII, but your MP3 board doesn't support them. This doesn't surprise me, and I think that the board (or it's firmware, rather) is of dubious quality: how can an MP3 decoder not support ID3 tags in our day and age?
However, since Unicode is not working, you may try another encoding for your filenames, such as Latin-1. This one will fit in 8 bits (ASCII only needs 7), so you are going to have fixed width. You can always convert from Latin-1 to UTF-8 downstream, if you need to. What language are your filenames written in?
Another solution — or a hack, really — would be to pre-generate a lookup table with filenames and titles (you do that programmatically on your computer, of course). So, for example, the file que_tal_los_ninos.mp3 corresponds to ¿Qué tal los niños? Or, you could make the file que_tal_los_ninos.45.mp3 (or even just 45.mp3, but you lose human readability) if the song is member 45 of an array of titles and all you have to do is parse that number. You get the idea.
Hy, yes, it was hard to find usb mp3 player board that forwards the information about file via uart, this is the best I was abled to get.
My solution to get names to display is to use normal characters, but _ instead of spaces...
Now it works, I will correct _ to be shown as space in my lcd code, but I need to remove whitespaces and .mp3
Will do some research on how to convert to latin-1.
Pre-generating is not the thing I would do, will solve the problem somehow....
so you don't have spaces but every other byte that is 0x00, that's why replace does not work.
But the good news is that the LSB in UTF16 does match the ASCII byte for ASCII so if you get rid of the extra 0x00 then you get back to the ASCII (or UTF-8) representation.
➜ iterate over each byte of the cString buffer representation of your String and get rid of the 0x00 (you'll need to keep the last one)
(it would be interesting to actually print each byte's value to see if it is really UTF-16)
side note, the doc you show in translated Chinese has a few bugs but would show UTF-16 for the file name in big endian
Copying it to a c_string should cast each letter of the string to char, which should get rid of the extra byte.
What's your output now if you Serial.println(Playing);
?
Edit.
Nevermind I'm wrong.