Implement ZCL Global control
authorJiwan Kim <ji-wan.kim@samsung.com>
Tue, 7 Feb 2017 11:16:28 +0000 (20:16 +0900)
committersaerome.kim <saerome.kim@samsung.com>
Thu, 11 May 2017 09:10:25 +0000 (18:10 +0900)
Change-Id: I80b8530899ed6d2ee3c601767e97a466fb331777
Signed-off-by: Jiwan Kim <ji-wan.kim@samsung.com>
common/include/zigbee_types.h
common/include/zigbee_zcl_global_control_type.h
zigbee-daemon/zigbee-interface/introspection/zcl-global-control.xml
zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface.c
zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_global_control.c
zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zdo_dev_control.c
zigbee-daemon/zigbee-lib/include/zblib_driver_zcl_global_control.h
zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zcl_global_control.c
zigbee-daemon/zigbee-lib/src/zblib_request.c

index 8ad04a1..43a3d37 100644 (file)
 #define ZIGBEE_MAX_ENDPOINT_CLUSTER 32
 
 /**
+ * @brief Definition for maximum count of analog attribute data size in bytes (8).
+ * @since_tizen 3.0
+ */
+#define ZIGBEE_MAX_ANALOG_DATA_SIZE 8
+
+/**
  * @brief Definition for custom send payload/data length (128).
  * @since_tizen 3.0
  */
index 7cd1b62..fa4b8b9 100644 (file)
  * @since_tizen 3.0
  */
 typedef struct {
-       char *attribute_id; /**< Attribute ID */
+       unsigned char *attribute_id; /**< Attribute ID */
        int attribute_id_len; /**< Attribute ID length */
-       short node_id; /**< Node ID */
-       char cluster_id; /**< Cluster ID */
-       char zcl_frame_ctrl; /**< ZCL frame control */
-       char dest_ep; /**< Destination endpoint */
+       unsigned short node_id; /**< Node ID */
+       unsigned char cluster_id; /**< Cluster ID */
+       unsigned char zcl_frame_ctrl; /**< ZCL frame control */
+       unsigned char dest_ep; /**< Destination endpoint */
 } ZigbeeZclGlobalControlReadAttributesRequest_t;
 
 /**
@@ -39,13 +39,13 @@ typedef struct {
  * @since_tizen 3.0
  */
 typedef struct {
-       char *write_records; /**< Write records */
+       unsigned char *write_records; /**< Write records */
        int records_len; /**< Records length */
-       short node_id; /**< Node ID */
-       char cluster_id; /**< Cluster ID */
-       char zcl_frame_ctrl; /**< ZCL frame control */
-       char src_ep; /**< Source endpoint */
-       char dest_ep; /**< Destination endpoint */
+       unsigned short node_id; /**< Node ID */
+       unsigned char cluster_id; /**< Cluster ID */
+       unsigned char zcl_frame_ctrl; /**< ZCL frame control */
+       unsigned char src_ep; /**< Source endpoint */
+       unsigned char dest_ep; /**< Destination endpoint */
 } ZigbeeZclGlobalControlWriteAttributesRequest_t;
 
 /**
@@ -53,13 +53,13 @@ typedef struct {
  * @since_tizen 3.0
  */
 typedef struct {
-       char *write_records; /**< Write records */
+       unsigned char *write_records; /**< Write records */
        int records_len; /**< Records length */
-       short node_id; /**< Node ID */
-       char cluster_id; /**< Cluster ID */
-       char zcl_frame_ctrl; /**< ZCL frame control */
-       char src_ep; /**< Source endpoint */
-       char dest_ep; /**< Destination endpoint */
+       unsigned short node_id; /**< Node ID */
+       unsigned char cluster_id; /**< Cluster ID */
+       unsigned char zcl_frame_ctrl; /**< ZCL frame control */
+       unsigned char src_ep; /**< Source endpoint */
+       unsigned char dest_ep; /**< Destination endpoint */
 } ZigbeeZclGlobalControlWriteAttributesUndividedRequest_t;
 
 /**
@@ -67,13 +67,13 @@ typedef struct {
  * @since_tizen 3.0
  */
 typedef struct {
-       char *write_records; /**< Write records */
+       unsigned char *write_records; /**< Write records */
        int records_len; /**< Records length */
-       short node_id; /**< Node ID */
-       char cluster_id; /**< Cluster ID */
-       char zcl_frame_ctrl; /**< ZCL frame control */
-       char src_ep; /**< Source endpoint */
-       char dest_ep; /**< Destination endpoint */
+       unsigned short node_id; /**< Node ID */
+       unsigned char cluster_id; /**< Cluster ID */
+       unsigned char zcl_frame_ctrl; /**< ZCL frame control */
+       unsigned char src_ep; /**< Source endpoint */
+       unsigned char dest_ep; /**< Destination endpoint */
 } ZigbeeZclGlobalControlWriteAttributesNoResponse_t;
 
 /**
@@ -81,13 +81,13 @@ typedef struct {
  * @since_tizen 3.0
  */
 typedef struct {
-       char *write_records; /**< Write records */
+       unsigned char *write_records; /**< Write records */
        int records_len; /**< Records length */
-       short node_id; /**< Node ID */
-       char cluster_id; /**< Cluster ID */
-       char zcl_frame_ctrl; /**< ZCL frame control */
-       char src_ep; /**< Source endpoint */
-       char dest_ep; /**< Destination endpoint */
+       unsigned short node_id; /**< Node ID */
+       unsigned char cluster_id; /**< Cluster ID */
+       unsigned char zcl_frame_ctrl; /**< ZCL frame control */
+       unsigned char src_ep; /**< Source endpoint */
+       unsigned char dest_ep; /**< Destination endpoint */
 } ZigbeeZclGlobalControlWriteAttributesStructed_t;
 
 /**
@@ -95,13 +95,13 @@ typedef struct {
  * @since_tizen 3.0
  */
 typedef struct {
-       char *read_records; /**< Read records */
+       unsigned char *read_records; /**< Read records */
        int records_len; /**< Records length */
-       short node_id; /**< Node ID */
-       char cluster_id; /**< Cluster ID */
-       char zcl_frame_ctrl; /**< ZCL frame control */
-       char src_ep; /**< Source endpoint */
-       char dest_ep; /**< Destination endpoint */
+       unsigned short node_id; /**< Node ID */
+       unsigned char cluster_id; /**< Cluster ID */
+       unsigned char zcl_frame_ctrl; /**< ZCL frame control */
+       unsigned char src_ep; /**< Source endpoint */
+       unsigned char dest_ep; /**< Destination endpoint */
 } ZigbeeZclGlobalControlReadAttributesStructed_t;
 
 /**
@@ -109,13 +109,13 @@ typedef struct {
  * @since_tizen 3.0
  */
 typedef struct {
-       char *read_records; /**< Read records */
+       unsigned char *read_records; /**< Read records */
        int records_len; /**< Records length */
-       short node_id; /**< Node ID */
-       char cluster_id; /**< Cluster ID */
-       char zcl_frame_ctrl; /**< ZCL frame control */
-       char src_ep; /**< Source endpoint */
-       char dest_ep; /**< Destination endpoint */
+       unsigned short node_id; /**< Node ID */
+       unsigned char cluster_id; /**< Cluster ID */
+       unsigned char zcl_frame_ctrl; /**< ZCL frame control */
+       unsigned char src_ep; /**< Source endpoint */
+       unsigned char dest_ep; /**< Destination endpoint */
 } ZigbeeZclGlobalControlConfigureReportingReq_t;
 
 /**
@@ -123,13 +123,13 @@ typedef struct {
  * @since_tizen 3.0
  */
 typedef struct {
-       char *read_records; /**< Read records */
+       unsigned char *read_records; /**< Read records */
        int records_len; /**< Records length */
-       short node_id; /**< Node ID */
-       char cluster_id; /**< Cluster ID */
-       char zcl_frame_ctrl; /**< ZCL frame control */
-       char src_ep; /**< Source endpoint */
-       char dest_ep; /**< Destination endpoint */
+       unsigned short node_id; /**< Node ID */
+       unsigned char cluster_id; /**< Cluster ID */
+       unsigned char zcl_frame_ctrl; /**< ZCL frame control */
+       unsigned char src_ep; /**< Source endpoint */
+       unsigned char dest_ep; /**< Destination endpoint */
 } ZigbeeZclGlobalControlReadConfigureReporting_t;
 
 /**
@@ -137,12 +137,12 @@ typedef struct {
  * @since_tizen 3.0
  */
 typedef struct {
-       short node_id; /**< Node ID */
-       char dest_ep; /**< Destination endpoint */
-       char zcl_frame_ctrl; /**< ZCL frame control */
-       char cluster_id; /**< Cluster ID */
-       char start_attribute; /**< Start attribute */
-       char max; /**< Maximum */
+       unsigned short node_id; /**< Node ID */
+       unsigned char dest_ep; /**< Destination endpoint */
+       unsigned char zcl_frame_ctrl; /**< ZCL frame control */
+       unsigned char cluster_id; /**< Cluster ID */
+       unsigned char start_attribute; /**< Start attribute */
+       unsigned char max_attribute_count; /**< Maximum */
 } ZigbeeZclGlobalControlDiscoverAttributes_t;
 
 /**
@@ -150,12 +150,12 @@ typedef struct {
  * @since_tizen 3.0
  */
 typedef struct {
-       short node_id; /**< Node ID */
-       char dest_ep; /**< Destination endpoint */
-       char zcl_frame_ctrl; /**< ZCL frame control */
-       char cluster_id; /**< Cluster ID */
-       char start_attribute; /**< Start attribute */
-       char max; /**< Maximum */
+       unsigned short node_id; /**< Node ID */
+       unsigned char dest_ep; /**< Destination endpoint */
+       unsigned char zcl_frame_ctrl; /**< ZCL frame control */
+       unsigned char cluster_id; /**< Cluster ID */
+       unsigned char start_attribute; /**< Start attribute */
+       unsigned char max_attribute_count; /**< Maximum */
 } ZigbeeZclGlobalControlDiscoverAttributesExtended_t;
 
 /**
@@ -163,12 +163,12 @@ typedef struct {
  * @since_tizen 3.0
  */
 typedef struct {
-       short node_id; /**< Node ID */
-       char dest_ep; /**< Destination endpoint */
-       char zcl_frame_ctrl; /**< ZCL frame control */
-       char cluster_id; /**< Cluster ID */
-       char start_attribute; /**< Start attribute */
-       char max; /**< Maximum */
+       unsigned short node_id; /**< Node ID */
+       unsigned char dest_ep; /**< Destination endpoint */
+       unsigned char zcl_frame_ctrl; /**< ZCL frame control */
+       unsigned char cluster_id; /**< Cluster ID */
+       unsigned char start_command; /**< Start attribute */
+       unsigned char max_command_count; /**< Maximum */
 } ZigbeeZclGlobalControlDiscoverCommandsReceived_t;
 
 /**
@@ -176,13 +176,185 @@ typedef struct {
  * @since_tizen 3.0
  */
 typedef struct {
-       short node_id; /**< Node ID */
-       char dest_ep; /**< Destination endpoint */
-       char zcl_frame_ctrl; /**< ZCL frame control */
-       char cluster_id; /**< Cluster ID */
-       char start_attribute; /**< Start attribute */
-       char max; /**< Maximum */
+       unsigned short node_id; /**< Node ID */
+       unsigned char dest_ep; /**< Destination endpoint */
+       unsigned char zcl_frame_ctrl; /**< ZCL frame control */
+       unsigned char cluster_id; /**< Cluster ID */
+       unsigned char start_command; /**< Start attribute */
+       unsigned char max_command_count; /**< Maximum */
 } ZigbeeZclGlobalControlDiscoverCommandsGenerated_t;
 
