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
8#include <unistd.h>
9
10using namespace dawn;
11
12extern "C"
13{
14 void ble_hci_sock_ack_handler(void *param);
15};
16
17void CProtoNimbleHci::thread()
18{
19 DAWNINFO("start HCI thread\n");
20
21 // Handle NimBLE socket task
22
23#ifdef CONFIG_DAWN_PROTO_NIMBLE_DUMMY
24 do
25 {
26 sleep(1);
27 }
28 while (!threadCtl.shouldQuit());
29#else
30 ble_hci_sock_ack_handler(nullptr);
31#endif
32
33 // Clean thread
34
35 DAWNINFO("clean HCI thread\n");
36}
37
38void CProtoNimbleHci::start()
39{
40 threadCtl.setThreadFunc([this]() { thread(); });
41 threadCtl.threadStart();
42}
43
44void CProtoNimbleHci::stop()
45{
46 // Stop hci
47
48#ifdef CONFIG_DAWN_PROTO_NIMBLE_DUMMY
49 threadCtl.requestStop();
50#else
51 // Upstream NimBLE has no clean HCI shutdown API; clean stop is only
52 // supported with CONFIG_DAWN_PROTO_NIMBLE_DUMMY.
53
54 DAWNERR("nimble HCI stop not supported on real backend\n");
55#endif
56
57 // Wait for thread exit
58
59 threadCtl.threadStop();
60}
61
62bool CProtoNimbleHci::isRunning() const
63{
64 return threadCtl.isRunning();
65}
Out-of-tree user-extension hooks for Dawn.
Definition bindable.hxx:13