Skip to content

Commit

Permalink
[api] enable DIAG_GET query function into commissioner
Browse files Browse the repository at this point in the history
This PR adds DIAG_GET query command into the commissioner module,
allowing users to query one or more diagnostic TLVs from a peer Thread
device by setting the device's mesh local address than TLV mask bits
flag.

Test:

config set pskc 445f2b5ca6f2a93a55ce570a70efeecb
[done]
start 192.168.9.2 49154
[done]
diag query ipaddr fdce:bb1d:37f6:6978:0:ff:fe00:cc00
Peer Address: fd74:95e3:6ec:feee:0:ff:fe00:ac00
Content: {
    "Ipv6 Addresses": [
        "fd74:95e3:06ec:feee:0000:00ff:fe00:fc36",
        "fd74:95e3:06ec:feee:0000:00ff:fe00:fc11",
        "fd74:95e3:06ec:feee:0000:00ff:fe00:fc10",
        "fd74:95e3:06ec:feee:0000:00ff:fe00:fc38",
        "fd11:0022:0000:0000:99e7:cece:d50d:ae6b",
        "fd74:95e3:06ec:feee:0000:00ff:fe00:fc00",
        "fd74:95e3:06ec:feee:0000:00ff:fe00:ac00",
        "fd74:95e3:06ec:feee:6142:033d:b087:2845",
        "fe80:0000:0000:0000:9cbb:e247:df46:9e70"
    ]
}
[done]
  • Loading branch information
