Skip to content

Commit e815be3

Browse files
committed
CordioHCILoop: properly terminate bleLoop thread
Fixes arduino-libraries#65
1 parent 3b228dc commit e815be3

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/utility/HCICordioTransport.cpp

Lines changed: 10 additions & 3 deletions
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy