upload mutimodal

This commit is contained in:
Summer
2025-06-11 04:55:38 -07:00
committed by Lorow
parent b30a00900f
commit d9ace4bc05
41 changed files with 2484 additions and 219 deletions

View File

@@ -8,6 +8,7 @@
#include <helpers.hpp>
#include "sdkconfig.h"
#include <Preferences.hpp>
#include "esp_log.h"
struct BaseConfigModel
{
@@ -31,11 +32,14 @@ struct DeviceMode_t : BaseConfigModel {
explicit DeviceMode_t( Preferences *pref) : BaseConfigModel(pref), mode(StreamingMode::AUTO){}
void load() {
this->mode = static_cast<StreamingMode>(this->pref->getInt("mode", 0));
int stored_mode = this->pref->getInt("mode", 0);
this->mode = static_cast<StreamingMode>(stored_mode);
ESP_LOGI("DeviceMode", "Loaded device mode: %d", stored_mode);
}
void save() const {
this->pref->putInt("mode", static_cast<int>(this->mode));
ESP_LOGI("DeviceMode", "Saved device mode: %d", static_cast<int>(this->mode));
}
};
@@ -182,6 +186,9 @@ struct WiFiConfig_t : BaseConfigModel
this->password = this->pref->getString(("password" + iter_str).c_str(), "");
this->channel = this->pref->getUInt(("channel" + iter_str).c_str());
this->power = this->pref->getUInt(("power" + iter_str).c_str());
ESP_LOGI("WiFiConfig", "Loaded network %d: name=%s, ssid=%s, channel=%d",
index, this->name.c_str(), this->ssid.c_str(), this->channel);
};
void save() const {
@@ -193,6 +200,9 @@ struct WiFiConfig_t : BaseConfigModel
this->pref->putString(("password" + iter_str).c_str(), this->password.c_str());
this->pref->putUInt(("channel" + iter_str).c_str(), this->channel);
this->pref->putUInt(("power" + iter_str).c_str(), this->power);
ESP_LOGI("WiFiConfig", "Saved network %d: name=%s, ssid=%s, channel=%d",
this->index, this->name.c_str(), this->ssid.c_str(), this->channel);
};
std::string toRepresentation()

View File

@@ -147,6 +147,8 @@ void ProjectConfig::setWifiConfig(const std::string &networkName,
it->password = password;
it->channel = channel;
it->power = power;
// Save the updated network immediately
it->save();
return;
}
@@ -155,6 +157,9 @@ void ProjectConfig::setWifiConfig(const std::string &networkName,
ESP_LOGI(CONFIGURATION_TAG, "No networks, We're adding a new network");
this->config.networks.emplace_back(this->pref, static_cast<uint8_t>(0), networkName, ssid, password, channel,
power);
// Save the new network immediately
this->config.networks.back().save();
saveNetworkCount(this->pref, 1);
return;
}
@@ -168,6 +173,9 @@ void ProjectConfig::setWifiConfig(const std::string &networkName,
uint8_t last_index = getNetworkCount(this->pref);
this->config.networks.emplace_back(this->pref, last_index, networkName, ssid, password, channel,
power);
// Save the new network immediately
this->config.networks.back().save();
saveNetworkCount(this->pref, static_cast<int>(this->config.networks.size()));
}
else
{
@@ -212,6 +220,7 @@ void ProjectConfig::setAPWifiConfig(const std::string &ssid,
void ProjectConfig::setDeviceMode(const StreamingMode deviceMode) {
this->config.device_mode.mode = deviceMode;
this->config.device_mode.save(); // Save immediately
}
//**********************************************************************************************************************
@@ -249,6 +258,10 @@ TrackerConfig_t &ProjectConfig::getTrackerConfig()
return this->config;
}
DeviceMode_t &ProjectConfig::getDeviceMode() {
DeviceMode_t &ProjectConfig::getDeviceModeConfig() {
return this->config.device_mode;
}
StreamingMode ProjectConfig::getDeviceMode() {
return this->config.device_mode.mode;
}

View File

@@ -31,7 +31,7 @@ public:
bool reset();
DeviceConfig_t &getDeviceConfig();
DeviceMode_t &getDeviceMode();
DeviceMode_t &getDeviceModeConfig();
CameraConfig_t &getCameraConfig();
std::vector<WiFiConfig_t> &getWifiConfigs();
AP_WiFiConfig_t &getAPWifiConfig();
@@ -61,6 +61,7 @@ public:
uint8_t channel);
void setWiFiTxPower(uint8_t power);
void setDeviceMode(StreamingMode deviceMode);
StreamingMode getDeviceMode();
private:
Preferences *pref;