Dawn Framework 1.0
Universal data acquisition framework for embedded systems
host.cxx
1// dawn/src/proto/nimble/host.cxx
2//
3// SPDX-License-Identifier: Apache-2.0
4//
5
6#include "dawn/proto/nimble/host.hxx"
7
8#include <unistd.h>
9
10#include "modbus/mb.h"
11#include "modbus/mbport.h"
12#include "nimble/nimble_port.h"
13
14using namespace dawn;
15
16void CProtoNimbleHost::thread()
17{
18 DAWNINFO("start Host thread\n");
19
20 // Handle NimBLE Host task
21
22#ifdef CONFIG_DAWN_PROTO_NIMBLE_DUMMY
23 do
24 {
25 sleep(1);
26 }
27 while (!threadCtl.shouldQuit());
28#else
29 nimble_port_run();
30#endif
31
32 // Clean thread
33
34 DAWNINFO("clean Host thread\n");
35}
36
37void CProtoNimbleHost::start()
38{
39 threadCtl.setThreadFunc([this]() { thread(); });
40 threadCtl.threadStart();
41}
42
43void CProtoNimbleHost::stop()
44{
45 // Stop host
46
47#ifdef CONFIG_DAWN_PROTO_NIMBLE_DUMMY
48 threadCtl.requestStop();
49#else
50 // Upstream NimBLE has no clean host shutdown API; clean stop is only
51 // supported with CONFIG_DAWN_PROTO_NIMBLE_DUMMY.
52
53 DAWNERR("nimble host stop not supported on real backend\n");
54#endif
55
56 // Wait for thread exit
57
58 threadCtl.threadStop();
59}
60
61bool CProtoNimbleHost::isRunning() const
62{
63 return threadCtl.isRunning();
64}
Out-of-tree user-extension hooks for Dawn.
Definition bindable.hxx:13