mirror of
https://github.com/espressif/openthread.git
synced 2026-08-01 00:27:47 +00:00
[cli] implement dataset updater CLI commands (#6227)
This commit is contained in:
@@ -38,6 +38,7 @@
|
||||
|
||||
#include <openthread/dataset.h>
|
||||
#include <openthread/dataset_ftd.h>
|
||||
#include <openthread/dataset_updater.h>
|
||||
|
||||
#include "cli/cli.hpp"
|
||||
#include "common/string.hpp"
|
||||
@@ -910,5 +911,46 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
#if OPENTHREAD_CONFIG_DATASET_UPDATER_ENABLE && OPENTHREAD_FTD
|
||||
|
||||
otError Dataset::ProcessUpdater(uint8_t aArgsLength, char *aArgs[])
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
if (aArgsLength == 0)
|
||||
{
|
||||
mInterpreter.OutputEnabledDisabledStatus(otDatasetUpdaterIsUpdateOngoing(mInterpreter.mInstance));
|
||||
ExitNow();
|
||||
}
|
||||
|
||||
if (strcmp(aArgs[0], "start") == 0)
|
||||
{
|
||||
error = otDatasetUpdaterRequestUpdate(mInterpreter.mInstance, &sDataset, &Dataset::HandleDatasetUpdater, this);
|
||||
}
|
||||
else if (strcmp(aArgs[0], "cancel") == 0)
|
||||
{
|
||||
otDatasetUpdaterCancelUpdate(mInterpreter.mInstance);
|
||||
}
|
||||
else
|
||||
{
|
||||
error = OT_ERROR_INVALID_ARGS;
|
||||
}
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
void Dataset::HandleDatasetUpdater(otError aError, void *aContext)
|
||||
{
|
||||
static_cast<Dataset *>(aContext)->HandleDatasetUpdater(aError);
|
||||
}
|
||||
|
||||
void Dataset::HandleDatasetUpdater(otError aError)
|
||||
{
|
||||
mInterpreter.OutputLine("Dataset update complete: %s", otThreadErrorToString(aError));
|
||||
}
|
||||
|
||||
#endif // OPENTHREAD_CONFIG_DATASET_UPDATER_ENABLE && OPENTHREAD_FTD
|
||||
|
||||
} // namespace Cli
|
||||
} // namespace ot
|
||||
|
||||
@@ -99,6 +99,12 @@ private:
|
||||
otError ProcessSecurityPolicy(uint8_t aArgsLength, char *aArgs[]);
|
||||
otError ProcessSet(uint8_t aArgsLength, char *aArgs[]);
|
||||
|
||||
#if OPENTHREAD_CONFIG_DATASET_UPDATER_ENABLE && OPENTHREAD_FTD
|
||||
otError ProcessUpdater(uint8_t aArgsLength, char *aArgs[]);
|
||||
static void HandleDatasetUpdater(otError aError, void *aContext);
|
||||
void HandleDatasetUpdater(otError aError);
|
||||
#endif
|
||||
|
||||
static constexpr Command sCommands[] = {
|
||||
{"active", &Dataset::ProcessActive},
|
||||
{"activetimestamp", &Dataset::ProcessActiveTimestamp},
|
||||
@@ -121,6 +127,9 @@ private:
|
||||
{"pskc", &Dataset::ProcessPskc},
|
||||
{"securitypolicy", &Dataset::ProcessSecurityPolicy},
|
||||
{"set", &Dataset::ProcessSet},
|
||||
#if OPENTHREAD_CONFIG_DATASET_UPDATER_ENABLE && OPENTHREAD_FTD
|
||||
{"updater", &Dataset::ProcessUpdater},
|
||||
#endif
|
||||
};
|
||||
|
||||
static_assert(Utils::LookupTable::IsSorted(sCommands), "Command Table is not sorted");
|
||||
|
||||
Reference in New Issue
Block a user