Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/utility/HCICordioTransport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ static void bleLoop()
}

static rtos::EventFlags bleEventFlags;
static rtos::Thread bleLoopThread;
static rtos::Thread* bleLoopThread = NULL;


HCICordioTransportClass::HCICordioTransportClass() :
Expand All @@ -186,7 +186,10 @@ int HCICordioTransportClass::begin()
CordioHCIHook::getDriver().initialize();
CordioHCIHook::getDriver().start_reset_sequence();

bleLoopThread.start(bleLoop);
if (bleLoopThread == NULL) {
bleLoopThread = new rtos::Thread();
bleLoopThread->start(bleLoop);
}

CordioHCIHook::setDataReceivedHandler(HCICordioTransportClass::onDataReceived);

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

void HCICordioTransportClass::end()
{
bleLoopThread.terminate();
if (bleLoopThread != NULL) {
bleLoopThread->terminate();
delete bleLoopThread;
bleLoopThread = NULL;
}

CordioHCIHook::getDriver().terminate();

Expand Down