Cascoda SDK
Cascoda SDK for building software to run with CA-821x transceivers
knx_click_handlers.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2022, Cascoda Ltd.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  * 3. Neither the name of the copyright holder nor the
13  * names of its contributors may be used to endorse or promote products
14  * derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26  * POSSIBILITY OF SUCH DAMAGE.
27  */
28 /*
29  * default examples for click sensor handlers - simple printing to console
30 */
31 
32 #ifndef KNX_CLICK_HANDLERS_H
33 #define KNX_CLICK_HANDLERS_H
34 
35 typedef int F16_t;
36 typedef int B1_t;
37 typedef int U16_t;
38 
39 #define F16_DATA_INVALID (F16_t)0x7FFF;
40 
41 /* knx data structure for THERMO */
42 typedef struct
43 {
44  F16_t thermocouple_temperature; // DPT_Value_Temp, 9.001, dpa.320.51
45  F16_t junction_temperature; // DPT_Value_Temp, 9.001, dpa.320.51
47 
48 /* knx data structure for THERMO3 */
49 typedef struct
50 {
51  float temperature; // DPT_Value_Temp, 9.001, dpa.320.51
53 
54 /* knx data structure for AIRQUALITY4 */
55 typedef struct
56 {
57  F16_t co2_h2; // DPT_Value_AirQuality, 9.008, dpa.65534.51
58  F16_t tvoc_eth; // DPT_Value_AirQuality, 9.008, dpa.65534.51 (note: [ppb], not [ppm]. Convert to [ppm]?)
60 
61 /* knx data structure for ENVIRONMENT2 */
62 typedef struct
63 {
64  F16_t humidity; // DPT_Value_Humidity, 9.007, dpa.337.51
65  F16_t temperature; // DPT_Value_Temp, 9.001, dpa.320.51
66  F16_t air_quality; // DPT_Value_AirQuality, 9.008, dpa.65534.51 (note: relative, not [ppm])
67  F16_t voc_index; // DPT_Value_AirQuality, 9.008, dpa.65534.51 (note: relative, not [ppm])
69 
70 /* knx data structure for SHT */
71 typedef struct
72 {
73  float humidity; // DPT_Value_Humidity, 9.007, dpa.337.51
74  float temperature; // DPT_Value_Temp, 9.001, dpa.320.51
75 } knx_data_sht;
76 
77 /* knx data structure for HVAC */
78 typedef struct
79 {
80  float co2content; // DPT_Value_AirQuality, 9.008, dpa.65534.51
81  float humidity; // DPT_Value_Humidity, 9.007, dpa.337.51
82  float temperature; // DPT_Value_Temp, 9.001, dpa.320.51
84 
85 typedef struct
86 {
87  B1_t detection_state; // DPT_Occupancy, 1.018, dpa.391.51
88  U16_t detection_time; // DPT_TimePeriodSec, ?.??? dpa.???.??
90 
91 typedef struct
92 {
93  B1_t relay_1_state; // DPT_Switch, 1.001, dpa.420.61
94  B1_t relay_2_state; // DPT_Switch, 1.001, dpa.420.61
96 
97 
98 /* application handlers */
107 
108 /* value conversion functions from sensor value to knx types */
113 void convert_SHT_to_knx(data_sht data, knx_data_sht *knx_data);
114 void convert_HVAC_to_knx(data_hvac data, knx_data_hvac *knx_data);
116 void convert_RELAY_to_knx(data_relay data, knx_data_relay *knx_data);
117 #endif // KNX_CLICK_HANDLERS_H
ca_error
Cascoda error type.
Definition: ca821x_error.h:51
void convert_MOTION_to_knx(data_motion data, knx_data_motion *knx_data)
Definition: knx_click_handlers.c:331
void convert_SHT_to_knx(data_sht data, knx_data_sht *knx_data)
Definition: knx_click_handlers.c:311
int F16_t
Definition: knx_click_handlers.h:35
ca_error CLICK_Handler_THERMO3(void)
Definition: knx_click_handlers.c:378
ca_error CLICK_Handler_HVAC(void)
Definition: knx_click_handlers.c:454
ca_error CLICK_Handler_ENVIRONMENT2(void)
Definition: knx_click_handlers.c:416
ca_error CLICK_Handler_AIRQUALITY4(void)
Definition: knx_click_handlers.c:397
void convert_THERMO_to_knx(data_thermo data, knx_data_thermo *knx_data)
Definition: knx_click_handlers.c:270
ca_error CLICK_Handler_MOTION(void)
Definition: knx_click_handlers.c:479
int B1_t
Definition: knx_click_handlers.h:36
int U16_t
Definition: knx_click_handlers.h:37
void convert_ENVIRONMENT2_to_knx(data_environment2 data, knx_data_environment2 *knx_data)
Definition: knx_click_handlers.c:295
ca_error CLICK_Handler_THERMO(void)
Definition: knx_click_handlers.c:359
ca_error CLICK_Handler_SHT(void)
Definition: knx_click_handlers.c:435
void convert_HVAC_to_knx(data_hvac data, knx_data_hvac *knx_data)
Definition: knx_click_handlers.c:320
void convert_THERMO3_to_knx(data_thermo3 data, knx_data_thermo3 *knx_data)
Definition: knx_click_handlers.c:279
void convert_RELAY_to_knx(data_relay data, knx_data_relay *knx_data)
Definition: knx_click_handlers.c:343
void convert_AIRQUALITY4_to_knx(data_airquality4 data, knx_data_airquality4 *knx_data)
Definition: knx_click_handlers.c:286
ca_error CLICK_Handler_RELAY(void)
Definition: knx_click_handlers.c:498
Definition: devboard_click.h:103
Definition: devboard_click.h:113
Definition: devboard_click.h:131
Definition: devboard_click.h:140
Definition: devboard_click.h:148
Definition: devboard_click.h:123
Definition: devboard_click.h:96
Definition: devboard_click.h:88
Definition: knx_click_handlers.h:56
F16_t co2_h2
Definition: knx_click_handlers.h:57
F16_t tvoc_eth
Definition: knx_click_handlers.h:58
Definition: knx_click_handlers.h:63
F16_t humidity
Definition: knx_click_handlers.h:64
F16_t voc_index
Definition: knx_click_handlers.h:67
F16_t air_quality
Definition: knx_click_handlers.h:66
F16_t temperature
Definition: knx_click_handlers.h:65
Definition: knx_click_handlers.h:79
float humidity
Definition: knx_click_handlers.h:81
float co2content
Definition: knx_click_handlers.h:80
float temperature
Definition: knx_click_handlers.h:82
Definition: knx_click_handlers.h:86
B1_t detection_state
Definition: knx_click_handlers.h:87
U16_t detection_time
Definition: knx_click_handlers.h:88
Definition: knx_click_handlers.h:92
B1_t relay_2_state
Definition: knx_click_handlers.h:94
B1_t relay_1_state
Definition: knx_click_handlers.h:93
Definition: knx_click_handlers.h:72
float humidity
Definition: knx_click_handlers.h:73
float temperature
Definition: knx_click_handlers.h:74
Definition: knx_click_handlers.h:50
float temperature
Definition: knx_click_handlers.h:51
Definition: knx_click_handlers.h:43
F16_t junction_temperature
Definition: knx_click_handlers.h:45
F16_t thermocouple_temperature
Definition: knx_click_handlers.h:44