Skip to content

Commit

Permalink
fix: change to IId interface to replace getName()
Browse files Browse the repository at this point in the history
  • Loading branch information
ZanzyTHEbar committed Apr 1, 2024
1 parent 5bea095 commit a7e2025
Show file tree
Hide file tree
Showing 14 changed files with 27 additions and 28 deletions.
2 changes: 1 addition & 1 deletion NetworkManager/examples/captivePortal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ void setup() {
*/
updateWrapper<WiFiState_e>(
networkManager.configHandler->config.getState(
networkManager.wifiHandler->getName()),
networkManager.wifiHandler->getID()),
[](WiFiState_e state) {
switch (state) {
//! intentional fallthrough case
Expand Down
2 changes: 1 addition & 1 deletion NetworkManager/examples/class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ void setup() {
*/
updateWrapper<WiFiState_e>(
networkManager.configHandler->config.getState(
networkManager.wifiHandler->getName()),
networkManager.wifiHandler->getID()),
[](WiFiState_e state) {
switch (state) {
//! intentional fallthrough case
Expand Down
2 changes: 1 addition & 1 deletion NetworkManager/examples/customConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ void setup() {
*/
updateWrapper<WiFiState_e>(
networkManager.configHandler->config.getState(
networkManager.wifiHandler->getName()),
networkManager.wifiHandler->getID()),
[](WiFiState_e state) {
switch (state) {
//! intentional fallthrough case
Expand Down
2 changes: 1 addition & 1 deletion NetworkManager/examples/customHTML.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void setup() {
*/
updateWrapper<WiFiState_e>(
networkManager.configHandler->config.getState(
networkManager.wifiHandler->getName()),
networkManager.wifiHandler->getID()),
[](WiFiState_e state) {
switch (state) {
//! intentional fallthrough case
Expand Down
2 changes: 1 addition & 1 deletion NetworkManager/examples/customHandlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ void setup() {
*/
updateWrapper<WiFiState_e>(
networkManager.configHandler->config.getState(
networkManager.wifiHandler->getName()),
networkManager.wifiHandler->getID()),
[](WiFiState_e state) {
switch (state) {
//! intentional fallthrough case
Expand Down
2 changes: 1 addition & 1 deletion NetworkManager/examples/functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ void setup() {
*/
updateWrapper<WiFiState_e>(
networkManager.configHandler->config.getState(
networkManager.wifiHandler->getName()),
networkManager.wifiHandler->getID()),
[](WiFiState_e state) {
switch (state) {
//! intentional fallthrough case
Expand Down
2 changes: 1 addition & 1 deletion NetworkManager/examples/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ void setup() {
*/
updateWrapper<WiFiState_e>(
networkManager.configHandler->config.getState(
networkManager.wifiHandler->getName()),
networkManager.wifiHandler->getID()),
[](WiFiState_e state) {
switch (state) {
//! intentional fallthrough case
Expand Down
2 changes: 1 addition & 1 deletion NetworkManager/include/data/config/config_handler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class ConfigHandler : public Helpers::IObserver<StateVariant> {
virtual ~ConfigHandler();
virtual void begin();
virtual void update(const StateVariant& event) override;
std::string getName() const override {
std::string getID() const override {
return "ConfigHandler";
}
ProjectConfig config;
Expand Down
2 changes: 1 addition & 1 deletion NetworkManager/include/network/mdns/mdns_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class MDNSHandler : public Helpers::IObserver<StateVariant> {
bool begin();
/* Overrides */
void update(const StateVariant& event) override;
std::string getName() const override {
std::string getID() const override {
return this->service_name;
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class WiFiHandler : public Helpers::IObserver<StateVariant> {
ProjectConfig& configManager;
Project_Config::WiFiTxPower_t& txpower;

std::string getName() const override {
std::string getID() const override {
return "WiFiHandler";
}

Expand Down
6 changes: 3 additions & 3 deletions NetworkManager/src/EasyNetworkManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ EasyNetworkManager::EasyNetworkManager(
EasyNetworkManager::~EasyNetworkManager() {}

void EasyNetworkManager::begin() {
configHandler->config.attach(configHandler->getName(), configHandler);
configHandler->config.attach(wifiHandler->getName(), wifiHandler);
configHandler->config.attach(configHandler->getID(), configHandler);
configHandler->config.attach(wifiHandler->getID(), wifiHandler);
if (mdnsHandler != nullptr)
configHandler->config.attach(mdnsHandler->getName(), mdnsHandler);
configHandler->config.attach(mdnsHandler->getID(), mdnsHandler);

configHandler->begin();
wifiHandler->begin();
Expand Down
7 changes: 3 additions & 4 deletions NetworkManager/src/network/mdns/mdns_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ bool MDNSHandler::begin() {
auto mdnsConfig = configManager.getMDNSConfig();
log_d("%s", mdnsConfig.hostname.c_str());
if (!MDNS.begin(mdnsConfig.hostname.c_str())) {
this->configManager.setState(this->getName(),
this->configManager.setState(this->getID(),
MDNSState_e::MDNSState_Error);
log_e("Error initializing MDNS");
return false;
}

this->configManager.setState(this->getName(),
this->configManager.setState(this->getID(),
MDNSState_e::MDNSState_Starting);
MDNS.addService(service_name.c_str(), proto.c_str(), atoi(value.c_str()));
MDNS.addServiceTxt(
Expand All @@ -31,8 +31,7 @@ bool MDNSHandler::begin() {
log_d("%s %s %s %s %s", service_name.c_str(), proto.c_str(),
service_text.c_str(), key.c_str(), value.c_str());
log_i("MDNS initialized!");
this->configManager.setState(this->getName(),
MDNSState_e::MDNSState_Started);
this->configManager.setState(this->getID(), MDNSState_e::MDNSState_Started);
return true;
}

Expand Down
18 changes: 9 additions & 9 deletions NetworkManager/src/network/wifihandler/wifi_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ WiFiHandler::~WiFiHandler() {}

void WiFiHandler::begin() {
if (this->_enable_adhoc) {
this->configManager.setState(this->getName(),
this->configManager.setState(this->getID(),
WiFiState_e::WiFiState_ADHOC);
return;
}
Expand All @@ -38,7 +38,7 @@ void WiFiHandler::begin() {
Serial.print(
"Could not connect to the hardcoded "
"network, setting up ADHOC network \n\r");
this->configManager.setState(this->getName(),
this->configManager.setState(this->getID(),
WiFiState_e::WiFiState_ADHOC);
return;
}
Expand Down Expand Up @@ -68,7 +68,7 @@ void WiFiHandler::begin() {
log_e(
"Could not connect to the hardcoded network, "
"setting up adhoc. \n\r");
this->configManager.setState(this->getName(), WiFiState_e::WiFiState_ADHOC);
this->configManager.setState(this->getID(), WiFiState_e::WiFiState_ADHOC);
}

void WiFiHandler::adhoc(const std::string& ssid, uint8_t channel,
Expand Down Expand Up @@ -138,15 +138,15 @@ bool WiFiHandler::iniSTA(const std::string& ssid, const std::string& password,
delay(1000);
log_v(".");
if ((currentMillis - startingMillis) >= connectionTimeout) {
this->configManager.setState(this->getName(),
this->configManager.setState(this->getID(),
WiFiState_e::WiFiState_Error);
log_e("Connection to: %s TIMEOUT \n\r", ssid.c_str());
delay(8000);
return false;
}
}

this->configManager.setState(this->getName(),
this->configManager.setState(this->getID(),
WiFiState_e::WiFiState_Connected);
Serial.printf("Successfully connected to %s \n\r", ssid.c_str());
// Serial.printf("Setting TX power to: %d \n\r", (uint8_t)power);
Expand Down Expand Up @@ -197,19 +197,19 @@ void WiFiHandler::update(const StateVariant& event) {
void WiFiHandler::onWiFiEvent(WiFiEvent_t event) {
switch (event) {
/* case SYSTEM_EVENT_WIFI_READY:
this->configManager.setState(this->getName(),
this->configManager.setState(this->getID(),
WiFiState_e::WiFiState_Idle);
break;
case SYSTEM_EVENT_SCAN_DONE:
this->configManager.setState(this->getName(),
this->configManager.setState(this->getID(),
WiFiState_e::WiFiState_Scanning_Done);
break; */
case SYSTEM_EVENT_STA_DISCONNECTED:
this->configManager.setState(this->getName(),
this->configManager.setState(this->getID(),
WiFiState_e::WiFiState_Disconnected);
break;
case SYSTEM_EVENT_STA_GOT_IP:
this->configManager.setState(this->getName(),
this->configManager.setState(this->getID(),
WiFiState_e::WiFiState_Connected);
break;
}
Expand Down
4 changes: 2 additions & 2 deletions NetworkManager/wokwi.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[wokwi]
version = 1
elf = ".pio/build/esp32s3_debug/EasyNetworkManager-v5.3.2-esp32s3_debug-c08ee58-main.elf"
firmware = ".pio/build/esp32s3_debug/EasyNetworkManager-v5.3.2-esp32s3_debug-c08ee58-main.bin"
elf = ".pio/build/esp32s3_debug/EasyNetworkManager-v5.3.4-esp32s3_debug-5bea095-main.elf"
firmware = ".pio/build/esp32s3_debug/EasyNetworkManager-v5.3.4-esp32s3_debug-5bea095-main.bin"
[[net.forward]]
from = "localhost:8180"
to = "target:80"

0 comments on commit a7e2025

Please sign in to comment.