EnOcean Link  1.14.0.0
Middleware to Connect EnOcean easily to other Projects
eoRemoteManager.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 #ifndef EO_REMOTE_MANAGER_H_
34 #define EO_REMOTE_MANAGER_H_
35 
36 
41 typedef enum
42 {
44  R_START_LEARN = 1, //Start learn
46  R_NEXT_CHANNEL, //Next channel
48  R_STOP_LEARN, //Stop learn
50  R_S_SIMPLE_LEARN, //SmartACK start simple learn mode
52  R_S_ADVANCED_LEARN, //SmartACK start advanced learn mode
54  R_S_STOP_LEARN //SmartACK stop learn
55 } REMOTE_TYPE;
56 
61 typedef enum
62 {
64  FN_UNLOCK = 0x001, //Unlock
66  FN_LOCK = 0x002, //Lock
68  FN_SETCODE = 0x003, //Set code
70  FN_QUERYID = 0x004, //Query ID
72  FN_QUERYID_ANSWER = 0x604, //Query ID answer
76  FN_ACTION = 0x005, //Action
78  FN_PING = 0x006, //Ping
80  FN_PING_ANSWER = 0x606, //Ping answer
82  FN_QUERY_FUNCTION = 0x007, //Query function
84  FN_QUERY_FUNCTION_ANSWER = 0x607, //Query function answer
86  FN_QUERY_STATUS = 0x008, //Query status
88  FN_QUERY_STATUS_ANSWER = 0x608, //Query status answer
96  FN_REMOTE_LEARNIN = 0x201, //Remote learn in
98  FN_REMOTE_FLASH_WRITE = 0x203, //Remote flash write
100  FN_REMOTE_FLASH_READ = 0x204, //Remote flash read
102  FN_REMOTE_FLASH_READ_ANSWER = 0x804, //Remote flash read answer
104  FN_SMARTACK_READ = 0x205, //SmartACK read
106  FN_SMARTACK_READ_MAILBOX_ANSWER = 0x805, //SmartACK read mailbox answer
108  FN_SMARTACK_READ_LEARNED_SENSOR_ANSWER = 0x806, //SmartACK read learned sensor answer
110  FN_SMARTACK_WRITE = 0x206 //SmartACK write
111 } FN_CODE;
112 
117 typedef struct
118 {
120  uint8_t rorg; //EEP RORG 8 bits
122  uint8_t func; //EEP Function 6 bits
124  uint8_t type; //EEP Type 7 bits
125 } QUERY_ID;
126 
131 typedef struct
132 {
134  uint8_t rorg; //EEP RORG 8 bits
136  uint8_t func; //EEP Function 6 bits
138  uint8_t type; //EEP Type 7 bits
140  uint8_t locked; //Locked by other manager - bool
142 
147 typedef struct
148 {
150  uint16_t functionNum; //Function number
152  uint16_t manufaturerID; //Manufacturer ID
154 
159 typedef struct
160 {
162  uint8_t rorg; //EEP RORG
164  uint8_t func; //EEP Function
166  uint8_t type; //EEP Type
168  int8_t rssi; //RSSI of the pinged device
169 } PING_RESPONSE;
170 
171 
172 typedef enum
173 {
174  START_SESSION_OK = 0x00,
177  START_RESPONSE_MAX,
183 typedef struct
184 {
186  bool codeSetFlag; //Code set flag
188  uint8_t lastSEQ; //Last SEQ
190  uint16_t lastFunc; //Last function code
192  uint8_t lastFuncRet; //Last function return code
194 
199 typedef struct
200 {
202  uint8_t data; //Read data
204 
209 typedef struct
210 {
212  uint16_t flashAddress;//SmartAck flash address where the settings are stored
214  uint16_t mailboxCount; //Number of mailboxes
216 
221 typedef struct
222 {
224  uint32_t sensorID; //Device ID of the sensor
226  uint32_t controllerID; //Device ID of the controller
228  uint8_t learnedCount; //Number of learned in devices
235 {
236 private:
237  eoGateway *gateway;
238  eoReManMessage reManMessage;
239  bool shallBeRepeated;
240  uint8_t keyToUse;
241 
242  eoReturn sendMessage()
243  {
244  return gateway->Send(reManMessage, shallBeRepeated, keyToUse);
245  }
246 public:
251  eoRemoteManager(eoGateway *gateway);
252  ~eoRemoteManager();
253 
254 
258  bool GetKeyToUse() const
259  {
260  return keyToUse;
261  };
265  void SetKeyToUse(uint8_t key)
266  {
267  keyToUse = key;
268  };
272  bool GetShallBeRepeated() const
273  {
274  return shallBeRepeated;
275  };
279  void SetShallBeRepeated(bool repeat)
280  {
281  shallBeRepeated = repeat;
282  };
291  eoReturn UnLock(const uint32_t securityCode, const uint32_t destinationID);
300  eoReturn Lock(const uint32_t securityCode, const uint32_t destinationID);
301 
302 
303  eoReturn Start(const uint32_t destinationID);
304  eoReturn ParseStartAnswear(START_RESPONSE &responseCode);
305 
306  eoReturn Close(const uint32_t destinationID);
307 
316  eoReturn SetCode(const uint32_t securityCode, const uint32_t destinationID);
322  eoReturn Action(const uint32_t destinationID);
333  eoReturn Ping(const uint32_t destinationID);
349  eoReturn QueryID(const QUERY_ID &msg);
367  eoReturn QueryFunction(const uint32_t destinationID);
374  eoReturn ParseQueryFunctionAnswer(QUERY_FUNCTION_RESPONSE *response, uint8_t maxIDCount, uint8_t &IDCount);
383  eoReturn QueryStatus(const uint32_t destinationID);
397  eoReturn RemoteLearnIn(const uint32_t destinationID, REMOTE_TYPE learnFlag);
408  eoReturn RemoteFlashWrite(const uint32_t destinationID, const uint16_t &memoryAddress, const uint16_t numOfBytes, const uint8_t data[]);
418  eoReturn RemoteFlashRead(const uint32_t destinationID, const uint16_t &memoryAddress, const uint16_t numOfBytes);
425  eoReturn ParseRemoteFlashReadAnswer(FLASH_READ_RESPONSE *response, uint16_t *dataCount, uint8_t maxDataCount);
433  eoReturn RemoteSmartReadMailboxSettings(const uint32_t destinationID);
446  eoReturn RemoteSmartReadLearnedSensors(const uint32_t destinationID);
453  eoReturn ParseRemoteSmartReadLearnedSensors(LEARNED_SENSOR_RESPONSE *response, uint8_t *learnedCount, uint8_t maxLearnedCount);
463  eoReturn RemoteSmartAddMailbox(const uint32_t destinationID, const uint8_t mailboxIndex, const uint32_t sensorID, const uint32_t postmasterID);
469  eoReturn RemoteSmartDeleteMailbox(const uint32_t destinationID, const uint8_t mailboxIndex);
477  eoReturn RemoteSmartLearnIn(const uint32_t destinationID, const uint8_t learnCount, const uint32_t sensorID, const uint32_t controllerID);
485  eoReturn RemoteSmartLearnOut(const uint32_t destinationID, const uint8_t learnCount, const uint32_t sensorID, const uint32_t controllerID);
486 
487 };
488 
489 #endif // !defined(EA_4BFBF49B_3520_48f7_BACB_B62331BA4509__INCLUDED_)
Unlock.
Definition: eoRemoteManager.h:64
eoReturn Lock(const uint32_t securityCode, const uint32_t destinationID)
eoReturn RemoteSmartDeleteMailbox(const uint32_t destinationID, const uint8_t mailboxIndex)
uint16_t functionNum
Function number.
Definition: eoRemoteManager.h:150
Query ID.
Definition: eoRemoteManager.h:68
SmartACK start advanced learn mode.
Definition: eoRemoteManager.h:52
Query ID answer.
Definition: eoRemoteManager.h:72
void SetShallBeRepeated(bool repeat)
Definition: eoRemoteManager.h:279
bool GetShallBeRepeated() const
Definition: eoRemoteManager.h:272
uint8_t lastFuncRet
Last function return code.
Definition: eoRemoteManager.h:192
uint8_t func
EEP Function - 6 bit.
Definition: eoRemoteManager.h:136
SmartACK write.
Definition: eoRemoteManager.h:110
Learned sensors response structure.
Definition: eoRemoteManager.h:221
Ext Query Id Answer.
Definition: eoRemoteManager.h:74
eoReturn RemoteSmartLearnOut(const uint32_t destinationID, const uint8_t learnCount, const uint32_t sensorID, const uint32_t controllerID)
uint32_t controllerID
Device ID of the controller.
Definition: eoRemoteManager.h:226
eoReturn RemoteSmartAddMailbox(const uint32_t destinationID, const uint8_t mailboxIndex, const uint32_t sensorID, const uint32_t postmasterID)
uint8_t func
EEP Function.
Definition: eoRemoteManager.h:164
eoReturn RemoteSmartReadMailboxSettings(const uint32_t destinationID)
SmartACK read mailbox answer.
Definition: eoRemoteManager.h:106
SmartACK stop learn mode.
Definition: eoRemoteManager.h:54
eoReturn QueryID(const QUERY_ID &msg)
eoReturn SetCode(const uint32_t securityCode, const uint32_t destinationID)
eoReturn QueryFunction(const uint32_t destinationID)
Query status.
Definition: eoRemoteManager.h:86
uint16_t flashAddress
SmartAck flash address where the settings are stored.
Definition: eoRemoteManager.h:212
Flash read response structure.
Definition: eoRemoteManager.h:199
uint8_t type
EEP Type - 7 bit.
Definition: eoRemoteManager.h:124
uint8_t data
Read data.
Definition: eoRemoteManager.h:202
Next channel.
Definition: eoRemoteManager.h:46
eoReturn ParseRemoteFlashReadAnswer(FLASH_READ_RESPONSE *response, uint16_t *dataCount, uint8_t maxDataCount)
eoReturn Ping(const uint32_t destinationID)
Query ID.
Definition: eoRemoteManager.h:70
Start a session with a secure ReMan device.
Definition: eoRemoteManager.h:90
eoReturn ParseQueryFunctionAnswer(QUERY_FUNCTION_RESPONSE *response, uint8_t maxIDCount, uint8_t &IDCount)
Remote flash read answer.
Definition: eoRemoteManager.h:102
Remote flash read.
Definition: eoRemoteManager.h:100
uint8_t rorg
EEP RORG - 8 bit.
Definition: eoRemoteManager.h:120
Query function answer.
Definition: eoRemoteManager.h:84
bool codeSetFlag
Code set flag.
Definition: eoRemoteManager.h:186
SmartACK read.
Definition: eoRemoteManager.h:104
eoReturn UnLock(const uint32_t securityCode, const uint32_t destinationID)
Query function response structure.
Definition: eoRemoteManager.h:147
Mailbox settings response structure.
Definition: eoRemoteManager.h:209
Start learning.
Definition: eoRemoteManager.h:44
eoReturn ParsePingAnswer(PING_RESPONSE &response)
Ping.
Definition: eoRemoteManager.h:78
SmartACK start simple learn mode.
Definition: eoRemoteManager.h:50
Query ID structure.
Definition: eoRemoteManager.h:117
eoRemoteManager(eoGateway *gateway)
uint8_t learnedCount
Number of learned in devices.
Definition: eoRemoteManager.h:228
eoReturn QueryStatus(const uint32_t destinationID)
eoReturn ParseQueryIDAnswer(QUERY_ID_RESPONSE &response)
FN_CODE
Function codes.
Definition: eoRemoteManager.h:61
void SetKeyToUse(uint8_t key)
Definition: eoRemoteManager.h:265
eoReturn ParseRemoteSmartReadMailboxSettingsAnswer(MAILBOX_SETTINGS_RESPONSE &response)
eoReturn RemoteSmartReadLearnedSensors(const uint32_t destinationID)
eoReturn
contains all the return values from different functions
Definition: eoApiDef.h:40
uint8_t lastSEQ
Last SEQ.
Definition: eoRemoteManager.h:188
REMOTE_TYPE
Remote learn types.
Definition: eoRemoteManager.h:41
uint16_t lastFunc
Last function code.
Definition: eoRemoteManager.h:190
EnOcean Gateway class, for handling a gateway Module.
Definition: eoGateway.h:139
eoReturn RemoteLearnIn(const uint32_t destinationID, REMOTE_TYPE learnFlag)
Ping answer.
Definition: eoRemoteManager.h:80
eoReturn ParseRemoteSmartReadLearnedSensors(LEARNED_SENSOR_RESPONSE *response, uint8_t *learnedCount, uint8_t maxLearnedCount)
Action.
Definition: eoRemoteManager.h:76
uint8_t type
EEP Type - 7 bit.
Definition: eoRemoteManager.h:138
virtual eoReturn Send(const eoPacket &p)
Query status answer.
Definition: eoRemoteManager.h:88
SmartACK read learned sensor answer.
Definition: eoRemoteManager.h:108
uint32_t sensorID
Device ID of the sensor.
Definition: eoRemoteManager.h:224
eoReturn ParseQueryStatusAnswer(QUERY_STATUS_RESPONSE &response)
eoReturn RemoteSmartLearnIn(const uint32_t destinationID, const uint8_t learnCount, const uint32_t sensorID, const uint32_t controllerID)
uint8_t rorg
EEP RORG.
Definition: eoRemoteManager.h:162
eoReturn Action(const uint32_t destinationID)
bool GetKeyToUse() const
Definition: eoRemoteManager.h:258
Ping response structure.
Definition: eoRemoteManager.h:159
Remote flash write.
Definition: eoRemoteManager.h:98
Stop learning.
Definition: eoRemoteManager.h:48
START_RESPONSE
Definition: eoRemoteManager.h:172
uint8_t func
EEP Function - 6 bit.
Definition: eoRemoteManager.h:122
Remote Manager interface class.
Definition: eoRemoteManager.h:234
Start a session with a secure ReMan device.
Definition: eoRemoteManager.h:94
Session is already controller by another controller.
Definition: eoRemoteManager.h:176
Query status response structure.
Definition: eoRemoteManager.h:183
uint8_t rorg
EEP RORG - 8 bit.
Definition: eoRemoteManager.h:134
Definition: eoReManMessage.h:43
Query function.
Definition: eoRemoteManager.h:82
int8_t rssi
RSSI of the pinged device.
Definition: eoRemoteManager.h:168
uint8_t locked
Locked by other manager - bool.
Definition: eoRemoteManager.h:140
uint16_t mailboxCount
Number of mailboxes.
Definition: eoRemoteManager.h:214
uint8_t type
EEP Type.
Definition: eoRemoteManager.h:166
Reply to the start command.
Definition: eoRemoteManager.h:92
uint16_t manufaturerID
Manufacturer ID.
Definition: eoRemoteManager.h:152
Lock.
Definition: eoRemoteManager.h:66
eoReturn RemoteFlashWrite(const uint32_t destinationID, const uint16_t &memoryAddress, const uint16_t numOfBytes, const uint8_t data[])
eoReturn RemoteFlashRead(const uint32_t destinationID, const uint16_t &memoryAddress, const uint16_t numOfBytes)
Query ID response structure.
Definition: eoRemoteManager.h:131
Remote learn in.
Definition: eoRemoteManager.h:96