INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs REQUIRED dbus-1 dbus-glib-1 dlog vconf gio-2.0 gio-unix-2.0 eventsystem capi-system-info)
+pkg_check_modules(pkgs REQUIRED dlog vconf gio-2.0 gio-unix-2.0 eventsystem capi-system-info)
FOREACH(flag ${pkgs_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
ADD_DEFINITIONS("-DAPPNAME=\"${APP_NAME}\"")
ADD_DEFINITIONS("-DAPP_DIR=\"${APP_DIR}\"")
ADD_DEFINITIONS("-DAPP_SYSCONFDIR=\"${APP_SYSCONFDIR}\"")
-ADD_DEFINITIONS("-DHPS_FEATURE")
+#ADD_DEFINITIONS("-DTIZEN_FEATURE_BT_HPS")
+ADD_DEFINITIONS("-DTIZEN_FEATURE_BT_OTP")
SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie")
#define BT_CORE_IDLE_TERM_TIME 200 /* 200ms */
#define BT_CORE_CHECK_ADAPTER_OBJECT_PATH_MAX 50
+#ifdef TIZEN_FEATURE_BT_OTP
+#define BT_OTP_OBJECT_PATH "/org/projectx/otp"
+#define BT_OTP_INTERFACE_NAME "org.projectx.otp_service"
+#define BLE_DISABLED "LeDisabled"
+#endif
static bt_status_t adapter_status = BT_DEACTIVATED;
static bt_le_status_t adapter_le_status = BT_LE_DEACTIVATED;
int _bt_enable_adapter_le(void)
{
- BT_DBG("+");
+ BT_DBG("");
int ret;
+ bt_status_t status;
bt_le_status_t le_status;
-
le_status = _bt_core_get_le_status();
- if (le_status == BT_LE_DEACTIVATED) {
+ retv_if(le_status != BT_LE_DEACTIVATED, -1);
+
+ status = _bt_core_get_status();
+ if (status == BT_DEACTIVATED) {
__bt_core_set_le_status(BT_LE_ACTIVATING);
BT_DBG("Activate BT");
if (TIZEN_FEATURE_BT_USB_DONGLE) {
} else {
ret = __execute_command("/usr/etc/bluetooth/bt-dev-end.sh &", NULL);
}
+ __bt_core_set_status(BT_DEACTIVATED);
__bt_core_set_le_status(BT_LE_DEACTIVATED);
return -1;
}
} else {
+ __bt_core_set_le_status(BT_LE_ACTIVATED);
g_timeout_add(BT_CORE_IDLE_TERM_TIME, __bt_core_idle_terminate, NULL);
}
-#ifdef HPS_FEATURE
+#ifdef TIZEN_FEATURE_BT_HPS
ret = _bt_core_start_httpproxy();
if (ret < 0)
BT_ERR("_bt_core_start_httpproxy() failed");
#endif
- __bt_core_set_le_status(BT_LE_ACTIVATED);
- BT_DBG("-");
return 0;
}
+#ifdef TIZEN_FEATURE_BT_OTP
+static void _bt_core_stop_otp()
+{
+ GError *error = NULL;
+ GDBusMessage *msg = NULL;
+ GDBusConnection *conn = _bt_core_get_gdbus_connection();
+ msg = g_dbus_message_new_signal(BT_OTP_OBJECT_PATH, BT_OTP_INTERFACE_NAME, BLE_DISABLED);
+ if (!g_dbus_connection_send_message(conn, msg, G_DBUS_SEND_MESSAGE_FLAGS_NONE, 0, NULL)) {
+ if (error != NULL) {
+ BT_ERR("Failed to send BLE_DISABLED signal to OTP : errCode[%x], \
+ message[%s]",
+ error->code, error->message);
+ g_clear_error(&error);
+ }
+ }
+}
+#endif
+
int _bt_disable_adapter_le(void)
{
BT_DBG("+");
+ bt_status_t status;
bt_le_status_t le_status;
le_status = _bt_core_get_le_status();
retv_if(le_status == BT_LE_DEACTIVATED, 0);
retv_if(le_status == BT_LE_DEACTIVATING, -1);
-#ifdef HPS_FEATURE
+#ifdef TIZEN_FEATURE_BT_HPS
_bt_core_stop_httpproxy();
#endif
- le_status = _bt_core_get_le_status();
- BT_DBG("status : %d", le_status);
+#ifdef TIZEN_FEATURE_BT_OTP
+ _bt_core_stop_otp();
+#endif
- if (le_status == BT_LE_ACTIVATED) {
+ status = _bt_core_get_status();
+ BT_DBG("status : %d", status);
+
+ if (status == BT_DEACTIVATED) {
__bt_core_set_le_status(BT_LE_DEACTIVATING);
int ret;
if (TIZEN_FEATURE_BT_USB_DONGLE) {
return ret;
}
-static gboolean __bt_core_check_the_adapter_path(GDBusConnection *conn)
+static gboolean __bt_core_check_the_adapter_path(void)
{
GError *err = NULL;
GDBusProxy *manager_proxy = NULL;
GVariant *result = NULL;
char *adapter_path = NULL;
+ GDBusConnection *conn = NULL;
+ conn = _bt_core_get_gdbus_connection();
if (conn == NULL)
return FALSE;
}
result = g_dbus_proxy_call_sync(manager_proxy, "DefaultAdapter", NULL,
- G_DBUS_CALL_FLAGS_NONE, -1, NULL, &err);
+ G_DBUS_CALL_FLAGS_NONE, 1000, NULL, &err);
if (!result) {
if (err != NULL) {
BT_ERR("Fail to get DefaultAdapter (Error: %s)", err->message);
int bt_le_status = VCONFKEY_BT_LE_STATUS_OFF;
gboolean ret = FALSE;
- ret = __bt_core_check_the_adapter_path(_bt_core_get_gdbus_connection());
+ ret = __bt_core_check_the_adapter_path();
BT_INFO("check the real status of bt_adapter");
if (ret != TRUE) {
if (bt_status & VCONFKEY_BT_STATUS_ON)
__bt_core_set_status(BT_ACTIVATED);
if (bt_le_status & VCONFKEY_BT_LE_STATUS_ON)
- __bt_core_set_le_status(BT_LE_ACTIVATED);
+ __bt_core_set_le_status(BT_ACTIVATED);
}
}
return TRUE;
}
+static gboolean __bt_core_terminate_cb(gpointer data)
+{
+ _bt_core_terminate();
+
+ return FALSE;
+}
+
gboolean _bt_core_disable_adapter(void)
{
int ret;
+ gboolean adapter_state;
_bt_set_flightmode_request(FALSE);
if (vconf_set_int(BT_OFF_DUE_TO_FLIGHT_MODE, 0) != 0)
BT_ERR("Set vconf failed");
+ adapter_state = __bt_core_check_the_adapter_path();
+ if (adapter_state == FALSE)
+ BT_INFO("Default adapter is NOT normal.");
+
ret = _bt_disable_adapter();
- if (ret < 0)
- return FALSE;
- else
+ if (adapter_state == FALSE) {
+ g_timeout_add(BT_CORE_IDLE_TERM_TIME,
+ __bt_core_terminate_cb, NULL);
return TRUE;
+ } else {
+ if (ret < 0)
+ return FALSE;
+ else
+ return TRUE;
+ }
}
gboolean _bt_core_recover_adapter(void)
arg_list[0] = "bt-enable-rf-channel.sh";
arg_list[1] = (char *)arg;
} else {
- _bt_core_terminate();
return FALSE;
}
if (__execute_command(cmd, arg_list) < 0)
BT_ERR("running script failed");
- _bt_core_terminate();
return TRUE;
}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" ?>
-
-<node name="/">
- <interface name="org.projectx.btcore">
- <method name="EnableAdapter">
- <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
- </method>
- <method name="DisableAdapter">
- <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
- </method>
- <method name="RecoverAdapter">
- <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
- </method>
- <method name="ResetAdapter">
- <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
- </method>
- <method name="EnableAdapterLe">
- <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
- </method>
- <method name="DisableAdapterLe">
- <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
- </method>
- <method name="EnableCore">
- <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
- </method>
- </interface>
-</node>
#define BT_SERVICE_NAME "org.projectx.bt"
#define BT_SERVICE_PATH "/org/projectx/bt_service"
-#ifdef HPS_FEATURE
+#ifdef TIZEN_FEATURE_BT_HPS
#define BT_HPS_SERVICE_NAME "org.projectx.httpproxy"
#define BT_HPS_OBJECT_PATH "/org/projectx/httpproxy"
#define BT_HPS_INTERFACE_NAME "org.projectx.httpproxy_service"
static GDBusConnection *service_gconn;
static GDBusProxy *service_gproxy;
-#ifdef HPS_FEATURE
+#ifdef TIZEN_FEATURE_BT_HPS
static GDBusProxy *hps_gproxy;
#endif
return (service_gproxy) ? service_gproxy : __bt_core_gdbus_init_service_proxy();
}
-#ifdef HPS_FEATURE
+#ifdef TIZEN_FEATURE_BT_HPS
int _bt_core_start_httpproxy(void)
{
GVariant *variant = NULL;
unsigned char enabled;
-
+ GError *err = NULL;
BT_DBG(" ");
hps_gproxy = _bt_core_gdbus_get_hps_proxy();
}
variant = g_dbus_proxy_call_sync(hps_gproxy, "enable",
- NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL);
+ NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &err);
+ if (err) {
+ BT_ERR("Error : %s" , err->message);
+ g_clear_error(&err);
+ }
if (variant) {
g_variant_get(variant, "(y)", &enabled);
BT_ERR("HPS enabled status 0x%x", enabled);
{
GVariant *variant = NULL;
unsigned char enabled;
-
+ GError *err = NULL;
BT_DBG(" ");
hps_gproxy = _bt_core_gdbus_get_hps_proxy();
}
variant = g_dbus_proxy_call_sync(hps_gproxy, "disable",
- NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL);
+ NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &err);
+ if (err) {
+ BT_ERR("Error : %s" , err->message);
+ g_clear_error(&err);
+ }
if (variant) {
g_variant_get(variant, "(y)", &enabled);
BT_ERR("HPS disabled status 0x%x", enabled);
service_gproxy = NULL;
}
-#ifdef HPS_FEATURE
+#ifdef TIZEN_FEATURE_BT_HPS
if (hps_gproxy) {
g_object_unref(hps_gproxy);
hps_gproxy = NULL;
GArray **out_param1)
{
GDBusProxy *proxy;
- GVariant *ret;
+ GVariant *ret = NULL;
GVariant *param1;
GVariant *param2;
GVariant *param3;
ret = _bt_core_factory_test_mode(type, arg);
g_dbus_method_invocation_return_value(invocation,
g_variant_new("(i)", ret));
+ _bt_core_terminate();
return;
} else {
ret = FALSE;
node_info->interfaces[0],
&method_table,
NULL, NULL, &error);
+ g_dbus_node_info_unref(node_info);
if (obj_id == 0) {
BT_ERR("Failed to register: %s", error->message);
g_error_free(error);
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" ?>
-<node name="/org/projectx/bt_service">
- <interface name="org.projectx.bt">
- <method name="service_request">
- <annotation name="org.freedesktop.DBus.GLib.Async" value="bt_service_request"/>
- <!-- INPUT PARAMS FOR SERVICE FUNCTION -->
- <arg type="i" name="service_type" direction="in" />
- <arg type="i" name="service_function" direction="in" />
- <arg type="i" name="request_type" direction="in" />
- <arg type="ay" name="input_param1" direction="in" />
- <arg type="ay" name="input_param2" direction="in" />
- <arg type="ay" name="input_param3" direction="in" />
- <arg type="ay" name="input_param4" direction="in" />
- <arg type="ay" name="input_param5" direction="in" />
- <!-- OUTPUT PARAMS FOR SERVICE FUNCTION -->
- <arg type="ay" name="output_param1" direction="out" />
- <arg type="ay" name="output_param2" direction="out" />
- </method>
- </interface>
-</node>
-
#include <sys/types.h>
#include <sys/wait.h>
#include <dlog.h>
-#include <dbus/dbus.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
#include <glib.h>
#include <gio/gio.h>
GArray **out_param1);
void _bt_core_fill_garray_from_variant(GVariant *var, GArray *param);
GDBusProxy *_bt_core_gdbus_get_service_proxy(void);
-#ifdef HPS_FEATURE
+#ifdef TIZEN_FEATURE_BT_HPS
GDBusProxy *_bt_core_gdbus_get_hps_proxy(void);
int _bt_core_start_httpproxy(void);
int _bt_core_stop_httpproxy(void);