X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=zigbee-daemon%2Fzigbee-lib%2Fsrc%2Fdrivers%2Fzblib_driver_zclglobal_control.c;h=0f96c114f2cc5b34b4e2e63092e8c3f73d95d24c;hb=4bb3660ee581e83c6d5f2f19e42c7e9486f9f1dc;hp=22cfbd13cb925e287f07edf0e84977bfe97739f4;hpb=47b8338a27e23131e7800798eddbc4e43e6b4248;p=platform%2Fcore%2Fconnectivity%2Fzigbee-manager.git diff --git a/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zclglobal_control.c b/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zclglobal_control.c index 22cfbd1..0f96c11 100644 --- a/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zclglobal_control.c +++ b/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zclglobal_control.c @@ -30,19 +30,23 @@ typedef struct { static gboolean __zblib_driver_zclglobal_control_dispatcher(ZigBeeDriver *driver, guint request_id) { ZigBeeService *service = NULL; + ZblibDriverZclglobalControlPrivData_t *priv_data = NULL; + ZblibDriverZclglobalControlOps_t *ops = NULL; guint request_type; guint ops_id; + gboolean ret = FALSE; - if (NULL == driver) { - Z_LOGE("driver is NULL"); - return FALSE; - } + zblib_check_null_ret_error("driver", driver, FALSE); service = zblib_driver_ref_service(driver); - if (NULL == service) { - Z_LOGE("service is NULL"); - return FALSE; - } + zblib_check_null_ret_error("service", service, FALSE); + + /* Fetch private data */ + priv_data = zblib_driver_ref_object(driver); + zblib_check_null_ret_error("priv_data", priv_data, FALSE); + + ops = priv_data->ops; + zblib_check_null_ret_error("ops", ops, FALSE); /* Fetch request_type using request_id */ request_type = zblib_request_ref_request_type_by_request_id(service, request_id); @@ -51,50 +55,98 @@ static gboolean __zblib_driver_zclglobal_control_dispatcher(ZigBeeDriver *driver ops_id = zblib_request_get_ops_id(request_type); switch (ops_id) { case ZBLIB_ZCLGLOBAL_CONTROL_OPS_READ_ATTRIBUTES_REQ: { + zblib_check_null_ret_error("ops->read_attributes_req", + ops->read_attributes_req, FALSE); + + ret = ops->read_attributes_req(driver, request_id); } break; case ZBLIB_ZCLGLOBAL_CONTROL_OPS_WRITE_ATTRIBUTES_REQ: { + zblib_check_null_ret_error("ops->write_attributes_req", + ops->write_attributes_req, FALSE); + + ret = ops->write_attributes_req(driver, request_id); } break; case ZBLIB_ZCLGLOBAL_CONTROL_OPS_WRITE_ATTRIBUTES_UNDIVIDED_REQ: { + zblib_check_null_ret_error("ops->write_attributes_undivided_req", + ops->write_attributes_undivided_req, FALSE); + + ret = ops->write_attributes_undivided_req(driver, request_id); } break; case ZBLIB_ZCLGLOBAL_CONTROL_OPS_WRITE_ATTRIBUTES_NO_RESP: { + zblib_check_null_ret_error("ops->write_attributes_no_resp", + ops->write_attributes_no_resp, FALSE); + + ret = ops->write_attributes_no_resp(driver, request_id); } break; case ZBLIB_ZCLGLOBAL_CONTROL_OPS_WRITE_ATTRIBUTES_STRUCTURED: { + zblib_check_null_ret_error("ops->write_attributes_structured", + ops->write_attributes_structured, FALSE); + + ret = ops->write_attributes_structured(driver, request_id); } break; case ZBLIB_ZCLGLOBAL_CONTROL_OPS_READ_ATTRIBUTES_STRUCTURED: { + zblib_check_null_ret_error("ops->read_attributes_structured", + ops->read_attributes_structured, FALSE); + + ret = ops->read_attributes_structured(driver, request_id); } break; case ZBLIB_ZCLGLOBAL_CONTROL_OPS_CONFIGURE_REPORTING_REQ: { + zblib_check_null_ret_error("ops->configure_reporting_req", + ops->configure_reporting_req, FALSE); + + ret = ops->configure_reporting_req(driver, request_id); } break; case ZBLIB_ZCLGLOBAL_CONTROL_OPS_READ_CONFIGURE_REPORTING: { + zblib_check_null_ret_error("ops->read_configure_reporting", + ops->read_configure_reporting, FALSE); + + ret = ops->read_configure_reporting(driver, request_id); } break; case ZBLIB_ZCLGLOBAL_CONTROL_OPS_DISCOVER_ATTRIBUTES: { + zblib_check_null_ret_error("ops->discover_attributes", + ops->discover_attributes, FALSE); + + ret = ops->discover_attributes(driver, request_id); } break; case ZBLIB_ZCLGLOBAL_CONTROL_OPS_DISCOVER_ATTRIBUTES_EXTENDED: { + zblib_check_null_ret_error("ops->discover_attributes_extended", + ops->discover_attributes_extended, FALSE); + + ret = ops->discover_attributes_extended(driver, request_id); } break; case ZBLIB_ZCLGLOBAL_CONTROL_OPS_DISCOVER_COMMANDS_RECEIVED: { + zblib_check_null_ret_error("ops->discover_commands_received", + ops->discover_commands_received, FALSE); + + ret = ops->discover_commands_received(driver, request_id); } break; case ZBLIB_ZCLGLOBAL_CONTROL_OPS_DISCOVER_COMMANDS_GENERATED: { + zblib_check_null_ret_error("ops->discover_commands_generated", + ops->discover_commands_generated, FALSE); + + ret = ops->discover_commands_generated(driver, request_id); } break; @@ -102,24 +154,20 @@ static gboolean __zblib_driver_zclglobal_control_dispatcher(ZigBeeDriver *driver break; } - return TRUE; + Z_LOGD("ret: [%d]", ret); + + return ret; } static void __zblib_driver_zclglobal_control_free_hook(ZigBeeDriver *driver) { ZblibDriverZclglobalControlPrivData_t *priv_data = NULL; - if (NULL == driver) { - Z_LOGE("driver is NULL"); - return; - } + zblib_check_null_ret("driver", driver); /* Fetch private data */ priv_data = zblib_driver_ref_object(driver); - if (NULL == priv_data) { - Z_LOGE("priv_data is NULL"); - return; - } + zblib_check_null_ret("priv_data", priv_data); /* Free resources */ g_free(priv_data); @@ -133,17 +181,11 @@ ZigBeeDriver *zblib_driver_zclglobal_control_new(ZigBeePlugin *plugin, ZblibDriverZclglobalControlPrivData_t *priv_data = NULL; gboolean ret; - if (NULL == plugin) { - Z_LOGE("plugin is NULL"); - return NULL; - } + zblib_check_null_ret_error("plugin", plugin, NULL); /* Create new driver */ driver = zblib_driver_new(plugin, driver_name, ZBLIB_DRIVER_TYPE_ZCLGLOBAL_CONTROL); - if (NULL == driver) { - Z_LOGE("driver is NULL"); - return NULL; - } + zblib_check_null_ret_error("driver", driver, NULL); /* Allocate memory for private data */ priv_data = g_malloc0(sizeof(ZblibDriverZclglobalControlPrivData_t)); @@ -192,10 +234,7 @@ ZigBeeDriver *zblib_driver_zclglobal_control_new(ZigBeePlugin *plugin, void zblib_driver_zclglobal_control_free(ZigBeeDriver *driver) { - if (NULL == driver) { - Z_LOGE("driver is NULL"); - return; - } + zblib_check_null_ret("driver", driver); /* Free driver */ zblib_driver_free(driver);