2 * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
4 * Contact: Suresh Kumar N (suresh.n@samsung.com)
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
20 #include <zblib_driver.h>
22 #include "zblib_driver_level_control.h"
26 ZblibDriverLevelControlOps_t *ops; /**< Operations */
27 } ZblibDriverLevelControlPrivData_t;
29 static gboolean __zblib_driver_level_control_dispatcher(ZigBeeDriver *driver)
32 Z_LOGE("driver is NULL");
39 static void __zblib_driver_level_control_free_hook(ZigBeeDriver *driver)
41 ZblibDriverLevelControlPrivData_t *priv_data = NULL;
44 Z_LOGE("driver is NULL");
48 /* Fetch private data */
49 priv_data = zblib_driver_ref_object(driver);
50 if (NULL == priv_data) {
51 Z_LOGE("priv_data is NULL");
59 ZigBeeDriver *zblib_driver_level_control_new(ZigBeePlugin *plugin,
60 const gchar *driver_name,
61 ZblibDriverLevelControlOps_t *ops)
63 ZigBeeDriver *driver = NULL;
64 ZblibDriverLevelControlPrivData_t *priv_data = NULL;
68 Z_LOGE("plugin is NULL");
72 /* Create new driver */
73 driver = zblib_driver_new(plugin, driver_name, ZBLIB_DRIVER_TYPE_LEVEL_CONTROL);
75 Z_LOGE("driver is NULL");
79 /* Allocate memory for private data */
80 priv_data = g_malloc0(sizeof(ZblibDriverLevelControlPrivData_t));
82 /* Update private data */
85 /* Link private data to driver */
86 ret = zblib_driver_link_object(driver, priv_data);
88 Z_LOGE("zblib_driver_link_object failed!");
90 /* Free allocated resources */
97 /* Set operations dispatcher function */
98 ret = zblib_driver_set_dispatcher(driver, __zblib_driver_level_control_dispatcher);
100 Z_LOGE("zblib_driver_set_dispatcher failed!");
102 /* Free allocated resources */
109 /* Set free hook function */
110 ret = zblib_driver_set_free_hook(driver, __zblib_driver_level_control_free_hook);
112 Z_LOGE("zblib_driver_set_free_hook failed!");
114 /* Free allocated resources */
124 void zblib_driver_level_control_free(ZigBeeDriver *driver)
126 if (NULL == driver) {
127 Z_LOGE("driver is NULL");
132 zblib_driver_free(driver);