I have a project that uses an MQTT service, and I'm wondering how to best store the configuration settings (server, user, password, port) for the service as right now they are just hard-coded into some constants.
I saw that EEPROM can be used for this but I'm not sure it is the best way. I went to look at the code for WifiManager to see how it accomplishes this task for the SSID and password since it works so well and it removed its EEPROM dependency back in 2015: https://github.com/tzapu/WiFiManager/commit/659df9cb277c5f93946d9d8795e39a5ae5863ab1
I can't figure out how those settings are persisted.
If EEPROM is the best way for storing something like this, I'd like to write my values without overwriting/corrupting existing values, is that possible? How can I set the initial values of the EEPROM to the constants that I need?
Edit: well after digging into the esp8266/Arduino repository I found that the WiFi.SSID()
and WiFi.psk()
settings come from wifi_station_get_config
and stored with wifi_station_set_config
although I haven't found how those work so I think EEPROM might be the way to go here, I just need a bit of guidance and clarification on the right way to use it.