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 "modbus/mb.h"
9#include "modbus/mbport.h"
10#include "nimble/nimble_port.h"
11
12using namespace dawn;
13
14void CProtoNimbleHost::thread()
15{
16 DAWNINFO("start Host thread\n");
17
18 // Handle NimBLE Host task
19
20#ifdef CONFIG_DAWN_PROTO_NIMBLE_DUMMY
21 do
22 {
23 sleep(1);
24 }
25 while (!threadCtl.shouldQuit());
26#else
27 nimble_port_run();
28#endif
29
30 // Clean thread
31
32 DAWNINFO("clean Host thread\n");
33}
34
35void CProtoNimbleHost::start()
36{
37 threadCtl.setThreadFunc([this]() { thread(); });
38 threadCtl.threadStart();
39}
40
41void CProtoNimbleHost::stop()
42{
43 // Stop host
44
45#ifdef CONFIG_DAWN_PROTO_NIMBLE_DUMMY
46 threadCtl.requestStop();
47#else
48 // Upstream NimBLE has no clean host shutdown API; clean stop is only
49 // supported with CONFIG_DAWN_PROTO_NIMBLE_DUMMY.
50
51 DAWNERR("nimble host stop not supported on real backend\n");
52#endif
53
54 // Wait for thread exit
55
56 threadCtl.threadStop();
57}
58
59bool CProtoNimbleHost::isRunning() const
60{
61 return threadCtl.isRunning();
62}
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