diff --git a/include/openthread.h b/include/openthread.h index 84069e020..f297c7c60 100644 --- a/include/openthread.h +++ b/include/openthread.h @@ -1657,6 +1657,13 @@ void otSetAssignLinkQuality(otInstance *aInstance, const uint8_t *aExtAddr, uint */ void otPlatformReset(otInstance *aInstance); +/** + * This method deletes all the settings stored on non-volatile memory, and then triggers platform reset. + * + * @param[in] aInstance A pointer to an OpenThread instance. + */ +void otFactoryReset(otInstance *aInstance); + /** * Get the ROUTER_DOWNGRADE_THRESHOLD parameter used in the Router role. * diff --git a/src/cli/README.md b/src/cli/README.md index 71181daf2..016d54ea7 100644 --- a/src/cli/README.md +++ b/src/cli/README.md @@ -21,6 +21,7 @@ OpenThread test scripts use the CLI to execute test cases. * [eui64](#eui64) * [extaddr](#extaddr) * [extpanid](#extpanid) +* [factoryreset](#factoryreset) * [hashmacaddr](#hashmacaddr) * [ifconfig](#ifconfig) * [ipaddr](#ipaddr) @@ -711,6 +712,13 @@ Set the Thread Extended PAN ID value. Done ``` +### factoryreset +Delete all stored settings, and signal a platform reset. + +```bash +> factoryreset +``` + ### hashmacaddr Get the HashMac address. diff --git a/src/cli/cli.cpp b/src/cli/cli.cpp index 2a84a207e..f2a113b0b 100644 --- a/src/cli/cli.cpp +++ b/src/cli/cli.cpp @@ -87,6 +87,7 @@ const struct Command Interpreter::sCommands[] = #endif { "extaddr", &Interpreter::ProcessExtAddress }, { "extpanid", &Interpreter::ProcessExtPanId }, + { "factoryreset", &Interpreter::ProcessFactoryReset }, { "hashmacaddr", &Interpreter::ProcessHashMacAddress }, { "ifconfig", &Interpreter::ProcessIfconfig }, { "ipaddr", &Interpreter::ProcessIpAddr }, @@ -650,6 +651,13 @@ exit: AppendResult(error); } +void Interpreter::ProcessFactoryReset(int argc, char *argv[]) +{ + otFactoryReset(mInstance); + (void)argc; + (void)argv; +} + void Interpreter::ProcessHashMacAddress(int argc, char *argv[]) { ThreadError error = kThreadError_None; diff --git a/src/cli/cli.hpp b/src/cli/cli.hpp index 85efa9381..8d849876b 100644 --- a/src/cli/cli.hpp +++ b/src/cli/cli.hpp @@ -160,6 +160,7 @@ private: #endif void ProcessExtAddress(int argc, char *argv[]); void ProcessExtPanId(int argc, char *argv[]); + void ProcessFactoryReset(int argc, char *argv[]); void ProcessHashMacAddress(int argc, char *argv[]); void ProcessIfconfig(int argc, char *argv[]); void ProcessIpAddr(int argc, char *argv[]); diff --git a/src/core/openthread.cpp b/src/core/openthread.cpp index 0fc4b8324..48eec8d02 100644 --- a/src/core/openthread.cpp +++ b/src/core/openthread.cpp @@ -691,6 +691,12 @@ void otPlatformReset(otInstance *aInstance) otPlatReset(aInstance); } +void otFactoryReset(otInstance *aInstance) +{ + otPlatSettingsWipe(aInstance); + otPlatReset(aInstance); +} + uint8_t otGetRouterDowngradeThreshold(otInstance *aInstance) { return aInstance->mThreadNetif.GetMle().GetRouterDowngradeThreshold(); diff --git a/tools/harness-thci/ARM.py b/tools/harness-thci/ARM.py index 5f5ca8208..014b0077e 100644 --- a/tools/harness-thci/ARM.py +++ b/tools/harness-thci/ARM.py @@ -1103,7 +1103,9 @@ class ARM(IThci): """power down the Thread device""" print '%s call powerDown' % self.port self.isPowerDown = True - self.reset() + self._sendline('reset') + time.sleep(3) + self.setMAC(self.mac) def powerUp(self): """power up the Thread device""" @@ -1225,7 +1227,7 @@ class ARM(IThci): """factory reset""" print '%s call reset' % self.port try: - self._sendline('reset') + self._sendline('factoryreset') self._read() except Exception, e: ModuleHelper.WriteIntoDebugLogger("reset() Error: " + str(e)) @@ -2211,10 +2213,6 @@ class ARM(IThci): cmd += ' panid ' cmd += str(xPanId) - if xDelayTimer != None: - cmd += ' delay ' - cmd += str(xDelayTimer) - if listChannelMask != None: cmd += ' channelmask ' cmd += str(hex(1 << listChannelMask[1]))