[network-diagnostic] improve usability of Network Diagnostic API (#4619)

This commit improves usability of Network Diagnostic API by:

- Define native structures to represent various Network Diagnostic TLV
  values.

- Add facility function otThreadGetNextDiagnosticTlv to parse plain
  otMessage into structured data.

- Dump parsed DIAG_GET.ans/.rsp message in readable format for
  networkdiagnostic CLI command.
This commit is contained in:
kangping
2020-03-27 04:43:40 +08:00
committed by GitHub
parent 315a27bf08
commit e28608cd0b
16 changed files with 1076 additions and 122 deletions
-34
View File
@@ -38,7 +38,6 @@
#include "common/debug.hpp"
#include "common/instance.hpp"
#include "common/locator-getters.hpp"
#include "common/logging.hpp"
#include "common/settings.hpp"
using namespace ot;
@@ -363,39 +362,6 @@ exit:
return error;
}
#if OPENTHREAD_FTD || OPENTHREAD_CONFIG_TMF_NETWORK_DIAG_MTD_ENABLE
void otThreadSetReceiveDiagnosticGetCallback(otInstance * aInstance,
otReceiveDiagnosticGetCallback aCallback,
void * aCallbackContext)
{
Instance &instance = *static_cast<Instance *>(aInstance);
instance.Get<NetworkDiagnostic::NetworkDiagnostic>().SetReceiveDiagnosticGetCallback(aCallback, aCallbackContext);
}
otError otThreadSendDiagnosticGet(otInstance * aInstance,
const otIp6Address *aDestination,
const uint8_t aTlvTypes[],
uint8_t aCount)
{
Instance &instance = *static_cast<Instance *>(aInstance);
return instance.Get<NetworkDiagnostic::NetworkDiagnostic>().SendDiagnosticGet(
*static_cast<const Ip6::Address *>(aDestination), aTlvTypes, aCount);
}
otError otThreadSendDiagnosticReset(otInstance * aInstance,
const otIp6Address *aDestination,
const uint8_t aTlvTypes[],
uint8_t aCount)
{
Instance &instance = *static_cast<Instance *>(aInstance);
return instance.Get<NetworkDiagnostic::NetworkDiagnostic>().SendDiagnosticReset(
*static_cast<const Ip6::Address *>(aDestination), aTlvTypes, aCount);
}
#endif // OPENTHREAD_FTD || OPENTHREAD_CONFIG_TMF_NETWORK_DIAG_MTD_ENABLE
otError otThreadSetEnabled(otInstance *aInstance, bool aEnabled)
{
otError error = OT_ERROR_NONE;