[examples] Introducing pseudo resets (#2621)

Pseudo resets allow for `otPlatReset()` to reset the OpenThread state
without resetting the chip. This is important if the SoC is presenting
itself as a USB device.

The build option `OPENTHREAD_PLATFORM_USE_PSEUDO_RESET` can be used to
force this feature to be enabled or disabled by setting it to `1` or
`0` accordingly. Otherwise it will be set to a platform-specified
default value.
This commit is contained in:
Robert Quattlebaum
2018-03-15 20:53:49 +00:00
committed by Jonathan Hui
parent 1545b0d658
commit ccb354fb31
19 changed files with 147 additions and 12 deletions
+7 -3
View File
@@ -63,6 +63,8 @@ int main(int argc, char *argv[])
uint8_t *otInstanceBuffer = NULL;
#endif
pseudo_reset:
PlatformInit(argc, argv);
#if OPENTHREAD_ENABLE_MULTIPLE_INSTANCES
@@ -86,17 +88,19 @@ int main(int argc, char *argv[])
otDiagInit(sInstance);
#endif
while (1)
while (!PlatformPseudoResetWasRequested())
{
otTaskletsProcess(sInstance);
PlatformProcessDrivers(sInstance);
}
// otInstanceFinalize(sInstance);
otInstanceFinalize(sInstance);
#if OPENTHREAD_ENABLE_MULTIPLE_INSTANCES
// free(otInstanceBuffer);
free(otInstanceBuffer);
#endif
goto pseudo_reset;
return 0;
}