#include "zigbee_service_interface_common.h"
+#include <zblib_driver_service.h>
+
+static void *_service_interface_ref_zigbee_service(ZigBeeServiceInterface *service_interface)
+{
+ ZigbeeObjectSkeleton *zigbee_object;
+ ZigbeeCustomData_t *custom_data = NULL;
+ ZigbeeService *service = 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 (zigbee_object) {
+ Z_LOGW("Cannot find ZigBee D-BUS interface object!", zigbee_object);
+ return NULL;
+ }
+
+ service = zigbee_object_get_service(ZIGBEE_OBJECT(zigbee_object));
+ return service;
+}
+
+static void on_service_enable_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;
+
+ ZigbeeService *service_object;
+ GDBusMethodInvocation *invocation;
+
+ NOT_USED(service_interface);
+ NOT_USED(request_id);
+ NOT_USED(resp_data);
+ NOT_USED(resp_data_len);
+
+ service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
+ zblib_check_null_ret("service_object", service_object);
+
+ invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
+ zblib_check_null_ret("invocation", invocation);
+
+ zigbee_service_complete_enable(service_object, invocation, TRUE);
+
+ g_free(cb_data);
+}
+
static gboolean on_service_enable(ZigbeeService *service_object,
GDBusMethodInvocation *invocation,
gpointer user_data)
{
- ZigBeeService *service = (ZigBeeService *)user_data;
+ ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
+ ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
- NOT_USED(service_object);
- NOT_USED(invocation);
- NOT_USED(service);
+ gboolean ret;
- /*
- * TODO -
- * Create and send request for processing
- */
+ Z_LOGE("KSR");
+
+ /* Allocate response callback data */
+ resp_cb_data =
+ zigbee_service_dbus_interface_create_resp_cb_data(service_object,
+ invocation, NULL, 0);
+ if (NULL == resp_cb_data) {
+ Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
+
+ /* Send failure response */
+ ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
+
+ return TRUE;
+ }
+
+ /* Dispatch request */
+ ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
+ ZBLIB_DRIVER_TYPE_SERVICE,
+ ZBLIB_SERVICE_OPS_ENABLE,
+ NULL, 0,
+ on_service_enable_resp, resp_cb_data);
+ if (FALSE == ret) {
+ Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
+
+ /* Free response callback data */
+ zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
+
+ /* Send failure response */
+ ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
+
+ return TRUE;
+ }
return TRUE;
}
+static void on_service_disable_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;
+
+ ZigbeeService *service_object;
+ GDBusMethodInvocation *invocation;
+
+ NOT_USED(service_interface);
+ NOT_USED(request_id);
+ NOT_USED(resp_data);
+ NOT_USED(resp_data_len);
+
+ service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
+ zblib_check_null_ret("service_object", service_object);
+
+ invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
+ zblib_check_null_ret("invocation", invocation);
+
+ zigbee_service_complete_disable(service_object, invocation);
+
+ g_free(cb_data);
+}
+
static gboolean on_service_disable(ZigbeeService *service_object,
GDBusMethodInvocation *invocation,
gpointer user_data)
{
- ZigBeeService *service = (ZigBeeService *)user_data;
+ ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
+ ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
- NOT_USED(service_object);
- NOT_USED(invocation);
- NOT_USED(service);
+ gboolean ret;
- /*
- * TODO -
- * Create and send request for processing
- */
+ /* Allocate response callback data */
+ resp_cb_data =
+ zigbee_service_dbus_interface_create_resp_cb_data(service_object,
+ invocation, NULL, 0);
+ if (NULL == resp_cb_data) {
+ Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
+
+ /* Send failure response */
+ ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
+
+ return TRUE;
+ }
+
+ /* Dispatch request */
+ ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
+ ZBLIB_DRIVER_TYPE_SERVICE,
+ ZBLIB_SERVICE_OPS_DISABLE,
+ NULL, 0,
+ on_service_disable_resp, resp_cb_data);
+ if (FALSE == ret) {
+ Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
+
+ /* Free response callback data */
+ zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
+
+ /* Send failure response */
+ ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
+
+ return TRUE;
+ }
return TRUE;
}
+static void on_service_zb_hw_reset_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;
+
+ ZigbeeService *service_object;
+ GDBusMethodInvocation *invocation;
+
+ NOT_USED(service_interface);
+ NOT_USED(request_id);
+ NOT_USED(resp_data);
+ NOT_USED(resp_data_len);
+
+ service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
+ zblib_check_null_ret("service_object", service_object);
+
+ invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
+ zblib_check_null_ret("invocation", invocation);
+
+ zigbee_service_complete_zb_hw_reset(service_object, invocation);
+
+ g_free(cb_data);
+}
+
static gboolean on_service_zb_hw_reset(ZigbeeService *service_object,
GDBusMethodInvocation *invocation,
gpointer user_data)
{
- ZigBeeService *service = (ZigBeeService *)user_data;
+ ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
+ ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
- NOT_USED(service_object);
- NOT_USED(invocation);
- NOT_USED(service);
+ gboolean ret;
- /*
- * TODO -
- * Create and send request for processing
- */
+ /* Allocate response callback data */
+ resp_cb_data =
+ zigbee_service_dbus_interface_create_resp_cb_data(service_object,
+ invocation, NULL, 0);
+ if (NULL == resp_cb_data) {
+ Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
+
+ /* Send failure response */
+ ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
+
+ return TRUE;
+ }
+
+ /* Dispatch request */
+ ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
+ ZBLIB_DRIVER_TYPE_SERVICE,
+ ZBLIB_SERVICE_OPS_ZB_HW_RESET,
+ NULL, 0,
+ on_service_zb_hw_reset_resp, resp_cb_data);
+ if (FALSE == ret) {
+ Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
+
+ /* Free response callback data */
+ zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
+
+ /* Send failure response */
+ ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
+
+ return TRUE;
+ }
return TRUE;
}
+static void on_service_form_network_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;
+
+ ZigbeeService *service_object;
+ GDBusMethodInvocation *invocation;
+
+ NOT_USED(service_interface);
+ NOT_USED(request_id);
+ NOT_USED(resp_data);
+ NOT_USED(resp_data_len);
+
+ service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
+ zblib_check_null_ret("service_object", service_object);
+
+ invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
+ zblib_check_null_ret("invocation", invocation);
+
+ zigbee_service_complete_form_network(service_object, invocation);
+
+ g_free(cb_data);
+}
+
static gboolean on_service_form_network(ZigbeeService *service_object,
GDBusMethodInvocation *invocation,
gpointer user_data)
{
- ZigBeeService *service = (ZigBeeService *)user_data;
+ ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
+ ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
- NOT_USED(service_object);
- NOT_USED(invocation);
- NOT_USED(service);
+ gboolean ret;
- /*
- * TODO -
- * Create and send request for processing
- */
+ /* Allocate response callback data */
+ resp_cb_data =
+ zigbee_service_dbus_interface_create_resp_cb_data(service_object,
+ invocation, NULL, 0);
+ if (NULL == resp_cb_data) {
+ Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
+
+ /* Send failure response */
+ ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
+
+ return TRUE;
+ }
+
+ /* Dispatch request */
+ ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
+ ZBLIB_DRIVER_TYPE_SERVICE,
+ ZBLIB_SERVICE_OPS_FORM_NETWORK,
+ NULL, 0,
+ on_service_form_network_resp, resp_cb_data);
+ if (FALSE == ret) {
+ Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
+
+ /* Free response callback data */
+ zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
+
+ /* Send failure response */
+ ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
+
+ return TRUE;
+ }
return TRUE;
}
+static void on_service_coex_start_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;
+
+ ZigbeeService *service_object;
+ GDBusMethodInvocation *invocation;
+
+ NOT_USED(service_interface);
+ NOT_USED(request_id);
+ NOT_USED(resp_data);
+ NOT_USED(resp_data_len);
+
+ service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
+ zblib_check_null_ret("service_object", service_object);
+
+ invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
+ zblib_check_null_ret("invocation", invocation);
+
+ zigbee_service_complete_coex_start(service_object, invocation);
+
+ g_free(cb_data);
+}
+
static gboolean on_service_coex_start(ZigbeeService *service_object,
GDBusMethodInvocation *invocation,
gchar channel,
gpointer user_data)
{
- ZigBeeService *service = (ZigBeeService *)user_data;
+ ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
+ ZigbeeServiceCoexStart_t req;
+ ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
- NOT_USED(service_object);
- NOT_USED(invocation);
- NOT_USED(service);
- NOT_USED(channel);
+ gboolean ret;
- /*
- * TODO -
- * Create and send request for processing
- */
+ memset(&req, 0x0, sizeof(ZigbeeServiceCoexStart_t));
+
+ /* Update request structure */
+ req.channel = channel;
+
+ /* Allocate response callback data */
+ resp_cb_data =
+ zigbee_service_dbus_interface_create_resp_cb_data(service_object,
+ invocation, NULL, 0);
+ if (NULL == resp_cb_data) {
+ Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
+
+ /* Send failure response */
+ ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
+
+ return TRUE;
+ }
+
+ /* Dispatch request */
+ ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
+ ZBLIB_DRIVER_TYPE_SERVICE,
+ ZBLIB_SERVICE_OPS_COEX_START,
+ &req, sizeof(req),
+ on_service_coex_start_resp, resp_cb_data);
+ if (FALSE == ret) {
+ Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
+
+ /* Free response callback data */
+ zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
+
+ /* Send failure response */
+ ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
+
+ return TRUE;
+ }
return TRUE;
}
+static void on_service_coex_stop_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;
+
+ ZigbeeService *service_object;
+ GDBusMethodInvocation *invocation;
+
+ NOT_USED(service_interface);
+ NOT_USED(request_id);
+ NOT_USED(resp_data);
+ NOT_USED(resp_data_len);
+
+ service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
+ zblib_check_null_ret("service_object", service_object);
+
+ invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
+ zblib_check_null_ret("invocation", invocation);
+
+ zigbee_service_complete_coex_stop(service_object, invocation);
+
+ g_free(cb_data);
+}
+
static gboolean on_service_coex_stop(ZigbeeService *service_object,
GDBusMethodInvocation *invocation,
gpointer user_data)
{
- ZigBeeService *service = (ZigBeeService *)user_data;
+ ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
+ ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
- NOT_USED(service_object);
- NOT_USED(invocation);
- NOT_USED(service);
+ gboolean ret;
- /*
- * TODO -
- * Create and send request for processing
- */
+ /* Allocate response callback data */
+ resp_cb_data =
+ zigbee_service_dbus_interface_create_resp_cb_data(service_object,
+ invocation, NULL, 0);
+ if (NULL == resp_cb_data) {
+ Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
+
+ /* Send failure response */
+ ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
+
+ return TRUE;
+ }
+
+ /* Dispatch request */
+ ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
+ ZBLIB_DRIVER_TYPE_SERVICE,
+ ZBLIB_SERVICE_OPS_COEX_STOP,
+ NULL, 0,
+ on_service_coex_stop_resp, resp_cb_data);
+ if (FALSE == ret) {
+ Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
+
+ /* Free response callback data */
+ zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
+
+ /* Send failure response */
+ ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
+
+ return TRUE;
+ }
return TRUE;
}
+static void on_service_leave_network_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;
+
+ ZigbeeService *service_object;
+ GDBusMethodInvocation *invocation;
+
+ NOT_USED(service_interface);
+ NOT_USED(request_id);
+ NOT_USED(resp_data);
+ NOT_USED(resp_data_len);
+
+ service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
+ zblib_check_null_ret("service_object", service_object);
+
+ invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
+ zblib_check_null_ret("invocation", invocation);
+
+ zigbee_service_complete_leave_network(service_object, invocation);
+
+ g_free(cb_data);
+}
+
static gboolean on_service_leave_network(ZigbeeService *service_object,
GDBusMethodInvocation *invocation,
gpointer user_data)
{
- ZigBeeService *service = (ZigBeeService *)user_data;
+ ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
+ ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
- NOT_USED(service_object);
- NOT_USED(invocation);
- NOT_USED(service);
+ gboolean ret;
- /*
- * TODO -
- * Create and send request for processing
- */
+ /* Allocate response callback data */
+ resp_cb_data =
+ zigbee_service_dbus_interface_create_resp_cb_data(service_object,
+ invocation, NULL, 0);
+ if (NULL == resp_cb_data) {
+ Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
+
+ /* Send failure response */
+ ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
+
+ return TRUE;
+ }
+
+ /* Dispatch request */
+ ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
+ ZBLIB_DRIVER_TYPE_SERVICE,
+ ZBLIB_SERVICE_OPS_LEAVE_NETWORK,
+ NULL, 0,
+ on_service_leave_network_resp, resp_cb_data);
+ if (FALSE == ret) {
+ Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
+
+ /* Free response callback data */
+ zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
+
+ /* Send failure response */
+ ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
+
+ return TRUE;
+ }
return TRUE;
}
+static void on_service_get_network_info_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;
+
+ ZigbeeService *service_object;
+ GDBusMethodInvocation *invocation;
+
+ ZigbeeServiceGetNetworkInfo_t payload;
+
+ NOT_USED(service_interface);
+ NOT_USED(request_id);
+ NOT_USED(resp_data);
+ NOT_USED(resp_data_len);
+
+ service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
+ zblib_check_null_ret("service_object", service_object);
+
+ invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
+ zblib_check_null_ret("invocation", invocation);
+
+ memcpy(&payload, resp_data, resp_data_len);
+ zigbee_service_complete_get_network_info(service_object, invocation,
+ payload.eui64, payload.node_id, payload.pan_id, payload.channel,
+ payload.radio_tx_power);
+
+ g_free(cb_data);
+}
+
static gboolean on_service_get_network_info(ZigbeeService *service_object,
GDBusMethodInvocation *invocation,
gpointer user_data)
{
- ZigBeeService *service = (ZigBeeService *)user_data;
+ ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
+ ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
- NOT_USED(service_object);
- NOT_USED(invocation);
- NOT_USED(service);
+ gboolean ret;
- /*
- * TODO -
- * Create and send request for processing
- */
+ /* Allocate response callback data */
+ resp_cb_data =
+ zigbee_service_dbus_interface_create_resp_cb_data(service_object,
+ invocation, NULL, 0);
+ if (NULL == resp_cb_data) {
+ Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
+
+ /* Send failure response */
+ ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
+
+ return TRUE;
+ }
+
+ /* Dispatch request */
+ ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
+ ZBLIB_DRIVER_TYPE_SERVICE,
+ ZBLIB_SERVICE_OPS_GET_NETWORK_INFO,
+ NULL, 0,
+ on_service_get_network_info_resp, resp_cb_data);
+ if (FALSE == ret) {
+ Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
+
+ /* Free response callback data */
+ zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
+
+ /* Send failure response */
+ ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
+
+ return TRUE;
+ }
return TRUE;
}
+static void on_service_permit_join_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;
+
+ ZigbeeService *service_object;
+ GDBusMethodInvocation *invocation;
+
+ NOT_USED(service_interface);
+ NOT_USED(request_id);
+ NOT_USED(resp_data);
+ NOT_USED(resp_data_len);
+
+ service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
+ zblib_check_null_ret("service_object", service_object);
+
+ invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
+ zblib_check_null_ret("invocation", invocation);
+
+ zigbee_service_complete_permit_join(service_object, invocation);
+
+ g_free(cb_data);
+}
+
static gboolean on_service_permit_join(ZigbeeService *service_object,
GDBusMethodInvocation *invocation,
gint duration,
- gboolean broadcast_mgmt_permit_join,
+ gboolean permit_join,
gpointer user_data)
{
- ZigBeeService *service = (ZigBeeService *)user_data;
+ ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
+ ZigbeeServicePermitJoin_t req;
+ ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
- NOT_USED(service_object);
- NOT_USED(invocation);
- NOT_USED(service);
- NOT_USED(duration);
- NOT_USED(broadcast_mgmt_permit_join);
+ gboolean ret;
- /*
- * TODO -
- * Create and send request for processing
- */
+ memset(&req, 0x0, sizeof(ZigbeeServicePermitJoin_t));
+
+ /* Update request structure */
+ req.duration = duration;
+ req.permit_join = permit_join;
+
+ /* Allocate response callback data */
+ resp_cb_data =
+ zigbee_service_dbus_interface_create_resp_cb_data(service_object,
+ invocation, NULL, 0);
+ if (NULL == resp_cb_data) {
+ Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
+
+ /* Send failure response */
+ ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
+
+ return TRUE;
+ }
+
+ /* Dispatch request */
+ ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
+ ZBLIB_DRIVER_TYPE_SERVICE,
+ ZBLIB_SERVICE_OPS_PERMIT_JOIN,
+ &req, sizeof(req),
+ on_service_permit_join_resp, resp_cb_data);
+ if (FALSE == ret) {
+ Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
+
+ /* Free response callback data */
+ zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
+
+ /* Send failure response */
+ ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
+
+ return TRUE;
+ }
return TRUE;
}
+static void on_service_leave_request_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;
+
+ ZigbeeService *service_object;
+ GDBusMethodInvocation *invocation;
+
+ NOT_USED(service_interface);
+ NOT_USED(request_id);
+ NOT_USED(resp_data);
+ NOT_USED(resp_data_len);
+
+ service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
+ zblib_check_null_ret("service_object", service_object);
+
+ invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
+ zblib_check_null_ret("invocation", invocation);
+
+ zigbee_service_complete_leave_request(service_object, invocation);
+
+ g_free(cb_data);
+}
+
static gboolean on_service_leave_request(ZigbeeService *service_object,
GDBusMethodInvocation *invocation,
GVariant *eui64,
gchar rejoin,
gpointer user_data)
{
- ZigBeeService *service = (ZigBeeService *)user_data;
+ ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
+ ZigbeeServiceLeaveRequest_t req;
+ ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
- NOT_USED(service_object);
- NOT_USED(invocation);
- NOT_USED(service);
- NOT_USED(eui64);
- NOT_USED(remove_child);
- NOT_USED(rejoin);
+ GVariantIter *iter = NULL;
+ guint i = 0;
- /*
- * TODO -
- * Create and send request for processing
- */
+ gboolean ret;
+
+ memset(&req, 0x0, sizeof(ZigbeeServiceLeaveRequest_t));
+
+ /* Update request structure */
+ g_variant_get(eui64, "ay", &iter);
+ while (g_variant_iter_loop(iter, "y", req.eui64[i])) {
+ i++;
+ if (i >= ZIGBEE_EUI64_SIZE)
+ break;
+ }
+ req.remove_child = remove_child;
+ req.rejoin = rejoin;
+
+ /* Allocate response callback data */
+ resp_cb_data =
+ zigbee_service_dbus_interface_create_resp_cb_data(service_object,
+ invocation, NULL, 0);
+ if (NULL == resp_cb_data) {
+ Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
+
+ /* Send failure response */
+ ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
+
+ return TRUE;
+ }
+
+ /* Dispatch request */
+ ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
+ ZBLIB_DRIVER_TYPE_SERVICE,
+ ZBLIB_SERVICE_OPS_LEAVE_REQUEST,
+ &req, sizeof(req),
+ on_service_leave_request_resp, resp_cb_data);
+ if (FALSE == ret) {
+ Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
+
+ /* Free response callback data */
+ zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
+
+ /* Send failure response */
+ ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
+
+ return TRUE;
+ }
return TRUE;
}
+static void on_service_get_device_list_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;
+
+ ZigbeeService *service_object;
+ GDBusMethodInvocation *invocation;
+
+ NOT_USED(service_interface);
+ NOT_USED(request_id);
+
+ if (NULL == resp_data || 0 == resp_data_len) {
+ Z_LOGE("resp_data is null");
+ g_free(cb_data);
+ return;
+ }
+
+ service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
+ zblib_check_null_ret("service_object", service_object);
+
+ invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
+ zblib_check_null_ret("invocation", invocation);
+
+ zigbee_service_complete_get_device_list(service_object, invocation, resp_data);
+
+ g_free(cb_data);
+}
+
static gboolean on_service_get_device_list(ZigbeeService *service_object,
GDBusMethodInvocation *invocation,
gpointer user_data)
{
- ZigBeeService *service = (ZigBeeService *)user_data;
+ ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
+ ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
- NOT_USED(service_object);
- NOT_USED(invocation);
- NOT_USED(service);
+ gboolean ret;
- /*
- * TODO -
- * Create and send request for processing
- */
+ /* Allocate response callback data */
+ resp_cb_data =
+ zigbee_service_dbus_interface_create_resp_cb_data(service_object,
+ invocation, NULL, 0);
+ if (NULL == resp_cb_data) {
+ Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
+
+ /* Send failure response */
+ ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
+
+ return TRUE;
+ }
+
+ /* Dispatch request */
+ ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
+ ZBLIB_DRIVER_TYPE_SERVICE,
+ ZBLIB_SERVICE_OPS_GET_DEVICE_LIST,
+ NULL, 0,
+ on_service_get_device_list_resp, resp_cb_data);
+ if (FALSE == ret) {
+ Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
+
+ /* Free response callback data */
+ zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
+
+ /* Send failure response */
+ ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
+
+ return TRUE;
+ }
return TRUE;
}
+static void on_service_get_mac_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;
+
+ ZigbeeService *service_object;
+ GDBusMethodInvocation *invocation;
+
+ NOT_USED(cb_data);
+ NOT_USED(service_interface);
+ NOT_USED(request_id);
+
+ if (NULL == resp_data || 0 == resp_data_len) {
+ Z_LOGE("resp_data is null");
+ g_free(cb_data);
+ return;
+ }
+
+ service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
+ zblib_check_null_ret("service_object", service_object);
+
+ invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
+ zblib_check_null_ret("invocation", invocation);
+
+ /* Todo : plugin must load resp_data as char pointer */
+ zigbee_service_complete_get_mac(service_object, invocation, resp_data);
+
+ g_free(cb_data);
+
+}
+
static gboolean on_service_get_mac(ZigbeeService *service_object,
GDBusMethodInvocation *invocation,
gpointer user_data)
{
- ZigBeeService *service = (ZigBeeService *)user_data;
+ ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
+ ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
- NOT_USED(service_object);
- NOT_USED(invocation);
- NOT_USED(service);
+ gboolean ret;
- /*
- * TODO -
- * Create and send request for processing
- */
+ /* Allocate response callback data */
+ resp_cb_data =
+ zigbee_service_dbus_interface_create_resp_cb_data(service_object,
+ invocation, NULL, 0);
+ if (NULL == resp_cb_data) {
+ Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
+
+ /* Send failure response */
+ ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
+
+ return TRUE;
+ }
+
+ /* Dispatch request */
+ ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
+ ZBLIB_DRIVER_TYPE_SERVICE,
+ ZBLIB_SERVICE_OPS_GET_MAC,
+ NULL, 0,
+ on_service_get_mac_resp, resp_cb_data);
+ if (FALSE == ret) {
+ Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
+
+ /* Free response callback data */
+ zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
+
+ /* Send failure response */
+ ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
+
+ return TRUE;
+ }
return TRUE;
}
+static void on_service_get_device_info_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;
+
+ ZigbeeService *service_object;
+ GDBusMethodInvocation *invocation;
+
+ NOT_USED(cb_data);
+ NOT_USED(service_interface);
+ NOT_USED(request_id);
+
+ if (NULL == resp_data || 0 == resp_data_len) {
+ Z_LOGE("resp_data is null");
+ g_free(cb_data);
+ return;
+ }
+
+ service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
+ zblib_check_null_ret("service_object", service_object);
+
+ invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
+ zblib_check_null_ret("invocation", invocation);
+
+ zigbee_service_complete_get_device_info(service_object, invocation, resp_data);
+
+ g_free(cb_data);
+}
+
static gboolean on_service_get_device_info(ZigbeeService *service_object,
GDBusMethodInvocation *invocation,
gpointer user_data)
{
- ZigBeeService *service = (ZigBeeService *)user_data;
+ ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
+ ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
- NOT_USED(service_object);
- NOT_USED(invocation);
- NOT_USED(service);
+ gboolean ret;
- /*
- * TODO -
- * Create and send request for processing
- */
+ /* Allocate response callback data */
+ resp_cb_data =
+ zigbee_service_dbus_interface_create_resp_cb_data(service_object,
+ invocation, NULL, 0);
+ if (NULL == resp_cb_data) {
+ Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
+
+ /* Send failure response */
+ ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
+
+ return TRUE;
+ }
+
+ /* Dispatch request */
+ ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
+ ZBLIB_DRIVER_TYPE_SERVICE,
+ ZBLIB_SERVICE_OPS_GET_DEVICE_INFO,
+ NULL, 0,
+ on_service_get_device_info_resp, resp_cb_data);
+ if (FALSE == ret) {
+ Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
+
+ /* Free response callback data */
+ zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
+
+ /* Send failure response */
+ ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
+
+ return TRUE;
+ }
return TRUE;
}
+static void on_service_get_endpoint_list_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;
+
+ ZigbeeService *service_object;
+ GDBusMethodInvocation *invocation;
+
+ NOT_USED(cb_data);
+ NOT_USED(service_interface);
+ NOT_USED(request_id);
+
+ if (NULL == resp_data || 0 == resp_data_len) {
+ Z_LOGE("resp_data is null");
+ g_free(cb_data);
+ return;
+ }
+
+ service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
+ zblib_check_null_ret("service_object", service_object);
+
+ invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
+ zblib_check_null_ret("invocation", invocation);
+
+ /* To fix : end-points must be changed gchar* -> GVariant ay */
+ zigbee_service_complete_get_endpoint_list(service_object, invocation, resp_data);
+
+ g_free(cb_data);
+}
+
static gboolean on_service_get_endpoint_list(ZigbeeService *service_object,
GDBusMethodInvocation *invocation,
GVariant *eui64,
gpointer user_data)
{
- ZigBeeService *service = (ZigBeeService *)user_data;
+ ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
+ ZigbeeServiceGetEndpointList_t req;
+ ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
- NOT_USED(service_object);
- NOT_USED(invocation);
- NOT_USED(service);
- NOT_USED(eui64);
+ GVariantIter *iter = NULL;
+ guint i = 0;
- /*
- * TODO -
- * Create and send request for processing
- */
+ gboolean ret;
+
+ memset(&req, 0x0, sizeof(ZigbeeServiceGetEndpointList_t));
+
+ /* Update request structure */
+ g_variant_get(eui64, "ay", &iter);
+ while (g_variant_iter_loop(iter, "y", req.eui64[i])) {
+ i++;
+ if (i >= ZIGBEE_EUI64_SIZE)
+ break;
+ }
+
+ /* Allocate response callback data */
+ resp_cb_data =
+ zigbee_service_dbus_interface_create_resp_cb_data(service_object,
+ invocation, NULL, 0);
+ if (NULL == resp_cb_data) {
+ Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
+
+ /* Send failure response */
+ ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
+
+ return TRUE;
+ }
+
+ /* Dispatch request */
+ ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
+ ZBLIB_DRIVER_TYPE_SERVICE,
+ ZBLIB_SERVICE_OPS_GET_ENDPOINT_LIST,
+ &req, sizeof(req),
+ on_service_get_endpoint_list_resp, resp_cb_data);
+ if (FALSE == ret) {
+ Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
+
+ /* Free response callback data */
+ zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
+
+ /* Send failure response */
+ ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
+
+ return TRUE;
+ }
return TRUE;
}
+static void on_service_get_cluster_list_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;
+
+ ZigbeeService *service_object;
+ GDBusMethodInvocation *invocation;
+
+ NOT_USED(cb_data);
+ NOT_USED(service_interface);
+ NOT_USED(request_id);
+
+ if (NULL == resp_data || 0 == resp_data_len) {
+ Z_LOGE("resp_data is null");
+ g_free(cb_data);
+ return;
+ }
+
+ service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
+ zblib_check_null_ret("service_object", service_object);
+
+ invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
+ zblib_check_null_ret("invocation", invocation);
+
+ zigbee_service_complete_get_cluster_list(service_object, invocation, resp_data);
+
+ g_free(cb_data);
+}
+
static gboolean on_service_get_cluster_list(ZigbeeService *service_object,
GDBusMethodInvocation *invocation,
GVariant *eui64,
gchar endpoint,
gpointer user_data)
{
- ZigBeeService *service = (ZigBeeService *)user_data;
+ ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
+ ZigbeeServiceGetClusterList_t req;
+ ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
- NOT_USED(service_object);
- NOT_USED(invocation);
- NOT_USED(service);
- NOT_USED(eui64);
- NOT_USED(endpoint);
+ GVariantIter *iter = NULL;
+ guint i = 0;
- /*
- * TODO -
- * Create and send request for processing
- */
+ gboolean ret;
+
+ memset(&req, 0x0, sizeof(ZigbeeServiceGetClusterList_t));
+
+ /* Update request structure */
+ g_variant_get(eui64, "ay", &iter);
+ while (g_variant_iter_loop(iter, "y", req.eui64[i])) {
+ i++;
+ if (i >= ZIGBEE_EUI64_SIZE)
+ break;
+ }
+ req.endpoint = endpoint;
+
+ /* Allocate response callback data */
+ resp_cb_data =
+ zigbee_service_dbus_interface_create_resp_cb_data(service_object,
+ invocation, NULL, 0);
+ if (NULL == resp_cb_data) {
+ Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
+
+ /* Send failure response */
+ ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
+
+ return TRUE;
+ }
+
+ /* Dispatch request */
+ ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
+ ZBLIB_DRIVER_TYPE_SERVICE,
+ ZBLIB_SERVICE_OPS_GET_CLUSTER_LIST,
+ &req, sizeof(req),
+ on_service_get_cluster_list_resp, resp_cb_data);
+ if (FALSE == ret) {
+ Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
+
+ /* Free response callback data */
+ zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
+
+ /* Send failure response */
+ ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
+
+ return TRUE;
+ }
return TRUE;
}
+static void on_service_get_node_type_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;
+
+ ZigbeeService *service_object;
+ GDBusMethodInvocation *invocation;
+ ZigbeeServiceServiceNodeType_t payload;
+
+ NOT_USED(cb_data);
+ NOT_USED(service_interface);
+ NOT_USED(request_id);
+
+ if (NULL == resp_data || 0 == resp_data_len) {
+ Z_LOGE("resp_data is null");
+ g_free(cb_data);
+ return;
+ }
+
+ memcpy(&payload, resp_data, resp_data_len);
+
+ service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
+ zblib_check_null_ret("service_object", service_object);
+
+ invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
+ zblib_check_null_ret("invocation", invocation);
+
+ zigbee_service_complete_get_node_type(service_object, invocation, payload.node_type);
+
+ g_free(cb_data);
+}
+
static gboolean on_service_get_node_type(ZigbeeService *service_object,
GDBusMethodInvocation *invocation,
GVariant *eui64,
gpointer user_data)
{
- ZigBeeService *service = (ZigBeeService *)user_data;
+ ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
+ ZigbeeServiceGetNodeType_t req;
+ ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
- NOT_USED(service_object);
- NOT_USED(invocation);
- NOT_USED(service);
- NOT_USED(eui64);
+ GVariantIter *iter = NULL;
+ guint i = 0;
- /*
- * TODO -
- * Create and send request for processing
- */
+ gboolean ret;
+
+ memset(&req, 0x0, sizeof(ZigbeeServiceGetNodeType_t));
+
+ /* Update request structure */
+ g_variant_get(eui64, "ay", &iter);
+ while (g_variant_iter_loop(iter, "y", req.eui64[i])) {
+ i++;
+ if (i >= ZIGBEE_EUI64_SIZE)
+ break;
+ }
+
+ /* Allocate response callback data */
+ resp_cb_data =
+ zigbee_service_dbus_interface_create_resp_cb_data(service_object,
+ invocation, NULL, 0);
+ if (NULL == resp_cb_data) {
+ Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
+
+ /* Send failure response */
+ ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
+
+ return TRUE;
+ }
+
+ /* Dispatch request */
+ ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
+ ZBLIB_DRIVER_TYPE_SERVICE,
+ ZBLIB_SERVICE_OPS_GET_NODE_TYPE,
+ &req, sizeof(req),
+ on_service_get_node_type_resp, resp_cb_data);
+ if (FALSE == ret) {
+ Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
+
+ /* Free response callback data */
+ zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
+
+ /* Send failure response */
+ ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
+
+ return TRUE;
+ }
return TRUE;
}
-gboolean zigbee_service_dbus_interface_service_init(ZigBeeService *service,
+void zigbee_service_dbus_interface_service_notification(ZigBeeServiceInterface *service_interface,
+ guint noti_id, gpointer noti_data, guint noti_data_len, gpointer noti_cb_data)
+{
+ ZigbeeService *service_object;
+
+ zblib_check_null_ret("service_interface", service_interface);
+
+ if (NULL == noti_data || 0 == noti_data_len) {
+ Z_LOGE("noti_data is NULL");
+ return;
+ }
+
+ service_object = _service_interface_ref_zigbee_service(service_interface);
+ zblib_check_null_ret("service_object", service_object);
+
+ NOT_USED(noti_cb_data);
+
+ switch(noti_id) {
+ case ZBLIB_SERVICE_NOTI_FORM_NETWORK_DONE: {
+ ZigbeeServiceServiceFormNetworkDone_t panid_t;
+ memcpy(&panid_t, noti_data, noti_data_len);
+ zigbee_service_emit_form_network_done(service_object, panid_t.pan_id);
+ }
+ break;
+ case ZBLIB_SERVICE_NOTI_CHILD_JOINED: {
+ zigbee_service_emit_child_joined(service_object, (GVariant *)noti_data);
+ }
+ break;
+ case ZBLIB_SERVICE_NOTI_CHILD_REJOINED: {
+ ZigbeeServiceServiceChildRejoined_t ieee_addr_t;
+ memcpy(&ieee_addr_t, noti_data, noti_data_len);
+ zigbee_service_emit_child_rejoined(service_object, ieee_addr_t.eui64);
+ }
+ break;
+ case ZBLIB_SERVICE_NOTI_CHILD_LEFT: {
+ ZigbeeServiceServiceChildLeft_t child_left_t;
+ memcpy(&child_left_t, noti_data, noti_data_len);
+ zigbee_service_emit_child_left(service_object, child_left_t.eui64, child_left_t.status);
+ }
+ break;
+ case ZBLIB_SERVICE_NOTI_LEAVE_NETWORK_DONE: {
+ ZigbeeServiceServiceLeaveNetworkDone_t leave_net_t;
+ memcpy(&leave_net_t, noti_data, noti_data_len);
+ zigbee_service_emit_leave_network_done(service_object, leave_net_t.pan_id);
+ }
+ break;
+ default:
+ Z_LOGE("Unexpected notification [%x]", noti_id);
+ break;
+ }
+
+ /* ZigbeeService should be dereferenced */
+ g_object_unref(service_object);
+}
+
+gboolean zigbee_service_dbus_interface_service_init(ZigBeeServiceInterface *service_interface,
ZigbeeObjectSkeleton *zigbee_object)
{
ZigbeeService *service_object;
- if (NULL == service) {
- Z_LOGE("service is NULL");
+ if (NULL == service_interface) {
+ Z_LOGE("service_interface is NULL");
return FALSE;
}
*/
g_signal_connect(service_object,
"handle-enable",
- G_CALLBACK(on_service_enable), service);
+ G_CALLBACK(on_service_enable), service_interface);
g_signal_connect(service_object,
"handle-disable",
- G_CALLBACK(on_service_disable), service);
+ G_CALLBACK(on_service_disable), service_interface);
g_signal_connect(service_object,
"handle-zb-hw-reset",
- G_CALLBACK(on_service_zb_hw_reset), service);
+ G_CALLBACK(on_service_zb_hw_reset), service_interface);
g_signal_connect(service_object,
"handle-form-network",
- G_CALLBACK(on_service_form_network), service);
+ G_CALLBACK(on_service_form_network), service_interface);
g_signal_connect(service_object,
"handle-coex-start",
- G_CALLBACK(on_service_coex_start), service);
+ G_CALLBACK(on_service_coex_start), service_interface);
g_signal_connect(service_object,
"handle-coex-stop",
- G_CALLBACK(on_service_coex_stop), service);
+ G_CALLBACK(on_service_coex_stop), service_interface);
g_signal_connect(service_object,
"handle-leave-network",
- G_CALLBACK(on_service_leave_network), service);
+ G_CALLBACK(on_service_leave_network), service_interface);
g_signal_connect(service_object,
"handle-get-network-info",
- G_CALLBACK(on_service_get_network_info), service);
+ G_CALLBACK(on_service_get_network_info), service_interface);
g_signal_connect(service_object,
"handle-permit-join",
- G_CALLBACK(on_service_permit_join), service);
+ G_CALLBACK(on_service_permit_join), service_interface);
g_signal_connect(service_object,
"handle-leave-request",
- G_CALLBACK(on_service_leave_request), service);
+ G_CALLBACK(on_service_leave_request), service_interface);
g_signal_connect(service_object,
"handle-get-device-list",
- G_CALLBACK(on_service_get_device_list), service);
+ G_CALLBACK(on_service_get_device_list), service_interface);
g_signal_connect(service_object,
"handle-get-mac",
- G_CALLBACK(on_service_get_mac), service);
+ G_CALLBACK(on_service_get_mac), service_interface);
g_signal_connect(service_object,
"handle-get-device-info",
- G_CALLBACK(on_service_get_device_info), service);
+ G_CALLBACK(on_service_get_device_info), service_interface);
g_signal_connect(service_object,
"handle-get-endpoint-list",
- G_CALLBACK(on_service_get_endpoint_list), service);
+ G_CALLBACK(on_service_get_endpoint_list), service_interface);
g_signal_connect(service_object,
"handle-get-cluster-list",
- G_CALLBACK(on_service_get_cluster_list), service);
+ G_CALLBACK(on_service_get_cluster_list), service_interface);
g_signal_connect(service_object,
"handle-get-node-type",
- G_CALLBACK(on_service_get_node_type), service);
+ G_CALLBACK(on_service_get_node_type), service_interface);
return TRUE;
}