Dawn Framework 1.0
Universal data acquisition framework for embedded systems
hci.cxx
1// dawn/src/proto/nimble/hci.cxx
2//
3// SPDX-License-Identifier: Apache-2.0
4//
5
6#include "dawn/proto/nimble/hci.hxx"
7
8using namespace dawn;
9
10extern "C"
11{
12 void ble_hci_sock_ack_handler(void *param);
13};
14
15void CProtoNimbleHci::thread()
16{
17 DAWNINFO("start HCI thread\n");
18
19 // Handle NimBLE socket task
20
21#ifdef CONFIG_DAWN_PROTO_NIMBLE_DUMMY
22 do
23 {
24 sleep(1);
25 }
26 while (!threadCtl.shouldQuit());
27#else
28 ble_hci_sock_ack_handler(nullptr);
29#endif
30
31 // Clean thread
32
33 DAWNINFO("clean HCI thread\n");
34}
35
36void CProtoNimbleHci::start()
37{
38 threadCtl.setThreadFunc([this]() { thread(); });
39 threadCtl.threadStart();
40}
41
42void CProtoNimbleHci::stop()
43{
44 // Stop hci
45
46#ifdef CONFIG_DAWN_PROTO_NIMBLE_DUMMY
47 threadCtl.requestStop();
48#else
49 // Upstream NimBLE has no clean HCI shutdown API; clean stop is only
50 // supported with CONFIG_DAWN_PROTO_NIMBLE_DUMMY.
51
52 DAWNERR("nimble HCI stop not supported on real backend\n");
53#endif
54
55 // Wait for thread exit
56
57 threadCtl.threadStop();
58}
59
60bool CProtoNimbleHci::isRunning() const
61{
62 return threadCtl.isRunning();
63}
bool isRunning() const
Check if the worker thread is running.
Definition thread.cxx:256
int threadStop()
Stop the worker thread.
Definition thread.cxx:240
int threadStart()
Start the worker thread.
Definition thread.cxx:166
void setThreadFunc(Func &&func)
Assign the function executed by threadStart().
Definition thread.hxx:100
Out-of-tree user-extension hooks for Dawn.
Definition bindable.hxx:13