NewAskSin
 All Classes Files Functions Variables Groups Pages
THSensor.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 th sensor class ------------------------------------------------------------------------------------------------
6 //- -----------------------------------------------------------------------------------------------------------------------
7 
8 #ifndef _THSENSOR_H
9 #define _THSENSOR_H
10 
11 #include "AS.h"
12 #include "HAL.h"
13 
14 // default settings for list3 or list4
15 const uint8_t peerOdd[] = {
16 };
17 const uint8_t peerEven[] = {
18 };
19 const uint8_t peerSingle[] = {
20 };
21 
22 
23 class THSensor {
24  //- user code here ------------------------------------------------------------------------------------------------------
25  public://----------------------------------------------------------------------------------------------------------------
26  protected://-------------------------------------------------------------------------------------------------------------
27  private://---------------------------------------------------------------------------------------------------------------
28  struct s_lstCnl {
29  } lstCnl;
30 
31  struct s_lstPeer {
32  // 0x01,
33  uint8_t peerNeedsBurst :1; // 0x01, s:0, e:1
34  uint8_t :7; //
35  } lstPeer;
36 
37 
38  //- user defined functions ----------------------------------------------------------------------------------------------
39  public://----------------------------------------------------------------------------------------------------------------
40  void (*fInit)(void); // pointer to init function in main sketch
41  void (*fMeas)(void); // pointer to measurement function in main sketch
42  uint8_t *ptrVal; // pointer to byte which holds the measured value
43 
44  uint8_t mMode :1; // 0 timer based, 1 level of changed based transmition
45  uint8_t mLevelChange; // value change
46  uint32_t mSendDelay; // delay for transmition or minimum delay while value changed
47 
48  uint8_t sState :1; // indicates if we are in measuring or transmition state
49  uint8_t msgCnt; // message counter of sensor module
50  uint8_t sensVal[2]; // sensor value, byte 1 is message counter, byte 2 is sensor value
51 
52  void config(void Init(), void Measure(), uint8_t *Val); // configure the sensor module from outside
53  void timing(uint8_t mode, uint32_t sendDelay, uint8_t levelChange); // mode 0 transmit based on timing or 1 on level change; level change value; while in mode 1 timing value will stay as minimum delay on level change
54 
55  void sensPoll(void); // polling function for tasks done on a regular manner
56  uint32_t calcSendSlot(void); // calculate next send slot based on HMID
57 
58  //- mandatory functions for every new module to communicate within AS protocol stack ------------------------------------
59  public://----------------------------------------------------------------------------------------------------------------
60  uint8_t modStat; // module status byte, needed for list3 modules to answer status requests
61  uint8_t modDUL; // module down up low battery byte
62  uint8_t regCnl; // holds the channel for the module
63 
64  AS *hm; // pointer to HM class instance
65 
66  void configCngEvent(void); // list1 on registered channel had changed
67  void pairSetEvent(uint8_t *data, uint8_t len); // pair message to specific channel, handover information for value, ramp time and so on
68  void pairStatusReq(void); // event on status request
69  void peerMsgEvent(uint8_t type, uint8_t *data, uint8_t len); // peer message was received on the registered channel, handover the message bytes and length
70 
71  void poll(void); // poll function, driven by HM loop
72 
73  //- predefined, no reason to touch --------------------------------------------------------------------------------------
74  void regInHM(uint8_t cnl, uint8_t lst, AS *instPtr); // register this module in HM on the specific channel
75  void hmEventCol(uint8_t by3, uint8_t by10, uint8_t by11, uint8_t *data, uint8_t len);// call back address for HM for informing on events
76  void peerAddEvent(uint8_t *data, uint8_t len); // peer was added to the specific channel, 1st and 2nd byte shows peer channel, third and fourth byte shows peer index
77 };
78 
79 
80 #endif
Main class for implementation of the AskSin protocol stack. Every device needs exactly one instance o...
Definition: AS.h:39
Definition: THSensor.h:23