#include <bundle.h>
#include <eventsystem.h>
#include <stdio.h>
-#ifdef TIZEN_FEATURE_ACTD
#include <actd/unit_control.h>
-#endif
#include "bt-core-main.h"
#include "bt-core-adapter.h"
}
}
-#ifdef TIZEN_FEATURE_ACTD
static int __bt_call_systemact_service(const char *service_name)
{
int ret;
return 0;
}
-#else
-static int __bt_call_systemact_service(const char *file_path)
-{
- BT_DBG("+");
- FILE *fp;
-
- if (!file_path) {
- BT_ERR("service file path is NULL");
- return -1;
- }
-
- if (!access(file_path, F_OK)) {
- remove(file_path);
- usleep(100);
- }
-
- fp = fopen(file_path, "w");
- if (!fp) {
- BT_ERR("Failed to fopen service file");
- return -1;
- }
-
-
- fclose(fp);
- BT_DBG("-");
- return 0;
-
-}
-#endif
static int __execute_command(const char *cmd, char *const arg_list[])
{
{
int ret;
bt_status_t status;
-#if 0
- bt_le_status_t le_status;
-#endif
+
BT_INFO("");
status = _bt_core_get_status();
return -1;
}
-#if 0 /* only the concept of private */
+/* only the concept of private
+#if 0
+ bt_le_status_t le_status;
+
le_status = _bt_core_get_le_status();
if (le_status == BT_LE_ACTIVATED) {
- /* Turn on PSCAN, (ISCAN if needed) */
- /* Return with 0 for the Enabled response. */
+ // Turn on PSCAN, (ISCAN if needed)
+ // Return with 0 for the Enabled response.
__bt_core_set_status(BT_ACTIVATED);
BT_INFO("BR/EDR is enabled.");
g_timeout_add(BT_CORE_IDLE_TERM_TIME, __bt_core_idle_terminate, NULL);
return 0;
}
#endif
+*/
__bt_core_set_status(BT_ACTIVATING);
if (TIZEN_FEATURE_BT_USB_DONGLE) {
+ /* activate Bluez */
+ ret = __bt_call_systemact_service(BT_SYSTEMACT_BLUEZ_START);
+ if (ret < 0)
+ BT_ERR("If bluez already exist, skip this error");
+
ret = __bt_call_systemact_service(BT_SYSTEMACT_HCI_UP);
if (ret < 0)
BT_ERR("Failed to call systemact service");
int _bt_disable_adapter(void)
{
bt_status_t status;
-#if 0
- bt_le_status_t le_status;
-#endif
BT_INFO_C("Disable adapter");
-#if 0 /* only the concept of private */
+/* only the concept of private
+#if 0
+ bt_le_status_t le_status;
+
le_status = _bt_core_get_le_status();
BT_DBG("le_status : %d", le_status);
if (le_status == BT_LE_ACTIVATED) {
- /* Turn off PSCAN, (ISCAN if needed) */
- /* Return with 0 for the Disabled response. */
+ // Turn off PSCAN, (ISCAN if needed)
+ // Return with 0 for the Disabled response.
__bt_core_set_status(BT_DEACTIVATED);
BT_INFO("BR/EDR is disabled. now LE only mode");
g_timeout_add(BT_CORE_IDLE_TERM_TIME, __bt_core_idle_terminate, NULL);
return 0;
}
#endif
+*/
status = _bt_core_get_status();
if (status == BT_ACTIVATING) {
if (__bt_call_systemact_service(BT_SYSTEMACT_HCI_DOWN) < 0)
BT_ERR("Failed to call systemact service");
} else {
-#ifdef TIZEN_FEATURE_RADIO
int radio_status = VCONFKEY_RADIO_STATUS_OFF;
/* Check if radio status on or off */
if (__bt_call_systemact_service(BT_SYSTEMACT_STACK_DOWN) < 0)
BT_ERR("running script failed");
}
-#else
- if (__bt_call_systemact_service(BT_SYSTEMACT_STACK_DOWN) < 0)
- BT_ERR("running script failed");
-#endif
}
_bt_core_terminate();
return 0;
}
g_timeout_add(BT_CORE_IDLE_TERM_TIME, __bt_core_idle_terminate, NULL);
} else {
-#ifdef TIZEN_FEATURE_RADIO
int radio_status = VCONFKEY_RADIO_STATUS_OFF;
/* Check if radio status on or off */
return -1;
}
}
-#else
- if (__bt_call_systemact_service(BT_SYSTEMACT_STACK_DOWN) < 0) {
- BT_ERR("running script failed");
- __bt_core_set_status(BT_ACTIVATED);
- return -1;
- }
-#endif
}
return 0;
gboolean _bt_core_recover_adapter(void)
{
int ret;
-#if 0
- int ret_le;
-#endif
+
BT_INFO_C("Recover bt adapter");
_bt_set_flightmode_request(FALSE);
if (_bt_core_get_status() == BT_ACTIVATED) {
_bt_core_set_bt_status(BT_RECOVERY_MODE, 1);
-#ifdef TIZEN_FEATURE_BUSACT
- _bt_core_service_request_adapter(BT_DISABLE_ADAPTER);
-#endif
}
if (_bt_core_get_le_status() == BT_LE_ACTIVATED) {
_bt_core_set_bt_le_status(BT_RECOVERY_MODE, 1);
-#ifdef TIZEN_FEATURE_BUSACT
- _bt_core_service_request_adapter(BT_DISABLE_ADAPTER_LE);
-#endif
}
ret = _bt_disable_adapter();
if (ret < 0)
BT_ERR("_bt_disable_adapter() failed");
-/* In platform, don't seperate BR/EDR and LE status */
+/* In platform, don't seperate BR/EDR and LE status
#if 0
+ int ret_le;
+
ret_le = _bt_disable_adapter_le();
if (ret_le < 0)
BT_ERR("_bt_disable_adapter_le() failed");
#endif
+*/
return TRUE;
}
gboolean _bt_core_factory_test_mode(const char *type, const char *arg)
{
+ int ret;
BT_DBG("Test item : %s", type);
-#ifdef TIZEN_FEATURE_ACTD
if (g_strcmp0(type, "Enable_RF_Test") == 0) {
- __bt_call_systemact_service(BT_SYSTEMACT_EDUTM_ON);
+ ret = __bt_call_systemact_service(BT_SYSTEMACT_EDUTM_ON);
+ if (ret < 0)
+ BT_ERR("Failed to call systemact service");
} else if (g_strcmp0(type, "Disable_RF_Test") == 0) {
- __bt_call_systemact_service(BT_SYSTEMACT_EDUTM_OFF);
+ ret = __bt_call_systemact_service(BT_SYSTEMACT_EDUTM_OFF);
+ if (ret < 0)
+ BT_ERR("Failed to call systemact service");
} else {
BT_DBG("Terminate bt-core process");
g_timeout_add(BT_CORE_IDLE_TERM_TIME, __bt_core_idle_terminate, NULL);
return FALSE;
}
-#else
- char *cmd = NULL;
- char *arg_list[3] = { NULL, NULL, NULL };
-
- if (g_strcmp0(type, "Enable_RF_Test") == 0) {
- cmd = "/usr/etc/bluetooth/bt-edutm-on.sh";
- arg_list[0] = "bt-edutm-on.sh";
- } else if (g_strcmp0(type, "Disable_RF_Test") == 0) {
- cmd = "/usr/etc/bluetooth/bt-edutm-off.sh";
- arg_list[0] = "bt-edutm-off.sh";
- } else if (g_strcmp0(type, "Slave_Mode") == 0) {
- cmd = "/usr/etc/bluetooth/bt-mode-slave.sh";
- arg_list[0] = "bt-mode-slave.sh";
- } else if (g_strcmp0(type, "Master_Mode") == 0) {
- cmd = "/usr/etc/bluetooth/bt-mode-master.sh";
- arg_list[0] = "bt-mode-master.sh";
- } else if (g_strcmp0(type, "SSP_Debug_Mode") == 0) {
- cmd = "/usr/etc/bluetooth/bt-set-ssp-debug-mode.sh";
- arg_list[0] = "bt-set-ssp-debug-mode.sh";
- arg_list[1] = (char *)arg;
- } else if (g_strcmp0(type, "RF_Channel") == 0) {
- cmd = "/usr/etc/bluetooth/bt-enable-rf-channel.sh";
- arg_list[0] = "bt-enable-rf-channel.sh";
- arg_list[1] = (char *)arg;
- } else {
- return FALSE;
- }
-
- BT_DBG("Run %s", cmd);
- if (__execute_command(cmd, arg_list) < 0)
- BT_ERR("running script failed");
-#endif
return TRUE;
}
BT_ERR("_bt_enable_adapter() failed");
}
-#if 0
- if (_bt_core_get_bt_le_status(BT_RECOVERY_MODE) == 1) {
- _bt_core_set_bt_le_status(BT_RECOVERY_MODE, 0);
- ret = _bt_enable_adapter_le();
- if (ret < 0)
- BT_ERR("_bt_enable_adapter_le() failed");
- }
-#endif
is_recovery_mode = FALSE;
BT_DBG("-");
if (vconf_get_int(VCONFKEY_BT_STATUS, &bt_status_before_mode) == 0)
_bt_core_set_bt_status(BT_FLIGHT_MODE, bt_status_before_mode);
-#ifdef TIZEN_FEATURE_BUSACT
- _bt_core_service_request_adapter(BT_DISABLE_ADAPTER);
-#endif
_bt_disable_adapter();
}
if (vconf_get_int(VCONFKEY_BT_LE_STATUS, &bt_le_status_before_mode) == 0)
_bt_core_set_bt_le_status(BT_FLIGHT_MODE, bt_le_status_before_mode);
-#ifdef TIZEN_FEATURE_BUSACT
- _bt_core_service_request_adapter(BT_DISABLE_ADAPTER_LE);
-#endif
_bt_disable_adapter_le();
}