BeeeOn Gateway  v2020.3.1-2-g6f737dc
Platform to interconnect the IoT world
BluezHciInterface.h
1 #pragma once
2 
3 #include <utility>
4 #include <vector>
5 
6 #include <Poco/Mutex.h>
7 
8 #include "bluetooth/HciInterface.h"
9 #include "util/Loggable.h"
10 
11 namespace BeeeOn {
12 
14 public:
15  BluezHciInterface(const std::string &name);
16 
17  void up() const override;
18  void reset() const override;
19  bool detect(const MACAddress &address) const override;
20  std::map<MACAddress, std::string> scan() const override;
21  std::map<MACAddress, std::string> lescan(
22  const Poco::Timespan &seconds) const override;
23  HciInfo info() const override;
24  HciConnection::Ptr connect(
25  const MACAddress& address,
26  const Poco::Timespan& timeout) const override;
27  void watch(
28  const MACAddress& address,
29  Poco::SharedPtr<WatchCallback> callBack) override;
30  void unwatch(const MACAddress& address) override;
31 
32 protected:
37  static std::string parseLEName(uint8_t *eir, size_t length);
38 
39 private:
44  int hciSocket() const;
45 
51  int findHci(const std::string &name) const;
52 
59  int findHci(int sock, const std::string &name) const;
60 
66  bool processNextEvent(const int &fd, std::map<MACAddress, std::string> &devices) const;
67 
76  std::map<MACAddress, std::string> listLE(
77  const int sock, const Poco::Timespan &seconds) const;
78 
79 private:
80  std::string m_name;
81 };
82 
84 public:
85  HciInterface::Ptr lookup(const std::string &name) override;
86 };
87 
88 }
Definition: HciInterface.h:87
std::map< MACAddress, std::string > scan() const override
Definition: BluezHciInterface.cpp:225
HciInfo info() const override
Definition: BluezHciInterface.cpp:279
bool detect(const MACAddress &address) const override
Definition: BluezHciInterface.cpp:192
Definition: BluezHciInterface.h:83
Definition: MACAddress.h:8
void unwatch(const MACAddress &address) override
Definition: BluezHciInterface.cpp:299
static std::string parseLEName(uint8_t *eir, size_t length)
Definition: BluezHciInterface.cpp:304
Definition: HciInfo.h:15
std::map< MACAddress, std::string > lescan(const Poco::Timespan &seconds) const override
Definition: BluezHciInterface.cpp:441
void up() const override
Definition: BluezHciInterface.cpp:164
HciConnection::Ptr connect(const MACAddress &address, const Poco::Timespan &timeout) const override
Definition: BluezHciInterface.cpp:285
void watch(const MACAddress &address, Poco::SharedPtr< WatchCallback > callBack) override
Definition: BluezHciInterface.cpp:292
Definition: Loggable.h:19
void reset() const override
Definition: BluezHciInterface.cpp:180
Definition: BluezHciInterface.h:13
Definition: HciInterface.h:16