Fixed ACR issue.
[platform/core/api/zigbee.git] / src / zbl-zcl-level-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_levelctrl_move_to_level(zb_zigbee_h handle, zb_nwk_addr addr16,
21         unsigned char ep, unsigned char level, unsigned short transition_time)
22 {
23         int ret;
24         CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
25         RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
26         RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR);
27         RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS);
28         RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT);
29
30         ret = zbl_level_control_move_to_level(addr16, ep, level, transition_time);
31         return ret;
32 }
33
34 API int zb_zcl_levelctrl_move(zb_zigbee_h handle, zb_nwk_addr addr16,
35         unsigned char ep, unsigned char move_mode, unsigned char rate)
36 {
37         int ret;
38         CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
39         RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
40         RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR);
41         RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS);
42         RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT);
43
44         ret = zbl_level_control_move(addr16, ep, move_mode, rate);
45         return ret;
46 }
47
48 API int zb_zcl_levelctrl_step(zb_zigbee_h handle, zb_nwk_addr addr16, unsigned char ep,
49         unsigned char step_mode, unsigned char step_size, unsigned short transition_time)
50 {
51         int ret;
52         CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
53         RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
54         RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR);
55         RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS);
56         RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT);
57
58         ret = zbl_level_control_step(addr16, ep, step_mode, step_size, transition_time);
59         return ret;
60 }
61
62 API int zb_zcl_levelctrl_stop(zb_zigbee_h handle, zb_nwk_addr addr16, unsigned char ep)
63 {
64         int ret;
65         CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
66         RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
67         RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR);
68         RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS);
69         RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT);
70
71         ret = zbl_level_control_stop(addr16, ep);
72         return ret;
73 }
74
75 API int zb_zcl_levelctrl_move_to_level_with_on_off(zb_zigbee_h handle, zb_nwk_addr addr16,
76         unsigned char ep, unsigned char level, unsigned short transition_time)
77 {
78         int ret;
79         CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
80         RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
81         RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR);
82         RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS);
83         RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT);
84
85         ret = zbl_level_control_move_to_level_with_on_off(addr16, ep, level, transition_time);
86         return ret;
87 }
88
89 API int zb_zcl_levelctrl_move_with_on_off(zb_zigbee_h handle, zb_nwk_addr addr16,
90         unsigned char ep, unsigned char move_mode, unsigned char rate)
91 {
92         int ret;
93         CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
94         RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
95         RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR);
96         RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS);
97         RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT);
98
99         ret = zbl_level_control_move_with_on_off(addr16, ep, move_mode, rate);
100         return ret;
101 }
102
103 API int zb_zcl_levelctrl_step_with_on_off(zb_zigbee_h handle, zb_nwk_addr addr16,
104         unsigned char ep, unsigned char step_mode, unsigned char step_size,
105         unsigned short transition_time)
106 {
107         int ret;
108         CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
109         RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
110         RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR);
111         RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS);
112         RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT);
113
114         ret = zbl_level_control_step_with_on_off(addr16, ep, step_mode, step_size, transition_time);
115         return ret;
116 }
117