BeeeOn Gateway  v2020.3.1-2-g6f737dc
Platform to interconnect the IoT world
IQRFDevice.h
1 #pragma once
2 
3 #include <list>
4 #include <string>
5 
6 #include <Poco/SharedPtr.h>
7 #include <Poco/Timespan.h>
8 
9 #include "core/PollableDevice.h"
10 #include "iqrf/DPAMessage.h"
11 #include "iqrf/DPAProtocol.h"
12 #include "iqrf/IQRFEventFirer.h"
13 #include "iqrf/IQRFMqttConnector.h"
14 #include "model/DeviceID.h"
15 #include "model/ModuleType.h"
16 #include "model/RefreshTime.h"
17 #include "util/Loggable.h"
18 
19 namespace BeeeOn {
20 
32 public:
33  typedef Poco::SharedPtr<IQRFDevice> Ptr;
34 
35  IQRFDevice(
36  IQRFMqttConnector::Ptr connector,
37  const Poco::Timespan &receiveTimeout,
38  DPAMessage::NetworkAddress address,
39  DPAProtocol::Ptr protocol,
40  const RefreshTime &refreshTime,
41  const RefreshTime &refreshTimePeripheralInfo,
42  IQRFEventFirer::Ptr eventFirer);
43 
47  DPAMessage::NetworkAddress networkAddress() const;
48 
52  uint32_t mid() const;
53 
57  DPAProtocol::Ptr protocol() const;
58 
64  std::list<ModuleType> modules() const;
65 
70  uint16_t HWPID() const;
71  void setHWPID(uint16_t HWPID);
72 
81  DeviceID id() const override;
82 
83  std::string vendorName() const;
84  std::string productName() const;
85 
86  RefreshTime refresh() const override;
87  void poll(Distributor::Ptr distributor) override;
88 
89 
94  std::string toString() const;
95 
99  void probe(const Poco::Timespan &methodTimeout);
100 
105 
111 
112 private:
117  uint16_t detectNodeHWPID(const Poco::Timespan &methodTimeout);
118 
124  uint32_t detectMID(const Poco::Timespan &methodTimeout);
125 
131  std::list<ModuleType> detectModules(
132  const Poco::Timespan &methodTimeout);
133 
139  DPAProtocol::ProductInfo detectProductInfo(
140  const Poco::Timespan &methodTimeout);
141 
142  ModuleID batteryModuleID() const;
143  ModuleID rssiModuleID() const;
144 
145 private:
146  IQRFMqttConnector::Ptr m_connector;
147  Poco::Timespan m_receiveTimeout;
148  DPAMessage::NetworkAddress m_address;
149  DPAProtocol::Ptr m_protocol;
150  RefreshTime m_refreshTime;
151  RefreshTime m_refreshTimePeripheralInfo;
152 
153  mutable Poco::Timespan m_remainingValueTime;
154  mutable Poco::Timespan m_remainingPeripheralInfoTime;
155  mutable Poco::Timespan m_remaining;
156 
157  uint32_t m_mid;
158  std::list<ModuleType> m_modules;
159  uint16_t m_HWPID;
160  std::string m_vendorName;
161  std::string m_productName;
162 
163  IQRFEventFirer::Ptr m_eventFirer;
164 };
165 
166 }
void probe(const Poco::Timespan &methodTimeout)
Probes information about IQRF device in a network.
Definition: IQRFDevice.cpp:142
Vendor and product name for each paired device. It can be filled from IQRF repository or statically f...
Definition: DPAProtocol.h:29
RefreshTime represents time of refreshing values from sensors. E.g. sensors are polled periodically o...
Definition: RefreshTime.h:24
void poll(Distributor::Ptr distributor) override
Perform polling for data and ship them via the given distributor.
Definition: IQRFDevice.cpp:330
Definition: SensorData.h:20
SensorData obtainPeripheralInfo()
Definition: IQRFDevice.cpp:298
IQRFDevice represents information about a particular device from the IQRF network. Each IQRF device is identified by network address. Network address is a unique identifier in IQRF network. Each IQRF device has IQRF transceiver. The MID (Module ID) is globally unique. Each IQRF device can communicate using own or general protocol.
Definition: IQRFDevice.h:31
std::string toString() const
Converts all device parameters into one string for easy viewing.
Definition: IQRFDevice.cpp:98
RefreshTime refresh() const override
Regular period telling how often to call the method PollableDevice::poll(). The refresh must contain ...
Definition: IQRFDevice.cpp:325
std::list< ModuleType > modules() const
Supported modules on the device.
Definition: IQRFDevice.cpp:49
DPAProtocol::Ptr protocol() const
Protocol that communicates with the coordinator.
Definition: IQRFDevice.cpp:54
Definition: ModuleID.h:12
uint32_t mid() const
Definition: IQRFDevice.cpp:44
Definition: Loggable.h:19
DeviceID id() const override
Definition: IQRFDevice.cpp:69
SensorData obtainValues()
Definition: IQRFDevice.cpp:271
DPAMessage::NetworkAddress networkAddress() const
Definition: IQRFDevice.cpp:39
uint16_t HWPID() const
Identification of node in the IQRF repository. Device name and manufacturer can be obtained on the ba...
Definition: IQRFDevice.cpp:59
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