mirror of
https://github.com/MrUnknownDE/OpenIris-ESPIDF.git
synced 2026-04-19 14:33:45 +02:00
fix scan timeouts
This commit is contained in:
@@ -74,8 +74,8 @@ std::function<CommandResult()> CommandManager::createCommand(const CommandType t
|
||||
case CommandType::RESTART_DEVICE:
|
||||
return restartDeviceCommand;
|
||||
case CommandType::SCAN_NETWORKS:
|
||||
return [this]
|
||||
{ return scanNetworksCommand(this->registry); };
|
||||
return [this, json]
|
||||
{ return scanNetworksCommand(this->registry, json); };
|
||||
case CommandType::START_STREAMING:
|
||||
return startStreamingCommand;
|
||||
case CommandType::GET_WIFI_STATUS:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "scan_commands.hpp"
|
||||
#include "sdkconfig.h"
|
||||
|
||||
CommandResult scanNetworksCommand(std::shared_ptr<DependencyRegistry> registry)
|
||||
CommandResult scanNetworksCommand(std::shared_ptr<DependencyRegistry> registry, const nlohmann::json &json)
|
||||
{
|
||||
#if !CONFIG_GENERAL_ENABLE_WIRELESS
|
||||
return CommandResult::getErrorResult("Not supported by current firmware");
|
||||
@@ -12,7 +12,14 @@ CommandResult scanNetworksCommand(std::shared_ptr<DependencyRegistry> registry)
|
||||
return CommandResult::getErrorResult("Not supported by current firmware");
|
||||
}
|
||||
|
||||
auto networks = wifiManager->ScanNetworks();
|
||||
// Extract timeout from JSON if provided, default to 15000ms (15 seconds)
|
||||
int timeout_ms = 15000;
|
||||
if (json.contains("timeout_ms") && json["timeout_ms"].is_number_integer())
|
||||
{
|
||||
timeout_ms = json["timeout_ms"].get<int>();
|
||||
}
|
||||
|
||||
auto networks = wifiManager->ScanNetworks(timeout_ms);
|
||||
|
||||
nlohmann::json result;
|
||||
std::vector<nlohmann::json> networksJson;
|
||||
|
||||
@@ -8,6 +8,6 @@
|
||||
#include <string>
|
||||
#include <nlohmann-json.hpp>
|
||||
|
||||
CommandResult scanNetworksCommand(std::shared_ptr<DependencyRegistry> registry);
|
||||
CommandResult scanNetworksCommand(std::shared_ptr<DependencyRegistry> registry, const nlohmann::json &json);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user