mirror of
https://github.com/MrUnknownDE/OpenIris-ESPIDF.git
synced 2026-04-18 22:13:45 +02:00
Finish writing tests for commands, fix resolution being accidentally set to lower one, improve fixtures - need rewrite
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
CommandResult setWiFiCommand(std::shared_ptr<DependencyRegistry> registry, const nlohmann::json &json)
|
||||
{
|
||||
#if !CONFIG_GENERAL_ENABLE_WIRELESS
|
||||
return CommandResult::getErrorResult("Not supported by current firmware");
|
||||
return CommandResult::getErrorResult("Not supported by current firmware");
|
||||
#endif
|
||||
|
||||
auto payload = json.get<WifiPayload>();
|
||||
@@ -33,7 +33,7 @@ CommandResult setWiFiCommand(std::shared_ptr<DependencyRegistry> registry, const
|
||||
CommandResult deleteWiFiCommand(std::shared_ptr<DependencyRegistry> registry, const nlohmann::json &json)
|
||||
{
|
||||
#if !CONFIG_GENERAL_ENABLE_WIRELESS
|
||||
return CommandResult::getErrorResult("Not supported by current firmware");
|
||||
return CommandResult::getErrorResult("Not supported by current firmware");
|
||||
#endif
|
||||
|
||||
const auto payload = json.get<deleteNetworkPayload>();
|
||||
@@ -49,7 +49,7 @@ CommandResult deleteWiFiCommand(std::shared_ptr<DependencyRegistry> registry, co
|
||||
CommandResult updateWiFiCommand(std::shared_ptr<DependencyRegistry> registry, const nlohmann::json &json)
|
||||
{
|
||||
#if !CONFIG_GENERAL_ENABLE_WIRELESS
|
||||
return CommandResult::getErrorResult("Not supported by current firmware");
|
||||
return CommandResult::getErrorResult("Not supported by current firmware");
|
||||
#endif
|
||||
|
||||
auto payload = json.get<UpdateWifiPayload>();
|
||||
@@ -82,7 +82,7 @@ CommandResult updateWiFiCommand(std::shared_ptr<DependencyRegistry> registry, co
|
||||
CommandResult updateAPWiFiCommand(std::shared_ptr<DependencyRegistry> registry, const nlohmann::json &json)
|
||||
{
|
||||
#if !CONFIG_GENERAL_ENABLE_WIRELESS
|
||||
return CommandResult::getErrorResult("Not supported by current firmware");
|
||||
return CommandResult::getErrorResult("Not supported by current firmware");
|
||||
#endif
|
||||
|
||||
const auto payload = json.get<UpdateAPWiFiPayload>();
|
||||
|
||||
@@ -35,14 +35,14 @@ struct DeviceMode_t : BaseConfigModel
|
||||
|
||||
void load()
|
||||
{
|
||||
// Default mode can be controlled via sdkconfig:
|
||||
// - If CONFIG_START_IN_UVC_MODE is enabled, default to UVC
|
||||
// - Otherwise default to SETUP
|
||||
// Default mode can be controlled via sdkconfig:
|
||||
// - If CONFIG_START_IN_UVC_MODE is enabled, default to UVC
|
||||
// - Otherwise default to SETUP
|
||||
int default_mode =
|
||||
#if CONFIG_START_IN_UVC_MODE
|
||||
static_cast<int>(StreamingMode::UVC);
|
||||
#else
|
||||
static_cast<int>(StreamingMode::SETUP);
|
||||
static_cast<int>(StreamingMode::SETUP);
|
||||
#endif
|
||||
|
||||
int stored_mode = this->pref->getInt("mode", default_mode);
|
||||
@@ -103,12 +103,12 @@ struct MDNSConfig_t : BaseConfigModel
|
||||
|
||||
void load()
|
||||
{
|
||||
// Default hostname comes from GENERAL_ADVERTISED_NAME (unified advertised name)
|
||||
std::string default_hostname =
|
||||
// Default hostname comes from GENERAL_ADVERTISED_NAME (unified advertised name)
|
||||
std::string default_hostname =
|
||||
#ifdef CONFIG_GENERAL_ADVERTISED_NAME
|
||||
CONFIG_GENERAL_ADVERTISED_NAME;
|
||||
CONFIG_GENERAL_ADVERTISED_NAME;
|
||||
#else
|
||||
"openiristracker";
|
||||
"openiristracker";
|
||||
#endif
|
||||
|
||||
if (default_hostname.empty())
|
||||
@@ -146,7 +146,7 @@ struct CameraConfig_t : BaseConfigModel
|
||||
{
|
||||
this->vflip = this->pref->getInt("vflip", 0);
|
||||
this->href = this->pref->getInt("href", 0);
|
||||
this->framesize = this->pref->getInt("framesize", 4);
|
||||
this->framesize = this->pref->getInt("framesize", 5);
|
||||
this->quality = this->pref->getInt("quality", 7);
|
||||
this->brightness = this->pref->getInt("brightness", 2);
|
||||
};
|
||||
|
||||
@@ -74,10 +74,11 @@ esp_err_t StreamHelpers::stream(httpd_req_t *req)
|
||||
}
|
||||
if (response != ESP_OK)
|
||||
break;
|
||||
|
||||
|
||||
// Only log every 100 frames to reduce overhead
|
||||
static int frame_count = 0;
|
||||
if (++frame_count % 100 == 0) {
|
||||
if (++frame_count % 100 == 0)
|
||||
{
|
||||
long request_end = Helpers::getTimeInMillis();
|
||||
long latency = (request_end - last_request_time);
|
||||
last_request_time = request_end;
|
||||
@@ -98,13 +99,12 @@ esp_err_t StreamServer::startStreamServer()
|
||||
{
|
||||
httpd_config_t config = HTTPD_DEFAULT_CONFIG();
|
||||
config.stack_size = 20480;
|
||||
// todo bring this back to 1 once we're done with logs over websockets
|
||||
config.max_uri_handlers = 10;
|
||||
config.server_port = STREAM_SERVER_PORT;
|
||||
config.ctrl_port = STREAM_SERVER_PORT;
|
||||
config.recv_wait_timeout = 5; // 5 seconds for receiving
|
||||
config.send_wait_timeout = 5; // 5 seconds for sending
|
||||
config.lru_purge_enable = true; // Enable LRU purge for better connection handling
|
||||
config.recv_wait_timeout = 5; // 5 seconds for receiving
|
||||
config.send_wait_timeout = 5; // 5 seconds for sending
|
||||
config.lru_purge_enable = true; // Enable LRU purge for better connection handling
|
||||
|
||||
httpd_uri_t stream_page = {
|
||||
.uri = "/",
|
||||
@@ -139,7 +139,6 @@ esp_err_t StreamServer::startStreamServer()
|
||||
httpd_register_uri_handler(camera_stream, &stream_page);
|
||||
|
||||
ESP_LOGI(STREAM_SERVER_TAG, "Stream server started on port %d", STREAM_SERVER_PORT);
|
||||
// todo add printing IP addr here
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
Reference in New Issue
Block a user