From a5e0d599dee25c3d7c29c0875486769e299c8ebb Mon Sep 17 00:00:00 2001 From: Nick Banks Date: Tue, 7 Feb 2017 17:01:24 -0800 Subject: [PATCH] Retry otInstanceInit multiple times in otNodeInit (#1271) --- examples/drivers/windows/otNodeApi/otNodeApi.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/examples/drivers/windows/otNodeApi/otNodeApi.cpp b/examples/drivers/windows/otNodeApi/otNodeApi.cpp index 2d3c403b5..6bc22ce16 100644 --- a/examples/drivers/windows/otNodeApi/otNodeApi.cpp +++ b/examples/drivers/windows/otNodeApi/otNodeApi.cpp @@ -766,8 +766,17 @@ OTNODEAPI otNode* OTCALL otNodeInit(uint32_t id) otvmpRemoveVirtualBus(gVmpHandle, newBusIndex); return nullptr; } - - auto instance = otInstanceInit(ApiInstance, &ifGuid); + + // Try multiple times to instantiate the otInstance, as the MP comes up first + // and the LWF driver might not be ready immedaitely. + tries = 0; + otInstance *instance = nullptr; + do + { + if (tries != 0) Sleep(100); + instance = otInstanceInit(ApiInstance, &ifGuid); + } while (instance == nullptr && ++tries <= 30); + if (instance == nullptr) { printf("otInstanceInit failed!\r\n");