-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Store more string variables but receive back only the last #17
Comments
I think you may be a little confused how the library works and in general how file system works on the ESP's. You are overriding all the contents in the file when you save back to if (fileSystem.saveToFile("/configuration.txt", Station1)) to this line if (fileSystem.saveToFile("/configuration.txt", Station2)) which is why you are only seeing the string There are a couple of ways you can fix this, depending on your code architecture. If you really need the string to be dynamic as you may be changing them from a web interface and you would like to persist them through reboots, then simply have 2 if (fileSystem.saveToFile("/configuration1.txt", Station1)) {
Serial.println("Successfully wrote data to file");
}
if (fileSystem.saveToFile("/configuration2.txt", Station2)) {
Serial.println("Successfully wrote data to file");
} If these string remain the same regardless of what you do in your application, then I would suggest not using this library at all and just use the flash string helpers built into arduino (note this is untested code I wrote from the top of my head): String Station1 = F("http://retro.dancewave.online/retrodance.mp3");
String Station2 = F("http://live.topfm.hu:8000/radio.mp3"); |
Sure, im not a advanced developer, just a hobby code writer. I just think this libraray can handle more from same type variable and if im define more string will store as station 1 and station 2 ,,variable" in configuration.txt. This can be more perfect against the standard SPIFFS. My wifi radio project currently using the <Preferences.h> to store in struct the station / urls what working well, but because this was designed not store large variables fail using more than 10 channels. With SPIFFS was for me realy clear as hobby code writer, if i want handle 20 stations/url i need make 20 different txt and write/rewrite these, what maybe not a nice solution My idea was using one big single configuration.txt with saved last played station, last volume settings: http://retro.dancewave.online/retrodance.mp3 For me was clear currently the second step rewrite the txt, i just think thats was worked not ok, but if im good understand, with this library i need do same what i dont want, making 20 txt for the 20 stations if i want less pain writing code, the libraray itself not working so what im thinking about first time. The only one help, i can use all station as variable and so more easier as handle \n lines: With the standard SPIFFS im counting (if i have single configuration.txt) the \n lines to handle the 20 line configuration.txt and read all line in a ,,buffer". But for change lookslike i dont have another way if i dont want create 20, 30 files, rebuild by any station url change the single configuration.txt: maybe this is not part of this library section/bug, but im share the test code what im using currently:
Thank you for the fast answer and sorry because i dont have other way in github ask question than added as bug. Maybe i will use 20 txt as solution, more easier against handle one file with the 20+ values. You can close this, because this is not bug, this is how working the library itself. |
This lib will be a great choose to my wifi radio project to store/change url-s, but i have trouble to store more String. I have altered example so:
I wait to receive both Station 1 and Station2, but just receive only the second one:
19:43:16.441 -> Station1 url:http://live.topfm.hu:8000/radio.mp3
19:43:17.430 -> Station2 url:http://live.topfm.hu:8000/radio.mp3
19:43:18.423 -> Station1 url:http://live.topfm.hu:8000/radio.mp3
19:43:19.428 -> Station2 url:http://live.topfm.hu:8000/radio.mp3
Library allows store only one String variable?
The text was updated successfully, but these errors were encountered: