#include <zigbee_types.h>
+/* --------------------------------------------------------------------------------------
+ * For Request
+ * -------------------------------------------------------------------------------------*/
+
/**
* @brief Definition for ZCL IAS zone enroll response structure.
* @since_tizen 3.0
char zone_id; /**< Zone ID */
} ZigbeeZclIasZoneEnrollResponse_t;
+/* --------------------------------------------------------------------------------------
+ * For Notifications
+ * -------------------------------------------------------------------------------------*/
+
+/**
+ * @brief Definition for ZCL IAS zone status change notification structure.
+ * @since_tizen 3.0
+ */
+typedef struct {
+ short node_id; /**< Node ID */
+ char src_ep; /**< Source endpoint */
+ short zone_status; /**< Zone status */
+ char extended_status; /**< Extended status */
+ char zone_id; /**< Zone ID */
+ short delay; /**< Delay */
+} ZigbeeZclIasZoneStatusChangeNoti_t;
+
+/**
+ * @brief Definition for ZCL IAS zone enroll request notification structure.
+ * @since_tizen 3.0
+ */
+typedef struct {
+ short node_id; /**< Node ID */
+ char src_ep; /**< Source endpoint */
+ short zone_type; /**< Zone type */
+ char mfg_code; /**< Manufacturer code */
+} ZigbeeZclIasEnrollRequestNoti_t;
+
#endif /* __ZIGBEE_ZCL_IAS_ZONE_TYPE_H__ */
#include <zblib_driver_zcl_ias_zone.h>
+static void *_service_interface_ref_zigbee_zcl_ias_zone(ZigBeeServiceInterface *service_interface)
+{
+ ZigbeeObjectSkeleton *zigbee_object = NULL;
+ ZigbeeCustomData_t *custom_data = NULL;
+ ZigbeeZcl_ias_zone *ias_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;
+ }
+
+ ias_object = zigbee_object_get_zcl_ias_zone(ZIGBEE_OBJECT(zigbee_object));
+ return ias_object;
+}
+
static void on_zclias_control_enroll_response_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_ias_zone *ias_object = NULL;
+ GDBusMethodInvocation *invocation = NULL;
+
+ 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;
+ }
+
+ ias_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
+ zblib_check_null_free_and_ret("ias_object", ias_object, cb_data);
+
+ invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
+ zblib_check_null_free_and_ret("invocation", invocation, cb_data);
+
+ zigbee_zcl_ias_zone_complete_enroll_response(ias_object, invocation, payload->result);
+
+ g_free(cb_data);
}
static gboolean on_zclias_control_enroll_response(ZigbeeZcl_ias_zone *zclias_control_object,
void zigbee_service_dbus_interface_zcl_ias_zone_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_ias_zone *ias_object;
+
+ zblib_check_null_ret("service_interface", service_interface);
+
+ if (NULL == noti_data || 0 == noti_data_len) {
+ Z_LOGE("noti_data=%p or noti_data_len=%d is null", noti_data, noti_data_len);
return;
}
- NOT_USED(noti_id);
- NOT_USED(noti_data);
- NOT_USED(noti_data_len);
+ ias_object = _service_interface_ref_zigbee_zcl_ias_zone(service_interface);
+ zblib_check_null_ret("ias_object", ias_object);
+
NOT_USED(noti_cb_data);
+
+ switch(noti_id) {
+ case ZBLIB_ZCL_IAS_ZONE_NOTI_ZONE_STATUS_CHANGE_NOTI: {
+ ZigbeeZclIasZoneStatusChangeNoti_t *rsp =
+ (ZigbeeZclIasZoneStatusChangeNoti_t*)noti_data;
+
+ Z_LOGD("status_change_rsp from : [0x%X]", rsp->node_id);
+
+ zigbee_zcl_ias_zone_emit_status_change_rsp(ias_object, rsp->node_id, rsp->src_ep,
+ rsp->zone_status, rsp->extended_status, rsp->zone_id, rsp->delay);
+ }
+ break;
+ case ZBLIB_ZCL_IAS_ZONE_NOTI_ENROLL_REQUEST: {
+ ZigbeeZclIasEnrollRequestNoti_t *rsp =
+ (ZigbeeZclIasEnrollRequestNoti_t*)noti_data;
+
+ Z_LOGD("enroll_request from : [0x%X]", rsp->node_id);
+
+ zigbee_zcl_ias_zone_emit_enroll_request(ias_object, rsp->node_id, rsp->src_ep,
+ rsp->zone_type, rsp->mfg_code);
+ }
+ break;
+ default:
+ Z_LOGE("Unexpected notification [%x]", noti_id);
+ break;
+ }
+
+ /* ZigbeeZcl_ias_zone should be dereferenced */
+ g_object_unref(ias_object);
}
gboolean zigbee_service_dbus_interface_zcl_ias_zone_init(ZigBeeServiceInterface *service_interface,
#include <zblib.h>
#include <zblib_driver.h>
+#include <zblib_plugin.h>
#include <zblib_request.h>
#include "zblib_driver_zcl_ias_zone.h"
ZblibDriverZclIasZoneOps_t *ops)
{
ZigBeeDriver *driver = NULL;
+ ZigBeeService *service = NULL;
ZblibDriverZclIasZonePrivData_t *priv_data = NULL;
gboolean ret;
/* 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) {