Fixed ACR issue.
[platform/core/api/zigbee.git] / lib / zbl-zcl-color-control.c
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #include "zbl.h"
17 #include "zbl-dbus.h"
18 #include "zb-common.h"
19
20 API int zb_zcl_ccontrol_move_to_hue(zb_zigbee_h handle, zb_nwk_addr addr16,
21         unsigned char ep, unsigned char hue, unsigned char direction,
22         unsigned short transition_time)
23 {
24         int ret = ZIGBEE_ERROR_NONE;
25         CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
26         RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
27         RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR);
28         RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS);
29         RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT);
30
31         ret = zbl_ccontrol_move_to_hue(addr16, ep, hue, direction, transition_time);
32         return ret;
33 }
34
35 API int zb_zcl_ccontrol_move_hue(zb_zigbee_h handle, zb_nwk_addr addr16,
36         unsigned char ep, unsigned char move_mode, unsigned char rate)
37 {
38         int ret = ZIGBEE_ERROR_NONE;
39         CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
40         RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
41         RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR);
42         RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS);
43         RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT);
44
45         ret = zbl_ccontrol_move_hue(addr16, ep, move_mode, rate);
46         return ret;
47 }
48
49 API int zb_zcl_ccontrol_step_hue(zb_zigbee_h handle, zb_nwk_addr addr16,
50         unsigned char ep, unsigned char step_mode, unsigned char step_size,
51         unsigned char transition_time)
52 {
53         int ret = ZIGBEE_ERROR_NONE;
54         CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
55         RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
56         RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR);
57         RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS);
58         RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT);
59
60         ret = zbl_ccontrol_step_hue(addr16, ep, step_mode, step_size, transition_time);
61         return ret;
62 }
63
64 API int zb_zcl_ccontrol_move_to_saturation(zb_zigbee_h handle,
65         zb_nwk_addr addr16, unsigned char ep, unsigned char saturation,
66         unsigned short transition_time)
67 {
68         int ret = ZIGBEE_ERROR_NONE;
69         CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
70         RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
71         RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR);
72         RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS);
73         RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT);
74
75         ret = zbl_ccontrol_move_to_saturation(addr16, ep, saturation, transition_time);
76         return ret;
77 }
78
79 API int zb_zcl_ccontrol_move_saturation(zb_zigbee_h handle, zb_nwk_addr addr16,
80         unsigned char ep, unsigned char move_mode, unsigned char rate)
81 {
82         int ret = ZIGBEE_ERROR_NONE;
83         CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
84         RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
85         RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR);
86         RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS);
87         RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT);
88
89         ret = zbl_ccontrol_move_saturation(addr16, ep, move_mode, rate);
90         return ret;
91 }
92
93 API int zb_zcl_ccontrol_step_saturation(zb_zigbee_h handle, zb_nwk_addr addr16,
94         unsigned char ep, unsigned char step_mode, unsigned char step_size,
95         unsigned char transition_time)
96 {
97         int ret = ZIGBEE_ERROR_NONE;
98         CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
99         RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
100         RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR);
101         RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS);
102         RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT);
103
104         ret = zbl_ccontrol_step_saturation(addr16, ep, step_mode, step_size, transition_time);
105         return ret;
106 }
107
108 API int zb_zcl_ccontrol_move_to_hue_and_saturation(zb_zigbee_h handle,
109         zb_nwk_addr addr16, unsigned char ep, unsigned char hue, unsigned char saturation,
110         unsigned short transition_time)
111 {
112         int ret = ZIGBEE_ERROR_NONE;
113         CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
114         RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
115         RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR);
116         RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS);
117         RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT);
118
119         ret = zbl_ccontrol_move_to_hue_and_saturation(addr16, ep, hue, saturation, transition_time);
120         return ret;
121 }
122
123 API int zb_zcl_ccontrol_move_to_color(zb_zigbee_h handle, zb_nwk_addr addr16,
124         unsigned char ep, unsigned short color_x, unsigned short color_y,
125         unsigned short transition_time)
126 {
127         int ret = ZIGBEE_ERROR_NONE;
128         CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
129         RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
130         RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR);
131         RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS);
132         RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT);
133
134         ret = zbl_ccontrol_move_to_color(addr16, ep, color_x, color_y, transition_time);
135         return ret;
136 }
137
138 API int zb_zcl_ccontrol_move_color(zb_zigbee_h handle, zb_nwk_addr addr16,
139         unsigned char ep, unsigned short rate_x, unsigned short rate_y)
140 {
141         int ret = ZIGBEE_ERROR_NONE;
142         CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
143         RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
144         RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR);
145         RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS);
146         RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT);
147
148         ret = zbl_ccontrol_move_color(addr16, ep, rate_x, rate_y);
149         return ret;
150 }
151
152 API int zb_zcl_ccontrol_step_color(zb_zigbee_h handle, zb_nwk_addr addr16,
153         unsigned char ep, unsigned short step_x, unsigned short step_y,
154         unsigned short transition_time)
155 {
156         int ret = ZIGBEE_ERROR_NONE;
157         CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
158         RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
159         RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR);
160         RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS);
161         RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT);
162
163         ret = zbl_ccontrol_step_color(addr16, ep, step_x, step_y, transition_time);
164         return ret;
165 }
166
167 API int zb_zcl_ccontrol_move_to_color_temperature(zb_zigbee_h handle,
168         zb_nwk_addr addr16, unsigned char ep, unsigned short color_temperature,
169         unsigned short transition_time)
170 {
171         int ret = ZIGBEE_ERROR_NONE;
172         CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
173         RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
174         RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR);
175         RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS);
176         RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT);
177
178         ret = zbl_ccontrol_move_to_color_temperature(addr16, ep, color_temperature, transition_time);
179         return ret;
180 }
181