Skip to content

Commit 1768462

Browse files
authored
Merge pull request #92 from facchinm/cordio_begin_again
CordioHCILoop: properly terminate bleLoop thread
2 parents 693268d + e815be3 commit 1768462

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/utility/HCICordioTransport.cpp

+10-3
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ static void bleLoop()
162162
}
163163

164164
static rtos::EventFlags bleEventFlags;
165-
static rtos::Thread bleLoopThread;
165+
static rtos::Thread* bleLoopThread = NULL;
166166

167167

168168
HCICordioTransportClass::HCICordioTransportClass() :
@@ -186,7 +186,10 @@ int HCICordioTransportClass::begin()
186186
CordioHCIHook::getDriver().initialize();
187187
CordioHCIHook::getDriver().start_reset_sequence();
188188

189-
bleLoopThread.start(bleLoop);
189+
if (bleLoopThread == NULL) {
190+
bleLoopThread = new rtos::Thread();
191+
bleLoopThread->start(bleLoop);
192+
}
190193

191194
CordioHCIHook::setDataReceivedHandler(HCICordioTransportClass::onDataReceived);
192195

@@ -197,7 +200,11 @@ int HCICordioTransportClass::begin()
197200

198201
void HCICordioTransportClass::end()
199202
{
200-
bleLoopThread.terminate();
203+
if (bleLoopThread != NULL) {
204+
bleLoopThread->terminate();
205+
delete bleLoopThread;
206+
bleLoopThread = NULL;
207+
}
201208

202209
CordioHCIHook::getDriver().terminate();
203210

0 commit comments

Comments
 (0)