mirror of
https://github.com/MrUnknownDE/OpenIris-ESPIDF.git
synced 2026-04-19 06:23:44 +02:00
cleanup project config from unused observer code
This commit is contained in:
@@ -44,8 +44,7 @@ CommandResult updateCameraCommand::execute(std::string_view jsonPayload)
|
||||
updatedConfig.framesize.has_value() ? updatedConfig.framesize.value() : oldConfig.framesize,
|
||||
updatedConfig.href.has_value() ? updatedConfig.href.value() : oldConfig.href,
|
||||
updatedConfig.quality.has_value() ? updatedConfig.quality.value() : oldConfig.quality,
|
||||
updatedConfig.brightness.has_value() ? updatedConfig.brightness.value() : oldConfig.brightness,
|
||||
true);
|
||||
updatedConfig.brightness.has_value() ? updatedConfig.brightness.value() : oldConfig.brightness);
|
||||
|
||||
return CommandResult::getSuccessResult("Config updated");
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ CommandResult setMDNSCommand::execute(std::string_view jsonPayload)
|
||||
if (!payload.has_value())
|
||||
return CommandResult::getErrorResult("Invalid payload");
|
||||
|
||||
projectConfig->setMDNSConfig(payload.value().hostname, true);
|
||||
projectConfig->setMDNSConfig(payload.value().hostname);
|
||||
|
||||
return CommandResult::getSuccessResult("Config updated");
|
||||
}
|
||||
|
||||
@@ -60,8 +60,7 @@ CommandResult setWiFiCommand::execute(std::string_view jsonPayload)
|
||||
wifiConfig.ssid,
|
||||
wifiConfig.password,
|
||||
wifiConfig.channel,
|
||||
wifiConfig.power,
|
||||
true);
|
||||
wifiConfig.power);
|
||||
|
||||
return CommandResult::getSuccessResult("Config updated");
|
||||
}
|
||||
@@ -93,7 +92,7 @@ CommandResult deleteWifiCommand::execute(std::string_view jsonPayload)
|
||||
if (!payload.has_value())
|
||||
return CommandResult::getErrorResult("Invalid payload");
|
||||
|
||||
projectConfig->deleteWifiConfig(payload.value().networkName, false);
|
||||
projectConfig->deleteWifiConfig(payload.value().networkName);
|
||||
return CommandResult::getSuccessResult("Config updated");
|
||||
}
|
||||
|
||||
@@ -164,8 +163,7 @@ CommandResult updateWifiCommand::execute(std::string_view jsonPayload)
|
||||
updatedConfig.ssid.has_value() ? updatedConfig.ssid.value() : networkToUpdate->ssid,
|
||||
updatedConfig.password.has_value() ? updatedConfig.password.value() : networkToUpdate->password,
|
||||
updatedConfig.channel.has_value() ? updatedConfig.channel.value() : networkToUpdate->channel,
|
||||
updatedConfig.power.has_value() ? updatedConfig.power.value() : networkToUpdate->power,
|
||||
false);
|
||||
updatedConfig.power.has_value() ? updatedConfig.power.value() : networkToUpdate->power);
|
||||
|
||||
return CommandResult::getSuccessResult("Config updated");
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
#include "esp_log.h"
|
||||
#include "mdns.h"
|
||||
|
||||
// TODO add observer pattern here
|
||||
class MDNSManager
|
||||
{
|
||||
private:
|
||||
|
||||
@@ -221,8 +221,6 @@ void ProjectConfig::load()
|
||||
this->config.camera.brightness = getInt("brightness", 2);
|
||||
|
||||
this->_already_loaded = true;
|
||||
// TODO add support for what's the pattern? Eh, the pattern
|
||||
// this->notifyAll(ConfigState_e::configLoaded);
|
||||
}
|
||||
//**********************************************************************************************************************
|
||||
//*
|
||||
@@ -231,36 +229,25 @@ void ProjectConfig::load()
|
||||
//**********************************************************************************************************************
|
||||
void ProjectConfig::setDeviceConfig(const std::string &OTALogin,
|
||||
const std::string &OTAPassword,
|
||||
int OTAPort,
|
||||
bool shouldNotify)
|
||||
int OTAPort)
|
||||
{
|
||||
ESP_LOGD(CONFIGURATION_TAG, "Updating device config");
|
||||
this->config.device.OTALogin.assign(OTALogin);
|
||||
this->config.device.OTAPassword.assign(OTAPassword);
|
||||
this->config.device.OTAPort = OTAPort;
|
||||
|
||||
// TODO turn this on
|
||||
// if (shouldNotify)
|
||||
// this->notifyAll(ConfigState_e::deviceConfigUpdated);
|
||||
}
|
||||
|
||||
void ProjectConfig::setMDNSConfig(const std::string &hostname,
|
||||
bool shouldNotify)
|
||||
void ProjectConfig::setMDNSConfig(const std::string &hostname)
|
||||
{
|
||||
ESP_LOGD(CONFIGURATION_TAG, "Updating MDNS config");
|
||||
this->config.mdns.hostname.assign(hostname);
|
||||
|
||||
// TODO turn this on
|
||||
// if (shouldNotify)
|
||||
// this->notifyAll(ConfigState_e::mdnsConfigUpdated);
|
||||
}
|
||||
|
||||
void ProjectConfig::setCameraConfig(uint8_t vflip,
|
||||
uint8_t framesize,
|
||||
uint8_t href,
|
||||
uint8_t quality,
|
||||
uint8_t brightness,
|
||||
bool shouldNotify)
|
||||
uint8_t brightness)
|
||||
{
|
||||
ESP_LOGD(CONFIGURATION_TAG, "Updating camera config");
|
||||
this->config.camera.vflip = vflip;
|
||||
@@ -270,20 +257,17 @@ void ProjectConfig::setCameraConfig(uint8_t vflip,
|
||||
this->config.camera.brightness = brightness;
|
||||
|
||||
ESP_LOGD(CONFIGURATION_TAG, "Updating Camera config");
|
||||
// TODO turn this on
|
||||
// if (shouldNotify)
|
||||
// this->notifyAll(ConfigState_e::cameraConfigUpdated);
|
||||
}
|
||||
|
||||
void ProjectConfig::setWifiConfig(const std::string &networkName,
|
||||
const std::string &ssid,
|
||||
const std::string &password,
|
||||
uint8_t channel,
|
||||
uint8_t power,
|
||||
bool shouldNotify)
|
||||
uint8_t power)
|
||||
{
|
||||
size_t size = this->config.networks.size();
|
||||
|
||||
// rewrite it to std::find
|
||||
for (auto it = this->config.networks.begin();
|
||||
it != this->config.networks.end();)
|
||||
{
|
||||
@@ -298,16 +282,6 @@ void ProjectConfig::setWifiConfig(const std::string &networkName,
|
||||
it->channel = channel;
|
||||
it->power = power;
|
||||
|
||||
if (shouldNotify)
|
||||
{
|
||||
// TODO port state managers
|
||||
// wifiStateManager.setState(WiFiState_e::WiFiState_Disconnected);
|
||||
// WiFi.disconnect();
|
||||
this->wifiConfigSave();
|
||||
// TODO turn this on
|
||||
// this->notifyAll(ConfigState_e::networksConfigUpdated);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
else
|
||||
@@ -333,20 +307,9 @@ void ProjectConfig::setWifiConfig(const std::string &networkName,
|
||||
this->config.networks.emplace_back(networkName, ssid, password, channel,
|
||||
power, false);
|
||||
}
|
||||
|
||||
if (shouldNotify)
|
||||
{
|
||||
// TODO port state managers
|
||||
// wifiStateManager.setState(WiFiState_e::WiFiState_None);
|
||||
// WiFi.disconnect();
|
||||
this->wifiConfigSave();
|
||||
// TODO turn this on
|
||||
// this->notifyAll(ConfigState_e::networksConfigUpdated);
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectConfig::deleteWifiConfig(const std::string &networkName,
|
||||
bool shouldNotify)
|
||||
void ProjectConfig::deleteWifiConfig(const std::string &networkName)
|
||||
{
|
||||
size_t size = this->config.networks.size();
|
||||
if (size == 0)
|
||||
@@ -368,43 +331,22 @@ void ProjectConfig::deleteWifiConfig(const std::string &networkName,
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldNotify)
|
||||
{
|
||||
this->wifiConfigSave();
|
||||
// TODO turn this on
|
||||
// this->notifyAll(ConfigState_e::networksConfigUpdated);
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectConfig::setWiFiTxPower(uint8_t power, bool shouldNotify)
|
||||
void ProjectConfig::setWiFiTxPower(uint8_t power)
|
||||
{
|
||||
this->config.txpower.power = power;
|
||||
ESP_LOGD(CONFIGURATION_TAG, "Updating wifi tx power");
|
||||
// TODO turn this on
|
||||
// if (shouldNotify)
|
||||
// this->notifyAll(ConfigState_e::wifiTxPowerUpdated);
|
||||
}
|
||||
|
||||
void ProjectConfig::setAPWifiConfig(const std::string &ssid,
|
||||
const std::string &password,
|
||||
uint8_t channel,
|
||||
bool shouldNotify)
|
||||
uint8_t channel)
|
||||
{
|
||||
this->config.ap_network.ssid.assign(ssid);
|
||||
this->config.ap_network.password.assign(password);
|
||||
this->config.ap_network.channel = channel;
|
||||
ESP_LOGD(CONFIGURATION_TAG, "Updating access point config");
|
||||
if (shouldNotify)
|
||||
{
|
||||
// TODO port state managers
|
||||
// wifiStateManager.setState(WiFiState_e::WiFiState_None);
|
||||
// TODO Add some sort of signalling or IPC to tell the wifi manager to shut off
|
||||
// WiFi.disconnect();
|
||||
this->wifiConfigSave();
|
||||
// TODO turn this on
|
||||
// this->notifyAll(ConfigState_e::networksConfigUpdated);
|
||||
}
|
||||
}
|
||||
|
||||
//**********************************************************************************************************************
|
||||
|
||||
@@ -112,30 +112,25 @@ public:
|
||||
|
||||
void setDeviceConfig(const std::string &OTALogin,
|
||||
const std::string &OTAPassword,
|
||||
int OTAPort,
|
||||
bool shouldNotify);
|
||||
void setMDNSConfig(const std::string &hostname,
|
||||
bool shouldNotify);
|
||||
int OTAPort);
|
||||
void setMDNSConfig(const std::string &hostname);
|
||||
void setCameraConfig(uint8_t vflip,
|
||||
uint8_t framesize,
|
||||
uint8_t href,
|
||||
uint8_t quality,
|
||||
uint8_t brightness,
|
||||
bool shouldNotify);
|
||||
uint8_t brightness);
|
||||
void setWifiConfig(const std::string &networkName,
|
||||
const std::string &ssid,
|
||||
const std::string &password,
|
||||
uint8_t channel,
|
||||
uint8_t power,
|
||||
bool shouldNotify);
|
||||
uint8_t power);
|
||||
|
||||
void deleteWifiConfig(const std::string &networkName, bool shouldNotify);
|
||||
void deleteWifiConfig(const std::string &networkName);
|
||||
|
||||
void setAPWifiConfig(const std::string &ssid,
|
||||
const std::string &password,
|
||||
uint8_t channel,
|
||||
bool shouldNotify);
|
||||
void setWiFiTxPower(uint8_t power, bool shouldNotify);
|
||||
uint8_t channel);
|
||||
void setWiFiTxPower(uint8_t power);
|
||||
|
||||
private:
|
||||
TrackerConfig_t config;
|
||||
|
||||
Reference in New Issue
Block a user