BeeeOn Gateway  v2020.3.1-2-g6f737dc
Platform to interconnect the IoT world
BLESmartDevice.h
1 #pragma once
2 
3 #include <list>
4 #include <string>
5 #include <vector>
6 
7 #include <Poco/SharedPtr.h>
8 #include <Poco/SynchronizedObject.h>
9 #include <Poco/Timespan.h>
10 
11 #include "bluetooth/HciInterface.h"
12 #include "core/PollableDevice.h"
13 #include "model/DeviceID.h"
14 #include "model/ModuleID.h"
15 #include "model/ModuleType.h"
16 #include "model/RefreshTime.h"
17 #include "model/SensorData.h"
18 #include "net/MACAddress.h"
19 #include "util/Loggable.h"
20 
21 namespace BeeeOn {
22 
27  public PollableDevice,
28  protected Poco::SynchronizedObject,
29  protected Loggable {
30 public:
31  typedef Poco::SharedPtr<BLESmartDevice> Ptr;
32 
39  const MACAddress& address,
40  const Poco::Timespan& timeout,
41  const RefreshTime& refresh,
42  const HciInterface::Ptr hci);
43  virtual ~BLESmartDevice();
44 
45  DeviceID id() const override;
46  RefreshTime refresh() const override;
47  MACAddress macAddress() const;
48 
49  virtual std::list<ModuleType> moduleTypes() const = 0;
50  virtual std::string productName() const = 0;
51  virtual std::string vendor() const = 0;
52 
59  virtual void pair(
60  Poco::SharedPtr<HciInterface::WatchCallback> callback);
61 
65  virtual bool pollable() const;
66 
67  void poll(Distributor::Ptr distributor) override;
68 
76  virtual void requestModifyState(
77  const ModuleID& moduleID,
78  const double value);
79 
87  const std::vector<unsigned char>& data) const;
88 
89 protected:
90  DeviceID m_deviceId;
91  MACAddress m_address;
92  Poco::Timespan m_timeout;
93  RefreshTime m_refresh;
94 
95  HciInterface::Ptr m_hci;
96 };
97 
98 }
virtual SensorData parseAdvertisingData(const std::vector< unsigned char > &data) const
Transforms advertising data to SensorData.
Definition: BLESmartDevice.cpp:62
virtual bool pollable() const
Returns true if the device is pollable, otherwise false.
Definition: BLESmartDevice.cpp:41
RefreshTime represents time of refreshing values from sensors. E.g. sensors are polled periodically o...
Definition: RefreshTime.h:24
virtual void requestModifyState(const ModuleID &moduleID, const double value)
Modifies the device module given by moduleID to a given value.
Definition: BLESmartDevice.cpp:55
Definition: SensorData.h:20
Definition: MACAddress.h:8
RefreshTime refresh() const override
Regular period telling how often to call the method PollableDevice::poll(). The refresh must contain ...
Definition: BLESmartDevice.cpp:31
Definition: ModuleID.h:12
Definition: Loggable.h:19
BLESmartDevice(const MACAddress &address, const Poco::Timespan &timeout, const RefreshTime &refresh, const HciInterface::Ptr hci)
Definition: BLESmartDevice.cpp:9
void poll(Distributor::Ptr distributor) override
Perform polling for data and ship them via the given distributor.
Definition: BLESmartDevice.cpp:51
DeviceID id() const override
Definition: BLESmartDevice.cpp:26
Abstract class representing generic Bluetooth Low Energy smart device.
Definition: BLESmartDevice.h:26
Definition: DeviceID.h:17
PollableDevice is a device that is necessary to poll regularly for data. The polling can take some ti...
Definition: PollableDevice.h:18
virtual void pair(Poco::SharedPtr< HciInterface::WatchCallback > callback)
When the device supports processing of advertising data, it should call a watch() on the given HciInt...
Definition: BLESmartDevice.cpp:46