NewAskSin
 All Classes Files Functions Variables Groups Pages
Receive.h
1 //- -----------------------------------------------------------------------------------------------------------------------
2 // AskSin driver implementation
3 // 2013-08-03 <trilu@gmx.de> Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
4 //- -----------------------------------------------------------------------------------------------------------------------
5 //- AskSin receive function -----------------------------------------------------------------------------------------------
6 //- with a lot of support from martin876 at FHEM forum
7 //- -----------------------------------------------------------------------------------------------------------------------
8 
9 
10 #ifndef _RV_H
11 #define _RV_H
12 
13 #include "HAL.h"
14 #define MaxDataLen 60 // maximum length of received bytes
15 
16 class RV {
17  friend class AS;
18 
19  protected: //---------------------------------------------------------------------------------------------------------
20  struct s_mFlg {
21  uint8_t WKUP :1; // 0x01: send initially to keep the device awake
22  uint8_t WKMEUP :1; // 0x02: awake - hurry up to send messages
23  uint8_t CFG :1; // 0x04: Device in Config mode
24  uint8_t :1;
25  uint8_t BURST :1; // 0x10: set if burst is required by device
26  uint8_t BIDI :1; // 0x20: response is expected
27  uint8_t RPTED :1; // 0x40: repeated (repeater operation)
28  uint8_t RPTEN :1; // 0x80: set in every message. Meaning?
29  };
30 
31  struct s_msgBody {
32  uint8_t mLen; // message length
33  uint8_t mCnt; // counter, if it is an answer counter has to reflect the answered message, otherwise own counter has to be used
34  struct s_mFlg mFlg; // see structure of message flags
35  uint8_t mTyp; // type of message
36  uint8_t reID[3]; // sender ID
37  uint8_t toID[3]; // receiver id, broadcast for 0
38  uint8_t by10; // type of message
39  uint8_t by11; // type of message
40  uint8_t pyLd[MaxDataLen-12]; // payload
41  };
42 
43  public: //---------------------------------------------------------------------------------------------------------
44  struct s_msgBody mBdy; // structure for easier message creation
45  uint8_t peerId[4]; // hold for messages >= 3E the peerID with channel
46  uint8_t *buf; // cast to byte array
47 
48  #define hasData buf[0]?1:0 // check if something is in the buffer
49 
50  private: //---------------------------------------------------------------------------------------------------------
51  #define bufLen buf[0]+1
52  #define ackRq mBdy.mFlg.BIDI // check if an ACK is requested
53 
54  class AS *pHM; // pointer to main class for function calls
55 
56  public: //---------------------------------------------------------------------------------------------------------
57  protected: //---------------------------------------------------------------------------------------------------------
58  private: //---------------------------------------------------------------------------------------------------------
59  RV();
60  void init(AS *ptrMain);
61  void poll(void);
62 
63 };
64 
65 #endif
Main class for implementation of the AskSin protocol stack. Every device needs exactly one instance o...
Definition: AS.h:39
void init(void)
Initialize the AS module.
Definition: AS.cpp:20
Definition: Receive.h:31
Definition: Receive.h:20
Definition: Receive.h:16
void poll(void)
Poll routine for regular operation.
Definition: AS.cpp:44