Fix bt-service crash issue in testhub
[platform/core/connectivity/bluetooth-frwk.git] / bt-core / include / bt-core-adapter.h
1 /*
2  * Copyright (c) 2011 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  */
17
18 #ifndef _BT_CORE_ADAPTER_H_
19 #define _BT_CORE_ADAPTER_H_
20
21 #include <sys/types.h>
22 #include <sys/wait.h>
23 #include <dlog.h>
24 #include <glib.h>
25
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29
30 #define CONNMAN_DBUS_NAME "net.connman"
31 #define CONNMAN_BLUETOOTH_TECHNOLOGY_PATH "/net/connman/technology/bluetooth"
32 #define CONNMAN_BLUETOTOH_TECHNOLOGY_INTERFACE "net.connman.Technology"
33
34 #define BT_CORE_NAME "org.projectx.bt_core"
35 #define BT_CORE_PATH "/org/projectx/bt_core"
36
37 #ifdef TIZEN_FEATURE_ACTD
38 #define BT_SYSTEMACT_HCI_LOGGER_START "bluetooth-hci-logger.service"
39 #define BT_SYSTEMACT_HCI_LOGGER_STOP "bluetooth-hci-logger-stop.service"
40 #define BT_SYSTEMACT_HCI_UP "bluetooth-hci-up.service"
41 #define BT_SYSTEMACT_HCI_DOWN "bluetooth-hci-down.service"
42 #define BT_SYSTEMACT_BLUEZ_START "bluez-start.service"
43 #define BT_SYSTEMACT_BLUETOOTH_SHARE_START "bluetooth-share-start.service"
44 #define BT_SYSTEMACT_RFKILL_UNBLOCK "bluetooth-rfkill-unblock.service"
45 #define BT_SYSTEMACT_RFKILL_BLOCK "bluetooth-rfkill-block.service"
46 #define BT_SYSTEMACT_STACK_UP "bluetooth-stack-up.service"
47 #define BT_SYSTEMACT_STACK_DOWN "bluetooth-stack-down.service"
48 #define BT_SYSTEMACT_STACK_DOWN_WITH_RADIO "bluetooth-stack-down-with-radio.service"
49 #define BT_SYSTEMACT_EDUTM_ON "bluetooth-edutm-on.service"
50 #define BT_SYSTEMACT_EDUTM_OFF "bluetooth-edutm-off.service"
51 #else
52 #define BT_SYSTEMACT_HCI_LOGGER_START "/run/.hci_logger_start"
53 #define BT_SYSTEMACT_HCI_LOGGER_STOP "/run/.hci_logger_stop"
54 #define BT_SYSTEMACT_HCI_UP "/run/.hci_up"
55 #define BT_SYSTEMACT_HCI_DOWN "/run/.hci_down"
56 #define BT_SYSTEMACT_BLUEZ_START "/run/.bluez_start"
57 #define BT_SYSTEMACT_BLUETOOTH_SHARE_START "/run/.bluetooth_share_start"
58 #define BT_SYSTEMACT_RFKILL_UNBLOCK "/run/.rfkill_unblock"
59 #define BT_SYSTEMACT_RFKILL_BLOCK "/run/.rfkill_block"
60 #define BT_SYSTEMACT_STACK_UP "/run/.bt_stack_up"
61 #define BT_SYSTEMACT_STACK_DOWN "/run/.bt_stack_down"
62 #define BT_SYSTEMACT_STACK_DOWN_WITH_RADIO "/run/.bt_stack_down_with_radio"
63 #endif
64
65 #define BT_CORE_TYPE (bt_core_get_type())
66
67 typedef enum {
68         BT_DEACTIVATED,
69         BT_ACTIVATED,
70         BT_ACTIVATING,
71         BT_DEACTIVATING,
72 } bt_status_t;
73
74 typedef enum {
75         BT_LE_DEACTIVATED,
76         BT_LE_ACTIVATED,
77         BT_LE_ACTIVATING,
78         BT_LE_DEACTIVATING,
79 } bt_le_status_t;
80
81 typedef enum {
82         BT_POWER_SAVING_MODE,
83         BT_FLIGHT_MODE,
84         BT_RECOVERY_MODE,
85         BT_MODE_MAX
86 } bt_mode_e;
87
88 bt_status_t _bt_core_get_status(void);
89 bt_le_status_t _bt_core_get_le_status(void);
90 int _bt_core_get_bt_status(bt_mode_e mode);                     /* Get the status of BT before passed mode */
91 int _bt_core_get_bt_le_status(bt_mode_e mode);                  /* Get the status of BT LE before passed mode */
92 void _bt_core_set_bt_status(bt_mode_e mode, int status);        /* Set the status of BT before passed mode */
93 void _bt_core_set_bt_le_status(bt_mode_e mode, int status);     /* Set the status of BT LE before passed mode */
94
95 gboolean _bt_core_is_recovery_mode(void);
96 gboolean _bt_core_is_flight_mode_enabled(void);
97
98 int _bt_enable_adapter(void);
99 int _bt_disable_adapter(void);
100 int _bt_enable_adapter_le(void);
101 int _bt_disable_adapter_le(void);
102 int _bt_core_service_request_adapter(int service_function);
103
104 void _bt_core_adapter_added_cb(void);
105 void _bt_core_adapter_removed_cb(void);
106
107 gboolean _bt_core_enable_adapter(void);
108 gboolean _bt_core_disable_adapter(void);
109 gboolean _bt_core_recover_adapter(void);
110 gboolean _bt_core_enable_adapter_le(void);
111 gboolean _bt_core_disable_adapter_le(void);
112 gboolean __bt_core_reset_adapter(void);
113 gboolean _bt_core_enable_core(void);
114 gboolean _bt_core_set_transfer_value(gboolean value);
115 gboolean _bt_core_factory_test_mode(const char *type, const char *arg);
116
117 void _bt_core_update_status(void);
118
119 #ifdef __cplusplus
120 }
121 #endif /* __cplusplus */
122 #endif /*_BT_CORE_ADAPTER_H_*/