├── .gitattributes
├── .gitignore
├── .hm device list.txt
├── .project
├── .test_commands.txt
├── .tfignore
├── AS.cpp
├── AS.h
├── Battery.cpp
├── Battery.h
├── CC1101.cpp
├── CC1101.h
├── ConfButton.cpp
├── ConfButton.h
├── Dummy.cpp.old
├── Dummy.h.old
├── EEprom.cpp
├── EEprom.h
├── Fastdelegate.h
├── HAL.cpp
├── HAL.h
├── HAL_atmega328P.h
├── HAL_atmega32U4.h
├── HAL_extern.h
├── Power.cpp
├── Power.h
├── Receive.cpp
├── Receive.h
├── Registrar.cpp
├── Registrar.h
├── Send.cpp
├── Send.h
├── StatusLed.cpp
├── StatusLed.h
├── THSensor.cpp
├── THSensor.h
├── Version.h
├── cmBlind.cpp
├── cmBlind.h
├── cmDimmer.cpp
├── cmDimmer.h
├── cmSwitch.cpp
├── cmSwitch.h
├── destillRegs
├── .project
├── HMConfig.pm
├── RegConfig.pm
├── destillRegs.pl
├── devDefinition - Copy.pm
├── devDefinition - Dimmer.pm
├── devDefinition.pm
├── devDefinition.pm - HM6TastenSwitch
├── devDefinition.pm - HM_LC_SW1_BA_PCB
├── devDefinition.pm.pcb
├── devDefinition.pm.test
├── rf_dim_1pwm_644_le_v2_4.xml
└── rf_rc-sec4-2.xml
├── destillRegs2
├── .project
├── createReg.pl
├── createRegisterFromFile.pl
├── devDefinition - HM_LC_Dim1PWM_CV.pm
├── devDefinition - HM_LC_SW1_BA_PCB.pm
├── devDefinition.pm
├── devicetypes
│ ├── rf_4dis.xml
│ ├── rf_ash550.xml
│ ├── rf_bl.xml
│ ├── rf_bl_conf_644.xml
│ ├── rf_bl_conf_644_le_v2_1.xml
│ ├── rf_cc_rt_dn.xml
│ ├── rf_cc_rt_dn_bom.xml
│ ├── rf_cc_tc.xml
│ ├── rf_cc_tc_le_v1_9.xml
│ ├── rf_cc_vd.xml
│ ├── rf_central.xml
│ ├── rf_cf.xml
│ ├── rf_cfm.xml
│ ├── rf_cm.xml
│ ├── rf_cmm.xml
│ ├── rf_d.xml
│ ├── rf_d_le_v1_7.xml
│ ├── rf_d_le_v1_9.xml
│ ├── rf_ddc.xml
│ ├── rf_dim_1l_644.xml
│ ├── rf_dim_1l_644_le_v2_4.xml
│ ├── rf_dim_1pwm_644.xml
│ ├── rf_dim_1pwm_644_le_v2_4.xml
│ ├── rf_dim_1t_644.xml
│ ├── rf_dim_1t_644_le_v2_4.xml
│ ├── rf_dim_1tconf_644.xml
│ ├── rf_dim_1tconf_644_le_v2_4.xml
│ ├── rf_dim_2l_644.xml
│ ├── rf_dim_2l_644_le_v2_4.xml
│ ├── rf_dim_2t_644.xml
│ ├── rf_dim_2t_644_le_v2_4.xml
│ ├── rf_dim_t.xml
│ ├── rf_dim_t_le_v1_9.xml
│ ├── rf_es_pmsw.xml
│ ├── rf_fs_ba.xml
│ ├── rf_keymatic.xml
│ ├── rf_ks550.xml
│ ├── rf_ou_led16_ge_v1_1.xml
│ ├── rf_ou_led16_le_v1_0.xml
│ ├── rf_pbi.xml
│ ├── rf_rc-4-2.xml
│ ├── rf_rc-key4-2.xml
│ ├── rf_rc-sec4-2.xml
│ ├── rf_rc.xml
│ ├── rf_rc_12.xml
│ ├── rf_rc_19.xml
│ ├── rf_rc_single_on.xml
│ ├── rf_rc_wakeup.xml
│ ├── rf_rd.xml
│ ├── rf_rd_le_v1_3.xml
│ ├── rf_rep.xml
│ ├── rf_resc_win_pcb_sc.xml
│ ├── rf_rhs.xml
│ ├── rf_rhs_e_v1_7.xml
│ ├── rf_rhs_le_v1_6.xml
│ ├── rf_roto_wdf_solar.xml
│ ├── rf_s.xml
│ ├── rf_s550ia.xml
│ ├── rf_s_1conf_644.xml
│ ├── rf_s_1conf_644_le_v2_1.xml
│ ├── rf_s_4_ba.xml
│ ├── rf_s_ba.xml
│ ├── rf_s_le_v1_5.xml
│ ├── rf_s_mega168.xml
│ ├── rf_sc.xml
│ ├── rf_sc_e_v1_7.xml
│ ├── rf_sc_le_v1_6.xml
│ ├── rf_scd_v1_0.xml
│ ├── rf_sci_3.xml
│ ├── rf_sec_mdir.xml
│ ├── rf_sec_mdir_v1_5.xml
│ ├── rf_sec_sd.xml
│ ├── rf_sec_sd_schueco.xml
│ ├── rf_sec_sfa.xml
│ ├── rf_sen_ep.xml
│ ├── rf_sen_mdir.xml
│ ├── rf_sen_mdir_v1_5.xml
│ ├── rf_sen_wa_od.xml
│ ├── rf_swi.xml
│ ├── rf_tc_it_wm-w-eu.xml
│ ├── rf_tis.xml
│ ├── rf_tis_le_v1_0.xml
│ ├── rf_wds30_ot2.xml
│ ├── rf_wds40_th_i_2.xml
│ ├── rf_wds_v1_0.xml
│ ├── rf_wds_v1_1.xml
│ ├── rf_winmatic.xml
│ └── rf_ws550.xml
└── linkset.xml
├── docs
├── AskSin library.docx
├── Datasheets
│ ├── 32U4 datasheet.pdf
│ ├── ATmega48A-48PA-88A-88PA-168A-168PA-328-328P datasheet.pdf
│ ├── Arduino Pro Mini Pin out.png
│ ├── Dissecting HomeMatic AES.pdf
│ ├── Monopol-Antennen.png
│ ├── ProMini.pdf
│ ├── TSL45315 datasheet.pdf
│ ├── cc1100.pdf
│ └── radino_CC1101 datasheet.pdf
├── Doxyfile
├── README.md
├── calc fact for battery class.xlsx
├── mainpage.dox
└── snippets
│ ├── basic-AS.cpp
│ ├── hmserial.c
│ ├── register-h-cnlAddr.cpp
│ ├── register-h-cnlTbl.cpp
│ └── register-h-cnlTblAddr.cpp
├── examples
├── AskinNew_test
│ ├── AskinNew_test.ino
│ ├── hardware.cpp
│ ├── hardware.h
│ ├── register.h
│ └── status - broken
├── CUSTOM_LUX
│ ├── CUSTOM_LUX.ino
│ ├── LUX11.sch-1.pdf
│ ├── hardware.cpp
│ ├── hardware.h
│ ├── hardware_radino.zip
│ ├── register.h
│ └── status - broken
├── HM_LC_Bl1_SM
│ ├── HM_LC_Bl1_SM.ino
│ ├── HM_LC_Bl1_SM.sln
│ ├── HM_LC_Bl1_SM.vcxproj
│ ├── HM_LC_Bl1_SM.vcxproj.filters
│ ├── __vm
│ │ ├── .HM_LC_Bl1_SM.vsarduino.h
│ │ ├── Compile.vmps.xml
│ │ ├── Configuration.Debug.vmps.xml
│ │ └── Upload.vmps.xml
│ ├── hardware.cpp
│ ├── hardware.h
│ ├── register.h
│ └── status - in development
├── HM_LC_Dim1PWM_CV
│ ├── HM_LC_Dim1PWM_CV.ino
│ ├── hardware.cpp
│ ├── hardware.cpp-org
│ ├── hardware.h
│ ├── hardware.h-org
│ ├── register.h
│ └── status - testing
└── HM_LC_SW1_BA_PCB
│ ├── HM_LC_SW1_BA_PCB.ino
│ ├── hardware.cpp
│ ├── hardware.h
│ ├── register.h
│ └── status - working
└── library.json
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 | *.sln merge=union
7 | *.csproj merge=union
8 | *.vbproj merge=union
9 | *.fsproj merge=union
10 | *.dbproj merge=union
11 |
12 | # Standard to msysgit
13 | *.doc diff=astextplain
14 | *.DOC diff=astextplain
15 | *.docx diff=astextplain
16 | *.DOCX diff=astextplain
17 | *.dot diff=astextplain
18 | *.DOT diff=astextplain
19 | *.pdf diff=astextplain
20 | *.PDF diff=astextplain
21 | *.rtf diff=astextplain
22 | *.RTF diff=astextplain
23 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | Thumbs.db
2 | *.obj
3 | *.exe
4 | *.pdb
5 | *.user
6 | *.aps
7 | *.pch
8 | *.vspscc
9 | *_i.c
10 | *_p.c
11 | *.ncb
12 | *.suo
13 | *.sln.docstates
14 | *.tlb
15 | *.tlh
16 | *.bak
17 | *.cache
18 | *.ilk
19 | *.log
20 | [Bb]in
21 | [Dd]ebug*/
22 | *.lib
23 | *.sbr
24 | obj/
25 | [Rr]elease*/
26 | _ReSharper*/
27 | [Tt]est[Rr]esult*
28 | *.vssscc
29 | $tf*/
30 | Visual Micro/
31 | *.atsln
32 | *.atsuo
33 | *.cppproj
34 | .metadata/
35 | RemoteSystemsTempFiles/
36 | .projecthtml/
37 | html/
38 |
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | destillRegs
4 |
5 |
6 |
7 |
8 |
9 | org.epic.perleditor.perlbuilder
10 |
11 |
12 |
13 |
14 |
15 | org.epic.perleditor.perlnature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/.test_commands.txt:
--------------------------------------------------------------------------------
1 |
2 | // add peers
3 | 10 55 A0 01 63 19 63 01 02 04 01 01 1F A6 5C 06 05
4 | 10 55 A0 01 63 19 63 01 02 04 01 01 1F A6 5C 03 04
5 | 10 55 A0 01 63 19 63 01 02 04 01 01 1F A6 5C 02 01
6 |
7 | // remove peers
8 | 10 55 A0 01 63 19 63 01 02 04 01 02 1F A6 5C 06 05
9 | 10 55 A0 01 63 19 63 01 02 04 01 02 1F A6 5C 03 04
10 | 10 55 A0 01 63 19 63 01 02 04 01 02 1F A6 5C 02 01
11 |
12 | // get peer list
13 | 0B 05 A0 01 63 19 63 01 02 04 01 03
14 |
15 | // get reg list of cnl 0, lst 0
16 | 10 04 A0 01 63 19 63 01 02 04 00 04 00 00 00 00 00
17 |
18 | // get reg list of cnl 1, lst 1
19 | 10 04 A0 01 63 19 63 01 02 04 01 04 00 00 00 00 01
20 |
21 | // get reg list of cnl 1, lst 3
22 | 10 04 A0 01 63 19 63 01 02 04 01 04 01 02 03 04 03
23 |
24 | // config start cnl 0, lst 0
25 | 10 01 A0 01 63 19 63 01 02 04 00 05 00 00 00 00 00
26 |
27 | // config write cnl 0
28 | 13 02 A0 01 63 19 63 01 02 04 00 08 02 01 0A 63 0B 19 0C 63
29 |
30 | // config end
31 | 0B 01 A0 01 63 19 63 01 02 04 00 06
32 |
33 | // config serial request
34 | 0B 77 A0 01 63 19 63 01 02 04 00 09
35 |
36 |
37 | // pair by serial
38 | 15 92 B4 01 63 19 63 00 00 00 01 0A 74 6C 75 31 30 30 31 32 33 34
39 |
40 |
41 |
42 |
43 | 10 01 B0 01 63 19 62 1F B7 4A 00 05 00 00 00 00 00
44 |
45 | 13 02 B0 01 63 19 62 1F B7 4A 00 08 02 01 0A 63 0B 19 0C 63
46 |
47 | 0B 01 A0 01 63 19 62 1F B7 4A 00 06
48 |
49 |
50 | <- 13 02 B0 01 63 19 62 1F B7 4A 00 08 02 01 0A 63 0B 19 0C 63 (333511)
51 | l> 0A 02 80 02 1F B7 4A 63 19 62 00 (333641)
52 |
53 | <- 0B 01 A0 01 63 19 62 1F B7 4A 00 06 (341781)
54 | l> 0A 01 80 02 1F B7 4A 63 19 62 00 (341923)
55 |
56 | <- 0B 01 A0 01 63 19 62 1F B7 4A 00 06 (344493)
57 |
58 |
59 | l> 0D 04 A4 10 1F B7 4A 63 19 63 06 01 C8 80 (354344)
60 |
61 |
--------------------------------------------------------------------------------
/.tfignore:
--------------------------------------------------------------------------------
1 | \.git
--------------------------------------------------------------------------------
/Battery.cpp:
--------------------------------------------------------------------------------
1 | //- -----------------------------------------------------------------------------------------------------------------------
2 | // AskSin driver implementation
3 | // 2013-08-03 Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
4 | //- -----------------------------------------------------------------------------------------------------------------------
5 | //- AskSin battery status functions ---------------------------------------------------------------------------------------
6 | //- with a lot of support from dirk at FHEM forum
7 | //- -----------------------------------------------------------------------------------------------------------------------
8 |
9 | //#define BT_DBG
10 | #include "Battery.h"
11 | #include "AS.h"
12 |
13 | waitTimer battTmr; // battery timer for duration check
14 |
15 | // public: //---------------------------------------------------------------------------------------------------------
16 | void BT::set(uint8_t tenthVolt, uint32_t duration) {
17 | bDuration = duration;
18 | checkTenthVolt = tenthVolt;
19 | poll();
20 | }
21 |
22 | // private: //---------------------------------------------------------------------------------------------------------
23 | BT::BT() {
24 | }
25 | void BT::init(AS *ptrMain) {
26 |
27 | #ifdef BT_DBG // only if ee debug is set
28 | dbgStart(); // serial setup
29 | dbg << F("BT.\n"); // ...and some information
30 | #endif
31 |
32 | pHM = ptrMain;
33 | bMode = 0;
34 | bDuration = 0;
35 | }
36 | void BT::poll(void) {
37 | if (!battTmr.done() ) return; // timer still running
38 |
39 | measureTenthVolt = getBatteryVoltage();
40 | bState = (measureTenthVolt < checkTenthVolt) ? 1 : 0; // set the battery status
41 |
42 | #ifdef BT_DBG // only if ee debug is set
43 | dbg << "cTV:" << checkTenthVolt << ", mTV:" << measureTenthVolt << " , s:" << bState << '\n';
44 | #endif
45 |
46 | battTmr.set(bDuration); // set next check time
47 | }
48 | uint8_t BT::getStatus(void) {
49 | return bState;
50 | }
51 |
--------------------------------------------------------------------------------
/Battery.h:
--------------------------------------------------------------------------------
1 | //- -----------------------------------------------------------------------------------------------------------------------
2 | // AskSin driver implementation
3 | // 2013-08-03 Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
4 | //- -----------------------------------------------------------------------------------------------------------------------
5 | //- AskSin battery status functions ---------------------------------------------------------------------------------------
6 | //- with a lot of support from dirk at FHEM forum
7 | //- -----------------------------------------------------------------------------------------------------------------------
8 |
9 | #ifndef _BT_H
10 | #define _BT_H
11 |
12 | #include "HAL.h"
13 |
14 |
15 | class BT {
16 | friend class AS;
17 |
18 | public: //---------------------------------------------------------------------------------------------------------
19 | protected: //---------------------------------------------------------------------------------------------------------
20 | private: //---------------------------------------------------------------------------------------------------------
21 |
22 | class AS *pHM; // pointer to main class for function calls
23 |
24 | uint8_t checkTenthVolt; // holds the proof point
25 | uint8_t measureTenthVolt; // variable to hold last measured value
26 | uint8_t bState :1; // holds status bit
27 | uint8_t bMode :2; // mode variable
28 | uint32_t bDuration; // duration for the next check
29 |
30 | public: //---------------------------------------------------------------------------------------------------------
31 | BT();
32 | void set(uint8_t tenthVolt, uint32_t duration);
33 |
34 | protected: //---------------------------------------------------------------------------------------------------------
35 | private: //---------------------------------------------------------------------------------------------------------
36 | void init(AS *ptrMain);
37 | void poll(void);
38 | uint8_t getStatus(void);
39 | };
40 |
41 |
42 | #endif
43 |
--------------------------------------------------------------------------------
/ConfButton.cpp:
--------------------------------------------------------------------------------
1 | //- -----------------------------------------------------------------------------------------------------------------------
2 | // AskSin driver implementation
3 | // 2013-08-03 Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
4 | //- -----------------------------------------------------------------------------------------------------------------------
5 | //- AskSin config key function --------------------------------------------------------------------------------------------
6 | //- with a lot of support from martin876 at FHEM forum
7 | //- -----------------------------------------------------------------------------------------------------------------------
8 |
9 | //#define CB_DBG
10 | #include "ConfButton.h"
11 | #include "AS.h"
12 |
13 | waitTimer btnTmr; // button timer functionality
14 |
15 | // public: //---------------------------------------------------------------------------------------------------------
16 | void CB::config(uint8_t mode, uint8_t pcIntByte, uint8_t pcIntBit) {
17 | scn = mode;
18 | pciByte = pcIntByte;
19 | pciBit = pcIntBit;
20 | }
21 |
22 | // private: //---------------------------------------------------------------------------------------------------------
23 | CB::CB() {
24 | }
25 | void CB::init(AS *ptrMain) {
26 | #ifdef CB_DBG // only if ee debug is set
27 | dbgStart(); // serial setup
28 | dbg << F("CB.\n"); // ...and some information
29 | #endif
30 |
31 | pHM = ptrMain;
32 | }
33 | void CB::poll(void) {
34 | #define detectLong 3000
35 | #define repeatedLong 300
36 | #define timeoutDouble 1000
37 |
38 | if (!scn) return; // mode not set, nothing to do
39 |
40 | // 0 for button is pressed, 1 for released, 2 for falling and 3 for rising edge
41 | btn = chkPCINT(pciByte, pciBit, 1); // check input pin, do debouncing
42 |
43 | if (btn == 2) { // button was just pressed
44 | //dbg << "armed \n";
45 | btnTmr.set(detectLong); // set timer to detect a long
46 | pHM->pw.stayAwake(detectLong+500); // stay awake to check button status
47 | armFlg = 1; // set it armed
48 | return;
49 | }
50 |
51 | if (!armFlg) return; // nothing to do any more
52 |
53 |
54 | // check button status
55 | if (btn == 3) { // button was just released, keyShortSingle, keyShortDouble, keyLongRelease
56 | //dbg << "3 lstLng:" << lstLng << " dblLng:" << dblLng << " lngRpt:" << lngRpt << " lstSht:" << lstSht << '\n';
57 |
58 | btnTmr.set(timeoutDouble); // set timer to clear the repeated flags
59 | pHM->pw.stayAwake(timeoutDouble+500); // stay awake to check button status
60 |
61 | if ((lstLng) && (lngRpt)) { // keyLongRelease
62 | outSignal(5);
63 |
64 | } else if (lstLng) { // no action, only remember for a double
65 | dblLng = 1; // waiting for a key long double
66 |
67 | } else if (lstSht) { // keyShortDouble
68 | lstSht = 0;
69 | outSignal(2);
70 |
71 | } else if ((!lstLng) && (!dblLng)) { // keyShortSingle
72 | lstSht = 1; // waiting for a key short double
73 | outSignal(1);
74 |
75 | }
76 | lstLng = lngRpt = 0; // some cleanup
77 |
78 | } else if ((btn == 0) && (btnTmr.done() )) { // button is still pressed, but timed out, seems to be a long
79 | //dbg << "0 lstLng:" << lstLng << " dblLng:" << dblLng << " lngRpt:" << lngRpt << " lstSht:" << lstSht << '\n';
80 |
81 | pHM->pw.stayAwake(detectLong+500); // stay awake to check button status
82 |
83 | if (lstLng) { // keyLongRepeat
84 | btnTmr.set(repeatedLong); // set timer to detect a repeated long
85 | lngRpt = 1;
86 | outSignal(4); // last key state was a long, now it is a repeated long
87 |
88 | } else if (dblLng) { // keyLongDouble
89 | btnTmr.set(detectLong); // set timer to detect next long
90 | outSignal(6); // double flag is set, means was the second time for a long
91 |
92 | } else { // keyLongSingle
93 | btnTmr.set(detectLong); // set timer to detect a repeated long
94 | lstLng = 1; // remember last was long
95 | outSignal(3); // first time detect a long
96 |
97 | }
98 |
99 |
100 | } else if ((btn == 1) && (btnTmr.done() )) { // button is not pressed for a longer time, check if the double flags timed out
101 | //if (armFlg) dbg << "r\n";
102 | armFlg = lstSht = lstLng = lngRpt = dblLng = 0;
103 |
104 | }
105 | }
106 |
107 | void CB::outSignal(uint8_t mode) {
108 |
109 | pHM->pw.stayAwake(500); // stay awake to fulfill the action
110 | pHM->ld.blinkRed(); // show via led that we have some action in place
111 |
112 | #ifdef CB_DBG // only if ee debug is set
113 | if (mode == 1) dbg << F("keyShortSingle\n"); // ...and some information
114 | if (mode == 2) dbg << F("keyShortDouble\n");
115 | if (mode == 3) dbg << F("keyLongSingle\n");
116 | if (mode == 4) dbg << F("keyLongRepeat\n");
117 | if (mode == 5) dbg << F("keyLongRelease\n");
118 | if (mode == 6) dbg << F("keyLongDouble\n");
119 | if (mode == 7) dbg << F("keyLongTimeout\n");
120 | #endif
121 |
122 | if (mode == 1) { // keyShortSingle
123 |
124 | if (scn == 1) pHM->sendDEVICE_INFO(); // send pairing string
125 | if ((scn == 2) && (modTbl[0].cnl)) modTbl[0].mDlgt(0,1,0,NULL,0); // send toggle to user module registered on channel 1
126 |
127 | } else if (mode == 2) { // keyShortDouble
128 |
129 | } else if (mode == 3) { // keyLongSingle
130 |
131 | if (scn == 1) pHM->ld.set(key_long);
132 | if (scn == 2) pHM->sendDEVICE_INFO(); // send pairing string
133 |
134 | } else if (mode == 4) { // keyLongRepeat
135 | pHM->ld.set(nothing);
136 |
137 | } else if (mode == 5) { // keyLongRelease
138 |
139 | } else if (mode == 6) { // keyLongDouble
140 | pHM->ld.set(nothing);
141 |
142 | // 0x18 localResDis available, take care of it
143 | uint8_t localResDis = pHM->ee.getRegAddr(0,0,0,0x18); // get register address
144 | //dbg << "x:" << localResDis <<'\n';
145 | //if (localResDis) return; // if local reset is disabled, reset
146 |
147 | pHM->ee.clearPeers();
148 | pHM->ee.clearRegs();
149 | pHM->ee.getMasterID();
150 |
151 | pHM->ld.set(welcome);
152 |
153 | }
154 | }
--------------------------------------------------------------------------------
/ConfButton.h:
--------------------------------------------------------------------------------
1 | //- -----------------------------------------------------------------------------------------------------------------------
2 | // AskSin driver implementation
3 | // 2013-08-03 Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
4 | //- -----------------------------------------------------------------------------------------------------------------------
5 | //- AskSin config key function --------------------------------------------------------------------------------------------
6 | //- with a lot of support from martin876 at FHEM forum
7 | //- -----------------------------------------------------------------------------------------------------------------------
8 |
9 | #ifndef _CB_H
10 | #define _CB_H
11 |
12 | #include "HAL.h"
13 |
14 |
15 | // - scenario 00 ----------------------------
16 | // no config button used
17 | //
18 | // - scenario 01 ----------------------------
19 | // short press = pair
20 | // long press = nothing
21 | // double long = nothing
22 | // double long release = reset
23 | //
24 | // - scenario 02 ----------------------------
25 | // short press = toggle channel one
26 | // long press = pair
27 | // double long = nothing
28 | // double long release = reset
29 | //
30 | // if 0x18 localResDis available, take care of it and enable or disable double long
31 |
32 | /**
33 | * @short Class for the handling the configuration key of the device
34 | * Right now there are three possible scenarios which could be configured via the mode flag.
35 | *
36 | * - scenario 00 ----------------------------
37 | * no config button used
38 | *
39 | * - scenario 01 ----------------------------
40 | * short press = pair
41 | * long press = nothing
42 | * double long = nothing
43 | * double long release = reset
44 | *
45 | * - scenario 02 ----------------------------
46 | * short press = toggle channel one
47 | * long press = pair
48 | * double long = nothing
49 | * double long release = reset
50 | *
51 | * Interface to the hardware is done via the register byte address of the port
52 | * and hand over of the respective bit number within this byte
53 | */
54 | class CB {
55 | friend class AS;
56 |
57 | public: //---------------------------------------------------------------------------------------------------------
58 | protected: //---------------------------------------------------------------------------------------------------------
59 | private: //---------------------------------------------------------------------------------------------------------
60 | class AS *pHM; // pointer to main class for function calls
61 |
62 | public: //---------------------------------------------------------------------------------------------------------
63 | uint8_t scn :3; // scenario indicator
64 | uint8_t btn :3; // result of chkPCINT
65 |
66 | uint8_t armFlg :1; // armed flag, will be set on first touch
67 |
68 | uint8_t lstLng :1; // remember a long press
69 | uint8_t lngRpt :1; // remember last key press to detect double or long
70 | uint8_t dblLng :1; // check for a double long
71 |
72 | uint8_t lstSht :1; // remember that last key was a short
73 |
74 | uint8_t pciByte; // PCI byte, indicate interrupt channel
75 | uint8_t pciBit; // PCI bit indicate bit number in PCI channel byte
76 |
77 | public: //---------------------------------------------------------------------------------------------------------
78 | void config(uint8_t mode, uint8_t pcIntByte, uint8_t pcIntBit);
79 |
80 | protected: //---------------------------------------------------------------------------------------------------------
81 | private: //---------------------------------------------------------------------------------------------------------
82 | CB();
83 |
84 | void init(AS *ptrMain);
85 | void poll(void);
86 |
87 | void outSignal(uint8_t mode);
88 | };
89 |
90 | #endif
91 |
--------------------------------------------------------------------------------
/Dummy.cpp.old:
--------------------------------------------------------------------------------
1 | //- -----------------------------------------------------------------------------------------------------------------------
2 | // AskSin driver implementation
3 | // 2013-08-03 Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
4 | //- -----------------------------------------------------------------------------------------------------------------------
5 | //- AskSin dummy class ----------------------------------------------------------------------------------------------------
6 | //- with a lot of support from martin876 at FHEM forum
7 | //- -----------------------------------------------------------------------------------------------------------------------
8 |
9 | //#define DM_DBG // debug message flag
10 | #include "Dummy.h"
11 |
12 |
13 | //-------------------------------------------------------------------------------------------------------------------------
14 | //- mandatory functions for every new module to communicate within HM protocol stack -
15 | //-------------------------------------------------------------------------------------------------------------------------
16 | void Dummy::setToggle(void) {
17 | // setToggle will be addressed by config button in mode 2 by a short key press
18 | // here we can toggle the status of the actor
19 | #ifdef DM_DBG
20 | dbg << F("sT\n");
21 | #endif
22 |
23 | }
24 | void Dummy::configCngEvent(void) {
25 | // it's only for information purpose while something in the channel config was changed (List0/1 or List3/4)
26 | #ifdef DM_DBG
27 | dbg << F("CCE, lst1: ") << pHex(((uint8_t*)&lstCnl), sizeof(s_lstCnl)) << '\n';
28 | #endif
29 | }
30 |
31 | void Dummy::pairSetEvent(uint8_t *data, uint8_t len) {
32 | // we received a message from master to set a new value, typical you will find three bytes in data
33 | // 1st byte = value; 2nd byte = ramp time; 3rd byte = duration time;
34 | // after setting the new value we have to send an enhanced ACK (<- 0E E7 80 02 1F B7 4A 63 19 63 01 01 C8 00 54)
35 | #ifdef DM_DBG
36 | dbg << F("PSE, value:") << pHexB(data[0]);
37 | if (len > 1) dbg << F(", rampTime: ") << pHexB(data[1]);
38 | if (len > 2) dbg << F(", duraTime: ") << pHexB(data[2]);
39 | dbg << '\n';
40 | #endif
41 |
42 | hm->sendACK_STATUS(regCnl, data[0], modDUL);
43 | }
44 |
45 | void Dummy::pairStatusReq(void) {
46 | // we received a status request, appropriate answer is an InfoActuatorStatus message
47 | #ifdef DM_DBG
48 | dbg << F("PSR\n");
49 | #endif
50 |
51 | hm->sendINFO_ACTUATOR_STATUS(regCnl, modStat, modDUL);
52 | }
53 |
54 | void Dummy::peerMsgEvent(uint8_t type, uint8_t *data, uint8_t len) {
55 | // we received a peer event, in type you will find the marker if it was a switch(3E), remote(40) or sensor(41) event
56 | // appropriate answer is an ACK
57 | #ifdef DM_DBG
58 | dbg << F("PME, type: ") << pHexB(type) << F(", data: ") << pHex(data, len) << '\n';
59 | #endif
60 |
61 | if ((type == 0x3e) || (type == 0x40) || (type == 0x41)) {
62 | hm->sendACK_STATUS(regCnl, modStat, modDUL);
63 | } else {
64 | hm->sendACK();
65 | }
66 | }
67 |
68 | void Dummy::poll(void) {
69 | // just polling, as the function name said
70 | }
71 |
72 |
73 | //-------------------------------------------------------------------------------------------------------------------------
74 | //- predefined, no reason to touch -
75 | //-------------------------------------------------------------------------------------------------------------------------
76 | void Dummy::regInHM(uint8_t cnl, uint8_t lst, AS *instPtr) {
77 | hm = instPtr; // set pointer to the HM module
78 | hm->rg.regInAS(cnl, lst, s_mod_dlgt(this,&Dummy::hmEventCol), (uint8_t*)&lstCnl,(uint8_t*)&lstPeer);
79 | regCnl = cnl; // stores the channel we are responsible fore
80 | }
81 | void Dummy::hmEventCol(uint8_t by3, uint8_t by10, uint8_t by11, uint8_t *data, uint8_t len) {
82 | // dbg << "by3:" << by3 << " by10:" << by10 << " d:" << pHex(data, len) << '\n'; _delay_ms(100);
83 | if ((by3 == 0x00) && (by10 == 0x00)) poll();
84 | else if ((by3 == 0x00) && (by10 == 0x01)) setToggle();
85 | else if ((by3 == 0x01) && (by11 == 0x06)) configCngEvent();
86 | else if ((by3 == 0x11) && (by10 == 0x02)) pairSetEvent(data, len);
87 | else if ((by3 == 0x01) && (by11 == 0x0E)) pairStatusReq();
88 | else if ((by3 == 0x01) && (by11 == 0x01)) peerAddEvent(data, len);
89 | else if (by3 >= 0x3E) peerMsgEvent(by3, data, len);
90 | else return;
91 | }
92 | void Dummy::peerAddEvent(uint8_t *data, uint8_t len) {
93 | // we received an peer add event, which means, there was a peer added in this respective channel
94 | // 1st byte and 2nd byte shows the peer channel, 3rd and 4th byte gives the peer index
95 | // no need for sending an answer, but we could set default data to the respective list3/4
96 | #ifdef DM_DBG
97 | dbg << F("peerAddEvent: pCnl1: ") << pHexB(data[0]) << F(", pCnl2: ") << pHexB(data[1]) << F(", pIdx1: ") << pHexB(data[2]) << F(", pIdx2: ") << pHexB(data[3]) << '\n';
98 | #endif
99 |
100 | if ((data[0]) && (data[1])) { // dual peer add
101 | if (data[0]%2) { // odd
102 | //hm->setListFromModule(regCnl,data[2],(uint8_t*)peerOdd,sizeof(peerOdd));
103 | //hm->setListFromModule(regCnl,data[3],(uint8_t*)peerEven,sizeof(peerEven));
104 | } else { // even
105 | //hm->setListFromModule(regCnl,data[2],(uint8_t*)peerEven,sizeof(peerEven));
106 | //hm->setListFromModule(regCnl,data[3],(uint8_t*)peerOdd,sizeof(peerOdd));
107 | }
108 | } else { // single peer add
109 | //if (data[0]) hm->setListFromModule(regCnl,data[2],(uint8_t*)peerSingle,sizeof(peerSingle));
110 | //if (data[1]) hm->setListFromModule(regCnl,data[3],(uint8_t*)peerSingle,sizeof(peerSingle));
111 | }
112 | }
113 |
--------------------------------------------------------------------------------
/HAL_atmega328P.h:
--------------------------------------------------------------------------------
1 | #define power_serial_enable() power_usart0_enable();
2 | #define UCSR UCSR0B
3 | #define RXEN RXEN0
4 |
5 | //- cc1100 hardware definitions ---------------------------------------------------------------------------------------------
6 | #define SPI_PORT PORTB // SPI port definition
7 | #define SPI_DDR DDRB
8 | #define SPI_MISO PORTB4
9 | #define SPI_MOSI PORTB3
10 | #define SPI_SCLK PORTB5
11 | //- -------------------------------------------------------------------------------------------------------------------------
12 |
13 |
14 | //- power management definitions --------------------------------------------------------------------------------------------
15 | #define backupPwrRegs() uint8_t xPrr = PRR; PRR = 0xFF;
16 | #define recoverPwrRegs() PRR = xPrr;
17 | #define offBrownOut() MCUCR = (1< Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
4 | //- -----------------------------------------------------------------------------------------------------------------------
5 | //- AskSin power management function --------------------------------------------------------------------------------------
6 | //- with a lot of support from martin876 at FHEM forum
7 | //- -----------------------------------------------------------------------------------------------------------------------
8 |
9 | //#define PW_DBG
10 | #include "Power.h"
11 | #include "AS.h"
12 |
13 | // private: //---------------------------------------------------------------------------------------------------------
14 | waitTimer pwrTmr; // power timer functionality
15 |
16 |
17 | PW::PW() {
18 | }
19 | void PW::init(AS *ptrMain) {
20 | #ifdef PW_DBG // only if ee debug is set
21 | dbgStart(); // serial setup
22 | dbg << F("PW.\n"); // ...and some information
23 | #endif
24 |
25 | pHM = ptrMain; // pointer to main class
26 | pwrMode = 0; // set default
27 | }
28 | void PW::setMode(uint8_t mode) {
29 | pwrMode = mode;
30 |
31 | //#ifdef PW_DBG // only if pw debug is set
32 | dbg << F("PowerMode: ") << pwrMode << '\n'; // ...and some information
33 | //#endif
34 |
35 | initWakeupPin();
36 | //setSleepMode();
37 | stayAwake(10000); // startup means stay awake for next 20 seconds
38 | }
39 | void PW::stayAwake(uint16_t time) {
40 | if (time < pwrTmr.remain()) return; // set new timeout only if we have to add something
41 | pwrTmr.set(time);
42 | }
43 | void PW::poll(void) {
44 | // check against active flag of various modules
45 | // on mode 0 there is nothing to do, maybe set idle mode to save some energy
46 | //
47 | // mode 1 means - check every 250ms if there is a transmition signal, if yes, wait
48 | // 50ms and check again - if it is still active, then wakeup the device for some time,
49 | // if not, then sleep again
50 | //
51 | // mode 2 means - sleep for 250ms, wake up - check if something is to do, otherwise sleep again
52 | // communication module could stay idle, communication will start with transmition
53 | //
54 | // mode 3 means - sleep for 8000ms, wake up - check if something is to do, otherwise sleep again
55 | // communication module could stay idle, communication will start with transmition
56 | //
57 | // mode 4 means - sleep for ever until an interrupt get raised
58 |
59 | if (pwrMode == 0) return; // no power savings, there for we can exit
60 | if (!pwrTmr.done()) return; // timer active, jump out
61 | if (checkWakeupPin()) return; // wakeup pin active
62 |
63 | // some communication still active, jump out
64 | if ((pHM->sn.active) || (pHM->stcSlice.active) || (pHM->cFlag.active) || (pHM->pairActive) || (pHM->confButton.armFlg)) return;
65 |
66 | #ifdef PW_DBG // only if pw debug is set
67 | dbg << '.'; // ...and some information
68 | _delay_ms(1);
69 | uint32_t fTme = getMillis();
70 | #endif
71 |
72 |
73 | if (pwrMode == 1) { // check communication on power mode 1
74 |
75 | tmpCCBurst = pHM->cc.detectBurst();
76 |
77 | if ((tmpCCBurst) && (!chkCCBurst)) { // burst detected for the first time
78 | chkCCBurst = 1; // set the flag
79 |
80 | #ifdef PW_DBG // only if pw debug is set
81 | dbg << '1'; // ...and some information
82 | #endif
83 |
84 | } else if ((tmpCCBurst) && (chkCCBurst)) { // burst detected for the second time
85 | chkCCBurst = 0; // reset the flag
86 | stayAwake(500); // stay awake for some time to check if we receive a valid message
87 |
88 | #ifdef PW_DBG // only if pw debug is set
89 | dbg << '2'; // ...and some information
90 | #endif
91 |
92 | return; // we don't want proceed further, jump out
93 |
94 | } else if ((!tmpCCBurst) && (chkCCBurst)) { // secondary test was negative, reset the flag
95 | chkCCBurst = 0; // reset the flag
96 |
97 | #ifdef PW_DBG // only if pw debug is set
98 | dbg << '-'; // ...and some information
99 | #endif
100 | }
101 | }
102 |
103 | // if we are here, we could go sleep. set cc module idle, switch off led's and sleep
104 | pHM->cc.setIdle(); // set communication module to idle
105 | pHM->ld.set(nothing); // switch off all led's
106 |
107 | // start the respective watchdog timers
108 | cli();
109 | if ((pwrMode == 1) && (!chkCCBurst)) startWDG250ms();
110 | if ((pwrMode == 1) && (chkCCBurst)) startWDG32ms();
111 | if (pwrMode == 2) startWDG250ms();
112 | if (pwrMode == 3) startWDG8000ms();
113 | sei();
114 |
115 |
116 | setSleep(); // call sleep function in HAL
117 | // wake up will be here
118 | // ---------------------
119 | //
120 | if (pwrMode != 4) stopWDG(); // stop the watchdog
121 | stayAwake(6); // stay awake for a very short time to get things done
122 |
123 | #ifdef PW_DBG // only if pw debug is set
124 | dbg << ':';// << (getMillis() -fTme) << '\n'; // ...and some information
125 | #endif
126 |
127 | }
128 |
--------------------------------------------------------------------------------
/Power.h:
--------------------------------------------------------------------------------
1 | //- -----------------------------------------------------------------------------------------------------------------------
2 | // AskSin driver implementation
3 | // 2013-08-03 Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
4 | //- -----------------------------------------------------------------------------------------------------------------------
5 | //- AskSin power management function --------------------------------------------------------------------------------------
6 | //- with a lot of support from martin876 at FHEM forum
7 | //- -----------------------------------------------------------------------------------------------------------------------
8 |
9 | #ifndef _PW_H
10 | #define _PW_H
11 |
12 | #include "HAL.h"
13 |
14 | // - power modes to implement -----------
15 | // 0 - 19.9ma; no power management
16 | // 1 - wake up every 250ms, check for wakeup signal on air and stay awake accordingly, timer gets updated every 250ms
17 | // 2 - deep sleep, wakeup every 250ms, not able to receive anything while sleeping, timer gets updated every 256ms
18 | // 3 - 0.04ma; deep sleep, wakeup every 8 seconds, not able to receive anything while sleeping, timer gets updated every 8192ms
19 | // 4 - 0.00ma; deep sleep, wakeup only on interrupt
20 |
21 | class PW {
22 | friend class AS;
23 |
24 | private: //---------------------------------------------------------------------------------------------------------
25 | protected: //---------------------------------------------------------------------------------------------------------
26 | class AS *pHM; // pointer to main class for function calls
27 |
28 | uint8_t pwrMode :3; // remember the level of power savings
29 | uint8_t chkCCBurst :1;
30 | uint8_t comStat :1;
31 | uint8_t tmpCCBurst :1;
32 |
33 | public: //---------------------------------------------------------------------------------------------------------
34 |
35 | public: //---------------------------------------------------------------------------------------------------------
36 | void setMode(uint8_t mode);
37 | void stayAwake(uint16_t time);
38 |
39 | protected: //---------------------------------------------------------------------------------------------------------
40 | private: //---------------------------------------------------------------------------------------------------------
41 | PW();
42 | void init(AS *ptrMain);
43 | void poll(void);
44 | };
45 |
46 | #endif
47 |
--------------------------------------------------------------------------------
/Receive.cpp:
--------------------------------------------------------------------------------
1 | //- -----------------------------------------------------------------------------------------------------------------------
2 | // AskSin driver implementation
3 | // 2013-08-03 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 | #define RV_DBG
10 | //#define RV_DBG_EX
11 | #include "Receive.h"
12 | #include "AS.h"
13 |
14 |
15 | // private: //---------------------------------------------------------------------------------------------------------
16 | RV::RV() {
17 | }
18 | void RV::init(AS *ptrMain) {
19 |
20 | #ifdef RV_DBG // only if ee debug is set
21 | dbgStart(); // serial setup
22 | dbg << F("RV.\n"); // ...and some information
23 | #endif
24 |
25 | pHM = ptrMain;
26 | buf = (uint8_t*)&mBdy;
27 | }
28 | void RV::poll(void) {
29 | static uint8_t last_rCnt;
30 |
31 | if (this->bufLen > 10) { // create search string for peer
32 | memcpy(this->peerId, this->mBdy.reID, 3);
33 | this->peerId[3] = (this->buf[10] & 0x3f); // mask out long and battery low
34 | }
35 |
36 | uint8_t bIntend = pHM->ee.getIntend(this->mBdy.reID,this->mBdy.toID, this->peerId); // get the intend of the message
37 |
38 | // some debugs
39 | #ifdef RV_DBG // only if AS debug is set
40 | dbg << (char)bIntend << F("> ") << _HEX(this->buf, this->bufLen) << ' ' << _TIME << '\n';
41 | #endif
42 |
43 | #ifdef RV_DBG_EX // only if extended AS debug is set
44 | pHM->explainMessage(this->buf);
45 | #endif
46 |
47 | // filter out unknown or not for us
48 | if ((bIntend == 'l') || (bIntend == 'u')) { // not for us, or sender unknown
49 | this->mBdy.mLen = 0; // clear receive buffer
50 | return;
51 | }
52 |
53 | // filter out repeated messages
54 | if ((this->mBdy.mFlg.RPTED) && (last_rCnt == this->mBdy.mLen)) { // check if message was already received
55 | #ifdef RV_DBG // only if AS debug is set
56 | dbg << F(" repeated message\n");
57 | #endif
58 |
59 | this->mBdy.mLen = 0; // clear receive buffer
60 | return; // wait for next message
61 | }
62 | last_rCnt = this->mBdy.mLen;
63 |
64 | pHM->recvMessage();
65 |
66 | this->mBdy.mLen = 0;
67 | }
68 |
--------------------------------------------------------------------------------
/Receive.h:
--------------------------------------------------------------------------------
1 | //- -----------------------------------------------------------------------------------------------------------------------
2 | // AskSin driver implementation
3 | // 2013-08-03 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
66 |
--------------------------------------------------------------------------------
/Registrar.cpp:
--------------------------------------------------------------------------------
1 | //- -----------------------------------------------------------------------------------------------------------------------
2 | // AskSin driver implementation
3 | // 2013-08-03 Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
4 | //- -----------------------------------------------------------------------------------------------------------------------
5 | //- AskSin registrar functions --------------------------------------------------------------------------------------------
6 | //- with a lot of support from martin876 at FHEM forum
7 | //- -----------------------------------------------------------------------------------------------------------------------
8 |
9 | //#define RG_DBG
10 | #include "Registrar.h"
11 | #include "AS.h"
12 |
13 | // public: //---------------------------------------------------------------------------------------------------------
14 | void RG::regInAS(uint8_t cnl, uint8_t lst, s_mod_dlgt delegate, uint8_t *mainList, uint8_t *peerList) {
15 | modTbl[cnl-1].cnl = cnl;
16 | modTbl[cnl-1].lst = lst;
17 | modTbl[cnl-1].mDlgt = delegate;
18 | modTbl[cnl-1].lstCnl = mainList;
19 | modTbl[cnl-1].lstPeer = peerList;
20 |
21 | pHM->ee.getList(cnl,1,0,modTbl[cnl-1].lstCnl); // load list1 in the respective buffer
22 | modTbl[cnl-1].mDlgt(0x01, 0, 0x06, NULL, 0); // inform the module of the change
23 | }
24 |
25 | // private: //---------------------------------------------------------------------------------------------------------
26 | RG::RG() {
27 | }
28 | void RG::init(AS *ptrMain) {
29 |
30 | #ifdef RG_DBG // only if ee debug is set
31 | dbgStart(); // serial setup
32 | dbg << F("RG.\n"); // ...and some information
33 | #endif
34 |
35 | pHM = ptrMain;
36 | }
37 | void RG::poll(void) {
38 | // poll through the module table
39 | for (uint8_t i = 0; i < devDef.cnlNbr; i++) {
40 | if (modTbl[i].cnl) modTbl[i].mDlgt(0,0,0,NULL,0);
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/Registrar.h:
--------------------------------------------------------------------------------
1 | //- -----------------------------------------------------------------------------------------------------------------------
2 | // AskSin driver implementation
3 | // 2013-08-03 Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
4 | //- -----------------------------------------------------------------------------------------------------------------------
5 | //- AskSin registrar functions --------------------------------------------------------------------------------------------
6 | //- with a lot of support from martin876 at FHEM forum
7 | //- -----------------------------------------------------------------------------------------------------------------------
8 |
9 |
10 | #ifndef _RG_H
11 | #define _RG_H
12 |
13 | #include "HAL.h"
14 | #include "Fastdelegate.h"
15 |
16 | //- typedef for delegate to module function
17 | using namespace fastdelegate;
18 | typedef FastDelegate5 s_mod_dlgt; // void hmEventCol(uint8_t by3, uint8_t by10, uint8_t by11, uint8_t *data, uint8_t len)
19 |
20 | class RG {
21 | friend class AS;
22 |
23 | public: //---------------------------------------------------------------------------------------------------------
24 | struct s_modTable {
25 | uint8_t cnl; // channel where the module is registered to
26 | uint8_t lst; // module has a list3 or list 4
27 | uint8_t msgCnt; // channel message counter
28 | uint8_t *lstCnl; // pointer to list0/1
29 | uint8_t *lstPeer; // pointer to list3/4
30 | s_mod_dlgt mDlgt; // delegate to the module function
31 | };
32 |
33 | protected: //---------------------------------------------------------------------------------------------------------
34 |
35 | private: //---------------------------------------------------------------------------------------------------------
36 | class AS *pHM; // pointer to main class for function calls
37 |
38 | public: //---------------------------------------------------------------------------------------------------------
39 | void regInAS(uint8_t cnl, uint8_t lst, s_mod_dlgt delegate, uint8_t *mainList, uint8_t *peerList);
40 |
41 | protected: //---------------------------------------------------------------------------------------------------------
42 | private: //---------------------------------------------------------------------------------------------------------
43 | RG();
44 | void init(AS *ptrMain);
45 | void poll(void);
46 |
47 | };
48 | extern RG::s_modTable modTbl[]; // initial register.h
49 |
50 | #endif
51 |
--------------------------------------------------------------------------------
/Send.cpp:
--------------------------------------------------------------------------------
1 | //- -----------------------------------------------------------------------------------------------------------------------
2 | // AskSin driver implementation
3 | // 2013-08-03 Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
4 | //- -----------------------------------------------------------------------------------------------------------------------
5 | //- AskSin send function --------------------------------------------------------------------------------------------------
6 | //- with a lot of support from martin876 at FHEM forum
7 | //- -----------------------------------------------------------------------------------------------------------------------
8 |
9 | #define SN_DBG
10 | #include "Send.h"
11 | #include "AS.h"
12 |
13 | // private: //---------------------------------------------------------------------------------------------------------
14 | #define sndLen this->buf[0]+1 // amount of bytes in the send buffer
15 | #define reqACK this->mBdy.mFlg.BIDI // check if an ACK is requested
16 |
17 | waitTimer sndTmr; // send timer functionality
18 |
19 | SN::SN() {
20 | }
21 | void SN::init(AS *ptrMain) {
22 | #ifdef SN_DBG // only if ee debug is set
23 | dbgStart(); // serial setup
24 | dbg << F("SN.\n"); // ...and some information
25 | #endif
26 |
27 | pHM = ptrMain;
28 | buf = (uint8_t*)&mBdy;
29 | }
30 | void SN::poll(void) {
31 | #define maxRetries 3
32 | #define maxTime 300
33 |
34 | // set right amount of retries
35 | if (!this->maxRetr) { // first time run, check message type and set retries
36 | if (reqACK) this->maxRetr = maxRetries; // if BIDI is set, we have three retries
37 | else this->maxRetr = 1;
38 | }
39 |
40 | //dbg << "x:" << this->retrCnt << " y:" << this->maxRetr << " t:" << sndTmr.done() << '\n';
41 |
42 | // send something while timer is not busy with waiting for an answer and max tries are not done
43 | if ((this->retrCnt < this->maxRetr) && (sndTmr.done() )) { // not all sends done and timing is OK
44 |
45 | // some sanity
46 | this->mBdy.mFlg.RPTEN = 1; // every message need this flag
47 | //if (pHM->cFlag.active) this->mBdy.mFlg.CFG = pHM->cFlag.active; // set the respective flag while we are in config mode
48 | this->timeOut = 0; // not timed out because just started
49 | this->lastMsgCnt = this->mBdy.mCnt; // copy the message count to identify the ACK
50 | this->retrCnt++; // increase counter while send out
51 |
52 | // check if we should send an internal message
53 | if (compArray(this->mBdy.toID, HMID, 3)) { // message is addressed to us
54 | memcpy(pHM->rv.buf, this->buf, sndLen); // copy send buffer to received buffer
55 | this->retrCnt = 0xff; // ACK not required, because internal
56 |
57 | #ifdef SN_DBG // only if AS debug is set
58 | dbg << F("mBdy.mFlg.BURST; // get burst flag, while string will get encoded
63 | pHM->encode(this->buf); // encode the string
64 | disableGDO0Int();
65 | pHM->cc.sndData(this->buf,tBurst); // send to communication module
66 | enableGDO0Int();
67 | pHM->decode(this->buf); // decode the string, so it is readable next time
68 |
69 | if (reqACK) sndTmr.set(maxTime); // set the time out for the message
70 |
71 | #ifdef SN_DBG // only if AS debug is set
72 | dbg << F("<- ");
73 | #endif
74 |
75 | }
76 |
77 | if (!pHM->ld.active) pHM->ld.set(send); // fire the status led
78 |
79 | #ifdef SN_DBG // only if AS debug is set
80 | dbg << _HEX(this->buf,sndLen) << ' ' << _TIME << '\n';
81 | #endif
82 |
83 | } else if ((this->retrCnt >= this->maxRetr) && (sndTmr.done() )) { // max retries achieved, but seems to have no answer
84 | this->retrCnt = 0;
85 | this->maxRetr = 0;
86 | this->active = 0;
87 | if (!reqACK) return;
88 |
89 | this->timeOut = 1; // set the time out only while an ACK or answer was requested
90 | pHM->pw.stayAwake(100);
91 | pHM->ld.set(noack);
92 |
93 | #ifdef SN_DBG // only if AS debug is set
94 | dbg << F(" timed out") << ' ' << _TIME << '\n';
95 | #endif
96 | }
97 |
98 | if (this->retrCnt == 0xff) { // answer was received, clean up the structure
99 | this->timeOut = 0;
100 | this->retrCnt = 0;
101 | this->maxRetr = 0;
102 | this->active = 0;
103 | sndTmr.set(0);
104 |
105 | pHM->pw.stayAwake(100);
106 | if (!pHM->ld.active) pHM->ld.set(ack); // fire the status led
107 | }
108 |
109 |
110 | }
111 |
--------------------------------------------------------------------------------
/Send.h:
--------------------------------------------------------------------------------
1 | //- -----------------------------------------------------------------------------------------------------------------------
2 | // AskSin driver implementation
3 | // 2013-08-03 Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
4 | //- -----------------------------------------------------------------------------------------------------------------------
5 | //- AskSin send function --------------------------------------------------------------------------------------------------
6 | //- with a lot of support from martin876 at FHEM forum
7 | //- -----------------------------------------------------------------------------------------------------------------------
8 |
9 | #ifndef _SN_H
10 | #define _SN_H
11 |
12 | #include "HAL.h"
13 | #define MaxDataLen 60 // maximum length of received bytes
14 |
15 |
16 | class SN {
17 | friend class AS;
18 |
19 | private: //---------------------------------------------------------------------------------------------------------
20 |
21 | struct s_mFlg {
22 | uint8_t WKUP :1; // 0x01: send initially to keep the device awake
23 | uint8_t WKMEUP :1; // 0x02: awake - hurry up to send messages
24 | uint8_t CFG :1; // 0x04: Device in Config mode
25 | uint8_t :1;
26 | uint8_t BURST :1; // 0x10: set if burst is required by device
27 | uint8_t BIDI :1; // 0x20: response is expected
28 | uint8_t RPTED :1; // 0x40: repeated (repeater operation)
29 | uint8_t RPTEN :1; // 0x80: set in every message. Meaning?
30 | };
31 |
32 | struct s_msgBody {
33 | uint8_t mLen; // message length
34 | uint8_t mCnt; // counter, if it is an answer counter has to reflect the answered message, otherwise own counter has to be used
35 | struct s_mFlg mFlg; // see structure of message flags
36 | uint8_t mTyp; // type of message
37 | uint8_t reID[3]; // sender ID
38 | uint8_t toID[3]; // receiver id, broadcast for 0
39 | uint8_t by10; // type of message
40 | uint8_t by11; // type of message
41 | uint8_t pyLd[MaxDataLen-12]; // payload
42 | };
43 |
44 |
45 | uint8_t retrCnt; // variable to count how often a message was already send
46 | uint8_t maxRetr; // how often a message has to be send until ACK
47 | uint8_t lastMsgCnt; // store of message counter, needed to identify ACK
48 |
49 | class AS *pHM; // pointer to main class for function calls
50 |
51 | protected: //---------------------------------------------------------------------------------------------------------
52 | public: //---------------------------------------------------------------------------------------------------------
53 | struct s_msgBody mBdy; // structure for easier message creation
54 | uint8_t *buf; // cast to byte array
55 |
56 | uint8_t msgCnt; // message counter for standard sends, while not answering something
57 |
58 | uint8_t active :1; // is send module active, 1 indicates yes
59 | uint8_t timeOut :1; // was last message a timeout
60 |
61 | public: //---------------------------------------------------------------------------------------------------------
62 | protected: //---------------------------------------------------------------------------------------------------------
63 | private: //---------------------------------------------------------------------------------------------------------
64 |
65 | SN();
66 | void init(AS *ptrMain);
67 | void poll(void);
68 | };
69 |
70 | #endif
71 |
--------------------------------------------------------------------------------
/StatusLed.cpp:
--------------------------------------------------------------------------------
1 | //- -----------------------------------------------------------------------------------------------------------------------
2 | // AskSin driver implementation
3 | // 2013-08-03 Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
4 | //- -----------------------------------------------------------------------------------------------------------------------
5 | //- AskSin status led functions -------------------------------------------------------------------------------------------
6 | //- with a lot of support from martin876 at FHEM forum
7 | //- -----------------------------------------------------------------------------------------------------------------------
8 |
9 | //#define LD_DBG
10 | #include "StatusLed.h"
11 | #include "AS.h"
12 |
13 | waitTimer ledTmr; // config timer functionality
14 |
15 | // public: //---------------------------------------------------------------------------------------------------------
16 |
17 | // private: //---------------------------------------------------------------------------------------------------------
18 | LD::LD() {
19 | }
20 | void LD::init(uint8_t leds, AS *ptrMain) {
21 |
22 | #ifdef LD_DBG // only if ee debug is set
23 | dbgStart(); // serial setup
24 | dbg << F("LD.\n"); // ...and some information
25 | #endif
26 |
27 | pHM = ptrMain;
28 | bLeds = leds;
29 | }
30 |
31 | void LD::set(ledStat stat) {
32 | if (!bLeds) return; // no led available, skip...
33 | #ifdef LD_DBG
34 | dbg << "stat: " << stat << '\n';
35 | #endif
36 |
37 | ledRed(0); // new program starts, so switch leds off
38 | ledGrn(0);
39 |
40 | uint8_t leds = bLeds-1;
41 | if (stat == pairing) blinkPtr = &sPairing[leds];
42 | else if (stat == pair_suc) blinkPtr = &sPair_suc[leds];
43 | else if (stat == pair_err) blinkPtr = &sPair_err[leds];
44 | else if (stat == send) blinkPtr = &sSend[leds];
45 | else if (stat == ack) blinkPtr = &sAck[leds];
46 | else if (stat == noack) blinkPtr = &sNoack[leds];
47 | else if (stat == bat_low) blinkPtr = &sBattLow[leds];
48 | else if (stat == defect) blinkPtr = &sDefect[leds];
49 | else if (stat == welcome) blinkPtr = &sWelcome[leds];
50 | else if (stat == key_long) blinkPtr = &sKeyLong[leds];
51 |
52 | active = 1; // make module active
53 | lCnt = 0; // set start position
54 | dCnt = 1;
55 |
56 | // some sanity on blink pointer
57 | if (blinkPtr->len == 0) stat = nothing;
58 |
59 | if (stat == nothing) {
60 | ledTmr.set(0); // timer done
61 | active = 0; // nothing to do any more
62 | return; // jump out
63 | }
64 | }
65 | void LD::blinkRed(void) {
66 | if (!bLeds) return; // no led available, skip...
67 |
68 | ledRed(0); // switch led off
69 | _delay_ms(20); // wait
70 | ledRed(1); // switch led on
71 | _delay_ms(20); // wait
72 | ledRed(0); // switch led off
73 | }
74 | void LD::poll(void) {
75 | if (!active) return; // still waiting to do something
76 | if (!ledTmr.done()) return; // active but timer not done
77 |
78 | // if we are here we have something to do, set the led, timer and counter
79 | ledTmr.set(blinkPtr->pat[lCnt]*10); // set the timer for next check up
80 | if ((blinkPtr->led0) && (blinkPtr->pat[lCnt])) {
81 | ledRed((lCnt % 2)^1); // set the led
82 | #ifdef LD_DBG
83 | dbg << "lCnt:" << lCnt << " led0: " << ((lCnt % 2)^1) << '\n';
84 | #endif
85 | }
86 |
87 | if ((blinkPtr->led1) && (blinkPtr->pat[lCnt])) {
88 | ledGrn((lCnt % 2)^1);
89 | #ifdef LD_DBG
90 | dbg << "lCnt:" << lCnt << " led1: " << ((lCnt % 2)^1) << '\n';
91 | #endif
92 | }
93 | lCnt++; // increase the pointer for the blink string
94 |
95 | // check if position pointer runs out of string
96 | if (lCnt >= blinkPtr->len) { // we are through the pattern
97 | if (blinkPtr->dur == 0) { // we are in an endless loop
98 | lCnt = 0;
99 | #ifdef LD_DBG
100 | dbg << "lCnt 0\n";
101 | #endif
102 | } else if (dCnt < blinkPtr->dur) { // duration is not done
103 | lCnt = 0;
104 | dCnt++;
105 | #ifdef LD_DBG
106 | dbg << "lCnt 0, dCnt++\n";
107 | #endif
108 | } else {
109 | set(nothing);
110 | }
111 | }
112 | }
113 |
--------------------------------------------------------------------------------
/StatusLed.h:
--------------------------------------------------------------------------------
1 | //- -----------------------------------------------------------------------------------------------------------------------
2 | // AskSin driver implementation
3 | // 2013-08-03 Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
4 | //- -----------------------------------------------------------------------------------------------------------------------
5 | //- AskSin status led functions -------------------------------------------------------------------------------------------
6 | //- with a lot of support from martin876 at FHEM forum
7 | //- -----------------------------------------------------------------------------------------------------------------------
8 |
9 | #ifndef _LD_H
10 | #define _LD_H
11 |
12 | #include "HAL.h"
13 |
14 |
15 | struct s_blinkPattern { // struct for defining the blink pattern
16 | uint8_t len :3; // length of pattern string
17 | uint8_t dur :3; // how often the pattern has to be repeated, 0 for endless
18 | uint8_t led0 :1; // red
19 | uint8_t led1 :1; // green, if you like orange, set led0 and led1 to one
20 | uint8_t pat[6]; // the pattern it self, pattern starts always with the on time, followed by off time.
21 | }; // time is given in 10ms steps
22 |
23 | enum ledStat {nothing, pairing, pair_suc, pair_err, send, ack, noack, bat_low, defect, welcome, key_long};
24 |
25 | // we need two type of blink patterns, one with only one led and a second one with a bi color led
26 | const struct s_blinkPattern sPairing[2] = { // 1; define pairing string
27 | {2, 0, 1, 0, {50, 50,} },
28 | {2, 0, 1, 1, {50, 50,} },
29 | };
30 | const struct s_blinkPattern sPair_suc[2] = { // 2; define pairing success
31 | {2, 1, 1, 0, {200, 0,} },
32 | {2, 1, 0, 1, {200, 0,} },
33 | };
34 | const struct s_blinkPattern sPair_err[2] = { // 3; define pairing error
35 | {2, 3, 1, 0, {5, 10,} },
36 | {2, 1, 1, 0, {200, 0,} },
37 | };
38 | const struct s_blinkPattern sSend[2] = { // 4; define send indicator
39 | {2, 1, 1, 0, {5, 1,} },
40 | {2, 1, 1, 1, {5, 1,} },
41 | };
42 | const struct s_blinkPattern sAck[2] = { // 5; define ack indicator
43 | {0, 0, 0, 0, {0, 0,} },
44 | {2, 1, 0, 1, {5, 1,} },
45 | };
46 | const struct s_blinkPattern sNoack[2] = { // 6; define no ack indicator
47 | {0, 0, 0, 0, {0, 0,} },
48 | {2, 1, 1, 0, {10, 1,} },
49 | };
50 | const struct s_blinkPattern sBattLow[2] = { // 7; define battery low indicator
51 | {6, 3, 1, 0, {50, 10, 10, 10, 10, 100} },
52 | {6, 3, 1, 0, {50, 10, 10, 10, 10 ,100} },
53 | };
54 | const struct s_blinkPattern sDefect[2] = { // 8; define defect indicator
55 | {6, 3, 1, 0, {10, 10, 10, 10, 10, 100} },
56 | {6, 3, 1, 0, {10, 10, 10, 10, 10, 100} },
57 | };
58 | const struct s_blinkPattern sWelcome[2] = { // 9; define welcome indicator
59 | {6, 1, 1, 0, {10, 10, 50, 10, 50, 100} },
60 | {6, 1, 0, 1, {10, 10, 50, 10, 50, 100} },
61 | };
62 | const struct s_blinkPattern sKeyLong[2] = { // 10; key long indicator
63 | {2, 6, 1, 0, {20, 20, } },
64 | {2, 6, 1, 0, {20, 20, } },
65 | };
66 |
67 |
68 |
69 | class LD {
70 | friend class AS;
71 |
72 | public: //---------------------------------------------------------------------------------------------------------
73 | uint8_t active :1; // something active
74 |
75 | protected: //---------------------------------------------------------------------------------------------------------
76 | private: //---------------------------------------------------------------------------------------------------------
77 |
78 | class AS *pHM; // pointer to main class for function calls
79 |
80 | const struct s_blinkPattern *blinkPtr; // pointer to blink struct
81 |
82 | uint8_t bLeds :2; // 1 or 2 leds
83 | uint8_t lCnt :3; // counter for positioning inside of blink string
84 | uint8_t dCnt :3; // duration counter
85 |
86 | public: //---------------------------------------------------------------------------------------------------------
87 | void init(uint8_t leds, AS *ptrMain);
88 | void set(ledStat stat);
89 | void blinkRed(void);
90 |
91 | protected: //---------------------------------------------------------------------------------------------------------
92 | private: //---------------------------------------------------------------------------------------------------------
93 | LD();
94 | void poll(void);
95 |
96 | };
97 |
98 |
99 | #endif
100 |
--------------------------------------------------------------------------------
/THSensor.h:
--------------------------------------------------------------------------------
1 | //- -----------------------------------------------------------------------------------------------------------------------
2 | // AskSin driver implementation
3 | // 2013-08-03 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
81 |
--------------------------------------------------------------------------------
/Version.h:
--------------------------------------------------------------------------------
1 | //- -----------------------------------------------------------------------------------------------------------------------
2 | // AskSin driver implementation
3 | // 2013-08-03 , Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
4 | //- -----------------------------------------------------------------------------------------------------------------------
5 |
6 | #ifndef _VERSION_H
7 | #define _VERSION_H
8 |
9 | #define LIB_VERSION_MAJOR 0
10 | #define LIB_VERSION_MINOR 2
11 | #define LIB_VERSION_PATCH 2
12 |
13 | #define STR(x) #x
14 | #define LIB_VERSION_STRING_FUNC(v1, v2, v3) "AskSin-Lib V " STR(v1) "." STR(v2) "." STR(v3) "\n"
15 | #define LIB_VERSION_STRING LIB_VERSION_STRING_FUNC (LIB_VERSION_MAJOR, LIB_VERSION_MINOR, LIB_VERSION_PATCH)
16 |
17 | #endif
18 |
--------------------------------------------------------------------------------
/destillRegs/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | destillRegs
4 |
5 |
6 |
7 |
8 |
9 | org.epic.perleditor.perlbuilder
10 |
11 |
12 |
13 |
14 |
15 | org.epic.perleditor.perlnature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/destillRegs/devDefinition - Dimmer.pm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/trilu2000/NewAskSin/75d3209f34f6ab559c0b6d1d7cbe09c53da2cd61/destillRegs/devDefinition - Dimmer.pm
--------------------------------------------------------------------------------
/destillRegs/devDefinition.pm:
--------------------------------------------------------------------------------
1 | use strict;
2 | #Beispiel
3 |
4 | #----------------define reglist types-----------------
5 | package usrRegs;
6 |
7 | # sub types - needed in register.h
8 | # "01" => { st => "AlarmControl",
9 | # "10" => { st => "switch",
10 | # "12" => { st => "outputUnit",
11 | # "20" => { st => "dimmer",
12 | # "30" => { st => "blindActuator",
13 | # "39" => { st => "ClimateControl",
14 | # "40" => { st => "remote",
15 | # "41" => { st => "sensor",
16 | # "42" => { st => "swi",
17 | # "43" => { st => "pushButton",
18 | # "44" => { st => "singleButton",
19 | # "51" => { st => "powerMeter",
20 | # "58" => { st => "thermostat",
21 | # "60" => { st => "KFM100",
22 | # "70" => { st => "THSensor",
23 | # "80" => { st => "threeStateSensor"
24 | # "81" => { st => "motionDetector",
25 | # "C0" => { st => "keyMatic",
26 | # "C1" => { st => "winMatic",
27 | # "C3" => { st => "tipTronic",
28 | # "CD" => { st => "smokeDetector",
29 |
30 | my %listTypes = (
31 | #regDev => { burstRx=>1, intKeyVisib=>1, pairCentral=>1, localResDis=>1,
32 | regDev => { burstRx=>1, intKeyVisib=>1, pairCentral=>1,
33 | },
34 |
35 | regSwitch => { sign=>1, longPress=>1, dblPress=>1,
36 | peerNeedsBurst=>1, expectAES=>1,
37 | },
38 |
39 | regRelay => { sign=>1,
40 | shCtDlyOn=>1, shCtDlyOff=>1, shCtOn=>1, shCtOff=>1, shCtValLo=>1, shCtValHi=>1, shOnDly=>1, shOnTime=>1, shOffDly=>1, shOffTime=>1, shActionType=>1,
41 | shOffTimeMode=>1, shOnTimeMode=>1, shSwJtOn=>1, shSwJtOff=>1, shSwJtDlyOn=>1, shSwJtDlyOff=>1,
42 | lgCtDlyOn=>1, lgCtDlyOff=>1, lgCtOn=>1, lgCtOff=>1, lgCtValLo=>1, lgCtValHi=>1, lgOnDly=>1, lgOnTime=>1, lgOffDly=>1, lgOffTime=>1, lgActionType=>1, lgMultiExec=>1,
43 | lgOffTimeMode=>1, lgOnTimeMode=>1, lgSwJtOn=>1, lgSwJtOff=>1, lgSwJtDlyOn=>1, lgSwJtDlyOff=>1,
44 | },
45 |
46 |
47 | regDimmer => { transmitTryMax=>1, ovrTempLvl=>1, redTempLvl=>1, redLvl=>1, powerUpAction=>1, statusInfoMinDly=>1, statusInfoRandom=>1, characteristic=>1, logicCombination=>1,
48 |
49 | shCtRampOn=>1, shCtRampOff=>1, shCtDlyOn=>1, shCtDlyOff=>1, shCtOn=>1, shCtOff=>1, shCtValLo=>1, shCtValHi=>1, shOnDly=>1, shOnTime=>1, shOffDly=>1,
50 | shOffTime=>1, shActionTypeDim=>1, shOffTimeMode=>1, shOnTimeMode=>1, shDimJtOn=>1, shDimJtOff=>1, shDimJtDlyOn=>1, shDimJtDlyOff=>1, shDimJtRampOn=>1,
51 | shDimJtRampOff=>1, shOffDlyBlink=>1, shOnLvlPrio=>1, shOnDlyMode=>1, shOffLevel=>1, shOnMinLevel=>1, shOnLevel=>1, shRampSstep=>1, shRampOnTime=>1,
52 | shRampOffTime=>1, shDimMinLvl=>1, shDimMaxLvl=>1, shDimStep=>1, shOffDlyNewTime=>1, shOffDlyOldTime=>1, shDimElsActionType=>1, shDimElsOffTimeMd=>1,
53 | shDimElsOnTimeMd=>1, shDimElsJtOn=>1, shDimElsJtOff=>1, shDimElsJtDlyOn=>1, shDimElsJtDlyOff=>1, shDimElsJtRampOn=>1, shDimElsJtRampOff=>1,
54 | lgCtRampOn=>1, lgCtRampOff=>1, lgCtDlyOn=>1, lgCtDlyOff=>1, lgCtOn=>1, lgCtOff=>1, lgCtValLo=>1, lgCtValHi=>1, lgOnDly=>1, lgOnTime=>1, lgOffDly=>1,
55 | lgOffTime=>1, lgActionTypeDim=>1, lgMultiExec=>1, lgOffTimeMode=>1, lgOnTimeMode=>1, lgDimJtOn=>1, lgDimJtOff=>1, lgDimJtDlyOn=>1, lgDimJtDlyOff=>1,
56 | lgDimJtRampOn=>1, lgDimJtRampOff=>1, lgOffDlyBlink=>1, lgOnLvlPrio=>1, lgOnDlyMode=>1, lgOffLevel=>1, lgOnMinLevel=>1, lgOnLevel=>1, lgRampSstep=>1,
57 | lgRampOnTime=>1, lgRampOffTime=>1, lgDimMinLvl=>1, lgDimMaxLvl=>1, lgDimStep=>1, lgOffDlyNewTime=>1, lgOffDlyOldTime=>1, lgDimElsActionType=>1,
58 | lgDimElsOffTimeMd=>1, lgDimElsOnTimeMd=>1, lgDimElsJtOn=>1, lgDimElsJtOff=>1, lgDimElsJtDlyOn=>1, lgDimElsJtDlyOff=>1, lgDimElsJtRampOn=>1, lgDimElsJtRampOff=>1,
59 | },
60 |
61 | regTHSensor => { peerNeedsBurst=>1, expectAES=>1,
62 | },
63 |
64 | );
65 |
66 | #----------------assemble device -----------------
67 | my %regList;
68 | $regList{0}={type => "regDev",peers=>1};
69 |
70 | $regList{1}={type => "regDimmer",peers=>6};
71 | #$regList{1}={type => "regDimmer",peers=>6};
72 | #$regList{2}={type => "regDimmer",peers=>1};
73 | #$regList{3}={type => "regDimmer",peers=>1};
74 | #$regList{2}={type => "regSwitch",peers=>6};
75 | #$regList{3}={type => "regSwitch",peers=>6};
76 | #$regList{4}={type => "regSwitch",peers=>6};
77 | #$regList{5}={type => "regSwitch",peers=>6};
78 | #$regList{6}={type => "regSwitch",peers=>6};
79 |
80 |
81 | sub usr_getHash($){
82 | my $hn = shift;
83 | return %regList if($hn eq "regList" );
84 | return %listTypes if($hn eq "listTypes" );
85 | }
86 |
--------------------------------------------------------------------------------
/destillRegs/devDefinition.pm - HM6TastenSwitch:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/trilu2000/NewAskSin/75d3209f34f6ab559c0b6d1d7cbe09c53da2cd61/destillRegs/devDefinition.pm - HM6TastenSwitch
--------------------------------------------------------------------------------
/destillRegs/devDefinition.pm - HM_LC_SW1_BA_PCB:
--------------------------------------------------------------------------------
1 | use strict;
2 | #Beispiel
3 | # ========================switch =====================================
4 | #
5 | # "006C" => {name=>"HM-LC-SW1-BA-PCB" ,st=>'switch' ,cyc=>'' ,rxt=>'b' ,lst=>'3' ,chn=>"",},
6 | # 1 device
7 | # 1 kanal
8 | # 6 peers je kanal erlaubt
9 | #----------------define reglist types-----------------
10 | package usrRegs;
11 | my %listTypes = (
12 | regDev =>{ intKeyVisib=>1, ledMode=>1, lowBatLimitBA=>1, pairCentral=>1,
13 | },
14 | regChan =>{ sign =>1, #| literal | | signature (AES) options:on,off
15 | lgActionType =>1, #| literal | required | options:toggleToCntInv,off,toggleToCnt,jmpToTarget
16 | lgCtDlyOff =>1, #| literal | required | Jmp on condition from delayOff options:geLo,between,outside,ltLo,geHi,ltHi
17 | lgCtDlyOn =>1, #| literal | required | Jmp on condition from delayOn options:geLo,between,outside,ltLo,geHi,ltHi
18 | lgCtOff =>1, #| literal | required | Jmp on condition from off options:geLo,between,outside,ltLo,geHi,ltHi
19 | lgCtOn =>1, #| literal | required | Jmp on condition from on options:geLo,between,outside,ltLo,geHi,ltHi
20 | lgCtValHi =>1, #| 0 to 255 | required | Condition value high for CT table
21 | lgCtValLo =>1, #| 0 to 255 | required | Condition value low for CT table
22 | lgMultiExec =>1, #| literal | required | multiple execution per repeat of long trigger options:on,off
23 | lgOffDly =>1, #| 0 to 111600s | required | off delay
24 | lgOffTime =>1, #| 0 to 111600s | required | off time, 111600 = infinite
25 | lgOffTimeMode =>1, #| literal | required | off time mode options:minimal,absolut
26 | lgOnDly =>1, #| 0 to 111600s | required | on delay
27 | lgOnTime =>1, #| 0 to 111600s | required | on time, 111600 = infinite
28 | lgOnTimeMode =>1, #| literal | required | on time mode options:minimal,absolut
29 | lgSwJtDlyOff =>1, #| literal | required | Jump from delayOff options:on,off,dlyOn,no,dlyOff
30 | lgSwJtDlyOn =>1, #| literal | required | Jump from delayOn options:on,off,dlyOn,no,dlyOff
31 | lgSwJtOff =>1, #| literal | required | Jump from off options:on,off,dlyOn,no,dlyOff
32 | lgSwJtOn =>1, #| literal | required | Jump from on options:on,off,dlyOn,no,dlyOff
33 | shActionType =>1, #| literal | required | options:toggleToCntInv,off,toggleToCnt,jmpToTarget
34 | shCtDlyOff =>1, #| literal | required | Jmp on condition from delayOff options:geLo,between,outside,ltLo,geHi,ltHi
35 | shCtDlyOn =>1, #| literal | required | Jmp on condition from delayOn options:geLo,between,outside,ltLo,geHi,ltHi
36 | shCtOff =>1, #| literal | required | Jmp on condition from off options:geLo,between,outside,ltLo,geHi,ltHi
37 | shCtOn =>1, #| literal | required | Jmp on condition from on options:geLo,between,outside,ltLo,geHi,ltHi
38 | shCtValHi =>1, #| 0 to 255 | required | Condition value high for CT table
39 | shCtValLo =>1, #| 0 to 255 | required | Condition value low for CT table
40 | shOffDly =>1, #| 0 to 111600s | required | off delay
41 | shOffTime =>1, #| 0 to 111600s | required | off time, 111600 = infinite
42 | shOffTimeMode =>1, #| literal | required | off time mode options:minimal,absolut
43 | shOnDly =>1, #| 0 to 111600s | required | on delay
44 | shOnTime =>1, #| 0 to 111600s | required | on time, 111600 = infinite
45 | shOnTimeMode =>1, #| literal | required | on time mode options:minimal,absolut
46 | shSwJtDlyOff =>1, #| literal | required | Jump from delayOff options:on,off,dlyOn,no,dlyOff
47 | shSwJtDlyOn =>1, #| literal | required | Jump from delayOn options:on,off,dlyOn,no,dlyOff
48 | shSwJtOff =>1, #| literal | required | Jump from off options:on,off,dlyOn,no,dlyOff
49 | shSwJtOn =>1, #|
50 | },
51 | );
52 | # -----------assemble device -----------------
53 | my %regList;
54 | $regList{0}={type => "regDev",peers=>1};
55 | $regList{1}={type => "regChan",peers=>6};
56 |
57 | sub usr_getHash($){
58 | my $hn = shift;
59 | return %regList if($hn eq "regList" );
60 | return %listTypes if($hn eq "listTypes" );
61 | }
62 |
--------------------------------------------------------------------------------
/destillRegs/devDefinition.pm.pcb:
--------------------------------------------------------------------------------
1 | use strict;
2 | #Beispiel
3 | # ========================switch =====================================
4 | # battery powered 6 channel switch
5 | # "006C" => {name=>"HM-LC-SW1-BA-PCB" ,st=>'switch' ,cyc=>'' ,rxt=>'b' ,lst=>'3' ,chn=>"",},
6 | # 1 device
7 | # 1 kanal
8 | # 6 peers je kanal erlaubt
9 | #----------------define reglist types-----------------
10 | package usrRegs;
11 | my %listTypes = (
12 | regDev =>{ intKeyVisib=>1, ledMode=>1, lowBatLimitBA=>1, pairCentral=>1,
13 | },
14 | regChan =>{ sign =>1, #| literal | | signature (AES) options:on,off
15 | lgActionType =>1, #| literal | required | options:toggleToCntInv,off,toggleToCnt,jmpToTarget
16 | lgCtDlyOff =>1, #| literal | required | Jmp on condition from delayOff options:geLo,between,outside,ltLo,geHi,ltHi
17 | lgCtDlyOn =>1, #| literal | required | Jmp on condition from delayOn options:geLo,between,outside,ltLo,geHi,ltHi
18 | lgCtOff =>1, #| literal | required | Jmp on condition from off options:geLo,between,outside,ltLo,geHi,ltHi
19 | lgCtOn =>1, #| literal | required | Jmp on condition from on options:geLo,between,outside,ltLo,geHi,ltHi
20 | lgCtValHi =>1, #| 0 to 255 | required | Condition value high for CT table
21 | lgCtValLo =>1, #| 0 to 255 | required | Condition value low for CT table
22 | lgMultiExec =>1, #| literal | required | multiple execution per repeat of long trigger options:on,off
23 | lgOffDly =>1, #| 0 to 111600s | required | off delay
24 | lgOffTime =>1, #| 0 to 111600s | required | off time, 111600 = infinite
25 | lgOffTimeMode =>1, #| literal | required | off time mode options:minimal,absolut
26 | lgOnDly =>1, #| 0 to 111600s | required | on delay
27 | lgOnTime =>1, #| 0 to 111600s | required | on time, 111600 = infinite
28 | lgOnTimeMode =>1, #| literal | required | on time mode options:minimal,absolut
29 | lgSwJtDlyOff =>1, #| literal | required | Jump from delayOff options:on,off,dlyOn,no,dlyOff
30 | lgSwJtDlyOn =>1, #| literal | required | Jump from delayOn options:on,off,dlyOn,no,dlyOff
31 | lgSwJtOff =>1, #| literal | required | Jump from off options:on,off,dlyOn,no,dlyOff
32 | lgSwJtOn =>1, #| literal | required | Jump from on options:on,off,dlyOn,no,dlyOff
33 | shActionType =>1, #| literal | required | options:toggleToCntInv,off,toggleToCnt,jmpToTarget
34 | shCtDlyOff =>1, #| literal | required | Jmp on condition from delayOff options:geLo,between,outside,ltLo,geHi,ltHi
35 | shCtDlyOn =>1, #| literal | required | Jmp on condition from delayOn options:geLo,between,outside,ltLo,geHi,ltHi
36 | shCtOff =>1, #| literal | required | Jmp on condition from off options:geLo,between,outside,ltLo,geHi,ltHi
37 | shCtOn =>1, #| literal | required | Jmp on condition from on options:geLo,between,outside,ltLo,geHi,ltHi
38 | shCtValHi =>1, #| 0 to 255 | required | Condition value high for CT table
39 | shCtValLo =>1, #| 0 to 255 | required | Condition value low for CT table
40 | shOffDly =>1, #| 0 to 111600s | required | off delay
41 | shOffTime =>1, #| 0 to 111600s | required | off time, 111600 = infinite
42 | shOffTimeMode =>1, #| literal | required | off time mode options:minimal,absolut
43 | shOnDly =>1, #| 0 to 111600s | required | on delay
44 | shOnTime =>1, #| 0 to 111600s | required | on time, 111600 = infinite
45 | shOnTimeMode =>1, #| literal | required | on time mode options:minimal,absolut
46 | shSwJtDlyOff =>1, #| literal | required | Jump from delayOff options:on,off,dlyOn,no,dlyOff
47 | shSwJtDlyOn =>1, #| literal | required | Jump from delayOn options:on,off,dlyOn,no,dlyOff
48 | shSwJtOff =>1, #| literal | required | Jump from off options:on,off,dlyOn,no,dlyOff
49 | shSwJtOn =>1, #|
50 | },
51 | );
52 | # -----------assemble device -----------------
53 | my %regList;
54 | $regList{0}={type => "regDev",peers=>1};
55 | $regList{1}={type => "regChan",peers=>6};
56 |
57 | sub usr_getHash($){
58 | my $hn = shift;
59 | return %regList if($hn eq "regList" );
60 | return %listTypes if($hn eq "listTypes" );
61 | }
62 |
--------------------------------------------------------------------------------
/destillRegs/devDefinition.pm.test:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/trilu2000/NewAskSin/75d3209f34f6ab559c0b6d1d7cbe09c53da2cd61/destillRegs/devDefinition.pm.test
--------------------------------------------------------------------------------
/destillRegs2/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | destillRegs2
4 |
5 |
6 |
7 |
8 |
9 | org.epic.perleditor.perlbuilder
10 |
11 |
12 |
13 |
14 |
15 | org.epic.perleditor.perlnature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/destillRegs2/devDefinition - HM_LC_Dim1PWM_CV.pm:
--------------------------------------------------------------------------------
1 | ## -- definitions -------------------------------------------------------------------------------------------
2 | use strict; package usrRegs; my %regList;
3 |
4 | ## -- Sub Type ID information -------------------------------------------------------------------------------
5 | ## "0x01" => "AlarmControl" "0x41" => "sensor" "0x70" => "THSensor"
6 | ## "0x10" => "switch" "0x42" => "swi" "0x80" => "threeStateSensor"
7 | ## "0x12" => "outputUnit" "0x43" => "pushButton" "0x81" => "motionDetector"
8 | ## "0x20" => "dimmer" "0x44" => "singleButton" "0xC0" => "keyMatic"
9 | ## "0x30" => "blindActuator" "0x51" => "powerMeter" "0xC1" => "winMatic"
10 | ## "0x39" => "ClimateControl" "0x58" => "thermostat" "0xC3" => "tipTronic"
11 | ## "0x40" => "remote" "0x60" => "KFM100" "0xCD" => "smokeDetector"
12 |
13 |
14 | ## -- device config -----------------------------------------------------------------------------------------
15 | my %confType = (
16 | ## some basic information to create a new device, serial number and hm id has to be unique in your network
17 | ## on modelID you could choose between an already existing configuration or you can create a new device
18 |
19 | serial => 'XMS2345678', # 0 to get it automatically generated - otherwise 10 byte ASCII format
20 | hmID => '', # empty to get it automatically generated - otherwise 6 HEX digits (3 byte)
21 | hmKEY => '0102030405060708090a0b0c0d0e0f10', # 32 HEX digits (16 byte) HM AES Key
22 |
23 | modelID => '0f67', # if model id is known, details will taken from HM config xml files, 4 HEX digits
24 | firmwareVer => '25', # firmware version, 2 HEX digits - important if you took a model id where more then one device exists
25 |
26 |
27 | ## no input needed if model id is valid and device already exists in HM config software,
28 | ## otherwise fill accordingly to create a proper register.h and xml config file
29 |
30 | name => 'Test128', # name of the device, ascii [A-Z, a-z, 0-9, '-'], no blanks
31 | description => 'das ist ein test', # short description of the device
32 |
33 | subtypeID => '00', # depending on type of device
34 | deviceInfo => '410100', # not complete clear yes, but 3 bytes HEX needed
35 |
36 | burstRx => 0, # device needs a burst signal to wakeup
37 | localResDis => 1, # local reset disable
38 | intKeysVis => 1, # internal keys visible
39 |
40 | confKeyMode => 2, # config key mode;
41 | # 0 = no config key;
42 | # 1 = pair on short press, reset device on double long key press
43 | # 2 = short press to toogle channel one, long press to pair, and double long to reset device
44 |
45 | statusLED => 2, # amount of available status leds, possible values 0, 1 ,2
46 |
47 | battValue => 30, # one byte default value in milli volt, 0 if not a battery device
48 | battVisib => 0, # battery flag visible in registers of channel 0
49 | battChkDura => 3600000, # the time between two measurements, value in milli seconds
50 |
51 | powerMode => 0, # there are 5 power modes available, which could be choosed to get the best ratio between power consumption and availablity
52 | # 0, now power saving - 19.9ma
53 | # 1, wake up every 250ms, check for wakeup signal on air and stay awake accordingly, timer gets updated every 256ms
54 | # 2, deep sleep, wakeup every 250ms, not able to receive anything while sleeping, timer gets updated every 256ms
55 | # 3, deep sleep, wakeup every 8 seconds, not able to receive anything while sleeping, timer gets updated every 8192ms - 0.04ma
56 | # 4, deep sleep, wakeup only on interrupt - 0.00ma
57 |
58 | );
59 |
60 | ## -- channel config ----------------------------------------------------------------------------------------
61 | ## predefined type in linkset.xml choose xmlDimmer, xmlSwitch, xmlKey, xmlWeather - more to come
62 | ## peers reflects the amount of possible peers, hidden makes a channel hidden for the config software, but will still work
63 | ## with linked you can link channels together, e.g. key to dimmer
64 | ## todo: linked
65 |
66 | $regList{1} = {type => "xmlDimmer", peers => 6, hidden => 0, linked => 0 };
67 | $regList{2} = {type => "xmlDimmer", peers => 1, hidden => 0, linked => 0 };
68 | $regList{3} = {type => "xmlDimmer", peers => 1, hidden => 0, linked => 0 };
69 | #$regList{4} = {type => "xmlKey", peers => 6, hidden => 0, linked => 2 };
70 |
71 | #$regList{1} = {type => "xmlSwitch", peers => 6, hidden => 0, linked => 0 };
72 | #$regList{2} = {type => "xmlDimmer", peers => 6, hidden => 0, linked => 0 };
73 | #$regList{3} = {type => "xmlSwitch", peers => 6, hidden => 0, linked => {3,4} };
74 | #$regList{4} = {type => "xmlKey", peers => 6, hidden => 0, linked => 2 };
75 | #$regList{3} = {type => "xmlSwitch", peers => 6, hidden => 0, linked => 2 };
76 | #$regList{4} = {type => "xmlSwitch", peers => 6, hidden => 0, linked => 2 };
77 |
78 |
79 |
80 |
81 |
82 |
83 | ## -- helpers -----------------------------------------------------------------------------------------------
84 | sub usr_getHash($){
85 | my $hn = shift;
86 | return %regList if($hn eq "regList" );
87 | return %confType if($hn eq "configType" );
88 | }
89 |
--------------------------------------------------------------------------------
/destillRegs2/devDefinition - HM_LC_SW1_BA_PCB.pm:
--------------------------------------------------------------------------------
1 | ## -- definitions -------------------------------------------------------------------------------------------
2 | use strict; package usrRegs; my %regList;
3 |
4 | ## -- Sub Type ID information -------------------------------------------------------------------------------
5 | ## "0x01" => "AlarmControl" "0x41" => "sensor" "0x70" => "THSensor"
6 | ## "0x10" => "switch" "0x42" => "swi" "0x80" => "threeStateSensor"
7 | ## "0x12" => "outputUnit" "0x43" => "pushButton" "0x81" => "motionDetector"
8 | ## "0x20" => "dimmer" "0x44" => "singleButton" "0xC0" => "keyMatic"
9 | ## "0x30" => "blindActuator" "0x51" => "powerMeter" "0xC1" => "winMatic"
10 | ## "0x39" => "ClimateControl" "0x58" => "thermostat" "0xC3" => "tipTronic"
11 | ## "0x40" => "remote" "0x60" => "KFM100" "0xCD" => "smokeDetector"
12 |
13 |
14 | ## -- device config -----------------------------------------------------------------------------------------
15 | my %confType = (
16 | ## some basic information to create a new device, serial number and hm id has to be unique in your network
17 | ## on modelID you could choose between an already existing configuration or you can create a new device
18 |
19 | serial => 'XMS1234567', # 0 to get it automatically generated - otherwise 10 byte ASCII format
20 | hmID => '0', # 0 to get it automatically generated - otherwise 6 HEX digits
21 |
22 | modelID => 0x006c, # if model id is known, details will taken from HM config xml files, 4 HEX digits
23 | firmwareVer => 0x10, # firmware version, 2 HEX digits - important if you took a model id where more then one device exists
24 |
25 |
26 | ## no input needed if model id is valid and device already exists in HM config software,
27 | ## otherwise fill accordingly to create a proper register.h and xml config file
28 |
29 | name => 'Test127', # name of the device, ascii [A-Z, a-z, 0-9, '-'], no blanks
30 | description => 'das ist ein test', # short description of the device
31 |
32 | subtypeID => 0x00, # depending on type of device
33 | deviceInfo => 0x410100, # not complete clear yes, but 3 bytes HEX needed
34 |
35 | burstRx => 1, # device needs a burst signal to wakeup
36 | localResDis => 1, # local reset disable
37 | intKeysVis => 1, # internal keys visible
38 |
39 | confKeyMode => 2, # config key mode;
40 | # 0 = no config key;
41 | # 1 = pair on short press, reset device on double long key press
42 | # 2 = short press to toogle channel one, long press to pair, and double long to reset device
43 |
44 | statusLED => 2, # amount of available status leds, possible values 0, 1 ,2
45 |
46 | battValue => 30, # one byte default value in milli volt, 0 if not a battery device
47 | battVisib => 0, # battery flag visible in registers of channel 0
48 | battChkDura => 3600000, # the time between two measurements, value in milli seconds
49 |
50 | powerMode => 1, # there are 5 power modes available, which could be choosed to get the best ratio between power consumption and availablity
51 | # 0, now power saving - 19.9ma
52 | # 1, wake up every 250ms, check for wakeup signal on air and stay awake accordingly, timer gets updated every 256ms
53 | # 2, deep sleep, wakeup every 250ms, not able to receive anything while sleeping, timer gets updated every 256ms
54 | # 3, deep sleep, wakeup every 8 seconds, not able to receive anything while sleeping, timer gets updated every 8192ms - 0.04ma
55 | # 4, deep sleep, wakeup only on interrupt - 0.00ma
56 |
57 | );
58 |
59 | ## -- channel config ----------------------------------------------------------------------------------------
60 | ## predefined type in linkset.xml choose xmlDimmer, xmlSwitch, xmlKey, xmlWeather - more to come
61 | ## peers reflects the amount of possible peers, hidden makes a channel hidden for the config software, but will still work
62 | ## with linked you can link channels together, e.g. key to dimmer
63 | ## todo: linked
64 |
65 | #$regList{1} = {type => "xmlDimmer", peers => 6, hidden => 0, linked => 0 };
66 | #$regList{2} = {type => "xmlSwitch", peers => 6, hidden => 1, linked => {3,4} };
67 | #$regList{3} = {type => "xmlKey", peers => 6, hidden => 0, linked => 2 };
68 | #$regList{4} = {type => "xmlKey", peers => 6, hidden => 0, linked => 2 };
69 |
70 | $regList{1} = {type => "xmlSwitch", peers => 6, hidden => 0, linked => 0 };
71 | #$regList{2} = {type => "xmlDimmer", peers => 6, hidden => 0, linked => 0 };
72 | #$regList{3} = {type => "xmlSwitch", peers => 6, hidden => 0, linked => {3,4} };
73 | #$regList{4} = {type => "xmlKey", peers => 6, hidden => 0, linked => 2 };
74 | #$regList{3} = {type => "xmlSwitch", peers => 6, hidden => 0, linked => 2 };
75 | #$regList{4} = {type => "xmlSwitch", peers => 6, hidden => 0, linked => 2 };
76 |
77 |
78 |
79 |
80 |
81 |
82 | ## -- helpers -----------------------------------------------------------------------------------------------
83 | sub usr_getHash($){
84 | my $hn = shift;
85 | return %regList if($hn eq "regList" );
86 | return %confType if($hn eq "configType" );
87 | }
88 |
--------------------------------------------------------------------------------
/destillRegs2/devDefinition.pm:
--------------------------------------------------------------------------------
1 | ## -- definitions -------------------------------------------------------------------------------------------
2 | use strict; package usrRegs; my %regList;
3 |
4 | ## -- Sub Type ID information -------------------------------------------------------------------------------
5 | ## "0x01" => "AlarmControl" "0x41" => "sensor" "0x70" => "THSensor"
6 | ## "0x10" => "switch" "0x42" => "swi" "0x80" => "threeStateSensor"
7 | ## "0x12" => "outputUnit" "0x43" => "pushButton" "0x81" => "motionDetector"
8 | ## "0x20" => "dimmer" "0x44" => "singleButton" "0xC0" => "keyMatic"
9 | ## "0x30" => "blindActuator" "0x51" => "powerMeter" "0xC1" => "winMatic"
10 | ## "0x39" => "ClimateControl" "0x58" => "thermostat" "0xC3" => "tipTronic"
11 | ## "0x40" => "remote" "0x60" => "KFM100" "0xCD" => "smokeDetector"
12 |
13 |
14 | ## -- device config -----------------------------------------------------------------------------------------
15 | my %confType = (
16 | ## some basic information to create a new device, serial number and hm id has to be unique in your network
17 | ## on modelID you could choose between an already existing configuration or you can create a new device
18 |
19 | serial => 'XMS2345678', # 0 to get it automatically generated - otherwise 10 byte ASCII format
20 | hmID => '', # empty to get it automatically generated - otherwise 6 HEX digits (3 byte)
21 | hmKEY => '0102030405060708090a0b0c0d0e0f10', # 32 HEX digits (16 byte) HM AES Key
22 |
23 | modelID => '0f06', # if model id is known, details will taken from HM config xml files, 4 HEX digits
24 | firmwareVer => '11', # firmware version, 2 HEX digits - important if you took a model id where more then one device exists
25 |
26 |
27 | ## no input needed if model id is valid and device already exists in HM config software,
28 | ## otherwise fill accordingly to create a proper register.h and xml config file
29 |
30 | name => 'Test128', # name of the device, ascii [A-Z, a-z, 0-9, '-'], no blanks
31 | description => 'das ist ein test', # short description of the device
32 |
33 | subtypeID => '30', # depending on type of device / see above
34 | deviceInfo => '010100', # not complete clear yes, but 3 bytes HEX needed - referer to count_from_sysinfo="23.0:1.0"
35 |
36 | burstRx => 0, # device needs a burst signal to wakeup
37 | localResDis => 1, # local reset disable
38 | intKeysVis => 1, # internal keys visible
39 |
40 | confKeyMode => 2, # config key mode;
41 | # 0 = no config key;
42 | # 1 = pair on short press, reset device on double long key press
43 | # 2 = short press to toogle channel one, long press to pair, and double long to reset device
44 |
45 | statusLED => 2, # amount of available status leds, possible values 0, 1 ,2
46 |
47 | battValue => 30, # one byte default value in milli volt, 0 if not a battery device
48 | battVisib => 0, # battery flag visible in registers of channel 0
49 | battChkDura => 3600000, # the time between two measurements, value in milli seconds
50 |
51 | powerMode => 0, # there are 5 power modes available, which could be choosed to get the best ratio between power consumption and availablity
52 | # 0, now power saving - 19.9ma
53 | # 1, wake up every 250ms, check for wakeup signal on air and stay awake accordingly, timer gets updated every 256ms
54 | # 2, deep sleep, wakeup every 250ms, not able to receive anything while sleeping, timer gets updated every 256ms
55 | # 3, deep sleep, wakeup every 8 seconds, not able to receive anything while sleeping, timer gets updated every 8192ms - 0.04ma
56 | # 4, deep sleep, wakeup only on interrupt - 0.00ma
57 |
58 | );
59 |
60 | ## -- channel config ----------------------------------------------------------------------------------------
61 | ## predefined type in linkset.xml choose xmlDimmer, xmlSwitch, xmlKey, xmlWeather - more to come
62 | ## peers reflects the amount of possible peers, hidden makes a channel hidden for the config software, but will still work
63 | ## with linked you can link channels together, e.g. key to dimmer
64 | ## todo: linked
65 |
66 | $regList{1} = {type => "xmlBlind", peers => 6, hidden => 0, linked => 0 };
67 | #$regList{2} = {type => "xmlDimmer", peers => 1, hidden => 0, linked => 0 };
68 | #$regList{3} = {type => "xmlDimmer", peers => 1, hidden => 0, linked => 0 };
69 | #$regList{4} = {type => "xmlKey", peers => 6, hidden => 0, linked => 2 };
70 |
71 | #$regList{1} = {type => "xmlSwitch", peers => 6, hidden => 0, linked => 0 };
72 | #$regList{2} = {type => "xmlDimmer", peers => 6, hidden => 0, linked => 0 };
73 | #$regList{3} = {type => "xmlSwitch", peers => 6, hidden => 0, linked => {3,4} };
74 | #$regList{4} = {type => "xmlKey", peers => 6, hidden => 0, linked => 2 };
75 | #$regList{3} = {type => "xmlSwitch", peers => 6, hidden => 0, linked => 2 };
76 | #$regList{4} = {type => "xmlSwitch", peers => 6, hidden => 0, linked => 2 };
77 |
78 |
79 |
80 |
81 |
82 |
83 | ## -- helpers -----------------------------------------------------------------------------------------------
84 | sub usr_getHash($){
85 | my $hn = shift;
86 | return %regList if($hn eq "regList" );
87 | return %confType if($hn eq "configType" );
88 | }
89 |
--------------------------------------------------------------------------------
/destillRegs2/devicetypes/rf_ash550.xml:
--------------------------------------------------------------------------------
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 |
61 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
--------------------------------------------------------------------------------
/destillRegs2/devicetypes/rf_cc_vd.xml:
--------------------------------------------------------------------------------
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 |
39 |
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 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
--------------------------------------------------------------------------------
/destillRegs2/devicetypes/rf_central.xml:
--------------------------------------------------------------------------------
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 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
--------------------------------------------------------------------------------
/destillRegs2/devicetypes/rf_s550ia.xml:
--------------------------------------------------------------------------------
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 |
43 |
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 |
--------------------------------------------------------------------------------
/destillRegs2/devicetypes/rf_swi.xml:
--------------------------------------------------------------------------------
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 |
49 |
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 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
--------------------------------------------------------------------------------
/destillRegs2/devicetypes/rf_wds30_ot2.xml:
--------------------------------------------------------------------------------
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 |
58 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
--------------------------------------------------------------------------------
/destillRegs2/devicetypes/rf_wds40_th_i_2.xml:
--------------------------------------------------------------------------------
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 |
44 |
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 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
--------------------------------------------------------------------------------
/destillRegs2/devicetypes/rf_ws550.xml:
--------------------------------------------------------------------------------
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 |
51 |
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 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
--------------------------------------------------------------------------------
/docs/AskSin library.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/trilu2000/NewAskSin/75d3209f34f6ab559c0b6d1d7cbe09c53da2cd61/docs/AskSin library.docx
--------------------------------------------------------------------------------
/docs/Datasheets/32U4 datasheet.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/trilu2000/NewAskSin/75d3209f34f6ab559c0b6d1d7cbe09c53da2cd61/docs/Datasheets/32U4 datasheet.pdf
--------------------------------------------------------------------------------
/docs/Datasheets/ATmega48A-48PA-88A-88PA-168A-168PA-328-328P datasheet.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/trilu2000/NewAskSin/75d3209f34f6ab559c0b6d1d7cbe09c53da2cd61/docs/Datasheets/ATmega48A-48PA-88A-88PA-168A-168PA-328-328P datasheet.pdf
--------------------------------------------------------------------------------
/docs/Datasheets/Arduino Pro Mini Pin out.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/trilu2000/NewAskSin/75d3209f34f6ab559c0b6d1d7cbe09c53da2cd61/docs/Datasheets/Arduino Pro Mini Pin out.png
--------------------------------------------------------------------------------
/docs/Datasheets/Dissecting HomeMatic AES.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/trilu2000/NewAskSin/75d3209f34f6ab559c0b6d1d7cbe09c53da2cd61/docs/Datasheets/Dissecting HomeMatic AES.pdf
--------------------------------------------------------------------------------
/docs/Datasheets/Monopol-Antennen.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/trilu2000/NewAskSin/75d3209f34f6ab559c0b6d1d7cbe09c53da2cd61/docs/Datasheets/Monopol-Antennen.png
--------------------------------------------------------------------------------
/docs/Datasheets/ProMini.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/trilu2000/NewAskSin/75d3209f34f6ab559c0b6d1d7cbe09c53da2cd61/docs/Datasheets/ProMini.pdf
--------------------------------------------------------------------------------
/docs/Datasheets/TSL45315 datasheet.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/trilu2000/NewAskSin/75d3209f34f6ab559c0b6d1d7cbe09c53da2cd61/docs/Datasheets/TSL45315 datasheet.pdf
--------------------------------------------------------------------------------
/docs/Datasheets/cc1100.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/trilu2000/NewAskSin/75d3209f34f6ab559c0b6d1d7cbe09c53da2cd61/docs/Datasheets/cc1100.pdf
--------------------------------------------------------------------------------
/docs/Datasheets/radino_CC1101 datasheet.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/trilu2000/NewAskSin/75d3209f34f6ab559c0b6d1d7cbe09c53da2cd61/docs/Datasheets/radino_CC1101 datasheet.pdf
--------------------------------------------------------------------------------
/docs/README.md:
--------------------------------------------------------------------------------
1 | # Doxygen documentation
2 |
3 | In order to work with the API documentation, the html subdir must
4 | be inititalized once:
5 | mkdir html
6 | cd html
7 | git clone git@github.com:trilu2000/NewAskSin.git -b gh-pages
8 |
9 | To update the doxygen documentation, perform these steps in the
10 | local clone of the repository:
11 | (cd html; git pull)
12 | doxygen docs/Doxyfile
13 | (cd html && git add . && git commit -m 'Update API docs' && git push)
14 |
--------------------------------------------------------------------------------
/docs/calc fact for battery class.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/trilu2000/NewAskSin/75d3209f34f6ab559c0b6d1d7cbe09c53da2cd61/docs/calc fact for battery class.xlsx
--------------------------------------------------------------------------------
/docs/snippets/basic-AS.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include "register.h" // configuration sheet
3 |
4 | AS hm; // stage the asksin framework
5 |
6 | void setup() {
7 | hm.init(); // init the asksin framework
8 | }
9 |
10 | void loop()
11 | {
12 | hm.poll(); // poll the homematic main loop
13 | }
14 |
--------------------------------------------------------------------------------
/docs/snippets/hmserial.c:
--------------------------------------------------------------------------------
1 | // Defaults for HMID and HMSR (serial number)
2 | //
3 | // Fallback values are defined below; to override these, use
4 | // compiler switches
5 | // -DEF_HMID=0xFAFBFC
6 | // -DEF_HMSR='\"ABC6543210\"'
7 |
8 | #ifndef EF_HMID
9 | #define EF_HMID 0xF1F2F3
10 | #endif
11 | #ifndef EF_HMSR
12 | #define EF_HMSR "ABC0123456"
13 | #endif
14 |
15 | unsigned char HMID[3] = { (EF_HMID>>16)&0xFF , (EF_HMID>>8)&0xFF , (EF_HMID>>0)&0xFF };
16 | unsigned char HMSR[11] = EF_HMSR;
17 |
--------------------------------------------------------------------------------
/docs/snippets/register-h-cnlAddr.cpp:
--------------------------------------------------------------------------------
1 | const uint8_t cnlAddr[] PROGMEM = {
2 | 0x02, 0x05, 0x0a, 0x0b, 0x0c, 0x14, 0x24, 0x25, 0x26, 0x27, // sIdx 0x00, 10 bytes for Channel0/List0
3 | 0x01, // sIdx 0x0a, 1 byte for Channel1/List4
4 | }; // 11 byte
5 |
--------------------------------------------------------------------------------
/docs/snippets/register-h-cnlTbl.cpp:
--------------------------------------------------------------------------------
1 | EE::s_cnlTbl cnlTbl[] = {
2 | // cnl, lst, sIdx, sLen, pAddr;
3 | { 0, 0, 0x00, 10, 0x000f }, // Channel0/List0, 10 bytes at sIdx 0x00, Addr 0x000f
4 | { 1, 4, 0x0a, 1, 0x0019 }, // Channel1/List4, 1 byte at sIdx 0x0a, Addr 0x0019
5 | };
6 |
--------------------------------------------------------------------------------
/docs/snippets/register-h-cnlTblAddr.cpp:
--------------------------------------------------------------------------------
1 | const uint8_t cnlAddr[] PROGMEM = {
2 | 0x02, 0x05, 0x0a, 0x0b, 0x0c, 0x14, 0x24, 0x25, 0x26, 0x27, // sIdx 0x00, 10 bytes for Channel0/List0
3 | 0x01, // sIdx 0x0a, 1 byte for Channel1/List4
4 | }; // 11 byte
5 |
6 | EE::s_cnlTbl cnlTbl[] = {
7 | // cnl, lst, sIdx, sLen, pAddr;
8 | { 0, 0, 0x00, 10, 0x000f }, // Channel0/List0, 10 bytes at sIdx 0x00, Addr 0x000f
9 | { 1, 4, 0x0a, 1, 0x0019 }, // Channel1/List4, 1 byte at sIdx 0x0a, Addr 0x0019
10 | };
11 |
--------------------------------------------------------------------------------
/examples/AskinNew_test/hardware.cpp:
--------------------------------------------------------------------------------
1 | //- -----------------------------------------------------------------------------------------------------------------------
2 | // AskSin driver implementation
3 | // 2013-08-03 Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
4 | //- -----------------------------------------------------------------------------------------------------------------------
5 | //- AskSin hardware definition ----------------------------------------------------------------------------------------
6 | //- with a lot of support from martin876 at FHEM forum
7 | //- -------------------------------------------------------------------------------------------------------------------
8 |
9 | #include "hardware.h"
10 | #include
11 |
12 | void initWakeupPin(void) {
13 | #if defined(WAKE_UP_DDR)
14 | pinInput(WAKE_UP_DDR, WAKE_UP_PIN); // set pin as input
15 | setPinHigh(WAKE_UP_PORT, WAKE_UP_PIN); // enable internal pull up
16 | #endif
17 | }
18 | uint8_t checkWakeupPin(void) {
19 | // to enable the USB port for upload, configure PE2 as input and check if it is 0, this will avoid sleep mode and enable program upload via serial
20 | #if defined(WAKE_UP_DDR)
21 | if (getPin(WAKE_UP_PNR, WAKE_UP_PIN)) return 1; // return pin is active
22 | #endif
23 |
24 | return 0; // normal operation
25 | }
26 |
--------------------------------------------------------------------------------
/examples/AskinNew_test/hardware.h:
--------------------------------------------------------------------------------
1 | //- -----------------------------------------------------------------------------------------------------------------------
2 | // AskSin driver implementation
3 | // 2013-08-03 Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
4 | //- -----------------------------------------------------------------------------------------------------------------------
5 | //- AskSin hardware definition ----------------------------------------------------------------------------------------
6 | //- with a lot of support from martin876 at FHEM forum
7 | //- -------------------------------------------------------------------------------------------------------------------
8 |
9 | #include
10 |
11 | #ifndef _HARDWARE_h
12 | #define _HARDWARE_h
13 |
14 | #define EXT_BATTERY_MEASUREMENT // comment out to use internal battery measurement
15 | #define BATTERY_FACTOR 17 // see excel table
16 | #define DEBOUNCE 5
17 |
18 | #if defined(__AVR_ATmega328P__)
19 | //- cc1100 hardware CS and GDO0 definitions -------------------------------------------------------------------
20 | #define CC_CS_DDR DDRB // SPI chip select definition
21 | #define CC_CS_PORT PORTB
22 | #define CC_CS_PIN PORTB2
23 |
24 | #define CC_GDO0_DDR DDRD // GDO0 pin, signals received data
25 | #define CC_GDO0_PIN PORTB2
26 |
27 | #define CC_GDO0_PCICR PCICR // GDO0 interrupt register
28 | #define CC_GDO0_PCIE PCIE2
29 | #define CC_GDO0_PCMSK PCMSK2 // GDO0 interrupt mask
30 | #define CC_GDO0_INT PCINT18 // pin interrupt
31 |
32 | //- LED's definition ------------------------------------------------------------------------------------------
33 | #define LED_RED_DDR DDRD // define led port and remaining pin
34 | #define LED_RED_PORT PORTD
35 | #define LED_RED_PIN PORTD4
36 |
37 | #define LED_GRN_DDR DDRD
38 | #define LED_GRN_PORT PORTD
39 | #define LED_GRN_PIN PORTD4
40 |
41 | #define LED_ACTIVE_LOW 0 // leds connected to GND = 0, VCC = 1
42 |
43 | //- configuration key ----------------------------------------------------------------------------------------
44 | #define CONFIG_KEY_DDR DDRB // define config key port and remaining pin
45 | #define CONFIG_KEY_PORT PORTB
46 | #define CONFIG_KEY_PIN PORTB0
47 |
48 | #define CONFIG_KEY_PCICR PCICR // interrupt register
49 | #define CONFIG_KEY_PCIE PCIE0 // pin change interrupt port bit
50 | #define CONFIG_KEY_PCMSK PCMSK0 // interrupt mask
51 | #define CONFIG_KEY_INT PCINT0 // pin interrupt
52 |
53 | //- battery external measurement functions --------------------------------------------------------------------
54 | #define BATT_ENABLE_DDR DDRD // define battery measurement enable pin, has to be low to start measuring
55 | #define BATT_ENABLE_PORT PORTD
56 | #define BATT_ENABLE_PIN PORTD7
57 |
58 | #define BATT_MEASURE_DDR DDRC // define battery measure pin, where ADC gets the measurement
59 | #define BATT_MEASURE_PORT PORTC
60 | #define BATT_MEASURE_PIN PORTC1
61 |
62 | #elif defined(__AVR_ATmega32U4__)
63 | //- cc1100 hardware CS and GDO0 definitions -------------------------------------------------------------------
64 | #define CC_CS_DDR DDRB // SPI chip select definition
65 | #define CC_CS_PORT PORTB
66 | #define CC_CS_PIN PORTB4
67 |
68 | #define CC_GDO0_DDR DDRB // GDO0 pin, signals received data
69 | #define CC_GDO0_PIN PORTB5
70 |
71 | #define CC_GDO0_PCICR PCICR // GDO0 interrupt register
72 | #define CC_GDO0_PCIE PCIE0
73 | #define CC_GDO0_PCMSK PCMSK0 // GDO0 interrupt mask
74 | #define CC_GDO0_INT PCINT5 // pin interrupt
75 |
76 | //- LED's definition ------------------------------------------------------------------------------------------
77 | #define LED_RED_DDR DDRB // define led port and remaining pin
78 | #define LED_RED_PORT PORTB
79 | #define LED_RED_PIN PORTB7
80 |
81 | #define LED_GRN_DDR DDRC
82 | #define LED_GRN_PORT PORTC
83 | #define LED_GRN_PIN PORTC7
84 |
85 | #define LED_ACTIVE_LOW 1 // leds against GND = 0, VCC = 1
86 |
87 | //- configuration key ----------------------------------------------------------------------------------------
88 | #define CONFIG_KEY_DDR DDRB // define config key port and remaining pin
89 | #define CONFIG_KEY_PORT PORTB
90 | #define CONFIG_KEY_PIN PORTB6
91 |
92 | #define CONFIG_KEY_PCICR PCICR // interrupt register
93 | #define CONFIG_KEY_PCIE PCIE0 // pin change interrupt port bit
94 | #define CONFIG_KEY_PCMSK PCMSK0 // interrupt mask
95 | #define CONFIG_KEY_INT PCINT6 // pin interrupt
96 |
97 | //- battery external measurement functions --------------------------------------------------------------------
98 | #define BATT_ENABLE_DDR DDRF // define battery measurement enable pin, has to be low to start measuring
99 | #define BATT_ENABLE_PORT PORTF
100 | #define BATT_ENABLE_PIN PORTF4
101 |
102 | #define BATT_MEASURE_DDR DDRF // define battery measure pin, where ADC gets the measurement
103 | #define BATT_MEASURE_PORT PORTF
104 | #define BATT_MEASURE_PIN PORTF7
105 |
106 | #else
107 | #error "Error: cc1100 CS and GDO0 not defined for your hardware in hardware.h!"
108 | #endif
109 | //- ---------------------------------------------------------------------------------------------------------------
110 |
111 |
112 | //- wake up pin ---------------------------------------------------------------------------------------------------
113 | #if defined(__AVR_ATmega32U4__)
114 | #define WAKE_UP_DDR DDRE // define wake up pin port and remaining pin
115 | #define WAKE_UP_PORT PORTE
116 | #define WAKE_UP_PNR PINE
117 | #define WAKE_UP_PIN PINE2
118 | #endif
119 | //- ---------------------------------------------------------------------------------------------------------------
120 |
121 | #endif
122 |
123 |
--------------------------------------------------------------------------------
/examples/AskinNew_test/register.h:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | // "003D" => {name=>"HM-WDS10-TH-O" ,st=>'THSensor' ,cyc=>'00:10' ,rxt=>'c:f' ,lst=>'p' ,chn=>"",}, #:w todo should be wakeup, does not react
4 |
5 | //- ----------------------------------------------------------------------------------------------------------------------
6 | //- eeprom defaults table ------------------------------------------------------------------------------------------------
7 | uint16_t EEMEM eMagicByte;
8 | uint8_t EEMEM eHMID[3] = {0x01,0x02,0x04};
9 | uint8_t EEMEM eHMSR[10] = {'t','l','u','2','0','0','1','2','3','4'};
10 |
11 | // if HMID and Serial are not set, then eeprom ones will be used
12 | uint8_t HMID[3] = {0x02,0x02,0x06};
13 | uint8_t HMSR[10] = {'t','l','u','2','0','0','1','2','3','6'}; // tlu1001236
14 |
15 | //- ----------------------------------------------------------------------------------------------------------------------
16 | //- settings of HM device for AS class -----------------------------------------------------------------------------------
17 | const uint8_t devIdnt[] PROGMEM = {
18 | /* Firmware version 1 byte */ 0x10, // don't know for what it is good for
19 | /* Model ID 2 byte */ 0x00, 0x3d, // model ID, describes HM hardware. Own devices should use high values due to HM starts from 0
20 | /* Sub Type ID 1 byte */ 0x70, // not needed for FHEM, it's something like a group ID
21 | /* Device Info 3 byte */ 0x03, 0x01, 0x00 // describes device, not completely clear yet. includes amount of channels
22 | };
23 |
24 |
25 | //- ----------------------------------------------------------------------------------------------------------------------
26 | //- channel slice address definition -------------------------------------------------------------------------------------
27 | const uint8_t cnlAddr[] PROGMEM = {
28 | 0x01,0x02,0x0a,0x0b,0x0c,
29 | 0x01,
30 | }; // 6 byte
31 |
32 | //- channel device list table --------------------------------------------------------------------------------------------
33 | EE::s_cnlTbl cnlTbl[] = {
34 | // cnl, lst, sIdx, sLen, pAddr;
35 | {0, 0, 0x00, 5, 0x000f},
36 | {1, 4, 0x05, 1, 0x0014}, // 1 * 6 = 6 (0x0006)
37 | }; // 12 byte
38 |
39 | //- peer device list table -----------------------------------------------------------------------------------------------
40 | EE::s_peerTbl peerTbl[] = {
41 | // cnl, pMax, pAddr;
42 | {1, 6, 0x001a} // 6 * 4 = 24 (0x18)
43 | }; // 4 byte
44 |
45 | //- handover to AskSin lib -----------------------------------------------------------------------------------------------
46 | EE::s_devDef devDef = {
47 | 1, 2, devIdnt, cnlAddr,
48 | }; // 6 byte
49 |
50 | //- module registrar -----------------------------------------------------------------------------------------------------
51 | RG::s_modTable modTbl[1];
52 |
53 |
--------------------------------------------------------------------------------
/examples/AskinNew_test/status - broken:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/trilu2000/NewAskSin/75d3209f34f6ab559c0b6d1d7cbe09c53da2cd61/examples/AskinNew_test/status - broken
--------------------------------------------------------------------------------
/examples/CUSTOM_LUX/LUX11.sch-1.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/trilu2000/NewAskSin/75d3209f34f6ab559c0b6d1d7cbe09c53da2cd61/examples/CUSTOM_LUX/LUX11.sch-1.pdf
--------------------------------------------------------------------------------
/examples/CUSTOM_LUX/hardware.cpp:
--------------------------------------------------------------------------------
1 | //- -----------------------------------------------------------------------------------------------------------------------
2 | // AskSin driver implementation
3 | // 2013-08-03 Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
4 | //- -----------------------------------------------------------------------------------------------------------------------
5 | //- AskSin hardware definition ----------------------------------------------------------------------------------------
6 | //- with a lot of support from martin876 at FHEM forum
7 | //- -------------------------------------------------------------------------------------------------------------------
8 |
9 | #include "hardware.h"
10 | #include
11 |
12 | void initWakeupPin(void) {
13 | #if defined(WAKE_UP_DDR)
14 | pinInput(WAKE_UP_DDR, WAKE_UP_PIN); // set pin as input
15 | setPinHigh(WAKE_UP_PORT, WAKE_UP_PIN); // enable internal pull up
16 | #endif
17 | }
18 | uint8_t checkWakeupPin(void) {
19 | // to enable the USB port for upload, configure PE2 as input and check if it is 0, this will avoid sleep mode and enable program upload via serial
20 | #if defined(WAKE_UP_DDR)
21 | if (getPin(WAKE_UP_PNR, WAKE_UP_PIN)) return 1; // return pin is active
22 | #endif
23 |
24 | return 0; // normal operation
25 | }
26 |
--------------------------------------------------------------------------------
/examples/CUSTOM_LUX/hardware.h:
--------------------------------------------------------------------------------
1 | //- -----------------------------------------------------------------------------------------------------------------------
2 | // AskSin driver implementation
3 | // 2013-08-03 Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
4 | //- -----------------------------------------------------------------------------------------------------------------------
5 | //- AskSin hardware definition ----------------------------------------------------------------------------------------
6 | //- with a lot of support from martin876 at FHEM forum
7 | //- -------------------------------------------------------------------------------------------------------------------
8 |
9 | #include
10 |
11 | #ifndef _HARDWARE_h
12 | #define _HARDWARE_h
13 |
14 | #define EXT_BATTERY_MEASUREMENT // comment out to use internal battery measurement
15 | #define BATTERY_FACTOR 17 // see excel table
16 | #define DEBOUNCE 5
17 |
18 | #if defined(__AVR_ATmega328P__)
19 | //- cc1100 hardware CS and GDO0 definitions -------------------------------------------------------------------
20 | #define CC_CS_DDR DDRB // SPI chip select definition
21 | #define CC_CS_PORT PORTB
22 | #define CC_CS_PIN PORTB2
23 |
24 | #define CC_GDO0_DDR DDRD // GDO0 pin, signals received data
25 | #define CC_GDO0_PIN PORTB2
26 |
27 | #define CC_GDO0_PCICR PCICR // GDO0 interrupt register
28 | #define CC_GDO0_PCIE PCIE2
29 | #define CC_GDO0_PCMSK PCMSK2 // GDO0 interrupt mask
30 | #define CC_GDO0_INT PCINT18 // pin interrupt
31 |
32 | //- LED's definition ------------------------------------------------------------------------------------------
33 | #define LED_RED_DDR DDRD // define led port and remaining pin
34 | #define LED_RED_PORT PORTD
35 | #define LED_RED_PIN PORTD4
36 |
37 | #define LED_GRN_DDR DDRD
38 | #define LED_GRN_PORT PORTD
39 | #define LED_GRN_PIN PORTD4
40 |
41 | #define LED_ACTIVE_LOW 0 // leds connected to GND = 0, VCC = 1
42 |
43 | //- configuration key ----------------------------------------------------------------------------------------
44 | #define CONFIG_KEY_DDR DDRB // define config key port and remaining pin
45 | #define CONFIG_KEY_PORT PORTB
46 | #define CONFIG_KEY_PIN PORTB0
47 |
48 | #define CONFIG_KEY_PCICR PCICR // interrupt register
49 | #define CONFIG_KEY_PCIE PCIE0 // pin change interrupt port bit
50 | #define CONFIG_KEY_PCMSK PCMSK0 // interrupt mask
51 | #define CONFIG_KEY_INT PCINT0 // pin interrupt
52 |
53 | //- battery external measurement functions --------------------------------------------------------------------
54 | #define BATT_ENABLE_DDR DDRD // define battery measurement enable pin, has to be low to start measuring
55 | #define BATT_ENABLE_PORT PORTD
56 | #define BATT_ENABLE_PIN PORTD7
57 |
58 | #define BATT_MEASURE_DDR DDRC // define battery measure pin, where ADC gets the measurement
59 | #define BATT_MEASURE_PORT PORTC
60 | #define BATT_MEASURE_PIN PORTC1
61 |
62 | #elif defined(__AVR_ATmega32U4__)
63 | //- cc1100 hardware CS and GDO0 definitions -------------------------------------------------------------------
64 | #define CC_CS_DDR DDRB // SPI chip select definition
65 | #define CC_CS_PORT PORTB
66 | #define CC_CS_PIN PORTB4
67 |
68 | #define CC_GDO0_DDR DDRB // GDO0 pin, signals received data
69 | #define CC_GDO0_PIN PORTB5
70 |
71 | #define CC_GDO0_PCICR PCICR // GDO0 interrupt register
72 | #define CC_GDO0_PCIE PCIE0
73 | #define CC_GDO0_PCMSK PCMSK0 // GDO0 interrupt mask
74 | #define CC_GDO0_INT PCINT5 // pin interrupt
75 |
76 | //- LED's definition ------------------------------------------------------------------------------------------
77 | #define LED_RED_DDR DDRB // define led port and remaining pin
78 | #define LED_RED_PORT PORTB
79 | #define LED_RED_PIN PORTB7
80 |
81 | #define LED_GRN_DDR DDRC
82 | #define LED_GRN_PORT PORTC
83 | #define LED_GRN_PIN PORTC7
84 |
85 | #define LED_ACTIVE_LOW 1 // leds against GND = 0, VCC = 1
86 |
87 | //- configuration key ----------------------------------------------------------------------------------------
88 | #define CONFIG_KEY_DDR DDRB // define config key port and remaining pin
89 | #define CONFIG_KEY_PORT PORTB
90 | #define CONFIG_KEY_PIN PORTB6
91 |
92 | #define CONFIG_KEY_PCICR PCICR // interrupt register
93 | #define CONFIG_KEY_PCIE PCIE0 // pin change interrupt port bit
94 | #define CONFIG_KEY_PCMSK PCMSK0 // interrupt mask
95 | #define CONFIG_KEY_INT PCINT6 // pin interrupt
96 |
97 | //- battery external measurement functions --------------------------------------------------------------------
98 | #define BATT_ENABLE_DDR DDRF // define battery measurement enable pin, has to be low to start measuring
99 | #define BATT_ENABLE_PORT PORTF
100 | #define BATT_ENABLE_PIN PORTF4
101 |
102 | #define BATT_MEASURE_DDR DDRF // define battery measure pin, where ADC gets the measurement
103 | #define BATT_MEASURE_PORT PORTF
104 | #define BATT_MEASURE_PIN PORTF7
105 |
106 | #else
107 | #error "Error: cc1100 CS and GDO0 not defined for your hardware in hardware.h!"
108 | #endif
109 | //- ---------------------------------------------------------------------------------------------------------------
110 |
111 |
112 | //- wake up pin ---------------------------------------------------------------------------------------------------
113 | #if defined(__AVR_ATmega32U4__)
114 | #define WAKE_UP_DDR DDRE // define wake up pin port and remaining pin
115 | #define WAKE_UP_PORT PORTE
116 | #define WAKE_UP_PNR PINE
117 | #define WAKE_UP_PIN PINE2
118 | #endif
119 | //- ---------------------------------------------------------------------------------------------------------------
120 |
121 | #endif
122 |
123 |
--------------------------------------------------------------------------------
/examples/CUSTOM_LUX/hardware_radino.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/trilu2000/NewAskSin/75d3209f34f6ab559c0b6d1d7cbe09c53da2cd61/examples/CUSTOM_LUX/hardware_radino.zip
--------------------------------------------------------------------------------
/examples/CUSTOM_LUX/register.h:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | // "003D" => {name=>"HM-WDS10-TH-O" ,st=>'THSensor' ,cyc=>'00:10' ,rxt=>'c:f' ,lst=>'p' ,chn=>"",}, #:w todo should be wakeup, does not react
4 |
5 | //- ----------------------------------------------------------------------------------------------------------------------
6 | //- eeprom defaults table ------------------------------------------------------------------------------------------------
7 | uint16_t EEMEM eMagicByte;
8 | uint8_t EEMEM eHMID[3] = {0x01,0x02,0x04};
9 | uint8_t EEMEM eHMSR[10] = {'t','l','u','2','0','0','1','2','3','4'};
10 |
11 | // if HMID and Serial are not set, then eeprom ones will be used
12 | uint8_t HMID[3] = {0x02,0x02,0x06};
13 | uint8_t HMSR[10] = {'t','l','u','2','0','0','1','2','3','6'}; // tlu1001236
14 |
15 | //- ----------------------------------------------------------------------------------------------------------------------
16 | //- settings of HM device for AS class -----------------------------------------------------------------------------------
17 | const uint8_t devIdnt[] PROGMEM = {
18 | /* Firmware version 1 byte */ 0x10, // don't know for what it is good for
19 | /* Model ID 2 byte */ 0x00, 0x3d, // model ID, describes HM hardware. Own devices should use high values due to HM starts from 0
20 | /* Sub Type ID 1 byte */ 0x70, // not needed for FHEM, it's something like a group ID
21 | /* Device Info 3 byte */ 0x03, 0x01, 0x00 // describes device, not completely clear yet. includes amount of channels
22 | };
23 |
24 |
25 | //- ----------------------------------------------------------------------------------------------------------------------
26 | //- channel slice address definition -------------------------------------------------------------------------------------
27 | const uint8_t cnlAddr[] PROGMEM = {
28 | 0x01,0x02,0x0a,0x0b,0x0c,
29 | 0x01,
30 | }; // 6 byte
31 |
32 | //- channel device list table --------------------------------------------------------------------------------------------
33 | EE::s_cnlTbl cnlTbl[] = {
34 | // cnl, lst, sIdx, sLen, pAddr;
35 | {0, 0, 0x00, 5, 0x000f},
36 | {1, 4, 0x05, 1, 0x0014}, // 1 * 6 = 6 (0x0006)
37 | }; // 12 byte
38 |
39 | //- peer device list table -----------------------------------------------------------------------------------------------
40 | EE::s_peerTbl peerTbl[] = {
41 | // cnl, pMax, pAddr;
42 | {1, 6, 0x001a} // 6 * 4 = 24 (0x18)
43 | }; // 4 byte
44 |
45 | //- handover to AskSin lib -----------------------------------------------------------------------------------------------
46 | EE::s_devDef devDef = {
47 | 1, 2, devIdnt, cnlAddr,
48 | }; // 6 byte
49 |
50 | //- module registrar -----------------------------------------------------------------------------------------------------
51 | RG::s_modTable modTbl[1];
52 |
53 | void everyTimeStart(void) {
54 | // place here everything which should be done on each start or reset of the device
55 | // typical use case are loading default values or user class configurations
56 |
57 |
58 | }
59 |
60 | void firstTimeStart(void) {
61 | // place here everything which should be done on the first start or after a complete reset of the sketch
62 | // typical use case are default values which should be written into the register or peer database
63 |
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/examples/CUSTOM_LUX/status - broken:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/trilu2000/NewAskSin/75d3209f34f6ab559c0b6d1d7cbe09c53da2cd61/examples/CUSTOM_LUX/status - broken
--------------------------------------------------------------------------------
/examples/HM_LC_Bl1_SM/HM_LC_Bl1_SM.ino:
--------------------------------------------------------------------------------
1 | #define SER_DBG
2 |
3 | //- load library's --------------------------------------------------------------------------------------------------------
4 | #include // the asksin framework
5 | #include "register.h" // configuration sheet
6 |
7 | //waitTimer xTmr;
8 |
9 | //- arduino functions -----------------------------------------------------------------------------------------------------
10 | void setup() {
11 | // - Hardware setup ---------------------------------------
12 | // everything off
13 | // - Hardware setup ---------------------------------------
14 | // - everything off ---------------------------------------
15 |
16 | //EIMSK = 0; // disable external interrupts
17 | //ADCSRA = 0; // ADC off
18 | //power_all_disable(); // and everything else
19 |
20 | //DDRB = DDRC = DDRD = 0x00; // everything as input
21 | //PORTB = PORTC = PORTD = 0x00; // pullup's off
22 |
23 | // todo: timer0 and SPI should enable internally
24 | power_timer0_enable();
25 | power_spi_enable(); // enable only needed functions
26 |
27 | // enable only what is really needed
28 |
29 |
30 | #ifdef SER_DBG
31 | dbgStart(); // serial setup
32 | dbg << F("HM_LC_Bl1_SM\n");
33 | dbg << F(LIB_VERSION_STRING);
34 | _delay_ms (50); // ...and some information
35 | #endif
36 |
37 |
38 | // - AskSin related ---------------------------------------
39 | hm.init(); // init the asksin framework
40 |
41 |
42 | sei(); // enable interrupts
43 |
44 |
45 | // - user related -----------------------------------------
46 | #ifdef SER_DBG
47 | dbg << F("HMID: ") << _HEX(HMID,3) << F(", MAID: ") << _HEX(MAID,3) << F("\n\n"); // some debug
48 | #endif
49 |
50 | }
51 |
52 | void loop() {
53 | // - AskSin related ---------------------------------------
54 | hm.poll(); // poll the homematic main loop
55 |
56 |
57 | // - user related -----------------------------------------
58 |
59 | }
60 |
61 |
62 | //- user functions --------------------------------------------------------------------------------------------------------
63 | void initBlind(uint8_t channel) {
64 | #ifdef SER_DBG
65 | dbg << F("initDim: ") << channel << "\n";
66 | #endif
67 |
68 | power_timer2_enable(); // enable the timer2 in power management
69 |
70 | pinOutput(DDRD,3); // init the relay pins
71 | //setPinLow(PORTD,3);
72 |
73 | TCCR2B |= (1<96) && (inChar<103)) inChar-=87; // a - f
104 | else if ((inChar>64) && (inChar<71)) inChar-=55; // A - F
105 | else if ((inChar>47) && (inChar<58)) inChar-=48; // 0 - 9
106 | else continue;
107 |
108 | if (i % 2 == 0) hm.sn.buf[i/2] = inChar << 4; // high byte
109 | else hm.sn.buf[i/2] |= inChar; // low byte
110 |
111 | i++;
112 | }
113 | #endif
114 | }
115 |
116 |
117 |
--------------------------------------------------------------------------------
/examples/HM_LC_Bl1_SM/HM_LC_Bl1_SM.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.23107.0
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HM_LC_Bl1_SM", "HM_LC_Bl1_SM.vcxproj", "{0B4083AE-230A-4669-B689-FD50061D9E9A}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|x64 = Debug|x64
11 | Debug|x86 = Debug|x86
12 | Release|x64 = Release|x64
13 | Release|x86 = Release|x86
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {0B4083AE-230A-4669-B689-FD50061D9E9A}.Debug|x64.ActiveCfg = Debug|x64
17 | {0B4083AE-230A-4669-B689-FD50061D9E9A}.Debug|x64.Build.0 = Debug|x64
18 | {0B4083AE-230A-4669-B689-FD50061D9E9A}.Debug|x86.ActiveCfg = Debug|Win32
19 | {0B4083AE-230A-4669-B689-FD50061D9E9A}.Debug|x86.Build.0 = Debug|Win32
20 | {0B4083AE-230A-4669-B689-FD50061D9E9A}.Release|x64.ActiveCfg = Release|x64
21 | {0B4083AE-230A-4669-B689-FD50061D9E9A}.Release|x64.Build.0 = Release|x64
22 | {0B4083AE-230A-4669-B689-FD50061D9E9A}.Release|x86.ActiveCfg = Release|Win32
23 | {0B4083AE-230A-4669-B689-FD50061D9E9A}.Release|x86.Build.0 = Release|Win32
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | EndGlobal
29 |
--------------------------------------------------------------------------------
/examples/HM_LC_Bl1_SM/HM_LC_Bl1_SM.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 | Headerdateien
23 |
24 |
25 | Headerdateien
26 |
27 |
28 | Headerdateien
29 |
30 |
31 |
32 |
33 | Quelldateien
34 |
35 |
36 |
--------------------------------------------------------------------------------
/examples/HM_LC_Bl1_SM/__vm/.HM_LC_Bl1_SM.vsarduino.h:
--------------------------------------------------------------------------------
1 | /*
2 | Editor: http://www.visualmicro.com
3 | visual micro and the arduino ide ignore this code during compilation. this code is automatically maintained by visualmicro, manual changes to this file will be overwritten
4 | the contents of the Visual Micro sketch sub folder can be deleted prior to publishing a project
5 | all non-arduino files created by visual micro and all visual studio project or solution files can be freely deleted and are not required to compile a sketch (do not delete your own code!).
6 | note: debugger breakpoints are stored in '.sln' or '.asln' files, knowledge of last uploaded breakpoints is stored in the upload.vmps.xml file. Both files are required to continue a previous debug session without needing to compile and upload again
7 |
8 | Hardware: Arduino Pro or Pro Mini w/ ATmega328 (3.3V, 8 MHz), Platform=avr, Package=arduino
9 | */
10 |
11 | #ifndef _VSARDUINO_H_
12 | #define _VSARDUINO_H_
13 | #define __AVR_ATmega328p__
14 | #define __AVR_ATmega328P__
15 | #define F_CPU 8000000L
16 | #define ARDUINO 165
17 | #define ARDUINO_AVR_PRO
18 | #define ARDUINO_ARCH_AVR
19 | #define __cplusplus
20 | #define __AVR__
21 | #define __inline__
22 | #define __asm__(x)
23 | #define __extension__
24 | //#define __ATTR_PURE__
25 | //#define __ATTR_CONST__
26 | #define __inline__
27 | //#define __asm__
28 | #define __volatile__
29 | #define GCC_VERSION 40801
30 | #define volatile(va_arg)
31 | #define _CONST
32 | typedef void *__builtin_va_list;
33 | #define __builtin_va_start
34 | #define __builtin_va_end
35 | //#define __DOXYGEN__
36 | #define __attribute__(x)
37 | #define NOINLINE __attribute__((noinline))
38 | #define prog_void
39 | #define PGM_VOID_P int
40 | #ifndef __builtin_constant_p
41 | #define __builtin_constant_p __attribute__((__const__))
42 | #endif
43 | #ifndef __builtin_strlen
44 | #define __builtin_strlen __attribute__((__const__))
45 | #endif
46 | #define NEW_H
47 | /*
48 | #ifndef __ATTR_CONST__
49 | #define __ATTR_CONST__ __attribute__((__const__))
50 | #endif
51 |
52 | #ifndef __ATTR_MALLOC__
53 | #define __ATTR_MALLOC__ __attribute__((__malloc__))
54 | #endif
55 |
56 | #ifndef __ATTR_NORETURN__
57 | #define __ATTR_NORETURN__ __attribute__((__noreturn__))
58 | #endif
59 |
60 | #ifndef __ATTR_PURE__
61 | #define __ATTR_PURE__ __attribute__((__pure__))
62 | #endif
63 | */
64 | typedef unsigned char byte;
65 | extern "C" void __cxa_pure_virtual() {;}
66 |
67 |
68 |
69 | #include
70 | #include
71 | #undef F
72 | #define F(string_literal) ((const PROGMEM char *)(string_literal))
73 | #undef PSTR
74 | #define PSTR(string_literal) ((const PROGMEM char *)(string_literal))
75 | #undef cli
76 | #define cli()
77 | #define pgm_read_byte(address_short)
78 | #define pgm_read_word(address_short)
79 | #define pgm_read_word2(address_short)
80 | #define digitalPinToPort(P)
81 | #define digitalPinToBitMask(P)
82 | #define digitalPinToTimer(P)
83 | #define analogInPinToBit(P)
84 | #define portOutputRegister(P)
85 | #define portInputRegister(P)
86 | #define portModeRegister(P)
87 | #include
88 | #include
89 | #include
90 | #include
91 | #endif
92 |
--------------------------------------------------------------------------------
/examples/HM_LC_Bl1_SM/hardware.cpp:
--------------------------------------------------------------------------------
1 | //- -----------------------------------------------------------------------------------------------------------------------
2 | // AskSin driver implementation
3 | // 2013-08-03 Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
4 | //- -----------------------------------------------------------------------------------------------------------------------
5 | //- AskSin hardware definition ----------------------------------------------------------------------------------------
6 | //- with a lot of support from martin876 at FHEM forum
7 | //- -------------------------------------------------------------------------------------------------------------------
8 |
9 | #include "hardware.h"
10 | #include
11 |
12 | void initWakeupPin(void) {
13 | #if defined(WAKE_UP_DDR)
14 | pinInput(WAKE_UP_DDR, WAKE_UP_PIN); // set pin as input
15 | setPinHigh(WAKE_UP_PORT, WAKE_UP_PIN); // enable internal pull up
16 | #endif
17 | }
18 | uint8_t checkWakeupPin(void) {
19 | // to enable the USB port for upload, configure PE2 as input and check if it is 0, this will avoid sleep mode and enable program upload via serial
20 | #if defined(WAKE_UP_DDR)
21 | if (getPin(WAKE_UP_PNR, WAKE_UP_PIN)) return 1; // return pin is active
22 | #endif
23 |
24 | return 0; // normal operation
25 | }
26 |
--------------------------------------------------------------------------------
/examples/HM_LC_Bl1_SM/hardware.h:
--------------------------------------------------------------------------------
1 | //- -----------------------------------------------------------------------------------------------------------------------
2 | // AskSin driver implementation
3 | // 2013-08-03 Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
4 | //- -----------------------------------------------------------------------------------------------------------------------
5 | //- AskSin hardware definition ----------------------------------------------------------------------------------------
6 | //- with a lot of support from martin876 at FHEM forum
7 | //- -------------------------------------------------------------------------------------------------------------------
8 |
9 | #include
10 |
11 | #ifndef _HARDWARE_h
12 | #define _HARDWARE_h
13 |
14 | #define EXT_BATTERY_MEASUREMENT // comment out to use internal battery measurement
15 | #define BATTERY_FACTOR 17 // see excel table
16 | #define DEBOUNCE 5 // input debounce time in ms - 5 seems to be a good value
17 |
18 | #if defined(__AVR_ATmega328P__)
19 | //- cc1100 hardware CS and GDO0 definitions -------------------------------------------------------------------
20 | #define CC_CS_DDR DDRB // SPI chip select definition
21 | #define CC_CS_PORT PORTB
22 | #define CC_CS_PIN PORTB2
23 |
24 | #define CC_GDO0_DDR DDRD // GDO0 pin, signals received data
25 | #define CC_GDO0_PIN PORTB2
26 |
27 | #define CC_GDO0_PCICR PCICR // GDO0 interrupt register
28 | #define CC_GDO0_PCIE PCIE2
29 | #define CC_GDO0_PCMSK PCMSK2 // GDO0 interrupt mask
30 | #define CC_GDO0_INT PCINT18 // pin interrupt
31 |
32 | //- LED's definition ------------------------------------------------------------------------------------------
33 | #define LED_RED_DDR DDRD // define led port and remaining pin
34 | #define LED_RED_PORT PORTD
35 | #define LED_RED_PIN PORTD4
36 |
37 | #define LED_GRN_DDR DDRD
38 | #define LED_GRN_PORT PORTD
39 | #define LED_GRN_PIN PORTD4
40 |
41 | #define LED_ACTIVE_LOW 0 // leds connected to GND = 0, VCC = 1
42 |
43 | //- configuration key ----------------------------------------------------------------------------------------
44 | #define CONFIG_KEY_DDR DDRB // define config key port and remaining pin
45 | #define CONFIG_KEY_PORT PORTB
46 | #define CONFIG_KEY_PIN PORTB0
47 |
48 | #define CONFIG_KEY_PCICR PCICR // interrupt register
49 | #define CONFIG_KEY_PCIE PCIE0 // pin change interrupt port bit
50 | #define CONFIG_KEY_PCMSK PCMSK0 // interrupt mask
51 | #define CONFIG_KEY_INT PCINT0 // pin interrupt
52 |
53 | //- battery external measurement functions --------------------------------------------------------------------
54 | #define BATT_ENABLE_DDR DDRD // define battery measurement enable pin, has to be low to start measuring
55 | #define BATT_ENABLE_PORT PORTD
56 | #define BATT_ENABLE_PIN PORTD7
57 |
58 | #define BATT_MEASURE_DDR DDRC // define battery measure pin, where ADC gets the measurement
59 | #define BATT_MEASURE_PORT PORTC
60 | #define BATT_MEASURE_PIN PORTC1
61 |
62 | #elif defined(__AVR_ATmega32U4__)
63 | //- cc1100 hardware CS and GDO0 definitions -------------------------------------------------------------------
64 | #define CC_CS_DDR DDRB // SPI chip select definition
65 | #define CC_CS_PORT PORTB
66 | #define CC_CS_PIN PORTB4
67 |
68 | #define CC_GDO0_DDR DDRB // GDO0 pin, signals received data
69 | #define CC_GDO0_PIN PORTB5
70 |
71 | #define CC_GDO0_PCICR PCICR // GDO0 interrupt register
72 | #define CC_GDO0_PCIE PCIE0
73 | #define CC_GDO0_PCMSK PCMSK0 // GDO0 interrupt mask
74 | #define CC_GDO0_INT PCINT5 // pin interrupt
75 |
76 | //- LED's definition ------------------------------------------------------------------------------------------
77 | #define LED_RED_DDR DDRB // define led port and remaining pin
78 | #define LED_RED_PORT PORTB
79 | #define LED_RED_PIN PORTB7
80 |
81 | #define LED_GRN_DDR DDRC
82 | #define LED_GRN_PORT PORTC
83 | #define LED_GRN_PIN PORTC7
84 |
85 | #define LED_ACTIVE_LOW 1 // leds against GND = 0, VCC = 1
86 |
87 | //- configuration key ----------------------------------------------------------------------------------------
88 | #define CONFIG_KEY_DDR DDRB // define config key port and remaining pin
89 | #define CONFIG_KEY_PORT PORTB
90 | #define CONFIG_KEY_PIN PORTB6
91 |
92 | #define CONFIG_KEY_PCICR PCICR // interrupt register
93 | #define CONFIG_KEY_PCIE PCIE0 // pin change interrupt port bit
94 | #define CONFIG_KEY_PCMSK PCMSK0 // interrupt mask
95 | #define CONFIG_KEY_INT PCINT6 // pin interrupt
96 |
97 | //- battery external measurement functions --------------------------------------------------------------------
98 | #define BATT_ENABLE_DDR DDRF // define battery measurement enable pin, has to be low to start measuring
99 | #define BATT_ENABLE_PORT PORTF
100 | #define BATT_ENABLE_PIN PORTF4
101 |
102 | #define BATT_MEASURE_DDR DDRF // define battery measure pin, where ADC gets the measurement
103 | #define BATT_MEASURE_PORT PORTF
104 | #define BATT_MEASURE_PIN PORTF7
105 |
106 | #else
107 | #error "Error: cc1100 CS and GDO0 not defined for your hardware in hardware.h!"
108 | #endif
109 | //- ---------------------------------------------------------------------------------------------------------------
110 |
111 |
112 | //- wake up pin ---------------------------------------------------------------------------------------------------
113 | #if defined(__AVR_ATmega32U4__)
114 | #define WAKE_UP_DDR DDRE // define wake up pin port and remaining pin
115 | #define WAKE_UP_PORT PORTE
116 | #define WAKE_UP_PNR PINE
117 | #define WAKE_UP_PIN PINE2
118 | #endif
119 | //- ---------------------------------------------------------------------------------------------------------------
120 |
121 | #endif
122 |
123 |
--------------------------------------------------------------------------------
/examples/HM_LC_Bl1_SM/register.h:
--------------------------------------------------------------------------------
1 | //- ----------------------------------------------------------------------------------------------------------------------
2 | //- load libraries -------------------------------------------------------------------------------------------------------
3 | #include // the asksin framework
4 | #include "hardware.h" // hardware definition
5 | #include
6 |
7 | //- stage modules --------------------------------------------------------------------------------------------------------
8 | AS hm; // asksin framework
9 |
10 | cmBlind cmBlind[1]; // create instances of channel module
11 | extern void initBlind(uint8_t channel); // declare function to jump in
12 | extern void switchBlind(uint8_t channel, uint8_t status); // declare function to jump in
13 |
14 | //- ----------------------------------------------------------------------------------------------------------------------
15 | //- eeprom defaults table ------------------------------------------------------------------------------------------------
16 | uint16_t EEMEM eMagicByte;
17 | uint8_t EEMEM eHMID[3] = {0xa5,0x29,0xb9,};
18 | uint8_t EEMEM eHMSR[10] = {'X','M','S','2','3','4','5','6','7','9',};
19 | uint8_t EEMEM eHMKEY[16] = {0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,0x10,};
20 |
21 | // if HMID and Serial are not set, then eeprom ones will be used
22 | uint8_t HMID[3] = {0xa5,0x29,0xb9,};
23 | uint8_t HMSR[10] = {'X','M','S','2','3','4','5','6','7','9',}; // XMS2345679
24 | uint8_t HMKEY[16] = {0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,0x10,};
25 |
26 | //- ----------------------------------------------------------------------------------------------------------------------
27 | //- settings of HM device for AS class -----------------------------------------------------------------------------------
28 | const uint8_t devIdnt[] PROGMEM = {
29 | /* Firmware version 1 byte */ 0x25, // don't know for what it is good for
30 | /* Model ID 2 byte */ 0x00,0x05, // model ID, describes HM hardware. Own devices should use high values due to HM starts from 0
31 | /* Sub Type ID 1 byte */ 0x30, // not needed for FHEM, it's something like a group ID
32 | /* Device Info 3 byte */ 0x01,0x01,0x00, // describes device, not completely clear yet. includes amount of channels
33 | }; // 7 byte
34 |
35 | //- ----------------------------------------------------------------------------------------------------------------------
36 | //- channel slice address definition -------------------------------------------------------------------------------------
37 | const uint8_t cnlAddr[] PROGMEM = {
38 | 0x02,0x0a,0x0b,0x0c,0x12,0x18,
39 | 0x0b,0x0d,0x0f,0x10,
40 | 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0f,0x11,0x1c,0x1d,0x1e,0x1f,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8f,0x91,0x9c,0x9d,0x9e,0x9f,
41 | }; // 48 byte
42 |
43 | //- channel device list table --------------------------------------------------------------------------------------------
44 | EE::s_cnlTbl cnlTbl[] = {
45 | // cnl, lst, sIdx, sLen, pAddr, hidden
46 | { 0, 0, 0x00, 6, 0x001f, 0, },
47 | { 1, 1, 0x06, 4, 0x0025, 0, },
48 | { 1, 3, 0x0a, 38, 0x0029, 0, },
49 | }; // 21 byte
50 |
51 | //- peer device list table -----------------------------------------------------------------------------------------------
52 | EE::s_peerTbl peerTbl[] = {
53 | // cnl, pMax, pAddr;
54 | { 1, 6, 0x010d, },
55 | }; // 4 byte
56 |
57 | //- handover to AskSin lib -----------------------------------------------------------------------------------------------
58 | EE::s_devDef devDef = {
59 | 1, 3, devIdnt, cnlAddr,
60 | }; // 6 byte
61 |
62 | //- module registrar -----------------------------------------------------------------------------------------------------
63 | RG::s_modTable modTbl[1];
64 |
65 | //- ----------------------------------------------------------------------------------------------------------------------
66 | //- first time and regular start functions -------------------------------------------------------------------------------
67 |
68 | void everyTimeStart(void) {
69 | // place here everything which should be done on each start or reset of the device
70 | // typical usecase are loading default values or user class configurations
71 |
72 | // init the homematic framework
73 | hm.confButton.config(2, CONFIG_KEY_PCIE, CONFIG_KEY_INT); // configure the config button, mode, pci byte and pci bit
74 | hm.ld.init(2, &hm); // set the led
75 | hm.ld.set(welcome); // show something
76 | hm.bt.set(30, 3600000); // set battery check, internal, 2.7 reference, measurement each hour
77 | hm.pw.setMode(0); // set power management mode
78 |
79 | // register user modules
80 | cmBlind[0].regInHM(1, 3, &hm); // register user module
81 | cmBlind[0].config(&initBlind, &switchBlind); // configure user module
82 |
83 | }
84 |
85 | void firstTimeStart(void) {
86 | // place here everything which should be done on the first start or after a complete reset of the sketch
87 | // typical usecase are default values which should be written into the register or peer database
88 |
89 | }
90 |
91 |
--------------------------------------------------------------------------------
/examples/HM_LC_Bl1_SM/status - in development:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/trilu2000/NewAskSin/75d3209f34f6ab559c0b6d1d7cbe09c53da2cd61/examples/HM_LC_Bl1_SM/status - in development
--------------------------------------------------------------------------------
/examples/HM_LC_Dim1PWM_CV/HM_LC_Dim1PWM_CV.ino:
--------------------------------------------------------------------------------
1 | #define SER_DBG
2 |
3 | //- load library's --------------------------------------------------------------------------------------------------------
4 | #include // the asksin framework
5 | #include "register.h" // configuration sheet
6 |
7 | //waitTimer xTmr;
8 |
9 | //- arduino functions -----------------------------------------------------------------------------------------------------
10 | void setup() {
11 | // - Hardware setup ---------------------------------------
12 | // everything off
13 | // - Hardware setup ---------------------------------------
14 | // - everything off ---------------------------------------
15 |
16 | //EIMSK = 0; // disable external interrupts
17 | //ADCSRA = 0; // ADC off
18 | //power_all_disable(); // and everything else
19 |
20 | //DDRB = DDRC = DDRD = 0x00; // everything as input
21 | //PORTB = PORTC = PORTD = 0x00; // pullup's off
22 |
23 | // todo: timer0 and SPI should enable internally
24 | power_timer0_enable();
25 | power_spi_enable(); // enable only needed functions
26 |
27 | // enable only what is really needed
28 |
29 |
30 | #ifdef SER_DBG
31 | dbgStart(); // serial setup
32 | dbg << F("HM_LC_Dim1PWM_CV\n");
33 | dbg << F(LIB_VERSION_STRING);
34 | _delay_ms (50); // ...and some information
35 | #endif
36 |
37 |
38 | // - AskSin related ---------------------------------------
39 | hm.init(); // init the asksin framework
40 |
41 |
42 | sei(); // enable interrupts
43 |
44 |
45 | // - user related -----------------------------------------
46 | #ifdef SER_DBG
47 | dbg << F("HMID: ") << _HEX(HMID,3) << F(", MAID: ") << _HEX(MAID,3) << F("\n\n"); // some debug
48 | #endif
49 |
50 | }
51 |
52 | void loop() {
53 | // - AskSin related ---------------------------------------
54 | hm.poll(); // poll the homematic main loop
55 |
56 |
57 | // - user related -----------------------------------------
58 |
59 | }
60 |
61 |
62 | //- user functions --------------------------------------------------------------------------------------------------------
63 | void initDim(uint8_t channel) {
64 | #ifdef SER_DBG
65 | dbg << F("initDim: ") << channel << "\n";
66 | #endif
67 |
68 | power_timer2_enable(); // enable the timer2 in power management
69 |
70 | pinOutput(DDRD,3); // init the relay pins
71 | //setPinLow(PORTD,3);
72 |
73 | TCCR2B |= (1<96) && (inChar<103)) inChar-=87; // a - f
104 | else if ((inChar>64) && (inChar<71)) inChar-=55; // A - F
105 | else if ((inChar>47) && (inChar<58)) inChar-=48; // 0 - 9
106 | else continue;
107 |
108 | if (i % 2 == 0) hm.sn.buf[i/2] = inChar << 4; // high byte
109 | else hm.sn.buf[i/2] |= inChar; // low byte
110 |
111 | i++;
112 | }
113 | #endif
114 | }
115 |
116 |
117 |
--------------------------------------------------------------------------------
/examples/HM_LC_Dim1PWM_CV/hardware.cpp:
--------------------------------------------------------------------------------
1 | //- -----------------------------------------------------------------------------------------------------------------------
2 | // AskSin driver implementation
3 | // 2013-08-03 Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
4 | //- -----------------------------------------------------------------------------------------------------------------------
5 | //- AskSin hardware definition ----------------------------------------------------------------------------------------
6 | //- with a lot of support from martin876 at FHEM forum
7 | //- -------------------------------------------------------------------------------------------------------------------
8 |
9 | #include "hardware.h"
10 | #include
11 |
12 | void initWakeupPin(void) {
13 | #if defined(WAKE_UP_DDR)
14 | pinInput(WAKE_UP_DDR, WAKE_UP_PIN); // set pin as input
15 | setPinHigh(WAKE_UP_PORT, WAKE_UP_PIN); // enable internal pull up
16 | #endif
17 | }
18 | uint8_t checkWakeupPin(void) {
19 | // to enable the USB port for upload, configure PE2 as input and check if it is 0, this will avoid sleep mode and enable program upload via serial
20 | #if defined(WAKE_UP_DDR)
21 | if (getPin(WAKE_UP_PNR, WAKE_UP_PIN)) return 1; // return pin is active
22 | #endif
23 |
24 | return 0; // normal operation
25 | }
26 |
--------------------------------------------------------------------------------
/examples/HM_LC_Dim1PWM_CV/hardware.h:
--------------------------------------------------------------------------------
1 | //- -----------------------------------------------------------------------------------------------------------------------
2 | // AskSin driver implementation
3 | // 2013-08-03 Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
4 | //- -----------------------------------------------------------------------------------------------------------------------
5 | //- AskSin hardware definition ----------------------------------------------------------------------------------------
6 | //- with a lot of support from martin876 at FHEM forum
7 | //- -------------------------------------------------------------------------------------------------------------------
8 |
9 | #include
10 |
11 | #ifndef _HARDWARE_h
12 | #define _HARDWARE_h
13 |
14 | #define EXT_BATTERY_MEASUREMENT // comment out to use internal battery measurement
15 | #define BATTERY_FACTOR 17 // see excel table
16 | #define DEBOUNCE 5 // input debounce time in ms - 5 seems to be a good value
17 |
18 | #if defined(__AVR_ATmega328P__)
19 | //- cc1100 hardware CS and GDO0 definitions -------------------------------------------------------------------
20 | #define CC_CS_DDR DDRB // SPI chip select definition
21 | #define CC_CS_PORT PORTB
22 | #define CC_CS_PIN PORTB2
23 |
24 | #define CC_GDO0_DDR DDRD // GDO0 pin, signals received data
25 | #define CC_GDO0_PIN PORTB2
26 |
27 | #define CC_GDO0_PCICR PCICR // GDO0 interrupt register
28 | #define CC_GDO0_PCIE PCIE2
29 | #define CC_GDO0_PCMSK PCMSK2 // GDO0 interrupt mask
30 | #define CC_GDO0_INT PCINT18 // pin interrupt
31 |
32 | //- LED's definition ------------------------------------------------------------------------------------------
33 | #define LED_RED_DDR DDRD // define led port and remaining pin
34 | #define LED_RED_PORT PORTD
35 | #define LED_RED_PIN PORTD4
36 |
37 | #define LED_GRN_DDR DDRD
38 | #define LED_GRN_PORT PORTD
39 | #define LED_GRN_PIN PORTD4
40 |
41 | #define LED_ACTIVE_LOW 0 // leds connected to GND = 0, VCC = 1
42 |
43 | //- configuration key ----------------------------------------------------------------------------------------
44 | #define CONFIG_KEY_DDR DDRB // define config key port and remaining pin
45 | #define CONFIG_KEY_PORT PORTB
46 | #define CONFIG_KEY_PIN PORTB0
47 |
48 | #define CONFIG_KEY_PCICR PCICR // interrupt register
49 | #define CONFIG_KEY_PCIE PCIE0 // pin change interrupt port bit
50 | #define CONFIG_KEY_PCMSK PCMSK0 // interrupt mask
51 | #define CONFIG_KEY_INT PCINT0 // pin interrupt
52 |
53 | //- battery external measurement functions --------------------------------------------------------------------
54 | #define BATT_ENABLE_DDR DDRD // define battery measurement enable pin, has to be low to start measuring
55 | #define BATT_ENABLE_PORT PORTD
56 | #define BATT_ENABLE_PIN PORTD7
57 |
58 | #define BATT_MEASURE_DDR DDRC // define battery measure pin, where ADC gets the measurement
59 | #define BATT_MEASURE_PORT PORTC
60 | #define BATT_MEASURE_PIN PORTC1
61 |
62 | #elif defined(__AVR_ATmega32U4__)
63 | //- cc1100 hardware CS and GDO0 definitions -------------------------------------------------------------------
64 | #define CC_CS_DDR DDRB // SPI chip select definition
65 | #define CC_CS_PORT PORTB
66 | #define CC_CS_PIN PORTB4
67 |
68 | #define CC_GDO0_DDR DDRB // GDO0 pin, signals received data
69 | #define CC_GDO0_PIN PORTB5
70 |
71 | #define CC_GDO0_PCICR PCICR // GDO0 interrupt register
72 | #define CC_GDO0_PCIE PCIE0
73 | #define CC_GDO0_PCMSK PCMSK0 // GDO0 interrupt mask
74 | #define CC_GDO0_INT PCINT5 // pin interrupt
75 |
76 | //- LED's definition ------------------------------------------------------------------------------------------
77 | #define LED_RED_DDR DDRB // define led port and remaining pin
78 | #define LED_RED_PORT PORTB
79 | #define LED_RED_PIN PORTB7
80 |
81 | #define LED_GRN_DDR DDRC
82 | #define LED_GRN_PORT PORTC
83 | #define LED_GRN_PIN PORTC7
84 |
85 | #define LED_ACTIVE_LOW 1 // leds against GND = 0, VCC = 1
86 |
87 | //- configuration key ----------------------------------------------------------------------------------------
88 | #define CONFIG_KEY_DDR DDRB // define config key port and remaining pin
89 | #define CONFIG_KEY_PORT PORTB
90 | #define CONFIG_KEY_PIN PORTB6
91 |
92 | #define CONFIG_KEY_PCICR PCICR // interrupt register
93 | #define CONFIG_KEY_PCIE PCIE0 // pin change interrupt port bit
94 | #define CONFIG_KEY_PCMSK PCMSK0 // interrupt mask
95 | #define CONFIG_KEY_INT PCINT6 // pin interrupt
96 |
97 | //- battery external measurement functions --------------------------------------------------------------------
98 | #define BATT_ENABLE_DDR DDRF // define battery measurement enable pin, has to be low to start measuring
99 | #define BATT_ENABLE_PORT PORTF
100 | #define BATT_ENABLE_PIN PORTF4
101 |
102 | #define BATT_MEASURE_DDR DDRF // define battery measure pin, where ADC gets the measurement
103 | #define BATT_MEASURE_PORT PORTF
104 | #define BATT_MEASURE_PIN PORTF7
105 |
106 | #else
107 | #error "Error: cc1100 CS and GDO0 not defined for your hardware in hardware.h!"
108 | #endif
109 | //- ---------------------------------------------------------------------------------------------------------------
110 |
111 |
112 | //- wake up pin ---------------------------------------------------------------------------------------------------
113 | #if defined(__AVR_ATmega32U4__)
114 | #define WAKE_UP_DDR DDRE // define wake up pin port and remaining pin
115 | #define WAKE_UP_PORT PORTE
116 | #define WAKE_UP_PNR PINE
117 | #define WAKE_UP_PIN PINE2
118 | #endif
119 | //- ---------------------------------------------------------------------------------------------------------------
120 |
121 | #endif
122 |
123 |
--------------------------------------------------------------------------------
/examples/HM_LC_Dim1PWM_CV/status - testing:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/trilu2000/NewAskSin/75d3209f34f6ab559c0b6d1d7cbe09c53da2cd61/examples/HM_LC_Dim1PWM_CV/status - testing
--------------------------------------------------------------------------------
/examples/HM_LC_SW1_BA_PCB/HM_LC_SW1_BA_PCB.ino:
--------------------------------------------------------------------------------
1 | #define SER_DBG // serial debug messages
2 |
3 | //- load library's --------------------------------------------------------------------------------------------------------
4 | #include // ask sin framework
5 | #include "register.h" // configuration sheet
6 |
7 |
8 | //- arduino functions -----------------------------------------------------------------------------------------------------
9 | void setup() {
10 |
11 | // - Hardware setup ---------------------------------------
12 | // - everything off ---------------------------------------
13 |
14 | EIMSK = 0; // disable external interrupts
15 | ADCSRA = 0; // ADC off
16 | power_all_disable(); // and everything else
17 |
18 | DDRB = DDRC = DDRD = 0x00; // everything as input
19 | PORTB = PORTC = PORTD = 0x00; // pullup's off
20 |
21 | // todo: timer0 and SPI should enable internally
22 | power_timer0_enable();
23 | power_spi_enable(); // enable only needed functions
24 |
25 | // enable only what is really needed
26 |
27 | #ifdef SER_DBG // some debug
28 | dbgStart(); // serial setup
29 | dbg << F("HM_LC_SW1_BA_PCB\n");
30 | dbg << F(LIB_VERSION_STRING);
31 | _delay_ms (50); // ...and some information
32 | #endif
33 |
34 |
35 | // - AskSin related ---------------------------------------
36 | hm.init(); // init the asksin framework
37 | sei(); // enable interrupts
38 |
39 |
40 | // - user related -----------------------------------------
41 | #ifdef SER_DBG
42 | dbg << F("HMID: ") << _HEX(HMID,3) << F(", MAID: ") << _HEX(MAID,3) << F("\n\n"); // some debug
43 | #endif
44 | }
45 |
46 | void loop() {
47 | // - AskSin related ---------------------------------------
48 | hm.poll(); // poll the homematic main loop
49 |
50 | // - user related -----------------------------------------
51 |
52 | }
53 |
54 |
55 | //- user functions --------------------------------------------------------------------------------------------------------
56 | void initRly(uint8_t channel) {
57 | // setting the relay pin as output, could be done also by pinMode(3, OUTPUT)
58 | #ifdef SER_DBG
59 | dbg << F("initRly: ") << channel << "\n";
60 | #endif
61 |
62 | pinOutput(DDRD,3); // init the relay pins
63 | setPinLow(PORTD,3); // set relay pin to ground
64 | }
65 | void switchRly(uint8_t channel, uint8_t status) {
66 | // switching the relay, could be done also by digitalWrite(3,HIGH or LOW)
67 | #ifdef SER_DBG
68 | dbg << F("switchRly: ") << channel << ", " << status << "\n";
69 | #endif
70 |
71 | if (status) setPinHigh(PORTD,3); // check status and set relay pin accordingly
72 | else setPinLow(PORTD,3);
73 | }
74 |
75 |
76 | //- predefined functions --------------------------------------------------------------------------------------------------
77 | void serialEvent() {
78 | #ifdef SER_DBG
79 |
80 | static uint8_t i = 0; // it is a high byte next time
81 | while (Serial.available()) {
82 | uint8_t inChar = (uint8_t)Serial.read(); // read a byte
83 | if (inChar == '\n') { // send to receive routine
84 | i = 0;
85 | hm.sn.active = 1;
86 | }
87 |
88 | if ((inChar>96) && (inChar<103)) inChar-=87; // a - f
89 | else if ((inChar>64) && (inChar<71)) inChar-=55; // A - F
90 | else if ((inChar>47) && (inChar<58)) inChar-=48; // 0 - 9
91 | else continue;
92 |
93 | if (i % 2 == 0) hm.sn.buf[i/2] = inChar << 4; // high byte
94 | else hm.sn.buf[i/2] |= inChar; // low byte
95 |
96 | i++;
97 | }
98 | #endif
99 | }
100 |
--------------------------------------------------------------------------------
/examples/HM_LC_SW1_BA_PCB/hardware.cpp:
--------------------------------------------------------------------------------
1 | //- -----------------------------------------------------------------------------------------------------------------------
2 | // AskSin driver implementation
3 | // 2013-08-03 Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
4 | //- -----------------------------------------------------------------------------------------------------------------------
5 | //- AskSin hardware definition ----------------------------------------------------------------------------------------
6 | //- with a lot of support from martin876 at FHEM forum
7 | //- -------------------------------------------------------------------------------------------------------------------
8 |
9 | #include "hardware.h"
10 | #include
11 |
12 | void initWakeupPin(void) {
13 | #if defined(WAKE_UP_DDR)
14 | pinInput(WAKE_UP_DDR, WAKE_UP_PIN); // set pin as input
15 | setPinHigh(WAKE_UP_PORT, WAKE_UP_PIN); // enable internal pull up
16 | #endif
17 | }
18 | uint8_t checkWakeupPin(void) {
19 | // to enable the USB port for upload, configure PE2 as input and check if it is 0, this will avoid sleep mode and enable program upload via serial
20 | #if defined(WAKE_UP_DDR)
21 | if (getPin(WAKE_UP_PNR, WAKE_UP_PIN)) return 1; // return pin is active
22 | #endif
23 |
24 | return 0; // normal operation
25 | }
26 |
--------------------------------------------------------------------------------
/examples/HM_LC_SW1_BA_PCB/hardware.h:
--------------------------------------------------------------------------------
1 | //- -----------------------------------------------------------------------------------------------------------------------
2 | // AskSin driver implementation
3 | // 2013-08-03 Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
4 | //- -----------------------------------------------------------------------------------------------------------------------
5 | //- AskSin hardware definition ----------------------------------------------------------------------------------------
6 | //- with a lot of support from martin876 at FHEM forum
7 | //- -------------------------------------------------------------------------------------------------------------------
8 |
9 | #include
10 |
11 | #ifndef _HARDWARE_h
12 | #define _HARDWARE_h
13 |
14 | #define EXT_BATTERY_MEASUREMENT // comment out to use internal battery measurement
15 | #define BATTERY_FACTOR 17 // see excel table
16 | #define DEBOUNCE 5
17 |
18 | #if defined(__AVR_ATmega328P__)
19 | //- cc1100 hardware CS and GDO0 definitions -------------------------------------------------------------------
20 | #define CC_CS_DDR DDRB // SPI chip select definition
21 | #define CC_CS_PORT PORTB
22 | #define CC_CS_PIN PORTB2
23 |
24 | #define CC_GDO0_DDR DDRD // GDO0 pin, signals received data
25 | #define CC_GDO0_PIN PORTB2
26 |
27 | #define CC_GDO0_PCICR PCICR // GDO0 interrupt register
28 | #define CC_GDO0_PCIE PCIE2
29 | #define CC_GDO0_PCMSK PCMSK2 // GDO0 interrupt mask
30 | #define CC_GDO0_INT PCINT18 // pin interrupt
31 |
32 | //- LED's definition ------------------------------------------------------------------------------------------
33 | #define LED_RED_DDR DDRD // define led port and remaining pin
34 | #define LED_RED_PORT PORTD
35 | #define LED_RED_PIN PORTD4
36 |
37 | #define LED_GRN_DDR DDRD
38 | #define LED_GRN_PORT PORTD
39 | #define LED_GRN_PIN PORTD4
40 |
41 | #define LED_ACTIVE_LOW 0 // leds connected to GND = 0, VCC = 1
42 |
43 | //- configuration key ----------------------------------------------------------------------------------------
44 | #define CONFIG_KEY_DDR DDRB // define config key port and remaining pin
45 | #define CONFIG_KEY_PORT PORTB
46 | #define CONFIG_KEY_PIN PORTB0
47 |
48 | #define CONFIG_KEY_PCICR PCICR // interrupt register
49 | #define CONFIG_KEY_PCIE PCIE0 // pin change interrupt port bit
50 | #define CONFIG_KEY_PCMSK PCMSK0 // interrupt mask
51 | #define CONFIG_KEY_INT PCINT0 // pin interrupt
52 |
53 | //- battery external measurement functions --------------------------------------------------------------------
54 | #define BATT_ENABLE_DDR DDRD // define battery measurement enable pin, has to be low to start measuring
55 | #define BATT_ENABLE_PORT PORTD
56 | #define BATT_ENABLE_PIN PORTD7
57 |
58 | #define BATT_MEASURE_DDR DDRC // define battery measure pin, where ADC gets the measurement
59 | #define BATT_MEASURE_PORT PORTC
60 | #define BATT_MEASURE_PIN PORTC1
61 |
62 | #elif defined(__AVR_ATmega32U4__)
63 | //- cc1100 hardware CS and GDO0 definitions -------------------------------------------------------------------
64 | #define CC_CS_DDR DDRB // SPI chip select definition
65 | #define CC_CS_PORT PORTB
66 | #define CC_CS_PIN PORTB4
67 |
68 | #define CC_GDO0_DDR DDRB // GDO0 pin, signals received data
69 | #define CC_GDO0_PIN PORTB5
70 |
71 | #define CC_GDO0_PCICR PCICR // GDO0 interrupt register
72 | #define CC_GDO0_PCIE PCIE0
73 | #define CC_GDO0_PCMSK PCMSK0 // GDO0 interrupt mask
74 | #define CC_GDO0_INT PCINT5 // pin interrupt
75 |
76 | //- LED's definition ------------------------------------------------------------------------------------------
77 | #define LED_RED_DDR DDRB // define led port and remaining pin
78 | #define LED_RED_PORT PORTB
79 | #define LED_RED_PIN PORTB7
80 |
81 | #define LED_GRN_DDR DDRC
82 | #define LED_GRN_PORT PORTC
83 | #define LED_GRN_PIN PORTC7
84 |
85 | #define LED_ACTIVE_LOW 1 // leds against GND = 0, VCC = 1
86 |
87 | //- configuration key ----------------------------------------------------------------------------------------
88 | #define CONFIG_KEY_DDR DDRB // define config key port and remaining pin
89 | #define CONFIG_KEY_PORT PORTB
90 | #define CONFIG_KEY_PIN PORTB6
91 |
92 | #define CONFIG_KEY_PCICR PCICR // interrupt register
93 | #define CONFIG_KEY_PCIE PCIE0 // pin change interrupt port bit
94 | #define CONFIG_KEY_PCMSK PCMSK0 // interrupt mask
95 | #define CONFIG_KEY_INT PCINT6 // pin interrupt
96 |
97 | //- battery external measurement functions --------------------------------------------------------------------
98 | #define BATT_ENABLE_DDR DDRF // define battery measurement enable pin, has to be low to start measuring
99 | #define BATT_ENABLE_PORT PORTF
100 | #define BATT_ENABLE_PIN PORTF4
101 |
102 | #define BATT_MEASURE_DDR DDRF // define battery measure pin, where ADC gets the measurement
103 | #define BATT_MEASURE_PORT PORTF
104 | #define BATT_MEASURE_PIN PORTF7
105 |
106 | #else
107 | #error "Error: cc1100 CS and GDO0 not defined for your hardware in hardware.h!"
108 | #endif
109 | //- ---------------------------------------------------------------------------------------------------------------
110 |
111 |
112 | //- wake up pin ---------------------------------------------------------------------------------------------------
113 | #if defined(__AVR_ATmega32U4__)
114 | #define WAKE_UP_DDR DDRE // define wake up pin port and remaining pin
115 | #define WAKE_UP_PORT PORTE
116 | #define WAKE_UP_PNR PINE
117 | #define WAKE_UP_PIN PINE2
118 | #endif
119 | //- ---------------------------------------------------------------------------------------------------------------
120 |
121 | #endif
122 |
123 |
--------------------------------------------------------------------------------
/examples/HM_LC_SW1_BA_PCB/register.h:
--------------------------------------------------------------------------------
1 | //- ----------------------------------------------------------------------------------------------------------------------
2 | //- load libraries -------------------------------------------------------------------------------------------------------
3 | #include // the asksin framework
4 | #include "hardware.h" // hardware definition
5 | #include
6 |
7 | //- stage modules --------------------------------------------------------------------------------------------------------
8 | AS hm; // asksin framework
9 |
10 | cmSwitch cmSwitch[1]; // create instances of channel module
11 | extern void initRly(uint8_t channel); // declare function to jump in
12 | extern void switchRly(uint8_t channel, uint8_t status); // declare function to jump in
13 |
14 | //- ----------------------------------------------------------------------------------------------------------------------
15 | //- eeprom defaults table ------------------------------------------------------------------------------------------------
16 | uint16_t EEMEM eMagicByte;
17 | uint8_t EEMEM eHMID[3] = {0x58,0x23,0xff,};
18 | uint8_t EEMEM eHMSR[10] = {'X','M','S','1','2','3','4','5','6','7',};
19 | uint8_t EEMEM eHMKEY[16] = {0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,0x10,};
20 |
21 | // if HMID and Serial are not set, then eeprom ones will be used
22 | uint8_t HMID[3] = {0x58,0x23,0xff,};
23 | uint8_t HMSR[10] = {'X','M','S','1','2','3','4','5','6','7',}; // XMS1234567
24 | uint8_t HMKEY[16] = {0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,0x10,};
25 |
26 | //- ----------------------------------------------------------------------------------------------------------------------
27 | //- settings of HM device for AS class -----------------------------------------------------------------------------------
28 | const uint8_t devIdnt[] PROGMEM = {
29 | /* Firmware version 1 byte */ 0x10, // don't know for what it is good for
30 | /* Model ID 2 byte */ 0x00,0x6c, // model ID, describes HM hardware. Own devices should use high values due to HM starts from 0
31 | /* Sub Type ID 1 byte */ 0x00, // not needed for FHEM, it's something like a group ID
32 | /* Device Info 3 byte */ 0x41,0x01,0x00, // describes device, not completely clear yet. includes amount of channels
33 | }; // 7 byte
34 |
35 | //- ----------------------------------------------------------------------------------------------------------------------
36 | //- channel slice address definition -------------------------------------------------------------------------------------
37 | const uint8_t cnlAddr[] PROGMEM = {
38 | 0x02,0x0a,0x0b,0x0c,0x12,0x18,
39 | 0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,
40 | }; // 28 byte
41 |
42 | //- channel device list table --------------------------------------------------------------------------------------------
43 | EE::s_cnlTbl cnlTbl[] = {
44 | // cnl, lst, sIdx, sLen, pAddr, hidden
45 | { 0, 0, 0x00, 6, 0x000f, 0, },
46 | { 1, 1, 0x00, 0, 0x0000, 0, },
47 | { 1, 3, 0x06, 22, 0x0015, 0, },
48 | }; // 21 byte
49 |
50 | //- peer device list table -----------------------------------------------------------------------------------------------
51 | EE::s_peerTbl peerTbl[] = {
52 | // cnl, pMax, pAddr;
53 | { 1, 6, 0x0099, },
54 | }; // 4 byte
55 |
56 | //- handover to AskSin lib -----------------------------------------------------------------------------------------------
57 | EE::s_devDef devDef = {
58 | 1, 3, devIdnt, cnlAddr,
59 | }; // 6 byte
60 |
61 | //- module registrar -----------------------------------------------------------------------------------------------------
62 | RG::s_modTable modTbl[1];
63 |
64 | //- ----------------------------------------------------------------------------------------------------------------------
65 | //- first time and regular start functions -------------------------------------------------------------------------------
66 |
67 | void everyTimeStart(void) {
68 | // place here everything which should be done on each start or reset of the device
69 | // typical use case are loading default values or user class configurations
70 |
71 | // init the homematic framework
72 | hm.confButton.config(2, CONFIG_KEY_PCIE, CONFIG_KEY_INT); // configure the config button, mode, pci byte and pci bit
73 | hm.ld.init(2, &hm); // set the led
74 | hm.ld.set(welcome); // show something
75 | hm.bt.set(30, 3600000); // set battery check, internal, 2.7 reference, measurement each hour
76 | hm.pw.setMode(0); // set power management mode
77 |
78 | // register user modules
79 | cmSwitch[0].regInHM(1, 3, &hm); // register user module
80 | cmSwitch[0].config(&initRly, &switchRly); // configure user module
81 |
82 | }
83 |
84 | void firstTimeStart(void) {
85 | // place here everything which should be done on the first start or after a complete reset of the sketch
86 | // typical use case are default values which should be written into the register or peer database
87 |
88 | }
89 |
--------------------------------------------------------------------------------
/examples/HM_LC_SW1_BA_PCB/status - working:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/trilu2000/NewAskSin/75d3209f34f6ab559c0b6d1d7cbe09c53da2cd61/examples/HM_LC_SW1_BA_PCB/status - working
--------------------------------------------------------------------------------
/library.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "NewAskSin",
3 | "keywords": "protocol, message, communication, rf, cc1101",
4 | "description": "Library for HM compatible devices on base of Arduino Hardware",
5 | "repository":
6 | {
7 | "type": "git",
8 | "url": "https://github.com/trilu2000/NewAskSin"
9 | },
10 | "exclude" :
11 | [
12 | "docs",
13 | "destillRegs",
14 | "destillRegs2"
15 | ],
16 | "frameworks": "arduino",
17 | "platforms": "atmelavr"
18 | }
19 |
--------------------------------------------------------------------------------