+/* -----------------------------------------------------------------------------
+ * For Notifications
+ * ---------------------------------------------------------------------------*/
+
+/**
+ * @brief Definition for ZCL Global control read attributes response structure.
+ * @since_tizen 3.0
+ */
+typedef struct {
+       unsigned short node_id; /**< Node ID */
+       unsigned char src_ep; /**< Source endpoint */
+       unsigned char *values; /**< Attribute values */
+       unsigned short attribute_id; /**< Attribute ID */
+       unsigned short cluster_id; /**< Cluster ID */
+       unsigned char status; /**< Status */
+       unsigned char type; /**< Type */
+       unsigned short record_length; /**< Length of record */
+       int is_string; /**< Is this attribute string ? */
+} ZigbeeZclGlobalControlReadAttributesResp_t;
+
+/**
+ * @brief Definition for ZCL Global control write attributes response structure.
+ * @since_tizen 3.0
+ */
+typedef struct {
+       unsigned short node_id; /**< Node ID */
+       unsigned char src_ep; /**< Source endpoint */
+       unsigned char *values; /**< Attribute values */
+       unsigned short *attribute_list; /**< Attribute list */
+       unsigned short cluster_id; /**< Cluster ID */
+       int record_length; /**< Length of record */
+} ZigbeeZclGlobalControlWriteAttributesResp_t;
+
+/**
+ * @brief Definition for ZCL Global control configure reporting response structure.
+ * @since_tizen 3.0
+ */
+typedef struct {
+       unsigned char *status_list; /**< Status list */
+       unsigned short *attribute_list; /**< Attribute list */
+       unsigned char *dir_list; /**< Direction list */
+       unsigned short node_id; /**< Node ID */
+       unsigned char src_ep; /**< Source endpoint */
+       unsigned short cluster_id; /**< Cluster ID */
+       int record_length; /**< Length of record */
+} ZigbeeZclGlobalControlConfigReportResp_t;
+
+/**
+ * @brief Definition for ZCL Global control discover attribute response structure.
+ * @since_tizen 3.0
+ */
+typedef struct {
+       unsigned short node_id; /**< Node ID */
+       unsigned char src_ep; /**< Source endpoint */
+       unsigned char *type_list; /**< Type list */
+       unsigned short *attribute_list; /**< Attribute list */
+       unsigned short cluster_id; /**< Cluster ID */
+       int record_length; /**< Length of record */
+       int discovery_completed; /**< Discovery completed */
+} ZigbeeZclGlobalControlDiscoverAttributeResp_t;
+
+/**
+ * @brief Definition for ZCL Global control write attribute structured response structure.
+ * @since_tizen 3.0
+ */
+typedef struct {
+       unsigned char *status_list; /**< Status list */
+       unsigned short *attribute_list; /**< Attribute list */
+       unsigned char *indicator_list; /**< Indicator list */
+       unsigned short **index_list; /**< Index list */
+       unsigned short cluster_id; /**< Cluster ID */
+       int record_length; /**< Length of record */
+       unsigned short node_id; /**< Node ID */
+       unsigned char src_ep; /**< Source endpoint */
+} ZigbeeZclGlobalControlWriteAttributeStructuredResp_t;
+
+/**
+ * @brief Definition for ZCL Global control discover received commands response structure.
+ * @since_tizen 3.0
+ */
+typedef struct {
+       unsigned char *command_list; /**< Command list */
+       unsigned short list_count; /**< Length of record */
+       unsigned short cluster_id; /**< Cluster ID */
+       unsigned short node_id; /**< Node ID */
+       unsigned char src_ep; /**< Source endpoint */
+       unsigned char discovery_completed; /**< Discovery completed */
+} ZigbeeZclGlobalControlDiscoverCommandsReceivedResp_t;
+
+/**
+ * @brief Definition for ZCL Global control discover generated commands response structure.
+ * @since_tizen 3.0
+ */
+typedef struct {
+       unsigned char *command_list; /**< Command list */
+       unsigned short list_count; /**< Length of record */
+       unsigned short cluster_id; /**< Cluster ID */
+       unsigned short node_id; /**< Node ID */
+       unsigned char src_ep; /**< Source endpoint */
+       unsigned char discovery_completed; /**< Discovery completed */
+} ZigbeeZclGlobalControlDiscoverCommandsGeneratedResp_t;
+
+/**
+ * @brief Definition for ZCL Global control discover extended attributes response structure.
+ * @since_tizen 3.0
+ */
+typedef struct {
+       unsigned short *attribute_list; /**< Attribute list */
+       unsigned char *attribute_type_list; /**< Attribute type list */
+       unsigned char *access_list; /**< Access list */
+       unsigned short list_count; /**< Length of record */
+       unsigned short cluster_id; /**< Cluster ID */
+       unsigned short node_id; /**< Node ID */
+       unsigned char src_ep; /**< Source endpoint */
+       unsigned char discovery_completed; /**< Discovery completed */
+} ZigbeeZclGlobalControlDiscoverAttributesExtendedResp_t;
+
+/**
+ * @brief Definition for ZCL Global control default response structure.
+ * @since_tizen 3.0
+ */
+typedef struct {
+       unsigned short cluster_id; /**< Cluster ID */
+       unsigned short node_id; /**< Node ID */
+       unsigned char src_ep; /**< Source endpoint */
+       unsigned char command_id; /**< Command ID */
+       unsigned char status; /**< Status */
+} ZigbeeZclGlobalControlDefaultResp_t;
+
+/**
+ * @brief Definition for ZCL Global control discover extended attributes response structure.
+ * @since_tizen 3.0
+ */
+typedef struct {
+       unsigned short *attribute_list; /**< Attribute list */
+       unsigned char *data_type_list; /**< Attribute type list */
+       unsigned char **values; /**< Values list */
+       unsigned char *values_count; /**< Count for each value list */
+       unsigned short list_count; /**< Length of record */
+       unsigned short cluster_id; /**< Cluster ID */
+       unsigned short node_id; /**< Node ID */
+       unsigned char src_ep; /**< Source endpoint */
+} ZigbeeZclGlobalControlReportAttributeHandlerResp_t;
+
+/**
+ * @brief Definition for ZCL Global control read configure reporting entry structure.
+ * @since_tizen 3.0
+ */
+typedef struct {
+       unsigned char status; /**< status */
+       unsigned char dir; /**< direction */
+       unsigned short attribute_id; /**< attribute identifier */
+       unsigned char data_type; /**< attribute data type */
+       unsigned short min_interval; /**< minimum reporting interval */
+       unsigned short max_interval; /**< maximum reporting interval */
+       unsigned char *change; /**< reportable change */
+       unsigned char change_count; /**< The number of change list */
+       unsigned short timeout; /**< timeout period */
+} ZigbeeZclGlobalControlReadConfigureReportingEntry_t;
+
+/**
+ * @brief Definition for ZCL Global control read configure reporting response structure.
+ * @since_tizen 3.0
+ */
+typedef struct {
+       unsigned short cluster_id; /**< Cluster ID */
+       unsigned short node_id; /**< Node ID */
+       unsigned short record_count; /**< The number of record */
+       unsigned char src_ep; /**< Source endpoint */
+       ZigbeeZclGlobalControlReadConfigureReportingEntry_t *entry_list; /**< Entry */
+} ZigbeeZclGlobalControlReadConfigureReportingResp_t;
+
 
 #endif /* __ZIGBEE_ZCL_GLOBAL_CONTROL_TYPE_H__ */
index 545a3d3..772d7f8 100644 (file)
@@ -1,75 +1,83 @@
 <node>
        <interface name='org.tizen.zigbee.zcl_global_control'>
                <method name='read_attributes_req'>
-                       <arg type='ay' name='attributeId' direction='in'/>
+                       <arg type='a(y)' name='attributeId' direction='in'/>
                        <arg type='i' name='attributeIdsLen' direction='in'/>
                        <arg type='q' name='nodeId' direction='in'/>
                        <arg type='q' name='clusterId' direction='in'/>
                        <arg type='y' name='zcl_frame_ctrl' direction='in'/>
                        <arg type='y' name='dest_ep' direction='in'/>
+                       <arg type='i' name='result' direction='out'/>
                </method>
                <method name='write_attributes_req'>
-                       <arg type='ay' name='writeAttribute' direction='in'/>
+                       <arg type='a(y)' name='writeAttribute' direction='in'/>
                        <arg type='i' name='recordsLen' direction='in'/>
                        <arg type='q' name='nodeId' direction='in'/>
                        <arg type='q' name='clusterId' direction='in'/>
                        <arg type='y' name='zcl_frame_ctrl' direction='in'/>
                        <arg type='y' name='src_ep' direction='in'/>
                        <arg type='y' name='dest_ep' direction='in'/>
+                       <arg type='i' name='result' direction='out'/>
                </method>
                <method name='write_attributes_undivided_req'>
-                       <arg type='ay' name='writeAttribute' direction='in'/>
+                       <arg type='a(y)' name='writeAttribute' direction='in'/>
                        <arg type='i' name='recordsLen' direction='in'/>
                        <arg type='q' name='nodeId' direction='in'/>
                        <arg type='q' name='clusterId' direction='in'/>
                        <arg type='y' name='zcl_frame_ctrl' direction='in'/>
                        <arg type='y' name='src_ep' direction='in'/>
                        <arg type='y' name='dest_ep' direction='in'/>
+                       <arg type='i' name='result' direction='out'/>
                </method>
                <method name='write_attributes_no_resp'>
-                       <arg type='ay' name='writeAttribute' direction='in'/>
+                       <arg type='a(y)' name='writeAttribute' direction='in'/>
                        <arg type='i' name='recordsLen' direction='in'/>
                        <arg type='q' name='nodeId' direction='in'/>
                        <arg type='q' name='clusterId' direction='in'/>
                        <arg type='y' name='zcl_frame_ctrl' direction='in'/>
                        <arg type='y' name='src_ep' direction='in'/>
                        <arg type='y' name='dest_ep' direction='in'/>
+                       <arg type='i' name='result' direction='out'/>
                </method>
                <method name='write_attributes_structured'>
-                       <arg type='ay' name='writeAttribute' direction='in'/>
+                       <arg type='a(y)' name='writeAttribute' direction='in'/>
                        <arg type='q' name='recordsLen' direction='in'/>
                        <arg type='q' name='nodeId' direction='in'/>
                        <arg type='q' name='clusterId' direction='in'/>
                        <arg type='y' name='zcl_frame_ctrl' direction='in'/>
                        <arg type='y' name='src_ep' direction='in'/>
                        <arg type='y' name='dest_ep' direction='in'/>
