mirror of
https://github.com/espressif/openthread.git
synced 2026-09-08 02:00:12 +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);
|
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.
|
* 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)
|
* [eui64](#eui64)
|
||||||
* [extaddr](#extaddr)
|
* [extaddr](#extaddr)
|
||||||
* [extpanid](#extpanid)
|
* [extpanid](#extpanid)
|
||||||
|
* [factoryreset](#factoryreset)
|
||||||
* [hashmacaddr](#hashmacaddr)
|
* [hashmacaddr](#hashmacaddr)
|
||||||
* [ifconfig](#ifconfig)
|
* [ifconfig](#ifconfig)
|
||||||
* [ipaddr](#ipaddr)
|
* [ipaddr](#ipaddr)
|
||||||
@@ -711,6 +712,13 @@ Set the Thread Extended PAN ID value.
|
|||||||
Done
|
Done
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### factoryreset
|
||||||
|
Delete all stored settings, and signal a platform reset.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
> factoryreset
|
||||||
|
```
|
||||||
|
|
||||||
### hashmacaddr
|
### hashmacaddr
|
||||||
|
|
||||||
Get the HashMac address.
|
Get the HashMac address.
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ const struct Command Interpreter::sCommands[] =
|
|||||||
#endif
|
#endif
|
||||||
{ "extaddr", &Interpreter::ProcessExtAddress },
|
{ "extaddr", &Interpreter::ProcessExtAddress },
|
||||||
{ "extpanid", &Interpreter::ProcessExtPanId },
|
{ "extpanid", &Interpreter::ProcessExtPanId },
|
||||||
|
{ "factoryreset", &Interpreter::ProcessFactoryReset },
|
||||||
{ "hashmacaddr", &Interpreter::ProcessHashMacAddress },
|
{ "hashmacaddr", &Interpreter::ProcessHashMacAddress },
|
||||||
{ "ifconfig", &Interpreter::ProcessIfconfig },
|
{ "ifconfig", &Interpreter::ProcessIfconfig },
|
||||||
{ "ipaddr", &Interpreter::ProcessIpAddr },
|
{ "ipaddr", &Interpreter::ProcessIpAddr },
|
||||||
@@ -650,6 +651,13 @@ exit:
|
|||||||
AppendResult(error);
|
AppendResult(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Interpreter::ProcessFactoryReset(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
otFactoryReset(mInstance);
|
||||||
|
(void)argc;
|
||||||
|
(void)argv;
|
||||||
|
}
|
||||||
|
|
||||||
void Interpreter::ProcessHashMacAddress(int argc, char *argv[])
|
void Interpreter::ProcessHashMacAddress(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
ThreadError error = kThreadError_None;
|
ThreadError error = kThreadError_None;
|
||||||
|
|||||||
@@ -160,6 +160,7 @@ private:
|
|||||||
#endif
|
#endif
|
||||||
void ProcessExtAddress(int argc, char *argv[]);
|
void ProcessExtAddress(int argc, char *argv[]);
|
||||||
void ProcessExtPanId(int argc, char *argv[]);
|
void ProcessExtPanId(int argc, char *argv[]);
|
||||||
|
void ProcessFactoryReset(int argc, char *argv[]);
|
||||||
void ProcessHashMacAddress(int argc, char *argv[]);
|
void ProcessHashMacAddress(int argc, char *argv[]);
|
||||||
void ProcessIfconfig(int argc, char *argv[]);
|
void ProcessIfconfig(int argc, char *argv[]);
|
||||||
void ProcessIpAddr(int argc, char *argv[]);
|
void ProcessIpAddr(int argc, char *argv[]);
|
||||||
|
|||||||
@@ -691,6 +691,12 @@ void otPlatformReset(otInstance *aInstance)
|
|||||||
otPlatReset(aInstance);
|
otPlatReset(aInstance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void otFactoryReset(otInstance *aInstance)
|
||||||
|
{
|
||||||
|
otPlatSettingsWipe(aInstance);
|
||||||
|
otPlatReset(aInstance);
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t otGetRouterDowngradeThreshold(otInstance *aInstance)
|
uint8_t otGetRouterDowngradeThreshold(otInstance *aInstance)
|
||||||
{
|
{
|
||||||
return aInstance->mThreadNetif.GetMle().GetRouterDowngradeThreshold();
|
return aInstance->mThreadNetif.GetMle().GetRouterDowngradeThreshold();
|
||||||
|
|||||||
@@ -1103,7 +1103,9 @@ class ARM(IThci):
|
|||||||
"""power down the Thread device"""
|
"""power down the Thread device"""
|
||||||
print '%s call powerDown' % self.port
|
print '%s call powerDown' % self.port
|
||||||
self.isPowerDown = True
|
self.isPowerDown = True
|
||||||
self.reset()
|
self._sendline('reset')
|
||||||
|
time.sleep(3)
|
||||||
|
self.setMAC(self.mac)
|
||||||
|
|
||||||
def powerUp(self):
|
def powerUp(self):
|
||||||
"""power up the Thread device"""
|
"""power up the Thread device"""
|
||||||
@@ -1225,7 +1227,7 @@ class ARM(IThci):
|
|||||||
"""factory reset"""
|
"""factory reset"""
|
||||||
print '%s call reset' % self.port
|
print '%s call reset' % self.port
|
||||||
try:
|
try:
|
||||||
self._sendline('reset')
|
self._sendline('factoryreset')
|
||||||
self._read()
|
self._read()
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
ModuleHelper.WriteIntoDebugLogger("reset() Error: " + str(e))
|
ModuleHelper.WriteIntoDebugLogger("reset() Error: " + str(e))
|
||||||
@@ -2211,10 +2213,6 @@ class ARM(IThci):
|
|||||||
cmd += ' panid '
|
cmd += ' panid '
|
||||||
cmd += str(xPanId)
|
cmd += str(xPanId)
|
||||||
|
|
||||||
if xDelayTimer != None:
|
|
||||||
cmd += ' delay '
|
|
||||||
cmd += str(xDelayTimer)
|
|
||||||
|
|
||||||
if listChannelMask != None:
|
if listChannelMask != None:
|
||||||
cmd += ' channelmask '
|
cmd += ' channelmask '
|
||||||
cmd += str(hex(1 << listChannelMask[1]))
|
cmd += str(hex(1 << listChannelMask[1]))
|
||||||
|
|||||||
Reference in New Issue
Block a user