int main(int argc, char *argv[]) { otInstance *instance; #if OPENTHREAD_EXAMPLES_POSIX if (setjmp(gResetJump)) { alarm(0); #if OPENTHREAD_ENABLE_COVERAGE __gcov_flush(); #endif execvp(argv[0], argv); } #endif #if OPENTHREAD_ENABLE_MULTIPLE_INSTANCES size_t otInstanceBufferLength = 0; uint8_t *otInstanceBuffer = NULL; #endif pseudo_reset: otSysInit(argc, argv); #if OPENTHREAD_ENABLE_MULTIPLE_INSTANCES // Call to query the buffer size (void)otInstanceInit(NULL, &otInstanceBufferLength); // Call to allocate the buffer otInstanceBuffer = (uint8_t *)malloc(otInstanceBufferLength); assert(otInstanceBuffer); // Initialize OpenThread with the buffer instance = otInstanceInit(otInstanceBuffer, &otInstanceBufferLength); #else instance = otInstanceInitSingle(); #endif assert(instance); otNcpInit(instance); #if OPENTHREAD_ENABLE_DIAG otDiagInit(instance); #endif while (!otSysPseudoResetWasRequested()) { otTaskletsProcess(instance); otSysProcessDrivers(instance); } otInstanceFinalize(instance); #if OPENTHREAD_ENABLE_MULTIPLE_INSTANCES free(otInstanceBuffer); #endif goto pseudo_reset; return 0; }
int main(int argc, char *argv[]) { PlatformInit(argc, argv); otEnable(); otNcpInit(); while (1) { otProcessNextTasklet(); PlatformProcessDrivers(); } return 0; }
int main(int argc, char *argv[]) { otInstance *sInstance; #if OPENTHREAD_ENABLE_MULTIPLE_INSTANCES size_t otInstanceBufferLength = 0; uint8_t *otInstanceBuffer = NULL; #endif pseudo_reset: PlatformInit(argc, argv); #if OPENTHREAD_ENABLE_MULTIPLE_INSTANCES // Call to query the buffer size (void)otInstanceInit(NULL, &otInstanceBufferLength); // Call to allocate the buffer otInstanceBuffer = (uint8_t *)malloc(otInstanceBufferLength); assert(otInstanceBuffer); // Initialize OpenThread with the buffer sInstance = otInstanceInit(otInstanceBuffer, &otInstanceBufferLength); #else sInstance = otInstanceInitSingle(); #endif assert(sInstance); otNcpInit(sInstance); #if OPENTHREAD_ENABLE_DIAG otDiagInit(sInstance); #endif while (!PlatformPseudoResetWasRequested()) { otTaskletsProcess(sInstance); PlatformProcessDrivers(sInstance); } otInstanceFinalize(sInstance); #if OPENTHREAD_ENABLE_MULTIPLE_INSTANCES free(otInstanceBuffer); #endif goto pseudo_reset; return 0; }