+                       <arg type='i' name='result' direction='out'/>
                </method>
                <method name='read_attributes_structured'>
-                       <arg type='ay' name='ReadAttribute' direction='in'/>
+                       <arg type='a(y)' name='ReadAttribute' direction='in'/>
                        <arg type='q' name='recordsLen' direction='in'/>
                        <arg type='q' name='nodeId' direction='in'/>
                        <arg type='q' name='clusterId' direction='in'/>
                        <arg type='y' name='zcl_frame_ctrl' direction='in'/>
                        <arg type='y' name='src_ep' direction='in'/>
                        <arg type='y' name='dest_ep' direction='in'/>
+                       <arg type='i' name='result' direction='out'/>
                </method>
                <method name='configure_reporting_req'>
-                       <arg type='ay' name='ReadAttribute' direction='in'/>
+                       <arg type='a(y)' name='ReadAttribute' direction='in'/>
                        <arg type='q' name='recordsLen' direction='in'/>
                        <arg type='q' name='nodeId' direction='in'/>
                        <arg type='q' name='clusterId' direction='in'/>
                        <arg type='y' name='zcl_frame_ctrl' direction='in'/>
                        <arg type='y' name='src_ep' direction='in'/>
                        <arg type='y' name='dest_ep' direction='in'/>
+                       <arg type='i' name='result' direction='out'/>
                </method>
                <method name='read_configure_reporting'>
-                       <arg type='ay' name='ReadAttribute' direction='in'/>
+                       <arg type='a(y)' name='ReadAttribute' direction='in'/>
                        <arg type='q' name='recordsLen' direction='in'/>
                        <arg type='q' name='nodeId' direction='in'/>
                        <arg type='q' name='clusterId' direction='in'/>
                        <arg type='y' name='zcl_frame_ctrl' direction='in'/>
                        <arg type='y' name='src_ep' direction='in'/>
                        <arg type='y' name='dest_ep' direction='in'/>
+                       <arg type='i' name='result' direction='out'/>
                </method>
                <method name='discover_attributes'>
                        <arg type='q' name='nodeId' direction='in'/>
@@ -78,6 +86,7 @@
                        <arg type='q' name='clusterId' direction='in'/>
                        <arg type='q' name='startAttr' direction='in'/>
                        <arg type='y' name='max' direction='in'/>
+                       <arg type='i' name='result' direction='out'/>
                </method>
                <method name='discover_attributes_extended'>
                        <arg type='q' name='nodeId' direction='in'/>
@@ -86,6 +95,7 @@
                        <arg type='q' name='clusterId' direction='in'/>
                        <arg type='q' name='startAttr' direction='in'/>
                        <arg type='y' name='max' direction='in'/>
+                       <arg type='i' name='result' direction='out'/>
                </method>
                <method name='discover_commands_received'>
                        <arg type='q' name='nodeId' direction='in'/>
                        <arg type='q' name='clusterId' direction='in'/>
                        <arg type='q' name='startAttr' direction='in'/>
                        <arg type='y' name='max' direction='in'/>
+                       <arg type='i' name='result' direction='out'/>
                </method>
                <method name='discover_commands_generated'>
                        <arg type='q' name='nodeId' direction='in'/>
                        <arg type='q' name='clusterId' direction='in'/>
                        <arg type='q' name='startAttr' direction='in'/>
                        <arg type='y' name='max' direction='in'/>
+                       <arg type='i' name='result' direction='out'/>
                </method>
 
                <signal name='read_attributes_rsp'>
                        <arg type='q' name='nodeId'/>
-                       <arg type='y' name='endpoint'/>
-                       <arg type='ay' name='value'/>
+                       <arg type='y' name='src_ep'/>
+                       <arg type='a(y)' name='value'/>
                        <arg type='q' name='attribute_id'/>
                        <arg type='q' name='clusterId'/>
                        <arg type='y' name='status'/>
                </signal>
                <signal name='write_attributes_rsp'>
                        <arg type='q' name='nodeId'/>
-                       <arg type='y' name='endpoint'/>
-                       <arg type='ay' name='value'/>
+                       <arg type='y' name='src_ep'/>
+                       <arg type='a(y)' name='value'/>
                        <arg type='aq' name='attribute_id'/>
                        <arg type='q' name='clusterId'/>
                        <arg type='i' name='record_len'/>
                </signal>
                <signal name='configure_reporting_rsp'>
-                       <arg type='ay' name='status'/>
+                       <arg type='a(y)' name='status'/>
                        <arg type='aq' name='attribute_id'/>
-                       <arg type='ay' name='dir'/>
+                       <arg type='a(y)' name='dir'/>
                        <arg type='q' name='clusterId'/>
                        <arg type='i' name='record_len'/>
                        <arg type='q' name='nodeId'/>
                </signal>
                <signal name='discover_attribute_rsp'>
                        <arg type='q' name='nodeId'/>
-                       <arg type='y' name='endpoint'/>
-                       <arg type='ay' name='type'/>
+                       <arg type='y' name='src_ep'/>
+                       <arg type='a(y)' name='type'/>
                        <arg type='aq' name='attribute_id'/>
                        <arg type='q' name='clusterId'/>
                        <arg type='i' name='record_len'/>
                        <arg type='i' name='discoveryComplete'/>
                </signal>
                <signal name='write_attribute_structured_rsp'>
-                       <arg type='ay' name='type'/>
+                       <arg type='a(y)' name='status'/>
                        <arg type='aq' name='attribute_id'/>
-                       <arg type='ay' name='indicator'/>
+                       <arg type='a(y)' name='indicator'/>
                        <arg type='aq' name='index'/>
                        <arg type='q' name='clusterId'/>
                        <arg type='i' name='record_len'/>
                        <arg type='y' name='src_ep'/>
                </signal>
                <signal name='discover_commands_received_rsp'>
-                       <arg type='ay' name='type'/>
+                       <arg type='a(y)' name='commands'/>
                        <arg type='q' name='clusterId'/>
                        <arg type='q' name='commandLen'/>
                        <arg type='q' name='nodeId'/>
-                       <arg type='y' name='srcep'/>
+                       <arg type='y' name='src_ep'/>
                        <arg type='y' name='discoveryComplete'/>
                </signal>
                <signal name='discover_commands_generated_rsp'>
-                       <arg type='ay' name='type'/>
+                       <arg type='a(y)' name='commands'/>
                        <arg type='q' name='clusterId'/>
                        <arg type='q' name='commandLen'/>
                        <arg type='q' name='nodeId'/>
-                       <arg type='y' name='srcep'/>
+                       <arg type='y' name='src_ep'/>
                        <arg type='y' name='discoveryComplete'/>
                </signal>
                <signal name='discover_attributes_extended_rsp'>
                        <arg type='aq' name='attrId'/>
-                       <arg type='ay' name='attrtype'/>
-                       <arg type='ay' name='access'/>
+                       <arg type='a(y)' name='attrtype'/>
+                       <arg type='a(y)' name='access'/>
                        <arg type='q' name='clusterId'/>
-                       <arg type='q' name='commandLen'/>
+                       <arg type='q' name='attrCount'/>
                        <arg type='q' name='nodeId'/>
-                       <arg type='y' name='srcep'/>
+                       <arg type='y' name='src_ep'/>
                        <arg type='y' name='discoveryComplete'/>
                </signal>
                <signal name='zcl_global_default_response'>
                        <arg type='y' name='src_ep'/>
                        <arg type='q' name='cluster_id'/>
                        <arg type='aq' name='attribute_id'/>
-                       <arg type='ay' name='dataType'/>
-                       <arg type='ay' name='value'/>
+                       <arg type='a(y)' name='dataType'/>
+                       <arg type='a(y)' name='value'/>
                        <arg type='i' name='recordLength'/>
                </signal>
                <signal name='read_configure_reporting_rsp'>
