BeeeOn Gateway  v2020.3.1-2-g6f737dc
Platform to interconnect the IoT world
RevogiDevice.h
1 #pragma once
2 
3 #include <list>
4 #include <string>
5 #include <vector>
6 
7 #include <Poco/SharedPtr.h>
8 #include <Poco/Timespan.h>
9 #include <Poco/UUID.h>
10 
11 #include "bluetooth/BLESmartDevice.h"
12 #include "bluetooth/HciConnection.h"
13 #include "bluetooth/HciInterface.h"
14 #include "model/ModuleType.h"
15 #include "net/MACAddress.h"
16 
17 namespace BeeeOn {
18 
29 class RevogiDevice : public BLESmartDevice {
30 public:
31  typedef Poco::SharedPtr<RevogiDevice> Ptr;
32 
33 protected:
37  static const Poco::UUID ACTUAL_VALUES_GATT;
41  static const Poco::UUID WRITE_VALUES_GATT;
45  static const Poco::UUID UUID_DEVICE_NAME;
46  static const std::string VENDOR_NAME;
52  static const std::vector<unsigned char> NOTIFY_DATA;
53 
54 public:
56  const MACAddress& address,
57  const Poco::Timespan& timeout,
58  const RefreshTime& refresh,
59  const std::string& productName,
60  const std::list<ModuleType>& moduleTypes,
61  const HciInterface::Ptr hci);
62 
63  ~RevogiDevice();
64 
65  std::list<ModuleType> moduleTypes() const override;
66  std::string vendor() const override;
67  std::string productName() const override;
68 
69  bool pollable() const override;
70  void poll(Distributor::Ptr distributor) override;
71 
78  static bool match(const std::string& modelID);
79 
84  static RevogiDevice::Ptr createDevice(
85  const MACAddress& address,
86  const Poco::Timespan& timeout,
87  const RefreshTime& refresh,
88  const HciInterface::Ptr hci,
89  HciConnection::Ptr conn);
90 
91 protected:
95  virtual SensorData parseValues(const std::vector<unsigned char>& values) const = 0;
96 
101  void sendWriteRequest(
102  HciConnection::Ptr conn,
103  std::vector<unsigned char> payload,
104  const unsigned char checksum);
105 
106  virtual void prependHeader(std::vector<unsigned char>& payload) const = 0;
107  virtual void appendFooter(
108  std::vector<unsigned char>& payload,
109  const unsigned char checksum) const;
110 
111 private:
112  std::string m_productName;
113  std::list<ModuleType> m_moduleTypes;
114 };
115 
116 }
static const Poco::UUID UUID_DEVICE_NAME
Definition: RevogiDevice.h:45
RefreshTime represents time of refreshing values from sensors. E.g. sensors are polled periodically o...
Definition: RefreshTime.h:24
void sendWriteRequest(HciConnection::Ptr conn, std::vector< unsigned char > payload, const unsigned char checksum)
Prepends header and appends footer to payload and then sends it to device.
Definition: RevogiDevice.cpp:66
Definition: SensorData.h:20
static const Poco::UUID WRITE_VALUES_GATT
Definition: RevogiDevice.h:41
static const Poco::UUID ACTUAL_VALUES_GATT
Definition: RevogiDevice.h:37
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
static RevogiDevice::Ptr createDevice(const MACAddress &address, const Poco::Timespan &timeout, const RefreshTime &refresh, const HciInterface::Ptr hci, HciConnection::Ptr conn)
Creates Revogi device according to device name located in the vendor specific characteristic of the B...
Definition: RevogiDevice.cpp:90
static bool match(const std::string &modelID)
The method returns true if the model ID of the device may be model ID of some Revogi device...
Definition: RevogiDevice.cpp:85
static const std::vector< unsigned char > NOTIFY_DATA
Definition: RevogiDevice.h:52
Abstract class for Revogi devices.
Definition: RevogiDevice.h:29
bool pollable() const override
Returns true if the device is pollable, otherwise false.
Definition: RevogiDevice.cpp:50
Abstract class representing generic Bluetooth Low Energy smart device.
Definition: BLESmartDevice.h:26
virtual SensorData parseValues(const std::vector< unsigned char > &values) const =0
Convert actual setting of the device to SensorData.
void poll(Distributor::Ptr distributor) override
Perform polling for data and ship them via the given distributor.
Definition: RevogiDevice.cpp:55