forked from trilu2000/NewAskSin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
THSensor.h
80 lines (61 loc) · 4.68 KB
/
THSensor.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
//- -----------------------------------------------------------------------------------------------------------------------
// AskSin driver implementation
// 2013-08-03 <[email protected]> Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
//- -----------------------------------------------------------------------------------------------------------------------
//- AskSin th sensor class ------------------------------------------------------------------------------------------------
//- -----------------------------------------------------------------------------------------------------------------------
#ifndef _THSENSOR_H
#define _THSENSOR_H
#include "AS.h"
#include "HAL.h"
// default settings for list3 or list4
const uint8_t peerOdd[] = {
};
const uint8_t peerEven[] = {
};
const uint8_t peerSingle[] = {
};
class THSensor {
//- user code here ------------------------------------------------------------------------------------------------------
public://----------------------------------------------------------------------------------------------------------------
protected://-------------------------------------------------------------------------------------------------------------
private://---------------------------------------------------------------------------------------------------------------
struct s_lstCnl {
} lstCnl;
struct s_lstPeer {
// 0x01,
uint8_t peerNeedsBurst :1; // 0x01, s:0, e:1
uint8_t :7; //
} lstPeer;
//- user defined functions ----------------------------------------------------------------------------------------------
public://----------------------------------------------------------------------------------------------------------------
void (*fInit)(void); // pointer to init function in main sketch
void (*fMeas)(void); // pointer to measurement function in main sketch
uint8_t *ptrVal; // pointer to byte which holds the measured value
uint8_t mMode :1; // 0 timer based, 1 level of changed based transmition
uint8_t mLevelChange; // value change
uint32_t mSendDelay; // delay for transmition or minimum delay while value changed
uint8_t sState :1; // indicates if we are in measuring or transmition state
uint8_t msgCnt; // message counter of sensor module
uint8_t sensVal[2]; // sensor value, byte 1 is message counter, byte 2 is sensor value
void config(void Init(), void Measure(), uint8_t *Val); // configure the sensor module from outside
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
void sensPoll(void); // polling function for tasks done on a regular manner
uint32_t calcSendSlot(void); // calculate next send slot based on HMID
//- mandatory functions for every new module to communicate within AS protocol stack ------------------------------------
public://----------------------------------------------------------------------------------------------------------------
uint8_t modStat; // module status byte, needed for list3 modules to answer status requests
uint8_t modDUL; // module down up low battery byte
uint8_t regCnl; // holds the channel for the module
AS *hm; // pointer to HM class instance
void configCngEvent(void); // list1 on registered channel had changed
void pairSetEvent(uint8_t *data, uint8_t len); // pair message to specific channel, handover information for value, ramp time and so on
void pairStatusReq(void); // event on status request
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
void poll(void); // poll function, driven by HM loop
//- predefined, no reason to touch --------------------------------------------------------------------------------------
void regInHM(uint8_t cnl, uint8_t lst, AS *instPtr); // register this module in HM on the specific channel
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
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
};
#endif