-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewritten all configuration logic to use EEPROM
MachineID, MQTT server and MQTT Shelly topic now configurable via WiFiManager All persisted settings are now in SavedConfig and EEPROM FabServer and Machine class now can be configured at runtime (not initialization time) with configure methods Removed most of the secrets contents (only RFID tags remain)
- Loading branch information
Showing
13 changed files
with
422 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#ifndef SAVED_CONFIG_H_ | ||
#define SAVED_CONFIG_H_ | ||
|
||
#include <string> | ||
#include <cstdint> | ||
#include <optional> | ||
|
||
#include "MachineConfig.hpp" | ||
#include <EEPROM.h> | ||
|
||
namespace fablabbg | ||
{ | ||
|
||
struct SavedConfig | ||
{ | ||
static constexpr auto FIELD_LENGTH = 40; | ||
static constexpr auto INT_LENGTH = 5; // Must save as string for WiFiManager | ||
static constexpr auto MAGIC_NUMBER = 0x44; // Increment when changing the struct | ||
|
||
// Wifi | ||
char ssid[FIELD_LENGTH]{0}; | ||
char password[FIELD_LENGTH]{0}; | ||
|
||
// MQTT | ||
char mqtt_server[FIELD_LENGTH]{0}; | ||
char mqtt_user[FIELD_LENGTH]{0}; | ||
char mqtt_password[FIELD_LENGTH]{0}; | ||
|
||
// MQTT Switch | ||
char machine_topic[FIELD_LENGTH]{0}; | ||
|
||
char machine_id[INT_LENGTH]{0}; | ||
|
||
// Magic number to check if the EEPROM is initialized | ||
mutable uint8_t magic_number; | ||
|
||
bool SaveToEEPROM() const; | ||
std::string toString() const; | ||
|
||
static std::optional<SavedConfig> LoadFromEEPROM(); | ||
static SavedConfig DefaultConfig(); | ||
}; | ||
|
||
} // namespace fablabbg | ||
#endif // SAVED_CONFIG_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.