mirror of
https://github.com/espressif/openthread.git
synced 2026-08-24 03:09:52 +00:00
[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:
committed by
Jonathan Hui
parent
1545b0d658
commit
ccb354fb31
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user