mirror of
https://github.com/espressif/openthread.git
synced 2026-07-08 21:30:24 +00:00
Add 'factoryreset' cli (#892)
* add 'factoryreset' cli to delete all stored settings and then reset * use 'factoryreset' in THCI reset API to ensure that there is no pre-settings in DUT before running any test
This commit is contained in:
@@ -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.
|
||||
*
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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[]);
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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]))
|
||||
|
||||
Reference in New Issue
Block a user