Commit cc926d1a authored by aligungr's avatar aligungr

CLI improvements

parent 7c5ec424
......@@ -83,16 +83,19 @@ static std::map<std::string, bool> g_gnbCmdToHelpIfEmpty = {{"status", false},
static std::map<std::string, std::string> g_ueCmdToDescription = {
{"info", "Show some information about the UE"},
{"status", "Show some status information about the UE"},
{"timers", "Dump current status of the timers in the UE"},
};
static std::map<std::string, std::string> g_ueCmdToUsage = {
{"info", "[option...]"},
{"status", "[option...]"},
{"timers", "[option...]"},
};
static std::map<std::string, bool> g_ueCmdToHelpIfEmpty = {
{"info", false},
{"status", false},
{"timers", false},
};
std::unique_ptr<GnbCliCommand> ParseGnbCliCommand(std::vector<std::string> &&tokens, std::string &error,
......@@ -217,6 +220,10 @@ std::unique_ptr<UeCliCommand> ParseUeCliCommand(std::vector<std::string> &&token
{
return std::make_unique<UeCliCommand>(UeCliCommand::STATUS);
}
else if (subCmd == "timers")
{
return std::make_unique<UeCliCommand>(UeCliCommand::TIMERS);
}
return nullptr;
}
......
......@@ -41,6 +41,7 @@ struct UeCliCommand
{
INFO,
STATUS,
TIMERS,
} present;
explicit UeCliCommand(PR present) : present(present)
......
......@@ -118,4 +118,15 @@ int NasTimer::getRemaining() const
return static_cast<int>(std::max(interval - elapsed, 0L));
}
Json ToJson(const NasTimer &v)
{
int interval = v.getInterval();
return Json::Obj({
{"interval", interval == INT32_MAX ? Json{"inf"} : interval},
{"remaining", v.getRemaining()},
{"running", v.isRunning()},
});
}
} // namespace nas
......@@ -10,6 +10,8 @@
#include "ie4.hpp"
#include <utils/json.hpp>
namespace nas
{
......@@ -40,4 +42,6 @@ class NasTimer
[[nodiscard]] int getRemaining() const;
};
Json ToJson(const NasTimer &v);
} // namespace nas
\ No newline at end of file
......@@ -111,6 +111,10 @@ void UeCmdHandler::HandleCmdImpl(TaskBase &base, NwUeCliCommand &msg)
msg.sendResult(ToJson(*base.config).dumpYaml());
break;
}
case app::UeCliCommand::TIMERS: {
msg.sendResult(ToJson(base.nasTask->timers).dumpYaml());
break;
}
}
}
......
......@@ -131,4 +131,17 @@ Json ToJson(const UeConfig &v)
});
}
Json ToJson(const UeTimers &v)
{
return Json::Obj({
{"T3346", ToJson(v.t3346)}, {"T3396", ToJson(v.t3396)}, {"T3444", ToJson(v.t3444)},
{"T3445", ToJson(v.t3445)}, {"T3502", ToJson(v.t3502)}, {"T3510", ToJson(v.t3510)},
{"T3511", ToJson(v.t3511)}, {"T3512", ToJson(v.t3512)}, {"T3516", ToJson(v.t3516)},
{"T3517", ToJson(v.t3517)}, {"T3519", ToJson(v.t3519)}, {"T3520", ToJson(v.t3520)},
{"T3521", ToJson(v.t3521)}, {"T3525", ToJson(v.t3525)}, {"T3540", ToJson(v.t3540)},
{"T3580", ToJson(v.t3580)}, {"T3581", ToJson(v.t3581)}, {"T3582", ToJson(v.t3582)},
{"T3583", ToJson(v.t3583)}, {"T3584", ToJson(v.t3584)}, {"T3585", ToJson(v.t3585)},
});
}
} // namespace nr::ue
......@@ -364,5 +364,6 @@ Json ToJson(const ERmState &state);
Json ToJson(const EMmState &state);
Json ToJson(const EMmSubState &state);
Json ToJson(const UeConfig &v);
Json ToJson(const UeTimers &v);
} // namespace nr::ue
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment