#include <zblib.h>
#include <zblib_service.h>
#include <zblib_service_interface.h>
+#include <zblib_driver_manager.h>
#include "zigbee_service_interface.h"
#include "zigbee_service_interface_common.h"
/**< ZigBee D-BUS service interface name */
#define ZIGBEE_DBUS_SERVICE_INTERFACE_NAME "zigbee-dbus"
+static void _notify_zigbee_state(ZigBeeServiceInterface *service_interface,
+ gboolean result)
+{
+ ZigbeeCustomData_t *custom_data = zblib_service_interface_ref_user_data(service_interface);
+ ZigBeeService *service = zblib_service_interface_ref_service(service_interface);
+
+ if (NULL == custom_data) {
+ Z_LOGE("Unexpected invalid parameter !");
+ return;
+ }
+
+ if (result) {
+ /* Notify zigbee service manually here (Enabled) */
+ zigbee_manager_emit_zigbee_state(custom_data->zigbee_mgr, result);
+ } else {
+ /* ZigBee state will be emitted on bus termination */
+ zblib_service_exit(service);
+ }
+}
+
static gboolean on_manager_enable(ZigbeeManager *zigbee_mgr,
GDBusMethodInvocation *invocation,
gpointer user_data)
zigbee_manager_complete_enable(zigbee_mgr, invocation);
- if (TRUE == custom_data->sevice_interface_init_complete) {
- /* Emit zigbee_state - enabled */
- zigbee_manager_emit_zigbee_state(zigbee_mgr, TRUE);
- }
-
return TRUE;
}
}
break;
+ case ZBLIB_DRIVER_TYPE_MANAGER: {
+ /* Handle 'enabled' notification here */
+ if (notification_id == ZBLIB_MANAGER_NOTI_ZIGBEE_ENABLED) {
+ gboolean *rsp = (gboolean*)noti_data;
+
+ Z_LOGD("Firmware update result : [%s]", ((*rsp) ? "Succeed" : "Failed"));
+ _notify_zigbee_state(service_interface, *rsp);
+ } else
+ Z_LOGE("Unhandled notification id: [%d]", notification_id);
+ }
+ break;
+
case ZBLIB_DRIVER_TYPE_NONE: /* Fall through */
default: {
Z_LOGE("Unhandled driver type: [%d]", driver_type);
/* Bus name is 'acquired' */
custom_data->name_acquired = TRUE;
-
- if (TRUE == custom_data->sevice_interface_init_complete) {
- /* Emit zigbee_state - enabled */
- zigbee_manager_emit_zigbee_state(custom_data->zigbee_mgr, TRUE);
- }
}
static void zigbee_on_bus_acquired(GDBusConnection *connection,
goto EXIT;
}
+ /* Emit zigbee_state - disabled */
+ Z_LOGD("Update zigbee_state ----");
+ zigbee_manager_emit_zigbee_state(interface_data->zigbee_mgr, FALSE);
+
/*
* Unown "org.tizen.zigbee.manager" named bus on D-BUS SYSTEM bus
*/