index 1b962a5..b40748c 100644 (file)
@@ -259,7 +259,8 @@ static void zigbee_service_dbus_interface_noti_cb(ZigBeeServiceInterface *servic
 static void zigbee_on_name_lost(GDBusConnection *connection,
        const gchar *name, gpointer user_data)
 {
-       ZigbeeCustomData_t *custom_data = user_data;
+       ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
+       ZigbeeCustomData_t *custom_data = zblib_service_interface_ref_user_data(service_interface);
 
        Z_LOGW("'%s' - [Name Lost]", name);
 
index a152345..bfd8231 100644 (file)
 
 #include <zblib_driver_zcl_global_control.h>
 
+static void *_service_interface_ref_zigbee_zcl_global_control(ZigBeeServiceInterface *service_interface)
+{
+       ZigbeeObjectSkeleton *zigbee_object = NULL;
+       ZigbeeCustomData_t *custom_data = NULL;
+       ZigbeeZcl_global_control *global_control_object = NULL;
+
+       custom_data = (ZigbeeCustomData_t *)zblib_service_interface_ref_user_data(service_interface);
+       if (NULL == custom_data) {
+               Z_LOGE("D-BUS service interface custom_data is NULL!");
+               return NULL;
+       }
+
+       /* Get zigbee object */
+       zigbee_object = g_hash_table_lookup(custom_data->objects, ZIGBEE_SERVICE_PATH);
+       if (NULL == zigbee_object) {
+               Z_LOGW("Cannot find ZigBee D-BUS interface object!", zigbee_object);
+               return NULL;
+       }
+
+       global_control_object = zigbee_object_get_zcl_global_control(ZIGBEE_OBJECT(zigbee_object));
+       return global_control_object;
+}
+
 static void on_zclglobal_control_read_attributes_req_resp(ZigBeeServiceInterface *service_interface,
        guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
 {
        ZigbeeServiceInterfaceRespCbData_t *cb_data =
                (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
 
-       NOT_USED(cb_data);
+       ZigbeeZcl_global_control *global_control_object;
+       GDBusMethodInvocation *invocation;
+
+       ZigbeeGeneralResp_t *payload = (ZigbeeGeneralResp_t*)resp_data;
+
        NOT_USED(service_interface);
        NOT_USED(request_id);
-       NOT_USED(resp_data);
-       NOT_USED(resp_data_len);
+
+       if (NULL == resp_data || 0 == resp_data_len) {
+               Z_LOGE("resp_data=%p or resp_data_len=%d is null", resp_data, resp_data_len);
+               g_free(cb_data);
+               return;
+       }
+
+       global_control_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
+       zblib_check_null_free_and_ret("global_control_object", global_control_object, cb_data);
+
+       invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
+       zblib_check_null_free_and_ret("invocation", invocation, cb_data);
+
+       zigbee_zcl_global_control_complete_read_attributes_req(global_control_object,
+               invocation, payload->result);
+
+       g_free(cb_data);
 }
 
 static gboolean on_zclglobal_control_read_attributes_req(ZigbeeZcl_global_control *zclglobal_control_object,
@@ -54,9 +96,19 @@ static gboolean on_zclglobal_control_read_attributes_req(ZigbeeZcl_global_contro
 
        memset(&req, 0x0, sizeof(ZigbeeZclGlobalControlReadAttributesRequest_t));
 
+       req.attribute_id = g_try_malloc0_n(attribute_ids_length, sizeof(unsigned char));
+       if (NULL == req.attribute_id) {
+               Z_LOGE("Failed to allocation !");
+
+               /* Send failure response */
+               ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
+
+               return TRUE;
+       }
+
        /* Update request structure */
-       g_variant_get(attribute_id, "ay", &iter);
-       while (g_variant_iter_loop(iter, "y", req.attribute_id[i])) {
+       g_variant_get(attribute_id, "a(y)", &iter);
+       while (g_variant_iter_loop(iter, "(y)", &(req.attribute_id[i]))) {
                i++;
                if (i >= attribute_ids_length)
                        break;
@@ -107,11 +159,30 @@ static void on_zclglobal_control_write_attributes_req_resp(ZigBeeServiceInterfac
        ZigbeeServiceInterfaceRespCbData_t *cb_data =
                (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
 
-       NOT_USED(cb_data);
+       ZigbeeZcl_global_control *global_control_object;
+       GDBusMethodInvocation *invocation;
+
+       ZigbeeGeneralResp_t *payload = (ZigbeeGeneralResp_t*)resp_data;
+
        NOT_USED(service_interface);
        NOT_USED(request_id);
-       NOT_USED(resp_data);
-       NOT_USED(resp_data_len);
+
+       if (NULL == resp_data || 0 == resp_data_len) {
+               Z_LOGE("resp_data=%p or resp_data_len=%d is null", resp_data, resp_data_len);
+               g_free(cb_data);
+               return;
+       }
+
+       global_control_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
+       zblib_check_null_free_and_ret("global_control_object", global_control_object, cb_data);
+
+       invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
+       zblib_check_null_free_and_ret("invocation", invocation, cb_data);
+
+       zigbee_zcl_global_control_complete_write_attributes_req(global_control_object,
+               invocation, payload->result);
+
+       g_free(cb_data);
 }
 
 static gboolean on_zclglobal_control_write_attributes_req(ZigbeeZcl_global_control *zclglobal_control_object,
@@ -121,6 +192,7 @@ static gboolean on_zclglobal_control_write_attributes_req(ZigbeeZcl_global_contr
        gshort node_id,
        gshort cluster_id,
        gchar zcl_frame_ctrl,
+       gchar src_ep,
        gchar dest_ep,
        gpointer user_data)
 {
@@ -133,11 +205,25 @@ static gboolean on_zclglobal_control_write_attributes_req(ZigbeeZcl_global_contr
 
        gboolean ret;
 
-       memset(&req, 0x0, sizeof(ZigbeeZclGlobalControlReadAttributesRequest_t));
+       Z_LOGI("DBus Service interface: [%p]", service_interface);
+
+       memset(&req, 0x0, sizeof(ZigbeeZclGlobalControlWriteAttributesRequest_t));
+
+       req.write_records = g_try_malloc0_n(records_length, sizeof(unsigned char));
+       if (NULL == req.write_records) {
+               Z_LOGE("Failed to allocation !");
+
+               /* Send failure response */
+               ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
+
+               return TRUE;
+       }
+
+       Z_LOGI("DBus Service interface: [%p]", service_interface);
 
        /* Update request structure */
-       g_variant_get(write_attribute, "ay", &iter);
-       while (g_variant_iter_loop(iter, "y", req.write_records[i])) {
+       g_variant_get(write_attribute, "a(y)", &iter);
+       while (g_variant_iter_loop(iter, "(y)", &(req.write_records[i]))) {
                i++;
                if (i >= records_length)
                        break;
@@ -146,6 +232,7 @@ static gboolean on_zclglobal_control_write_attributes_req(ZigbeeZcl_global_contr
        req.node_id = node_id;
        req.cluster_id = cluster_id;
        req.zcl_frame_ctrl = zcl_frame_ctrl;
+       req.src_ep = src_ep;
        req.dest_ep = dest_ep;
 
        /* Allocate response callback data */
@@ -188,11 +275,30 @@ static void on_zclglobal_control_write_attributes_undivided_req_resp(ZigBeeServi
        ZigbeeServiceInterfaceRespCbData_t *cb_data =
                (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
 
-       NOT_USED(cb_data);
+       ZigbeeZcl_global_control *global_control_object;
+       GDBusMethodInvocation *invocation;
+
+       ZigbeeGeneralResp_t *payload = (ZigbeeGeneralResp_t*)resp_data;
+
        NOT_USED(service_interface);
        NOT_USED(request_id);
-       NOT_USED(resp_data);
-       NOT_USED(resp_data_len);
+
+       if (NULL == resp_data || 0 == resp_data_len) {
+               Z_LOGE("resp_data=%p or resp_data_len=%d is null", resp_data, resp_data_len);
+               g_free(cb_data);
+               return;
+       }
+
+       global_control_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
+       zblib_check_null_free_and_ret("global_control_object", global_control_object, cb_data);
+
+       invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
+       zblib_check_null_free_and_ret("invocation", invocation, cb_data);
+
+       zigbee_zcl_global_control_complete_write_attributes_undivided_req(global_control_object,
+               invocation, payload->result);
+
+       g_free(cb_data);
 }
 
 static gboolean on_zclglobal_control_write_attributes_undivided_req(ZigbeeZcl_global_control *zclglobal_control_object,
@@ -217,9 +323,19 @@ static gboolean on_zclglobal_control_write_attributes_undivided_req(ZigbeeZcl_gl
 
        memset(&req, 0x0, sizeof(ZigbeeZclGlobalControlWriteAttributesUndividedRequest_t));
 
+       req.write_records = g_try_malloc0_n(records_length, sizeof(unsigned char));
+       if (NULL == req.write_records) {
+               Z_LOGE("Failed to allocation !");
+
+               /* Send failure response */
+               ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
+
+               return TRUE;
+       }
+
        /* Update request structure */
-       g_variant_get(write_attribute, "ay", &iter);
-       while (g_variant_iter_loop(iter, "y", req.write_records[i])) {
+       g_variant_get(write_attribute, "a(y)", &iter);
+       while (g_variant_iter_loop(iter, "(y)", &(req.write_records[i]))) {
                i++;
                if (i >= records_length)
                        break;
@@ -271,11 +387,30 @@ static void on_zclglobal_control_write_attributes_no_resp_resp(ZigBeeServiceInte
        ZigbeeServiceInterfaceRespCbData_t *cb_data =
                (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
 
-       NOT_USED(cb_data);
+       ZigbeeZcl_global_control *global_control_object;
+       GDBusMethodInvocation *invocation;
+
+       ZigbeeGeneralResp_t *payload = (ZigbeeGeneralResp_t*)resp_data;
+
        NOT_USED(service_interface);
        NOT_USED(request_id);
-       NOT_USED(resp_data);
-       NOT_USED(resp_data_len);
+
+       if (NULL == resp_data || 0 == resp_data_len) {
+               Z_LOGE("resp_data=%p or resp_data_len=%d is null", resp_data, resp_data_len);
+               g_free(cb_data);
+               return;
+       }
+
+       global_control_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
+       zblib_check_null_free_and_ret("global_control_object", global_control_object, cb_data);
+
+       invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
+       zblib_check_null_free_and_ret("invocation", invocation, cb_data);
+
+       zigbee_zcl_global_control_complete_write_attributes_no_resp(global_control_object,
+               invocation, payload->result);
+
+       g_free(cb_data);
 }
 
 static gboolean on_zclglobal_control_write_attributes_no_resp(ZigbeeZcl_global_control *zclglobal_control_object,
@@ -300,9 +435,19 @@ static gboolean on_zclglobal_control_write_attributes_no_resp(ZigbeeZcl_global_c
 
        memset(&req, 0x0, sizeof(ZigbeeZclGlobalControlWriteAttributesNoResponse_t));
 
+       req.write_records = g_try_malloc0_n(records_length, sizeof(unsigned char));
+       if (NULL == req.write_records) {
+               Z_LOGE("Failed to allocation !");
+
+               /* Send failure response */
+               ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
+
+               return TRUE;
+       }
+
        /* Update request structure */
-       g_variant_get(write_attribute, "ay", &iter);
-       while (g_variant_iter_loop(iter, "y", req.write_records[i])) {
+       g_variant_get(write_attribute, "a(y)", &iter);
+       while (g_variant_iter_loop(iter, "(y)", &(req.write_records[i]))) {
                i++;
                if (i >= records_length)
                        break;
@@ -354,11 +499,30 @@ static void on_zclglobal_control_write_attributes_structured_resp(ZigBeeServiceI
        ZigbeeServiceInterfaceRespCbData_t *cb_data =
                (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
 
-       NOT_USED(cb_data);
+       ZigbeeZcl_global_control *global_control_object;
+       GDBusMethodInvocation *invocation;
+
+       ZigbeeGeneralResp_t *payload = (ZigbeeGeneralResp_t*)resp_data;
+
        NOT_USED(service_interface);
        NOT_USED(request_id);
-       NOT_USED(resp_data);
-       NOT_USED(resp_data_len);
+
+       if (NULL == resp_data || 0 == resp_data_len) {
+               Z_LOGE("resp_data=%p or resp_data_len=%d is null", resp_data, resp_data_len);
+               g_free(cb_data);
+               return;
+       }
+
+       global_control_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
+       zblib_check_null_free_and_ret("global_control_object", global_control_object, cb_data);
+
+       invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
+       zblib_check_null_free_and_ret("invocation", invocation, cb_data);
+
+       zigbee_zcl_global_control_complete_write_attributes_structured(global_control_object,
+               invocation, payload->result);
+
+       g_free(cb_data);
 }
 
 static gboolean on_zclglobal_control_write_attributes_structured(ZigbeeZcl_global_control *zclglobal_control_object,
@@ -383,9 +547,19 @@ static gboolean on_zclglobal_control_write_attributes_structured(ZigbeeZcl_globa
 
        memset(&req, 0x0, sizeof(ZigbeeZclGlobalControlWriteAttributesStructed_t));
 
+       req.write_records = g_try_malloc0_n(records_length, sizeof(unsigned char));
+       if (NULL == req.write_records) {
+               Z_LOGE("Failed to allocation !");
+
+               /* Send failure response */
+               ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
+
+               return TRUE;
+       }
+
        /* Update request structure */
-       g_variant_get(write_attribute, "ay", &iter);
-       while (g_variant_iter_loop(iter, "y", req.write_records[i])) {
+       g_variant_get(write_attribute, "a(y)", &iter);
+       while (g_variant_iter_loop(iter, "(y)", &(req.write_records[i]))) {
                i++;
                if (i >= records_length)
                        break;
@@ -437,11 +611,30 @@ static void on_zclglobal_control_read_attributes_structured_resp(ZigBeeServiceIn
        ZigbeeServiceInterfaceRespCbData_t *cb_data =
                (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
 
-       NOT_USED(cb_data);
+       ZigbeeZcl_global_control *global_control_object;
+       GDBusMethodInvocation *invocation;
+
+       ZigbeeGeneralResp_t *payload = (ZigbeeGeneralResp_t*)resp_data;
+
        NOT_USED(service_interface);
        NOT_USED(request_id);
-       NOT_USED(resp_data);
-       NOT_USED(resp_data_len);
+
+       if (NULL == resp_data || 0 == resp_data_len) {
+               Z_LOGE("resp_data=%p or resp_data_len=%d is null", resp_data, resp_data_len);
+               g_free(cb_data);
+               return;
+       }
+
+       global_control_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
+       zblib_check_null_free_and_ret("global_control_object", global_control_object, cb_data);
+
+       invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
+       zblib_check_null_free_and_ret("invocation", invocation, cb_data);
+
+       zigbee_zcl_global_control_complete_read_attributes_structured(global_control_object,
+               invocation, payload->result);
+
+       g_free(cb_data);
 }
 
 static gboolean on_zclglobal_control_read_attributes_structured(ZigbeeZcl_global_control *zclglobal_control_object,
@@ -466,9 +659,19 @@ static gboolean on_zclglobal_control_read_attributes_structured(ZigbeeZcl_global
 
        memset(&req, 0x0, sizeof(ZigbeeZclGlobalControlReadAttributesStructed_t));
 
+       req.read_records = g_try_malloc0_n(records_length, sizeof(unsigned char));
+       if (NULL == req.read_records) {
+               Z_LOGE("Failed to allocation !");
+
+               /* Send failure response */
+               ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
+
+               return TRUE;
+       }
+
        /* Update request structure */
-       g_variant_get(read_attribute, "ay", &iter);
-       while (g_variant_iter_loop(iter, "y", req.read_records[i])) {
+       g_variant_get(read_attribute, "a(y)", &iter);
+       while (g_variant_iter_loop(iter, "(y)", &(req.read_records[i]))) {
                i++;
                if (i >= records_length)
                        break;
@@ -520,11 +723,30 @@ static void on_zclglobal_control_configure_reporting_req_resp(ZigBeeServiceInter
        ZigbeeServiceInterfaceRespCbData_t *cb_data =
                (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
 
-       NOT_USED(cb_data);
+       ZigbeeZcl_global_control *global_control_object;
+       GDBusMethodInvocation *invocation;
+
+       ZigbeeGeneralResp_t *payload = (ZigbeeGeneralResp_t*)resp_data;
+
        NOT_USED(service_interface);
        NOT_USED(request_id);
-       NOT_USED(resp_data);
-       NOT_USED(resp_data_len);
+
+       if (NULL == resp_data || 0 == resp_data_len) {
+               Z_LOGE("resp_data=%p or resp_data_len=%d is null", resp_data, resp_data_len);
+               g_free(cb_data);
+               return;
+       }
+
+       global_control_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
+       zblib_check_null_free_and_ret("global_control_object", global_control_object, cb_data);
+
+       invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
+       zblib_check_null_free_and_ret("invocation", invocation, cb_data);
+
+       zigbee_zcl_global_control_complete_configure_reporting_req(global_control_object,
+               invocation, payload->result);
+
+       g_free(cb_data);
 }
 
 static gboolean on_zclglobal_control_configure_reporting_req(ZigbeeZcl_global_control *zclglobal_control_object,
@@ -549,9 +771,19 @@ static gboolean on_zclglobal_control_configure_reporting_req(ZigbeeZcl_global_co
 
        memset(&req, 0x0, sizeof(ZigbeeZclGlobalControlConfigureReportingReq_t));
 
+       req.read_records = g_try_malloc0_n(records_length, sizeof(unsigned char));
+       if (NULL == req.read_records) {
+               Z_LOGE("Failed to allocation !");
+
+               /* Send failure response */
+               ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
+
+               return TRUE;
+       }
+
        /* Update request structure */
-       g_variant_get(read_attribute, "ay", &iter);
-       while (g_variant_iter_loop(iter, "y", req.read_records[i])) {
+       g_variant_get(read_attribute, "a(y)", &iter);
+       while (g_variant_iter_loop(iter, "(y)", &(req.read_records[i]))) {
                i++;
                if (i >= records_length)
                        break;
@@ -603,11 +835,30 @@ static void on_zclglobal_control_read_configure_reporting_resp(ZigBeeServiceInte
        ZigbeeServiceInterfaceRespCbData_t *cb_data =
                (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
 
-       NOT_USED(cb_data);
+       ZigbeeZcl_global_control *global_control_object;
+       GDBusMethodInvocation *invocation;
+
+       ZigbeeGeneralResp_t *payload = (ZigbeeGeneralResp_t*)resp_data;
+
        NOT_USED(service_interface);
        NOT_USED(request_id);
-       NOT_USED(resp_data);
-       NOT_USED(resp_data_len);
+
+       if (NULL == resp_data || 0 == resp_data_len) {
+               Z_LOGE("resp_data=%p or resp_data_len=%d is null", resp_data, resp_data_len);
+               g_free(cb_data);
+               return;
+       }
+
+       global_control_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
+       zblib_check_null_free_and_ret("global_control_object", global_control_object, cb_data);
+
+       invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
+       zblib_check_null_free_and_ret("invocation", invocation, cb_data);
+
+       zigbee_zcl_global_control_complete_read_configure_reporting(global_control_object,
+               invocation, payload->result);
+
+       g_free(cb_data);
 }
 
 static gboolean on_zclglobal_control_read_configure_reporting(ZigbeeZcl_global_control *zclglobal_control_object,
@@ -632,9 +883,19 @@ static gboolean on_zclglobal_control_read_configure_reporting(ZigbeeZcl_global_c
 
        memset(&req, 0x0, sizeof(ZigbeeZclGlobalControlReadConfigureReporting_t));
 
+       req.read_records = g_try_malloc0_n(records_length, sizeof(unsigned char));
+       if (NULL == req.read_records) {
+               Z_LOGE("Failed to allocation !");
+
+               /* Send failure response */
+               ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
+
+               return TRUE;
+       }
+
        /* Update request structure */
-       g_variant_get(read_attribute, "ay", &iter);
-       while (g_variant_iter_loop(iter, "y", req.read_records[i])) {
+       g_variant_get(read_attribute, "a(y)", &iter);
+       while (g_variant_iter_loop(iter, "(y)", &(req.read_records[i]))) {
                i++;
                if (i >= records_length)
                        break;
@@ -686,11 +947,30 @@ static void on_zclglobal_control_discover_attributes_resp(ZigBeeServiceInterface
        ZigbeeServiceInterfaceRespCbData_t *cb_data =
                (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
 
-       NOT_USED(cb_data);
+       ZigbeeZcl_global_control *global_control_object;
+       GDBusMethodInvocation *invocation;
+
+       ZigbeeGeneralResp_t *payload = (ZigbeeGeneralResp_t*)resp_data;
+
        NOT_USED(service_interface);
        NOT_USED(request_id);
-       NOT_USED(resp_data);
-       NOT_USED(resp_data_len);
+
+       if (NULL == resp_data || 0 == resp_data_len) {
+               Z_LOGE("resp_data=%p or resp_data_len=%d is null", resp_data, resp_data_len);
+               g_free(cb_data);
+               return;
+       }
+
+       global_control_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
+       zblib_check_null_free_and_ret("global_control_object", global_control_object, cb_data);
+
+       invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
+       zblib_check_null_free_and_ret("invocation", invocation, cb_data);
+
+       zigbee_zcl_global_control_complete_discover_attributes(global_control_object,
+               invocation, payload->result);
+
+       g_free(cb_data);
 }
 
 static gboolean on_zclglobal_control_discover_attributes(ZigbeeZcl_global_control *zclglobal_control_object,
@@ -700,7 +980,7 @@ static gboolean on_zclglobal_control_discover_attributes(ZigbeeZcl_global_contro
        gchar zcl_frame_ctrl,
        gshort cluster_id,
        gshort start_attr,
-       gchar max,
+       gchar max_attribute_count,
        gpointer user_data)
 {
        ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
@@ -717,7 +997,7 @@ static gboolean on_zclglobal_control_discover_attributes(ZigbeeZcl_global_contro
        req.zcl_frame_ctrl = zcl_frame_ctrl;
        req.cluster_id = cluster_id;
        req.start_attribute = start_attr;
-       req.max = max;
+       req.max_attribute_count = max_attribute_count;
 
        /* Allocate response callback data */
        resp_cb_data =
@@ -759,11 +1039,30 @@ static void on_zclglobal_control_discover_attributes_extended_resp(ZigBeeService
        ZigbeeServiceInterfaceRespCbData_t *cb_data =
                (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
 
-       NOT_USED(cb_data);
+       ZigbeeZcl_global_control *global_control_object;
+       GDBusMethodInvocation *invocation;
+
+       ZigbeeGeneralResp_t *payload = (ZigbeeGeneralResp_t*)resp_data;
+
        NOT_USED(service_interface);
        NOT_USED(request_id);
-       NOT_USED(resp_data);
-       NOT_USED(resp_data_len);
+
+       if (NULL == resp_data || 0 == resp_data_len) {
+               Z_LOGE("resp_data=%p or resp_data_len=%d is null", resp_data, resp_data_len);
+               g_free(cb_data);
+               return;
+       }
+
+       global_control_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
+       zblib_check_null_free_and_ret("global_control_object", global_control_object, cb_data);
+
+       invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
+       zblib_check_null_free_and_ret("invocation", invocation, cb_data);
+
+       zigbee_zcl_global_control_complete_discover_attributes_extended(global_control_object,
+               invocation, payload->result);
+
+       g_free(cb_data);
 }
 
 static gboolean on_zclglobal_control_discover_attributes_extended(ZigbeeZcl_global_control *zclglobal_control_object,
@@ -773,7 +1072,7 @@ static gboolean on_zclglobal_control_discover_attributes_extended(ZigbeeZcl_glob
        gchar zcl_frame_ctrl,
        gshort cluster_id,
        gshort start_attr,
-       gchar max,
+       gchar max_attribute_count,
        gpointer user_data)
 {
        ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
@@ -790,7 +1089,7 @@ static gboolean on_zclglobal_control_discover_attributes_extended(ZigbeeZcl_glob
        req.zcl_frame_ctrl = zcl_frame_ctrl;
        req.cluster_id = cluster_id;
        req.start_attribute = start_attr;
-       req.max = max;
+       req.max_attribute_count = max_attribute_count;
 
        /* Allocate response callback data */
        resp_cb_data =
@@ -832,11 +1131,30 @@ static void on_zclglobal_control_discover_commands_received_resp(ZigBeeServiceIn
        ZigbeeServiceInterfaceRespCbData_t *cb_data =
                (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
 
-       NOT_USED(cb_data);
+       ZigbeeZcl_global_control *global_control_object;
+       GDBusMethodInvocation *invocation;
+
+       ZigbeeGeneralResp_t *payload = (ZigbeeGeneralResp_t*)resp_data;
+
        NOT_USED(service_interface);
        NOT_USED(request_id);
-       NOT_USED(resp_data);
-       NOT_USED(resp_data_len);
+
+       if (NULL == resp_data || 0 == resp_data_len) {
+               Z_LOGE("resp_data=%p or resp_data_len=%d is null", resp_data, resp_data_len);
+               g_free(cb_data);
+               return;
+       }
+
+       global_control_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
+       zblib_check_null_free_and_ret("global_control_object", global_control_object, cb_data);
+
+       invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
+       zblib_check_null_free_and_ret("invocation", invocation, cb_data);
+
+       zigbee_zcl_global_control_complete_discover_commands_received(global_control_object,
+               invocation, payload->result);
+
+       g_free(cb_data);;
 }
 
 static gboolean on_zclglobal_control_discover_commands_received(ZigbeeZcl_global_control *zclglobal_control_object,
@@ -845,8 +1163,8 @@ static gboolean on_zclglobal_control_discover_commands_received(ZigbeeZcl_global
        gchar dest_ep,
        gchar zcl_frame_ctrl,
        gshort cluster_id,
-       gshort start_attr,
-       gchar max,
+       gshort start_command,
+       gchar max_command_count,
        gpointer user_data)
 {
        ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
@@ -862,8 +1180,8 @@ static gboolean on_zclglobal_control_discover_commands_received(ZigbeeZcl_global
        req.dest_ep = dest_ep;
        req.zcl_frame_ctrl = zcl_frame_ctrl;
        req.cluster_id = cluster_id;
-       req.start_attribute = start_attr;
-       req.max = max;
+       req.start_command = start_command;
+       req.max_command_count = max_command_count;
 
        /* Allocate response callback data */
        resp_cb_data =
@@ -905,11 +1223,30 @@ static void on_zclglobal_control_discover_commands_generated_resp(ZigBeeServiceI
        ZigbeeServiceInterfaceRespCbData_t *cb_data =
                (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
 
-       NOT_USED(cb_data);
+       ZigbeeZcl_global_control *global_control_object;
+       GDBusMethodInvocation *invocation;
+
+       ZigbeeGeneralResp_t *payload = (ZigbeeGeneralResp_t*)resp_data;
+
        NOT_USED(service_interface);
        NOT_USED(request_id);
-       NOT_USED(resp_data);
-       NOT_USED(resp_data_len);
+
+       if (NULL == resp_data || 0 == resp_data_len) {
+               Z_LOGE("resp_data=%p or resp_data_len=%d is null", resp_data, resp_data_len);
+               g_free(cb_data);
+               return;
+       }
+
+       global_control_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
+       zblib_check_null_free_and_ret("global_control_object", global_control_object, cb_data);
+
+       invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
+       zblib_check_null_free_and_ret("invocation", invocation, cb_data);
+
+       zigbee_zcl_global_control_complete_discover_commands_generated(global_control_object,
+               invocation, payload->result);
+
+       g_free(cb_data);
 }
 
 static gboolean on_zclglobal_control_discover_commands_generated(ZigbeeZcl_global_control *zclglobal_control_object,
@@ -918,8 +1255,8 @@ static gboolean on_zclglobal_control_discover_commands_generated(ZigbeeZcl_globa
        gchar dest_ep,
        gchar zcl_frame_ctrl,
        gshort cluster_id,
-       gshort start_attr,
-       gchar max,
+       gshort start_command,
+       gchar max_command_count,
        gpointer user_data)
 {
        ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
@@ -935,8 +1272,8 @@ static gboolean on_zclglobal_control_discover_commands_generated(ZigbeeZcl_globa
        req.dest_ep = dest_ep;
        req.zcl_frame_ctrl = zcl_frame_ctrl;
        req.cluster_id = cluster_id;
-       req.start_attribute = start_attr;
-       req.max = max;
+       req.start_command = start_command;
+       req.max_command_count = max_command_count;
 
        /* Allocate response callback data */
        resp_cb_data =
@@ -975,15 +1312,369 @@ static gboolean on_zclglobal_control_discover_commands_generated(ZigbeeZcl_globa
 void zigbee_service_dbus_interface_zcl_global_control_notification(ZigBeeServiceInterface *service_interface,
        guint noti_id, gpointer noti_data, guint noti_data_len, gpointer noti_cb_data)
 {
-       if (NULL == service_interface) {
-               Z_LOGE("service_interface is NULL");
+       ZigbeeZcl_global_control *global_control_object = NULL;
+
+       zblib_check_null_ret("service_interface", service_interface);
+
+       if (NULL == noti_data || 0 == noti_data_len) {
+               Z_LOGE("noti_data is NULL");
                return;
        }
 
-       NOT_USED(noti_id);
-       NOT_USED(noti_data);
-       NOT_USED(noti_data_len);
+       global_control_object = _service_interface_ref_zigbee_zcl_global_control(service_interface);
+       zblib_check_null_ret("global_control_object", global_control_object);
+
        NOT_USED(noti_cb_data);
+
+       switch(noti_id) {
+       case ZBLIB_ZCL_GLOBAL_NOTI_READ_ATTR_RSP: {
+               ZigbeeZclGlobalControlReadAttributesResp_t *attr_t =
+                       (ZigbeeZclGlobalControlReadAttributesResp_t*)noti_data;
+
+               GVariant *v_values = NULL;
+               v_values = g_variant_new_from_data(G_VARIANT_TYPE("a(y)"),
+                       attr_t->values, attr_t->record_length, TRUE, NULL, NULL);
+               if (NULL == v_values) {
+                       Z_LOGE("Failed to create variant!");
+               } else {
+                       Z_LOGD("Read attributes resp");
+                       zigbee_zcl_global_control_emit_read_attributes_rsp(global_control_object,
+                               attr_t->node_id, attr_t->src_ep, v_values, attr_t->attribute_id,
+                               attr_t->cluster_id, attr_t->status, attr_t->type,
+                               attr_t->record_length, attr_t->is_string);
+               }
+       break;
+       }
+       case ZBLIB_ZCL_GLOBAL_NOTI_WRITE_ATTR_RSP: {
+               ZigbeeZclGlobalControlWriteAttributesResp_t *attr_t =
+                       (ZigbeeZclGlobalControlWriteAttributesResp_t*)noti_data;
+
+               GVariant *v_values = NULL;
+               GVariant *v_attrs = NULL;
+               v_values = g_variant_new_from_data(G_VARIANT_TYPE("a(y)"),
+                       attr_t->values, attr_t->record_length, TRUE, NULL, NULL);
+               v_attrs = g_variant_new_from_data(G_VARIANT_TYPE("aq"),
+                       attr_t->attribute_list, (sizeof(gushort) * attr_t->record_length),
+                       TRUE, NULL, NULL);
+               if (NULL == v_values || NULL == v_attrs) {
+                       Z_LOGE("Failed to create variant!");
+                       if (v_values)
+                               g_variant_unref(v_values);
+                       if (v_attrs)
+                               g_variant_unref(v_attrs);
+               } else {
+                       Z_LOGD("Write attributes resp");
+                       zigbee_zcl_global_control_emit_write_attributes_rsp(global_control_object,
+                               attr_t->node_id, attr_t->src_ep, v_values, v_attrs,
+                               attr_t->cluster_id, attr_t->record_length);
+               }
+       break;
+       }
+       case ZBLIB_ZCL_GLOBAL_NOTI_CONFIG_REPORT_RSP: {
+               ZigbeeZclGlobalControlConfigReportResp_t *attr_t =
+                       (ZigbeeZclGlobalControlConfigReportResp_t*)noti_data;
+
+               GVariant *v_status = NULL;
+               GVariant *v_attrs = NULL;
+               GVariant *v_dirs = NULL;
+               v_status = g_variant_new_from_data(G_VARIANT_TYPE("a(y)"),
+                       attr_t->status_list, attr_t->record_length, TRUE, NULL, NULL);
+               v_attrs = g_variant_new_from_data(G_VARIANT_TYPE("aq"),
+                       attr_t->attribute_list, (sizeof(gushort) * attr_t->record_length),
+                       TRUE, NULL, NULL);
+               v_dirs = g_variant_new_from_data(G_VARIANT_TYPE("a(y)"),
+                       attr_t->dir_list, attr_t->record_length, TRUE, NULL, NULL);
+               if (NULL == v_status || NULL == v_attrs || NULL == v_dirs) {
+                       Z_LOGE("Failed to create variant!");
+                       if (v_status)
+                               g_variant_unref(v_status);
+                       if (v_attrs)
+                               g_variant_unref(v_attrs);
+                       if (v_dirs)
+                               g_variant_unref(v_dirs);
+               } else {
+                       Z_LOGD("Configure reporting resp");
+                       zigbee_zcl_global_control_emit_configure_reporting_rsp(global_control_object,
+                               v_status, v_attrs, v_dirs, attr_t->cluster_id,
+                               attr_t->record_length, attr_t->node_id, attr_t->src_ep);
+               }
+       break;
+       }
+       case ZBLIB_ZCL_GLOBAL_NOTI_DISCOVER_ATTR_RSP: {
+               ZigbeeZclGlobalControlDiscoverAttributeResp_t *attr_t =
+                       (ZigbeeZclGlobalControlDiscoverAttributeResp_t*)noti_data;
+
+               GVariant *v_types = NULL;
+               GVariant *v_attrs = NULL;
+               v_types = g_variant_new_from_data(G_VARIANT_TYPE("a(y)"),
+                       attr_t->type_list, attr_t->record_length, TRUE, NULL, NULL);
+               v_attrs = g_variant_new_from_data(G_VARIANT_TYPE("aq"),
+                       attr_t->attribute_list, (sizeof(gushort) * attr_t->record_length),
+                       TRUE, NULL, NULL);
+               if (NULL == v_types || NULL == v_attrs) {
+                       Z_LOGE("Failed to create variant!");
+                       if (v_types)
+                               g_variant_unref(v_types);
+                       if (v_attrs)
+                               g_variant_unref(v_attrs);
+               } else {
+                       Z_LOGD("Discover attribute resp");
+                       zigbee_zcl_global_control_emit_discover_attribute_rsp(global_control_object,
+                               attr_t->node_id, attr_t->src_ep, v_types, v_attrs,
+                               attr_t->cluster_id, attr_t->record_length, attr_t->discovery_completed);
+               }
+       break;
+       }
+       case ZBLIB_ZCL_GLOBAL_NOTI_WRITE_ATTR_STRUCTURED_RSP: {
+               ZigbeeZclGlobalControlWriteAttributeStructuredResp_t *attr_t =
+                       (ZigbeeZclGlobalControlWriteAttributeStructuredResp_t*)noti_data;
+
+               GVariant *v_status = NULL;
+               GVariant *v_attrs = NULL;
+               GVariant *v_indicator = NULL;
+               GVariantBuilder *index_builder = NULL;
+               GVariant *v_index = NULL;
+               int i = 0, j = 0;
+
+               v_status = g_variant_new_from_data(G_VARIANT_TYPE("a(y)"),
+                       attr_t->status_list, attr_t->record_length, TRUE, NULL, NULL);
+               v_attrs = g_variant_new_from_data(G_VARIANT_TYPE("aq"),
+                       attr_t->attribute_list, (sizeof(gushort) * attr_t->record_length),
+                       TRUE, NULL, NULL);
+               v_indicator = g_variant_new_from_data(G_VARIANT_TYPE("a(y)"),
+                       attr_t->indicator_list, attr_t->record_length, TRUE, NULL, NULL);
+
+               if (NULL == v_status || NULL == v_attrs || NULL == v_indicator) {
+                       Z_LOGE("Failed to create variant!");
+                       if (v_status)
+                               g_variant_unref(v_status);
+                       if (v_attrs)
+                               g_variant_unref(v_attrs);
+                       if (v_indicator)
+                               g_variant_unref(v_indicator);
+                       break;
+               }
+
+               index_builder = g_variant_builder_new (G_VARIANT_TYPE ("aq"));
+               if (NULL == index_builder) {
+                       Z_LOGE("Failed to create variant builder!");
+                       g_variant_unref(v_status);
+                       g_variant_unref(v_attrs);
+                       g_variant_unref(v_indicator);
+                       break;
+               }
+               for(i = 0; i < attr_t->record_length; i++) {
+                       for(j = 0; j < attr_t->indicator_list[i]; j++) {
+                               g_variant_builder_add (index_builder, "q", attr_t->index_list[i][j]);
+                       }
+               }
+               v_index = g_variant_builder_end (index_builder);
+               g_variant_builder_unref(index_builder);
+               if (NULL == index_builder) {
+                       Z_LOGE("Failed to create variant!");
+                       g_variant_unref(v_status);
+                       g_variant_unref(v_attrs);
+                       g_variant_unref(v_indicator);
+                       break;
+               }
+
+               Z_LOGD("Write attribute structured resp");
+               zigbee_zcl_global_control_emit_write_attribute_structured_rsp(
+                       global_control_object,
+                       v_status, v_attrs, v_indicator, v_index,
+                       attr_t->cluster_id, attr_t->record_length,
+                       attr_t->node_id, attr_t->src_ep);
+       break;
+       }
+       case ZBLIB_ZCL_GLOBAL_NOTI_DISCOVER_CMDS_RECEIVED_RSP: {
+               ZigbeeZclGlobalControlDiscoverCommandsReceivedResp_t *attr_t =
+                       (ZigbeeZclGlobalControlDiscoverCommandsReceivedResp_t*)noti_data;
+
+               GVariant *v_commands = NULL;
+               v_commands = g_variant_new_from_data(G_VARIANT_TYPE("a(y)"),
+                       attr_t->command_list, attr_t->list_count, TRUE, NULL, NULL);
+               if (NULL == v_commands) {
+                       Z_LOGE("Failed to create variant!");
+               } else {
+                       Z_LOGD("Discover commands received resp");
+                       zigbee_zcl_global_control_emit_discover_commands_received_rsp(
+                               global_control_object,
+                               v_commands, attr_t->list_count, attr_t->cluster_id,
+                               attr_t->node_id, attr_t->src_ep, attr_t->discovery_completed);
+               }
+       break;
+       }
+       case ZBLIB_ZCL_GLOBAL_NOTI_DISCOVER_CMDS_GENERATED_RSP: {
+               ZigbeeZclGlobalControlDiscoverCommandsGeneratedResp_t *attr_t =
+                       (ZigbeeZclGlobalControlDiscoverCommandsGeneratedResp_t*)noti_data;
+
+               GVariant *v_commands = NULL;
+               v_commands = g_variant_new_from_data(G_VARIANT_TYPE("a(y)"),
+                       attr_t->command_list, attr_t->list_count, TRUE, NULL, NULL);
+               if (NULL == v_commands) {
+                       Z_LOGE("Failed to create variant!");
+               } else {
+                       Z_LOGD("Discover commands generated resp");
+                       zigbee_zcl_global_control_emit_discover_commands_generated_rsp(
+                               global_control_object,
+                               v_commands, attr_t->list_count, attr_t->cluster_id,
+                               attr_t->node_id, attr_t->src_ep, attr_t->discovery_completed);
+               }
+       break;
+       }
+       case ZBLIB_ZCL_GLOBAL_NOTI_DISCOVER_ATTR_EXT_RSP: {
+               ZigbeeZclGlobalControlDiscoverAttributesExtendedResp_t *attr_t =
+                       (ZigbeeZclGlobalControlDiscoverAttributesExtendedResp_t*)noti_data;
+
+               GVariant *v_attrs = NULL;
+               GVariant *v_attrs_type = NULL;
+               GVariant *v_access = NULL;
+               v_attrs = g_variant_new_from_data(G_VARIANT_TYPE("aq"),
+                       attr_t->attribute_list, (sizeof(gushort) * attr_t->list_count),
+                       TRUE, NULL, NULL);
+               v_attrs_type = g_variant_new_from_data(G_VARIANT_TYPE("a(y)"),
+                       attr_t->attribute_type_list, attr_t->list_count, TRUE, NULL, NULL);
+               v_access = g_variant_new_from_data(G_VARIANT_TYPE("a(y)"),
+                       attr_t->access_list, attr_t->list_count, TRUE, NULL, NULL);
+               if (NULL == v_attrs_type || NULL == v_attrs || NULL == v_access) {
+                       Z_LOGE("Failed to create variant!");
+                       if (v_attrs_type)
+                               g_variant_unref(v_attrs_type);
+                       if (v_attrs)
+                               g_variant_unref(v_attrs);
+                       if (v_access)
+                               g_variant_unref(v_access);
+               } else {
+                       Z_LOGD("Discover attributes extended resp");
+                       zigbee_zcl_global_control_emit_discover_attributes_extended_rsp(
+                               global_control_object,
+                               v_attrs, v_attrs_type, v_access,
+                               attr_t->list_count, attr_t->cluster_id,
+                               attr_t->node_id, attr_t->src_ep, attr_t->discovery_completed);
+               }
+       break;
+       }
+       case ZBLIB_ZCL_GLOBAL_NOTI_DEFAULT_RSP: {
+               ZigbeeZclGlobalControlDefaultResp_t *attr_t =
+                       (ZigbeeZclGlobalControlDefaultResp_t*)noti_data;
+
+               Z_LOGD("Global default resp");
+               zigbee_zcl_global_control_emit_zcl_global_default_response(
+                       global_control_object,
+                       attr_t->cluster_id, attr_t->node_id, attr_t->src_ep,
+                       attr_t->command_id, attr_t->status);
+       break;
+       }
+       case ZBLIB_ZCL_GLOBAL_NOTI_REPORT_ATTR_HANDLER_RSP: {
+               ZigbeeZclGlobalControlReportAttributeHandlerResp_t *attr_t =
+                       (ZigbeeZclGlobalControlReportAttributeHandlerResp_t*)noti_data;
+
+               GVariant *v_attrs = NULL;
+               GVariant *v_data_type = NULL;
+               GVariant *v_values = NULL;
+               GVariantBuilder *values_builder = NULL;
+               int i = 0, j = 0;
+
+               v_attrs = g_variant_new_from_data(G_VARIANT_TYPE("aq"),
+                       attr_t->attribute_list, (sizeof(gushort) * attr_t->list_count),
+                       TRUE, NULL, NULL);
+               v_data_type = g_variant_new_from_data(G_VARIANT_TYPE("a(y)"),
+                       attr_t->data_type_list, attr_t->list_count, TRUE, NULL, NULL);
+               if (NULL == v_data_type || NULL == v_attrs) {
+                       Z_LOGE("Failed to create variant!");
+                       if (v_data_type)
+                               g_variant_unref(v_data_type);
+                       if (v_attrs)
+                               g_variant_unref(v_attrs);
+                       break;
+               }
+
+               values_builder = g_variant_builder_new (G_VARIANT_TYPE ("a(y)"));
+               if (NULL == values_builder) {
+                       Z_LOGE("Failed to create variant builder!");
+                       g_variant_unref(v_data_type);
+                       g_variant_unref(v_attrs);
+                       break;
+               }
+               for(i = 0; i < attr_t->list_count; i++) {
+                       for(j = 0; j < attr_t->values_count[i]; j++) {
+                               g_variant_builder_add (values_builder, "(y)", attr_t->values[i][j]);
+                       }
+               }
+               v_values = g_variant_builder_end (values_builder);
+               g_variant_builder_unref(values_builder);
+               if (NULL == values_builder) {
+                       Z_LOGE("Failed to create variant!");
+                       g_variant_unref(v_data_type);
+                       g_variant_unref(v_attrs);
+                       break;
+               }
+
+               Z_LOGD("Report attributes handler resp");
+               zigbee_zcl_global_control_emit_report_attr_handler_rsp(
+                       global_control_object,
+                       attr_t->node_id, attr_t->src_ep, attr_t->cluster_id,
+                       v_attrs, v_data_type, v_values,
+                       attr_t->list_count);
+       break;
+       }
+       case ZBLIB_ZCL_GLOBAL_NOTI_READ_CONFIG_REPORT_RSP: {
+               ZigbeeZclGlobalControlReadConfigureReportingResp_t *resp_t =
+                       (ZigbeeZclGlobalControlReadConfigureReportingResp_t *)noti_data;
+               int i = 0;
+               int v = 0;
+
+               GVariant *v_entries = NULL;
+               GVariantBuilder *entry_builder =
+                               g_variant_builder_new (G_VARIANT_TYPE ("a(yyqyqqayq)"));
+               if (NULL == entry_builder) {
+                       Z_LOGE("Failed to create variant builder!");
+                       break;
+               }
+
+               for(i = 0; i < resp_t->record_count ; i++) {
+                       GVariantBuilder *change_builder =
+                                       g_variant_builder_new (G_VARIANT_TYPE ("ay"));
+                       if (NULL == change_builder) {
+                               Z_LOGE("Failed to create variant builder!");
+                               g_variant_builder_unref(entry_builder);
+                               break;
+                       }
+
+                       for (v = 0; v < resp_t->entry_list[i].change_count; v++) {
+                               g_variant_builder_add (change_builder, "y",
+                                       resp_t->entry_list[i].change[v]);
+                       }
+
+                       g_variant_builder_add (entry_builder, "(yyqyqqayq)",
+                               resp_t->entry_list[i].status,
+                               resp_t->entry_list[i].dir,
+                               resp_t->entry_list[i].attribute_id,
+                               resp_t->entry_list[i].data_type,
+                               resp_t->entry_list[i].min_interval,
+                               resp_t->entry_list[i].max_interval,
+                               change_builder,
+                               resp_t->entry_list[i].change_count,
+                               resp_t->entry_list[i].timeout);
+
+                       g_variant_builder_unref(change_builder);
+               }
+               v_entries = g_variant_builder_end(entry_builder);
+               g_variant_builder_unref(entry_builder);
+
+               Z_LOGD("Read configure reporting resp");
+               zigbee_zcl_global_control_emit_read_configure_reporting_rsp(
+                       global_control_object, resp_t->cluster_id, resp_t->node_id,
+                       resp_t->record_count, resp_t->src_ep, v_entries);
+       break;
+       }
+       default:
+               Z_LOGE("Unexpected notification [%x]", noti_id);
+       break;
+       }
+
+       /* ZigbeeZcl_global_control should be dereferenced */
+       g_object_unref(global_control_object);
 }
 
 gboolean zigbee_service_dbus_interface_zcl_global_control_init(ZigBeeServiceInterface *service_interface,
index 280cd70..d3ebcd2 100644 (file)
@@ -1585,7 +1585,8 @@ void zigbee_service_dbus_interface_zdo_dev_control_notification(ZigBeeServiceInt
                v_eui64 = g_variant_new_from_data(G_VARIANT_TYPE("a(y)"),
                        nwk_addr_t->eui64, ZIGBEE_EUI64_SIZE, TRUE, NULL, NULL);
                v_associated = g_variant_new_from_data(G_VARIANT_TYPE("aq"),
-                       nwk_addr_t->associated_addr_list, nwk_addr_t->associated_count, TRUE, NULL, NULL);
+                       nwk_addr_t->associated_addr_list,
+                       (sizeof(gushort) * nwk_addr_t->associated_count), TRUE, NULL, NULL);
                if (NULL == v_eui64 || NULL == v_associated) {
                        Z_LOGE("Failed to create variant!");
                        if (v_eui64)
index 6a7973f..470157d 100644 (file)
@@ -51,6 +51,21 @@ typedef enum {
        ZBLIB_ZCL_GLOBAL_CONTROL_OPS_DISCOVER_COMMANDS_GENERATED, /**< Discover commands generated */
 } ZblibZclGlobalControlOps_e;
 
+/**< ZigBee 'ZCL global control' notification IDs */
+typedef enum {
+       ZBLIB_ZCL_GLOBAL_NOTI_READ_ATTR_RSP = 1, /**< Read attributes response */
+       ZBLIB_ZCL_GLOBAL_NOTI_WRITE_ATTR_RSP, /**< Write attributes response */
+       ZBLIB_ZCL_GLOBAL_NOTI_CONFIG_REPORT_RSP, /**< Configure reporting response */
+       ZBLIB_ZCL_GLOBAL_NOTI_DISCOVER_ATTR_RSP, /**< Discover attributes response */
+       ZBLIB_ZCL_GLOBAL_NOTI_WRITE_ATTR_STRUCTURED_RSP, /**< Write attributes structured response */
+       ZBLIB_ZCL_GLOBAL_NOTI_DISCOVER_CMDS_RECEIVED_RSP, /**< Discover commands received response */
+       ZBLIB_ZCL_GLOBAL_NOTI_DISCOVER_CMDS_GENERATED_RSP, /**< Discover commands generated response */
+       ZBLIB_ZCL_GLOBAL_NOTI_DISCOVER_ATTR_EXT_RSP, /**< Discover attributes extended response */
+       ZBLIB_ZCL_GLOBAL_NOTI_DEFAULT_RSP, /**< ZCL Global default response */
+       ZBLIB_ZCL_GLOBAL_NOTI_REPORT_ATTR_HANDLER_RSP, /**< Report attribute handler response */
+       ZBLIB_ZCL_GLOBAL_NOTI_READ_CONFIG_REPORT_RSP /**< Read configure reporting response */
+} ZblibZclGlobalControlNoti_e;
+
 /* ZigBee 'ZCL global control' driver APIs */
 ZigBeeDriver *zblib_driver_zcl_global_control_new(ZigBeePlugin *plugin,
        const gchar *driver_name,
index 20d7fbd..e4e186a 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <zblib.h>
 #include <zblib_driver.h>
+#include <zblib_plugin.h>
 #include <zblib_request.h>
 
 #include "zblib_driver_zcl_global_control.h"
@@ -177,6 +178,7 @@ ZigBeeDriver *zblib_driver_zcl_global_control_new(ZigBeePlugin *plugin,
        const gchar *driver_name,
        ZblibDriverZclGlobalControlOps_t *ops)
 {
+       ZigBeeService *service = NULL;
        ZigBeeDriver *driver = NULL;
        ZblibDriverZclglobalControlPrivData_t *priv_data = NULL;
        gboolean ret;
@@ -193,6 +195,19 @@ ZigBeeDriver *zblib_driver_zcl_global_control_new(ZigBeePlugin *plugin,
        /* Update private data */
        priv_data->ops = ops;
 
+       /* Link service to driver */
+       service = zblib_plugin_ref_service(plugin);
+       if (NULL == service) {
+               Z_LOGE("zblib_plugin_ref_service failed!");
+
+               /* Free allocated resources */
+               g_free(priv_data);
+               g_free(driver);
+
+               return NULL;
+       }
+       zblib_driver_link_service(driver, service);
+
        /* Link private data to driver */
        ret = zblib_driver_link_object(driver, priv_data);
        if (FALSE == ret) {
index 21b78a3..9dd8e7d 100644 (file)
@@ -1489,7 +1489,7 @@ static gpointer __zblib_request_create_zcl_global_control_request_data(guint req
                                g_malloc0(sizeof(ZigbeeZclGlobalControlReadAttributesRequest_t));
 
                        /* Copy data */
-                       req->attribute_id = g_strdup(in_req->attribute_id);
+                       req->attribute_id = g_memdup(in_req->attribute_id, in_req->attribute_id_len);
                        req->attribute_id_len = in_req->attribute_id_len;
                        req->node_id = in_req->node_id;
                        req->cluster_id = in_req->cluster_id;
@@ -1512,7 +1512,7 @@ static gpointer __zblib_request_create_zcl_global_control_request_data(guint req
                                g_malloc0(sizeof(ZigbeeZclGlobalControlWriteAttributesRequest_t));
 
                        /* Copy data */
-                       req->write_records = g_strdup(in_req->write_records);
+                       req->write_records = g_memdup(in_req->write_records, in_req->records_len);
                        req->records_len = in_req->records_len;
                        req->node_id = in_req->node_id;
                        req->cluster_id = in_req->cluster_id;
@@ -1536,7 +1536,7 @@ static gpointer __zblib_request_create_zcl_global_control_request_data(guint req
                                g_malloc0(sizeof(ZigbeeZclGlobalControlWriteAttributesUndividedRequest_t));
 
                        /* Copy data */
-                       req->write_records = g_strdup(in_req->write_records);
+                       req->write_records = g_memdup(in_req->write_records, in_req->records_len);
                        req->records_len = in_req->records_len;
                        req->node_id = in_req->node_id;
                        req->cluster_id = in_req->cluster_id;
@@ -1560,7 +1560,7 @@ static gpointer __zblib_request_create_zcl_global_control_request_data(guint req
                                g_malloc0(sizeof(ZigbeeZclGlobalControlWriteAttributesNoResponse_t));
 
                        /* Copy data */
-                       req->write_records = g_strdup(in_req->write_records);
+                       req->write_records = g_memdup(in_req->write_records, in_req->records_len);
                        req->records_len = in_req->records_len;
                        req->node_id = in_req->node_id;
                        req->cluster_id = in_req->cluster_id;
@@ -1584,7 +1584,7 @@ static gpointer __zblib_request_create_zcl_global_control_request_data(guint req
                                g_malloc0(sizeof(ZigbeeZclGlobalControlWriteAttributesStructed_t));
 
                        /* Copy data */
-                       req->write_records = g_strdup(in_req->write_records);
+                       req->write_records = g_memdup(in_req->write_records, in_req->records_len);
                        req->records_len = in_req->records_len;
                        req->node_id = in_req->node_id;
                        req->cluster_id = in_req->cluster_id;
@@ -1608,7 +1608,7 @@ static gpointer __zblib_request_create_zcl_global_control_request_data(guint req
                                g_malloc0(sizeof(ZigbeeZclGlobalControlReadAttributesStructed_t));
 
                        /* Copy data */
-                       req->read_records = g_strdup(in_req->read_records);
+                       req->read_records = g_memdup(in_req->read_records, in_req->records_len);
                        req->records_len = in_req->records_len;
                        req->node_id = in_req->node_id;
                        req->cluster_id = in_req->cluster_id;
@@ -1632,7 +1632,7 @@ static gpointer __zblib_request_create_zcl_global_control_request_data(guint req
                                g_malloc0(sizeof(ZigbeeZclGlobalControlConfigureReportingReq_t));
 
                        /* Copy data */
-                       req->read_records = g_strdup(in_req->read_records);
+                       req->read_records = g_memdup(in_req->read_records, in_req->records_len);
                        req->records_len = in_req->records_len;
                        req->node_id = in_req->node_id;
                        req->cluster_id = in_req->cluster_id;
@@ -1656,7 +1656,7 @@ static gpointer __zblib_request_create_zcl_global_control_request_data(guint req
                                g_malloc0(sizeof(ZigbeeZclGlobalControlReadConfigureReporting_t));
 
                        /* Copy data */
-                       req->read_records = g_strdup(in_req->read_records);
+                       req->read_records = g_memdup(in_req->read_records, in_req->records_len);
                        req->records_len = in_req->records_len;
                        req->node_id = in_req->node_id;
                        req->cluster_id = in_req->cluster_id;
@@ -1685,7 +1685,7 @@ static gpointer __zblib_request_create_zcl_global_control_request_data(guint req
                        req->zcl_frame_ctrl = in_req->zcl_frame_ctrl;
                        req->cluster_id = in_req->cluster_id;
                        req->start_attribute = in_req->start_attribute;
-                       req->max = in_req->max;
+                       req->max_attribute_count = in_req->max_attribute_count;
                }
 
                zclglobal_control_request_data = (gpointer)req;
@@ -1708,7 +1708,7 @@ static gpointer __zblib_request_create_zcl_global_control_request_data(guint req
                        req->zcl_frame_ctrl = in_req->zcl_frame_ctrl;
                        req->cluster_id = in_req->cluster_id;
                        req->start_attribute = in_req->start_attribute;
-                       req->max = in_req->max;
+                       req->max_attribute_count = in_req->max_attribute_count;
                }
 
                zclglobal_control_request_data = (gpointer)req;
@@ -1730,8 +1730,8 @@ static gpointer __zblib_request_create_zcl_global_control_request_data(guint req
                        req->dest_ep = in_req->dest_ep;
                        req->zcl_frame_ctrl = in_req->zcl_frame_ctrl;
                        req->cluster_id = in_req->cluster_id;
-                       req->start_attribute = in_req->start_attribute;
-                       req->max = in_req->max;
+                       req->start_command = in_req->start_command;
+                       req->max_command_count = in_req->max_command_count;
                }
 
                zclglobal_control_request_data = (gpointer)req;
@@ -1753,8 +1753,8 @@ static gpointer __zblib_request_create_zcl_global_control_request_data(guint req
                        req->dest_ep = in_req->dest_ep;
                        req->zcl_frame_ctrl = in_req->zcl_frame_ctrl;
                        req->cluster_id = in_req->cluster_id;
-                       req->start_attribute = in_req->start_attribute;
-                       req->max = in_req->max;
+                       req->start_command = in_req->start_command;
+                       req->max_command_count = in_req->max_command_count;
                }
 
                zclglobal_control_request_data = (gpointer)req;