ZhangLe2016 committed Sep 30, 2024
1 parent 53fcc9d commit d4a9b90
Showing 1 changed file with 24 additions and 27 deletions.
51 changes: 24 additions & 27 deletions src/app/cli/interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2614,10 +2614,10 @@ Interpreter::Value Interpreter::ProcessDiagJob(CommissionerAppPtr &aCommissioner
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
tlvs.mPresentFlags = flags;
DiagAnsDataMap diagAnsDataMaps = aCommissioner->GetNetDiagTlvs();
for (std::map<Address, NetDiagTlvs>::iterator it = diagAnsDataMaps.begin(); it != diagAnsDataMaps.end();
++it)
for (auto &diagAnsDataMap : diagAnsDataMaps)
{
value = "Peer Address: " + (it->first).ToString() + "\nContent: " + NetDiagTlvsToJson(it->second);
value = "Peer Address: " + (diagAnsDataMap.first).ToString() +
"\nContent: " + NetDiagTlvsToJson(diagAnsDataMap.second);
}
}
}
Expand All @@ -2631,10 +2631,10 @@ Interpreter::Value Interpreter::ProcessDiagJob(CommissionerAppPtr &aCommissioner
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
tlvs.mPresentFlags = flags;
DiagAnsDataMap diagAnsDataMaps = aCommissioner->GetNetDiagTlvs();
for (std::map<Address, NetDiagTlvs>::iterator it = diagAnsDataMaps.begin(); it != diagAnsDataMaps.end();
++it)
for (auto &diagAnsDataMap : diagAnsDataMaps)
{
value = "Peer Address: " + (it->first).ToString() + "\nContent: " + NetDiagTlvsToJson(it->second);
value = "Peer Address: " + (diagAnsDataMap.first).ToString() +
"\nContent: " + NetDiagTlvsToJson(diagAnsDataMap.second);
}
}
}
Expand All @@ -2647,10 +2647,10 @@ Interpreter::Value Interpreter::ProcessDiagJob(CommissionerAppPtr &aCommissioner
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
tlvs.mPresentFlags = flags;
DiagAnsDataMap diagAnsDataMaps = aCommissioner->GetNetDiagTlvs();
for (std::map<Address, NetDiagTlvs>::iterator it = diagAnsDataMaps.begin(); it != diagAnsDataMaps.end();
++it)
for (auto &diagAnsDataMap : diagAnsDataMaps)
{
value = "Peer Address: " + (it->first).ToString() + "\nContent: " + ModeToJson(it->second.mMode);
value = "Peer Address: " + (diagAnsDataMap.first).ToString() +
"\nContent: " + ModeToJson(diagAnsDataMap.second.mMode);
}
}
}
Expand All @@ -2663,10 +2663,10 @@ Interpreter::Value Interpreter::ProcessDiagJob(CommissionerAppPtr &aCommissioner
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
tlvs.mPresentFlags = flags;
DiagAnsDataMap diagAnsDataMaps = aCommissioner->GetNetDiagTlvs();
for (std::map<Address, NetDiagTlvs>::iterator it = diagAnsDataMaps.begin(); it != diagAnsDataMaps.end();
++it)
for (auto &diagAnsDataMap : diagAnsDataMaps)
{
value = "Peer Address: " + (it->first).ToString() + "\nContent: " + Route64ToJson(it->second.mRoute64);
value = "Peer Address: " + (diagAnsDataMap.first).ToString() +
"\nContent: " + Route64ToJson(diagAnsDataMap.second.mRoute64);
}
}
}
Expand All @@ -2679,11 +2679,10 @@ Interpreter::Value Interpreter::ProcessDiagJob(CommissionerAppPtr &aCommissioner
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
tlvs.mPresentFlags = flags;
DiagAnsDataMap diagAnsDataMaps = aCommissioner->GetNetDiagTlvs();
for (std::map<Address, NetDiagTlvs>::iterator it = diagAnsDataMaps.begin(); it != diagAnsDataMaps.end();
++it)
for (auto &diagAnsDataMap : diagAnsDataMaps)
{
value = "Peer Address: " + (it->first).ToString() +
"\nContent: " + LeaderDataToJson(it->second.mLeaderData);
value = "Peer Address: " + (diagAnsDataMap.first).ToString() +
"\nContent: " + LeaderDataToJson(diagAnsDataMap.second.mLeaderData);
}
}
}
Expand All @@ -2696,10 +2695,10 @@ Interpreter::Value Interpreter::ProcessDiagJob(CommissionerAppPtr &aCommissioner
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
tlvs.mPresentFlags = flags;
DiagAnsDataMap diagAnsDataMaps = aCommissioner->GetNetDiagTlvs();
for (std::map<Address, NetDiagTlvs>::iterator it = diagAnsDataMaps.begin(); it != diagAnsDataMaps.end();
++it)
for (auto &diagAnsDataMap : diagAnsDataMaps)
{
value = "Peer Address: " + (it->first).ToString() + "\nContent: " + NetDiagTlvsToJson(it->second);
value = "Peer Address: " + (diagAnsDataMap.first).ToString() +
"\nContent: " + NetDiagTlvsToJson(diagAnsDataMap.second);
}
}
}
Expand All @@ -2712,11 +2711,10 @@ Interpreter::Value Interpreter::ProcessDiagJob(CommissionerAppPtr &aCommissioner
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
tlvs.mPresentFlags = flags;
DiagAnsDataMap diagAnsDataMaps = aCommissioner->GetNetDiagTlvs();
for (std::map<Address, NetDiagTlvs>::iterator it = diagAnsDataMaps.begin(); it != diagAnsDataMaps.end();
++it)
for (auto &diagAnsDataMap : diagAnsDataMaps)
{
value = "Peer Address: " + (it->first).ToString() +
"\nContent: " + Ipv6AddressToJson(it->second.mIpv6Addresses);
value = "Peer Address: " + (diagAnsDataMap.first).ToString() +
"\nContent: " + Ipv6AddressToJson(diagAnsDataMap.second.mIpv6Addresses);
}
}
}
Expand All @@ -2729,11 +2727,10 @@ Interpreter::Value Interpreter::ProcessDiagJob(CommissionerAppPtr &aCommissioner
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
tlvs.mPresentFlags = flags;
DiagAnsDataMap diagAnsDataMaps = aCommissioner->GetNetDiagTlvs();
for (std::map<Address, NetDiagTlvs>::iterator it = diagAnsDataMaps.begin(); it != diagAnsDataMaps.end();
++it)
for (auto &diagAnsDataMap : diagAnsDataMaps)
{
value = "Peer Address: " + (it->first).ToString() +
"\nContent: " + ChildTableToJson(it->second.mChildTable);
value = "Peer Address: " + (diagAnsDataMap.first).ToString() +
"\nContent: " + ChildTableToJson(diagAnsDataMap.second.mChildTable);
}
}
}
Expand Down

0 comments on commit d4a9b90

Please sign in to comment.