stephb9959
2023-04-18 14:30:41 -07:00
parent e258772ea4
commit ecdef5912e
4 changed files with 24 additions and 7 deletions

View File

@@ -562,6 +562,23 @@ namespace OpenWifi {
}
}
void OWLSclient::UNsupportedCommand(std::shared_ptr<OWLSclient> Client, uint64_t Id,
const std::string & Method) {
try {
Poco::JSON::Object Answer, Result, Status;
Status.set("error", 1);
Status.set("text", "Command not supported");
Result.set("serial", Client->SerialNumber_);
Result.set("status", Status);
OWLSutils::MakeRPCHeader(Answer, Id, Result);
poco_information(Logger_,fmt::format("UNSUPPORTED({}): command {} not allowed for simulated devices.",
SerialNumber_, Method));
SendObject(Answer);
} catch(const Poco::Exception &E) {
}
}
bool OWLSclient::Send(const std::string &Cmd) {
try {

View File

@@ -53,6 +53,7 @@ namespace OpenWifi {
void DoUpgrade(std::shared_ptr<OWLSclient> Client, uint64_t Id, const Poco::JSON::Object::Ptr Params);
void DoFactory(std::shared_ptr<OWLSclient> Client, uint64_t Id, const Poco::JSON::Object::Ptr Params);
void DoLEDs(std::shared_ptr<OWLSclient> Client, uint64_t Id, const Poco::JSON::Object::Ptr Params);
void UNsupportedCommand(std::shared_ptr<OWLSclient> Client, uint64_t Id, const std::string &Method);
using interface_location_t = std::tuple<ap_interface_types, std::string, radio_bands>;
using associations_map_t = std::map<interface_location_t, MockAssociations>;

View File

@@ -6,7 +6,6 @@
#include "SimStats.h"
#include "StorageService.h"
#include "Poco/Environment.h"
#include "fmt/format.h"
#include "framework/MicroServiceFuncs.h"
#include "framework/utils.h"
@@ -50,23 +49,21 @@ namespace OpenWifi {
void SimulationCoordinator::run() {
Running_ = true;
while (Running_) {
Poco::Thread::trySleep(10000);
Poco::Thread::trySleep(20000);
if (!Running_)
break;
uint64_t Now = Utils::Now();
std::lock_guard G(Mutex_);
std::cout << "Checking sims..." << std::endl;
for(auto it = Simulations_.begin(); it!=end(Simulations_); ) {
const auto &id = it->first;
const auto &simulation = it->second;
std::cout << "Checking sims...: " << simulation->Details.simulationLength << std::endl;
if (simulation->Details.simulationLength != 0 &&
(Now - SimStats()->GetStartTime(id)) > simulation->Details.simulationLength) {
poco_information(Logger(),fmt::format("Simulation'{}' ({}) just completed.", simulation->Details.name,
simulation->Runner.Id()));
std::string Error;
std::cout << "Sim is done: " << simulation->Details.name << std::endl;
simulation->Runner.Stop();
SimStats()->EndSim(id);
OWLSObjects::SimulationStatus S;
@@ -75,7 +72,8 @@ namespace OpenWifi {
SimStats()->RemoveSim(id);
it = Simulations_.erase(it);
} else {
std::cout << "Sim is good: " << simulation->Details.name << std::endl;
poco_information(Logger(),fmt::format("Simulation'{}' ({}) still running.", simulation->Details.name,
simulation->Runner.Id()));
++it;
}
}

View File

@@ -207,6 +207,7 @@ namespace OpenWifi {
Client->DoLEDs(Client, Id, Params);
} else {
Logger_.warning(fmt::format("COMMAND({}): unknown method '{}'", Client->SerialNumber_, Method));
Client->UNsupportedCommand(Client, Id, Method);
}
}