Added Haltest for zigbee-manager
[platform/core/connectivity/zigbee-manager.git] / haltest / zbl.cpp
1 /*
2  * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #include <errno.h>
17 #include <string.h>
18 #include <stdlib.h>
19 #include <glib.h>
20 #include <gio/gio.h>
21
22 #include "zbl.h"
23
24 Zigbee::Zigbee(void)
25 {
26         Create();
27 }
28
29 Zigbee::~Zigbee(void)
30 {
31         Destroy();
32 }
33
34 int Zigbee::zbl_enable(void)
35 {
36         int error = ZIGBEE_ERROR_NONE;
37         GVariant *message;
38
39         GLOGD("zbl_enable()");
40
41         message = InvokeMethod(ZIGBEE_MANAGER_INTERFACE,
42                         ZIGBEE_DBUS_OBJPATH,
43                         ZIGBEE_MANAGER_INTERFACE,
44                         "enable", NULL, &error);
45
46         if (message)
47                 g_variant_unref(message);
48
49         return error;
50 }
51
52 int Zigbee::zbl_disable(void)
53 {
54         int error = ZIGBEE_ERROR_NONE;
55         GVariant *message = NULL;
56
57         GLOGD("zbl_disable()");
58
59         message = InvokeMethod(ZIGBEE_MANAGER_INTERFACE,
60                         ZIGBEE_DBUS_OBJPATH,
61                         ZIGBEE_MANAGER_INTERFACE,
62                         "disable", NULL, &error);
63
64         if (message) {
65                 g_variant_get(message, "(i)", &error);
66                 GLOGD("ret = 0x%x", error);
67                 g_variant_unref(message);
68         }
69
70         return error;
71 }