22
22
*/
23
23
/* ***************************************************************************/
24
24
Wippersnapper_ESP32_nvs::Wippersnapper_ESP32_nvs () {
25
- // init. nvs, read-only
26
- nvs.begin (" wsNamespace" , false );
25
+ // Attempt to initialize NVS partition
26
+ if (!nvs.begin (" wsNamespace" , false )) {
27
+ WS.setStatusLEDColor (RED);
28
+ while (1 )
29
+ ;
30
+ }
27
31
}
28
32
29
33
/* ***************************************************************************/
@@ -35,39 +39,31 @@ Wippersnapper_ESP32_nvs::~Wippersnapper_ESP32_nvs() { nvs.end(); }
35
39
36
40
/* ***************************************************************************/
37
41
/* !
38
- @brief Reads and validates credentials from nvs' "wsNamespace"
42
+ @brief Reads, validates, and sets credentials from nvs' "wsNamespace"
39
43
namespace.
40
- @returns True if credentials were found, False otherwise.
41
44
*/
42
45
/* ***************************************************************************/
43
- bool Wippersnapper_ESP32_nvs::validateNVSConfig () {
46
+ void Wippersnapper_ESP32_nvs::parseSecrets () {
47
+ // parsey
44
48
_ssid = nvs.getString (" wsNetSSID" , " " );
45
49
_ssidPass = nvs.getString (" wsNetPass" , " " );
46
50
_aioUser = nvs.getString (" wsAIOUser" , " " );
47
51
_aioPass = nvs.getString (" wsAIOKey" , " " );
48
52
_aioURL = nvs.getString (" wsAIOURL" , " " );
49
53
50
- // validate config properly set in partition
54
+ // Validate configuration was set within the partition
51
55
if (_ssid == " " || _ssidPass == " " || _aioUser == " " || _aioPass == " " ) {
52
- // TODO: Possibly LED blink/some external error handling around this
53
- return false ;
56
+ WS.setStatusLEDColor (RED);
57
+ while (1 )
58
+ ;
54
59
}
55
- return true ;
56
- }
57
60
58
- /* ***************************************************************************/
59
- /* !
60
- @brief Sets Wippersnapper configuration using nvs configuration
61
- @returns True if credentials set successfully, False otherwise.
62
- */
63
- /* ***************************************************************************/
64
- bool Wippersnapper_ESP32_nvs::setNVSConfig () {
61
+ // Set global configuration strings
65
62
WS._network_ssid = _ssid.c_str ();
66
63
WS._network_pass = _ssidPass.c_str ();
67
64
WS._username = _aioUser.c_str ();
68
65
WS._key = _aioPass.c_str ();
69
66
WS._mqttBrokerURL = _aioURL.c_str ();
70
- return true ;
71
67
}
72
68
73
69
#endif // ARDUINO_ARCH_ESP32
0 commit comments