Commit 6759f50a authored by aligungr's avatar aligungr

CLI improvements

parent 2900d17e
...@@ -83,6 +83,18 @@ void UeCmdHandler::HandleCmdImpl(TaskBase &base, NwUeCliCommand &msg) ...@@ -83,6 +83,18 @@ void UeCmdHandler::HandleCmdImpl(TaskBase &base, NwUeCliCommand &msg)
switch (msg.cmd->present) switch (msg.cmd->present)
{ {
case app::UeCliCommand::STATUS: { 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({ Json json = Json::Obj({
{"cm-state", ToJson(base.nasTask->mm->m_cmState)}, {"cm-state", ToJson(base.nasTask->mm->m_cmState)},
{"rm-state", ToJson(base.nasTask->mm->m_rmState)}, {"rm-state", ToJson(base.nasTask->mm->m_rmState)},
...@@ -90,6 +102,7 @@ void UeCmdHandler::HandleCmdImpl(TaskBase &base, NwUeCliCommand &msg) ...@@ -90,6 +102,7 @@ void UeCmdHandler::HandleCmdImpl(TaskBase &base, NwUeCliCommand &msg)
{"sim-inserted", base.nasTask->mm->m_validSim}, {"sim-inserted", base.nasTask->mm->m_validSim},
{"stored-suci", ToJson(base.nasTask->mm->m_storedSuci)}, {"stored-suci", ToJson(base.nasTask->mm->m_storedSuci)},
{"stored-guti", ToJson(base.nasTask->mm->m_storedGuti)}, {"stored-guti", ToJson(base.nasTask->mm->m_storedGuti)},
{"pdu-sessions", Json::Arr(std::move(pduSessions))},
}); });
msg.sendResult(json.dumpYaml()); msg.sendResult(json.dumpYaml());
break; break;
......
...@@ -349,6 +349,26 @@ Json Json::Arr(std::initializer_list<Json> &&elements) ...@@ -349,6 +349,26 @@ Json Json::Arr(std::initializer_list<Json> &&elements)
return json; 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::Obj(std::initializer_list<std::pair<std::string, Json>> &&elements)
{ {
Json json{}; Json json{};
......
...@@ -65,6 +65,8 @@ class Json ...@@ -65,6 +65,8 @@ class Json
public: public:
static Json Arr(std::initializer_list<Json> &&elements); 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); static Json Obj(std::initializer_list<std::pair<std::string, Json>> &&elements);
public: 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