Commit 6759f50a authored by aligungr's avatar aligungr

CLI improvements

parent 2900d17e
......@@ -83,6 +83,18 @@ void UeCmdHandler::HandleCmdImpl(TaskBase &base, NwUeCliCommand &msg)
switch (msg.cmd->present)
{
case app::UeCliCommand::STATUS: {
std::vector<Json> pduSessions{};
int index = 0;
for (auto &pduSession : base.appTask->m_statusInfo.pduSessions)
{
if (pduSession.has_value())
{
pduSessions.push_back(
Json::Obj({{"id", index}, {"type", pduSession->type}, {"address", pduSession->address}}));
}
index++;
}
Json json = Json::Obj({
{"cm-state", ToJson(base.nasTask->mm->m_cmState)},
{"rm-state", ToJson(base.nasTask->mm->m_rmState)},
......@@ -90,6 +102,7 @@ void UeCmdHandler::HandleCmdImpl(TaskBase &base, NwUeCliCommand &msg)
{"sim-inserted", base.nasTask->mm->m_validSim},
{"stored-suci", ToJson(base.nasTask->mm->m_storedSuci)},
{"stored-guti", ToJson(base.nasTask->mm->m_storedGuti)},
{"pdu-sessions", Json::Arr(std::move(pduSessions))},
});
msg.sendResult(json.dumpYaml());
break;
......
......@@ -349,6 +349,26 @@ Json Json::Arr(std::initializer_list<Json> &&elements)
return json;
}
Json Json::Arr(const std::vector<Json> &elements)
{
Json json{};
json.m_type = Type::ARRAY;
int index = 0;
for (auto &item : elements)
json.m_children[std::to_string(index++)] = item;
return json;
}
Json Json::Arr(std::vector<Json> &&elements)
{
Json json{};
json.m_type = Type::ARRAY;
int index = 0;
for (auto &item : elements)
json.m_children[std::to_string(index++)] = std::move(item);
return json;
}
Json Json::Obj(std::initializer_list<std::pair<std::string, Json>> &&elements)
{
Json json{};
......
......@@ -65,6 +65,8 @@ class Json
public:
static Json Arr(std::initializer_list<Json> &&elements);
static Json Arr(const std::vector<Json> &elements);
static Json Arr(std::vector<Json> &&elements);
static Json Obj(std::initializer_list<std::pair<std::string, Json>> &&elements);
public:
......
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