BeeeOn Gateway  v2020.3.1-2-g6f737dc
Platform to interconnect the IoT world
HciInfoReporter.h
1 #pragma once
2 
3 #include <set>
4 #include <string>
5 
6 #include <Poco/Mutex.h>
7 #include <Poco/Timespan.h>
8 
9 #include "bluetooth/HciListener.h"
10 #include "bluetooth/HciInterface.h"
11 #include "hotplug/HotplugListener.h"
12 #include "loop/StoppableLoop.h"
13 #include "util/EventSource.h"
14 #include "util/Loggable.h"
15 #include "util/PeriodicRunner.h"
16 
17 namespace BeeeOn {
18 
31  public StoppableLoop,
32  public HotplugListener,
33  Loggable {
34 public:
36 
40  void setStatisticsInterval(const Poco::Timespan &interval);
41 
45  void setHciManager(HciInterfaceManager::Ptr manager);
46 
50  void setEventsExecutor(AsyncExecutor::Ptr executor);
51 
55  void registerListener(HciListener::Ptr listener);
56 
64  void onAdd(const HotplugEvent &event) override;
65 
72  void onRemove(const HotplugEvent &event) override;
73 
77  void start() override;
78 
82  void stop() override;
83 
84 protected:
85  std::set<std::string> dongles() const;
86 
87 private:
88  std::set<std::string> m_dongles;
89  HciInterfaceManager::Ptr m_hciManager;
90  PeriodicRunner m_statisticsRunner;
91  EventSource<HciListener> m_eventSource;
92  mutable Poco::FastMutex m_lock;
93 };
94 
95 }
Definition: HotplugListener.h:9
void setHciManager(HciInterfaceManager::Ptr manager)
Definition: HciInfoReporter.cpp:33
Executes some function periodacally based on the given interval.
Definition: PeriodicRunner.h:18
HciInfoReporter periodically collects and reports statistics information about HCI interfaces in the ...
Definition: HciInfoReporter.h:30
EventSource implements common logic for firing events to listeners.
Definition: EventSource.h:24
void start() override
Start the periodic reporting loop.
Definition: HciInfoReporter.cpp:82
Definition: StoppableLoop.h:17
void registerListener(HciListener::Ptr listener)
Definition: HciInfoReporter.cpp:43
void setEventsExecutor(AsyncExecutor::Ptr executor)
Definition: HciInfoReporter.cpp:38
void onAdd(const HotplugEvent &event) override
Check the given event whether it is a bluetooth controller. Every matching controller is added to the...
Definition: HciInfoReporter.cpp:48
Definition: HotplugEvent.h:10
Definition: Loggable.h:19
void stop() override
Stop the periodic reporting loop.
Definition: HciInfoReporter.cpp:103
void onRemove(const HotplugEvent &event) override
Check the given event whether it is a bluetooth controller. The method allows to unplug a device and ...
Definition: HciInfoReporter.cpp:65
void setStatisticsInterval(const Poco::Timespan &interval)
Definition: HciInfoReporter.cpp:25