Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/config/Config.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#pragma once

Check warning on line 1 in include/config/Config.h

View workflow job for this annotation

GitHub Actions / C/C++ Linter

include/config/Config.h:1:1 [portability-avoid-pragma-once]

avoid 'pragma once' directive; use include guards instead

#include "config/BackendConfig.h"
#include "config/CaptivePortalConfig.h"
Expand All @@ -20,16 +20,16 @@
void Init();

/* GetAsJSON and SaveFromJSON are used for Reading/Writing the config file in its human-readable form. */
std::string GetAsJSON(bool withSensitiveData);

Check warning on line 23 in include/config/Config.h

View workflow job for this annotation

GitHub Actions / C/C++ Linter

include/config/Config.h:23:15 [modernize-use-trailing-return-type]

use a trailing return type for this function
bool SaveFromJSON(std::string_view json);

Check warning on line 24 in include/config/Config.h

View workflow job for this annotation

GitHub Actions / C/C++ Linter

include/config/Config.h:24:8 [modernize-use-trailing-return-type]

use a trailing return type for this function

/* GetAsFlatBuffer and SaveFromFlatBuffer are used for Reading/Writing the config file in its binary form. */
[[nodiscard]] flatbuffers::Offset<Serialization::Configuration::HubConfig> GetAsFlatBuffer(flatbuffers::FlatBufferBuilder& builder, bool withSensitiveData);

Check warning on line 27 in include/config/Config.h

View workflow job for this annotation

GitHub Actions / C/C++ Linter

include/config/Config.h:27:78 [modernize-use-trailing-return-type]

use a trailing return type for this function
bool SaveFromFlatBuffer(const Serialization::Configuration::HubConfig* config);

Check warning on line 28 in include/config/Config.h

View workflow job for this annotation

GitHub Actions / C/C++ Linter

include/config/Config.h:28:8 [modernize-use-trailing-return-type]

use a trailing return type for this function

/* GetRaw and SetRaw are used for Reading/Writing the config file in its binary form. */
bool GetRaw(TinyVec<uint8_t>& buffer);

Check warning on line 31 in include/config/Config.h

View workflow job for this annotation

GitHub Actions / C/C++ Linter

include/config/Config.h:31:8 [modernize-use-trailing-return-type]

use a trailing return type for this function
bool SetRaw(const uint8_t* buffer, std::size_t size);

Check warning on line 32 in include/config/Config.h

View workflow job for this annotation

GitHub Actions / C/C++ Linter

include/config/Config.h:32:8 [modernize-use-trailing-return-type]

use a trailing return type for this function

/**
* @brief Resets the config file to the factory default values.
Expand All @@ -38,9 +38,9 @@
*/
void FactoryReset();

bool GetRFConfig(RFConfig& out);

Check warning on line 41 in include/config/Config.h

View workflow job for this annotation

GitHub Actions / C/C++ Linter

include/config/Config.h:41:8 [modernize-use-trailing-return-type]

use a trailing return type for this function
bool GetWiFiConfig(WiFiConfig& out);

Check warning on line 42 in include/config/Config.h

View workflow job for this annotation

GitHub Actions / C/C++ Linter

include/config/Config.h:42:8 [modernize-use-trailing-return-type]

use a trailing return type for this function
bool GetCaptivePortalConfig(CaptivePortalConfig& out);

Check warning on line 43 in include/config/Config.h

View workflow job for this annotation

GitHub Actions / C/C++ Linter

include/config/Config.h:43:8 [modernize-use-trailing-return-type]

use a trailing return type for this function
bool GetBackendConfig(BackendConfig& out);
bool GetSerialInputConfig(SerialInputConfig& out);
bool GetOtaUpdateConfig(OtaUpdateConfig& out);
Expand All @@ -63,6 +63,7 @@
bool GetRFConfigKeepAliveEnabled(bool& out);
bool SetRFConfigKeepAliveEnabled(bool enabled);

bool AnyWiFiCredentials();
bool AnyWiFiCredentials(std::function<bool(const Config::WiFiCredentials&)> predicate);
uint8_t AddWiFiCredentials(std::string_view ssid, std::string_view password, wifi_auth_mode_t authMode = WIFI_AUTH_MAX);
bool TryGetWiFiCredentialsByID(uint8_t id, WiFiCredentials& out);
Expand Down
7 changes: 7 additions & 0 deletions src/config/Config.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#include <freertos/FreeRTOS.h>

#include "config/Config.h"
Expand Down Expand Up @@ -445,6 +445,13 @@
return _trySaveConfig();
}

bool Config::AnyWiFiCredentials()
{
CONFIG_LOCK_READ(false);

return _configData.wifi.credentialsList.size() > 0;
}

bool Config::AnyWiFiCredentials(std::function<bool(const Config::WiFiCredentials&)> predicate)
{
CONFIG_LOCK_READ(false);
Expand Down
12 changes: 12 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#include <freertos/FreeRTOS.h>

const char* const TAG = "main";
Expand All @@ -24,6 +24,18 @@
// Internal setup function, returns true if setup succeeded, false otherwise.
bool trySetup()
{
// Try to initialize TCP/IP mac address
uint8_t mac[8];
if (esp_efuse_mac_get_default(mac) == ESP_OK) {
esp_base_mac_addr_set(mac);
}

// Try to initialize global TCP/IP stack
if (esp_netif_init() != ERR_OK) {
OS_LOGE(TAG, "Failed to initialize TCP/IP stack!");
return false;
}

if (!OpenShock::VisualStateManager::Init()) {
OS_LOGE(TAG, "Unable to initialize VisualStateManager");
return false;
Expand Down
Loading
Loading