mirror of
https://github.com/MrUnknownDE/OpenIris-ESPIDF.git
synced 2026-04-17 05:23:44 +02:00
Add command to set device mode between auto/uvc/wifi, add config to represent streaming mode, implement restart task, implement restart device command
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
#ifndef _PROJECT_CONFIG_MODELS_HPP_
|
||||
#define _PROJECT_CONFIG_MODELS_HPP_
|
||||
#ifndef PROJECT_CONFIG_MODELS_HPP
|
||||
#define PROJECT_CONFIG_MODELS_HPP
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
@@ -20,6 +20,26 @@ struct BaseConfigModel
|
||||
Preferences *pref;
|
||||
};
|
||||
|
||||
enum class StreamingMode {
|
||||
AUTO,
|
||||
UVC,
|
||||
WIFI,
|
||||
};
|
||||
|
||||
struct DeviceMode_t : BaseConfigModel {
|
||||
StreamingMode mode;
|
||||
explicit DeviceMode_t( Preferences *pref) : BaseConfigModel(pref), mode(StreamingMode::AUTO){}
|
||||
|
||||
void load() {
|
||||
this->mode = static_cast<StreamingMode>(this->pref->getInt("mode", 0));
|
||||
}
|
||||
|
||||
void save() const {
|
||||
this->pref->putInt("mode", static_cast<int>(this->mode));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct DeviceConfig_t : BaseConfigModel
|
||||
{
|
||||
DeviceConfig_t(Preferences *pref) : BaseConfigModel(pref) {}
|
||||
@@ -238,6 +258,7 @@ class TrackerConfig_t
|
||||
{
|
||||
public:
|
||||
DeviceConfig_t device;
|
||||
DeviceMode_t device_mode;
|
||||
CameraConfig_t camera;
|
||||
std::vector<WiFiConfig_t> networks;
|
||||
AP_WiFiConfig_t ap_network;
|
||||
@@ -246,16 +267,18 @@ public:
|
||||
|
||||
TrackerConfig_t(
|
||||
DeviceConfig_t device,
|
||||
DeviceMode_t device_mode,
|
||||
CameraConfig_t camera,
|
||||
std::vector<WiFiConfig_t> networks,
|
||||
AP_WiFiConfig_t ap_network,
|
||||
MDNSConfig_t mdns,
|
||||
WiFiTxPower_t txpower) : device(std::move(device)),
|
||||
camera(camera),
|
||||
device_mode(std::move(device_mode)),
|
||||
camera(std::move(camera)),
|
||||
networks(std::move(networks)),
|
||||
ap_network(std::move(ap_network)),
|
||||
mdns(std::move(mdns)),
|
||||
txpower(txpower) {}
|
||||
txpower(std::move(txpower)) {}
|
||||
|
||||
std::string toRepresentation()
|
||||
{
|
||||
|
||||
@@ -15,6 +15,7 @@ void saveNetworkCount(Preferences *pref, const int count)
|
||||
ProjectConfig::ProjectConfig(Preferences *pref) : pref(pref),
|
||||
_already_loaded(false),
|
||||
config(DeviceConfig_t(pref),
|
||||
DeviceMode_t(pref),
|
||||
CameraConfig_t(pref),
|
||||
std::vector<WiFiConfig_t>{},
|
||||
AP_WiFiConfig_t(pref),
|
||||
@@ -26,6 +27,7 @@ ProjectConfig::~ProjectConfig() = default;
|
||||
void ProjectConfig::save() const {
|
||||
ESP_LOGD(CONFIGURATION_TAG, "Saving project config");
|
||||
this->config.device.save();
|
||||
this->config.device_mode.save();
|
||||
this->config.camera.save();
|
||||
this->config.mdns.save();
|
||||
this->config.txpower.save();
|
||||
@@ -61,6 +63,7 @@ void ProjectConfig::load()
|
||||
ESP_LOGI(CONFIGURATION_TAG, "Config loaded: %s", success ? "true" : "false");
|
||||
|
||||
this->config.device.load();
|
||||
this->config.device_mode.load();
|
||||
this->config.camera.load();
|
||||
this->config.mdns.load();
|
||||
this->config.txpower.load();
|
||||
@@ -207,6 +210,10 @@ void ProjectConfig::setAPWifiConfig(const std::string &ssid,
|
||||
ESP_LOGD(CONFIGURATION_TAG, "Updating access point config");
|
||||
}
|
||||
|
||||
void ProjectConfig::setDeviceMode(const StreamingMode deviceMode) {
|
||||
this->config.device_mode.mode = deviceMode;
|
||||
}
|
||||
|
||||
//**********************************************************************************************************************
|
||||
//*
|
||||
//! Get Methods
|
||||
@@ -240,4 +247,8 @@ WiFiTxPower_t &ProjectConfig::getWiFiTxPowerConfig()
|
||||
TrackerConfig_t &ProjectConfig::getTrackerConfig()
|
||||
{
|
||||
return this->config;
|
||||
}
|
||||
|
||||
DeviceMode_t &ProjectConfig::getDeviceMode() {
|
||||
return this->config.device_mode;
|
||||
}
|
||||
@@ -31,6 +31,7 @@ public:
|
||||
bool reset();
|
||||
|
||||
DeviceConfig_t &getDeviceConfig();
|
||||
DeviceMode_t &getDeviceMode();
|
||||
CameraConfig_t &getCameraConfig();
|
||||
std::vector<WiFiConfig_t> &getWifiConfigs();
|
||||
AP_WiFiConfig_t &getAPWifiConfig();
|
||||
@@ -59,6 +60,7 @@ public:
|
||||
const std::string &password,
|
||||
uint8_t channel);
|
||||
void setWiFiTxPower(uint8_t power);
|
||||
void setDeviceMode(StreamingMode deviceMode);
|
||||
|
||||
private:
|
||||
Preferences *pref;
|
||||
|
||||
Reference in New Issue
Block a user