Fixed ACR issue.
[platform/core/api/zigbee.git] / src / zbl-zcl-scenes.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_scene_add_scene(zb_zigbee_h handle, zb_nwk_addr addr16, unsigned char ep,
21         unsigned short group_id, unsigned char scene_id, unsigned short transition_time,
22         const char *scene_name, unsigned short ext_field_len,
23         const char *extension_field_sets, zb_zcl_scene_add_scene_cb cb, void *user_data)
24 {
25         int ret;
26         CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
27         RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
28         RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR);
29         RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS);
30         RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT);
31         RETV_IF(NULL == scene_name, ZIGBEE_ERROR_INVALID_PARAMETER);
32         RETV_IF(NULL == extension_field_sets, ZIGBEE_ERROR_INVALID_PARAMETER);
33         ret = zbl_add_scene(addr16, ep, group_id, scene_id, transition_time, scene_name,
34                 ext_field_len, extension_field_sets, cb, user_data);
35         return ret;
36 }
37
38 API int zb_zcl_scene_view_scene(zb_zigbee_h handle, zb_nwk_addr addr16, unsigned char ep,
39         unsigned short group_id, unsigned char scene_id, zb_zcl_scene_view_scene_cb cb,
40         void *user_data)
41 {
42         int ret;
43         CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
44         RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
45         RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR);
46         RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS);
47         RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT);
48         ret = zbl_view_scene(addr16, ep, group_id, scene_id, cb, user_data);
49         return ret;
50 }
51
52 API int zb_zcl_scene_remove_scene(zb_zigbee_h handle, zb_nwk_addr addr16,
53         unsigned char ep, unsigned short group_id, unsigned char scene_id,
54         zb_zcl_scene_remove_scene_cb cb, void *user_data)
55 {
56         int ret;
57         CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
58         RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
59         RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR);
60         RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS);
61         RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT);
62         ret = zbl_remove_scene(addr16, ep, group_id, scene_id, cb, user_data);
63         return ret;
64 }
65
66 API int zb_zcl_scene_remove_all_scene(zb_zigbee_h handle, zb_nwk_addr addr16,
67         unsigned char ep, unsigned short group_id, zb_zcl_scene_remove_all_scene_cb cb,
68         void *user_data)
69 {
70         int ret;
71         CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
72         RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
73         RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR);
74         RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS);
75         RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT);
76         ret = zbl_remove_all_scene(addr16, ep, group_id, cb, user_data);
77         return ret;
78 }
79
80 API int zb_zcl_scene_store_scene(zb_zigbee_h handle, zb_nwk_addr addr16, unsigned char ep,
81         unsigned short group_id, unsigned char scene_id, zb_zcl_scene_store_scene_cb cb,
82         void *user_data)
83 {
84         int ret;
85         CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
86         RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
87         RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR);
88         RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS);
89         RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT);
90         ret = zbl_store_scene(addr16, ep, group_id, scene_id, cb, user_data);
91         return ret;
92 }
93
94 API int zb_zcl_scene_recall_scene(zb_zigbee_h handle, zb_nwk_addr addr16,
95         unsigned char ep, unsigned short group_id, unsigned char scene_id)
96 {
97         int ret;
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         ret = zbl_recall_scene(addr16, ep, group_id, scene_id);
104         return ret;
105 }
106
107 API int zb_zcl_scene_get_scene_membership(zb_zigbee_h handle, zb_nwk_addr addr16,
108         unsigned char ep, unsigned short group_id,
109         zb_zcl_scene_get_scene_membership_cb cb, void *user_data)
110 {
111         int ret;
112         CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
113         RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
114         RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR);
115         RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS);
116         RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT);
117         ret = zbl_get_scene_membership(addr16, ep, group_id, cb, user_data);
118         return ret;
119 }
120