EnOcean Link  1.14.0.0
Middleware to Connect EnOcean easily to other Projects
eoGateway.h
Go to the documentation of this file.
1 /******************************************************************************
2  DISCLAIMER
3 
4  THIS SOFTWARE PRODUCT ("SOFTWARE") IS PROPRIETARY TO ENOCEAN GMBH, OBERHACHING,
5  GERMANY (THE "OWNER") AND IS PROTECTED BY COPYRIGHT AND INTERNATIONAL TREATIES OR
6  PROTECTED AS TRADE SECRET OR AS OTHER INTELLECTUAL PROPERTY RIGHT. ALL RIGHTS, TITLE AND
7  INTEREST IN AND TO THE SOFTWARE, INCLUDING ANY COPYRIGHT, TRADE SECRET OR ANY OTHER
8  INTELLECTUAL PROPERTY EMBODIED IN THE SOFTWARE, AND ANY RIGHTS TO REPRODUCE,
9  DISTRIBUTE, MODIFY, DISPLAY OR OTHERWISE USE THE SOFTWARE SHALL EXCLUSIVELY VEST IN THE
10  OWNER. ANY UNAUTHORIZED REPRODUCTION, DISTRIBUTION, MODIFICATION, DISPLAY OR OTHER
11  USE OF THE SOFTWARE WITHOUT THE EXPLICIT PERMISSION OF OWNER IS PROHIBITED AND WILL
12  CONSTITUTE AN INFRINGEMENT OF THE OWNER'S RIGHT AND MAY BE SUBJECT TO CIVIL OR
13  CRIMINAL SANCTION.
14 
15  THIS SOFTWARE IS PROVIDED BY THE OWNER "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
16  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
17  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN PARTICULAR, THE OWNER DOES NOT WARRANT
18  THAT THE SOFTWARE SHALL BE ERROR FREE AND WORKS WITHOUT INTERRUPTION.
19 
20  IN NO EVENT SHALL THE OWNER BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  ******************************************************************************/
27 
33 #if !defined(_EO_GATEWAY_H)
34 #define _EO_GATEWAY_H
35 
36 #include "eoHalTypes.h"
37 #include "eoApiDef.h"
38 #include "eoISerialize.h"
39 #include "eoMessage.h"
40 #include "eoTelegram.h"
41 #include "eoTelegramERP2.h"
42 #include "eoDevice.h"
43 #include "eoIFilter.h"
44 #include "eoPacketStream.h"
45 #include "eoDeviceManager.h"
46 #include "eoMessageHandler.h"
47 #include "eoSecurity.h"
48 #include "eoProfileFactory.h"
49 #include "eoTeachInModule.h"
50 #include "eoReManMessage.h"
51 #include "eoMaintenanceMessage.h"
52 #include "eoSerialCommand.h"
53 #include "eoIWatcher.h"
54 #include <queue>
55 
62 typedef enum
63 {
65  RECV_PACKET = (1 << 0),
66  RECV_TELEGRAM = (1 << 1),
68  RECV_MESSAGE = (1 << 2),
70  RECV_TEACHIN = (1 << 3),
72  RECV_PROFILE = (1 << 4),
74  RECV_TELEGRAM_SEC = (1 << 5),
76  RECV_ERROR = (1 << 6),
78  RECV_DEVICE_ADDED = (1 << 7),
80  RECV_SECTEACHIN = (1 << 8),
82  RECV_REMAN = (1 << 9),
84  RECV_TELEGRAM_ERP2 = (1 << 10),
86  RECV_MAINTENANCE = (1 << 11),
139 class eoGateway: public eoISerialize
140 {
141 public:
143  inline void LearnModeOn()
144  {
145  LearnMode = true;
146  }
148  inline void LearnModeOff()
149  {
150  LearnMode = false;
151  }
167  uint32_t GetSecWatchResult() const
168  {
169  return secWatchResult;
170  }
172  bool LearnMode;
174  uint8_t errorCode;
198  eoGateway();
203  eoGateway(eoDeviceManager *devManager);
214  eoGateway(eoPacketStream *str, eoDeviceManager *devManager);
215 
223  eoGateway(eoPacketStream *str, eoDeviceManager *devManager, eoIFilter * normFilter, eoIFilter * lrnFilter);
224 
225  virtual ~eoGateway();
251  uint16_t Receive();
252 
260  virtual eoReturn Send(const eoPacket &p);
266  virtual eoReturn Send(const eoMessage &msg);
274  virtual eoReturn Send(const eoReManMessage &reMsg,bool shallBeRepeated=false,uint8_t keyToUse=0);
281  virtual eoReturn Send(const eoMaintenanceMessage &manMsg);
287  eoReturn Open(const char *port);
288 
294  void Close();
295  uint8_t Serialize(eoArchive &arch);
296 
297 private:
298  void defaultConstructor();
299 
300  eoMessageHandler msgHandler;
301 
302  uint16_t flags;
303  uint32_t secWatchResult;
304 
305  std::deque<eoPacket*> packet_queue;
306 
307  eoReturn learnHandler(eoTelegram &recvTelegram); //Handles received telegram in learnMode
308  eoReturn secHandler(eoTelegram &recvTelegram); //Handles secure telegram
309  eoReturn secHandler(eoMessage &recvTelegram); //Handles secure telegram
310  eoReturn normalHandler(eoTelegram &recvTelegram); //Handles received telegram in normalMode
311 
312  //helper
313  eoReturn handleSysEx(eoTelegram &recvTelegram);
314  eoReturn handleMaintenance(eoTelegram &recvTelegram);
315  eoReturn handleTelegramInLearn(eoTelegram &recvTelegram);
316  eoReturn handleTelegramNormal(eoTelegram &recvTelegram);
317 };
320 #endif // !defined(_EO_GATEWAY_H)
void LearnModeOn()
Activates Learn Mode.
Definition: eoGateway.h:143
The minimal Interface for an eoWatcher class.
Definition: eoIWatcher.h:28
Receiver got second teachIN.
Definition: eoGateway.h:81
contains Dolphin API Definitions
Received a Maintenance Message.
Definition: eoGateway.h:87
eoReManMessage reManMessage
received Remote Management Message
Definition: eoGateway.h:190
Interface for storing.
Definition: eoISerialize.h:48
eoIWatcher * secWatcher
security Watcher to Use
Definition: eoGateway.h:165
Definition: eoMessageHandler.h:55
eoDeviceManager * deviceManager
Pointer to the device manager, handling your Devices.
Definition: eoGateway.h:157
every Communication from an EnOcean Device to another one consist out of one more Telegrams...
Definition: eoTelegram.h:43
uint16_t Receive()
Handles received Telegrams.
a class to describe an EnOcean Device
Definition: eoDevice.h:49
eoMaintenanceMessage maintenanceMessage
received Maintenance Message
Definition: eoGateway.h:188
eoTelegram telegram
received Telegram
Definition: eoGateway.h:182
Manages the devices.
Definition: eoDeviceManager.h:51
Message Class for communication.
Definition: eoMessage.h:47
Receiver Remote Management MEssage.
Definition: eoGateway.h:83
RECEIVE_FLAGS
Definition: eoGateway.h:62
eoSecurity security
Security handler for the gateway.
Definition: eoGateway.h:290
The maintenance message class, these messages represent an EnOcean maintenance message.
Definition: eoMaintenanceMessage.h:56
EnOcean Common Commands class, enables an easy interface for the most common commands.
Definition: eoSerialCommand.h:473
void LearnModeOff()
Deactivates Learn Mode.
Definition: eoGateway.h:148
every Communication from an EnOcean Device to another one consist out of one more Telegrams...
Definition: eoTelegramERP2.h:56
uint8_t Serialize(eoArchive &arch)
Serialization Function which will be called by the eoStorageManager.
Received a Message.
Definition: eoGateway.h:69
eoPacket packet
received Packet data
Definition: eoGateway.h:178
uint32_t GetSecWatchResult() const
Returns the security Result of the eoIWatcher Interface.
Definition: eoGateway.h:167
Received Secured Telegram.
Definition: eoGateway.h:75
Received Package.
Definition: eoGateway.h:65
uint8_t errorCode
contains the last Error Code from the receive function
Definition: eoGateway.h:174
eoReturn Open(const char *port)
eoDeviceManager
Receiver Device Added.
Definition: eoGateway.h:79
eoIFilter
Received Teach in Telegram.
Definition: eoGateway.h:71
Watcher Header File.
eoReturn
contains all the return values from different functions
Definition: eoApiDef.h:40
Filter Interface.
Definition: eoIFilter.h:62
EnOcean Gateway class, for handling a gateway Module.
Definition: eoGateway.h:139
eoSerialCommand commands
Common Commands.
Definition: eoGateway.h:192
The base class for all PacketStreams Implementations.
Definition: eoPacketStream.h:58
virtual eoReturn Send(const eoPacket &p)
bool LearnMode
When true, activates LearnMode until set to False.
Definition: eoGateway.h:172
eoIFilter * learnFilter
Definition: eoGateway.h:163
eoMessage message
received Message
Definition: eoGateway.h:186
eoTeachInModule * TeachInModule
Pointer to eoTeachInModule.
Definition: eoGateway.h:155
handles EnOcean Security Telegrams
Definition: eoSecurity.h:53
eoDevice * device
Pointer to the device, to which the last received Telegram belongs.
Definition: eoGateway.h:176
handles TeachIn Messages
Definition: eoTeachInModule.h:97
eoDevice
eoTelegramERP2 telegramERP2
received Telegram
Definition: eoGateway.h:184
Received Error Telegram.
Definition: eoGateway.h:77
Class which contains a Packet.
Definition: eoPacket.h:43
eoPacket responsePacket
Response Packet after sending any sort of Packet/Message/Telegram with the Gateway.
Definition: eoGateway.h:180
Received a ERP2 Telegram.
Definition: eoGateway.h:85
eoIFilter * filter
Definition: eoGateway.h:160
Definition: eoReManMessage.h:43
eoPacketStream * stream
Pointer to the eoPacketStream Handler.
Definition: eoGateway.h:153
eoSerialCommand
bool advancedMode
ERP2 mode turned on.
Definition: eoGateway.h:194
Received Telegram.
Definition: eoGateway.h:67
the base Archive
Definition: eoArchive.h:46
Received Telegram containing learn_in Profile Information.
Definition: eoGateway.h:73
void Close()