BT_EXPORT_API int bluetooth_set_advertising(int handle, gboolean enable)
{
int result;
- gboolean use_reserved_slot = FALSE;
+ gboolean use_reserved_slot = TRUE;
BT_CHECK_ENABLED_ANY(return);
bluetooth_advertising_params_t *params)
{
int result;
- gboolean use_reserved_slot = FALSE;
+ gboolean use_reserved_slot = TRUE;
BT_CHECK_ENABLED_ANY(return);
BT_EXPORT_API int bluetooth_set_advertising_data(int handle, const bluetooth_advertising_data_t *value, int length)
{
int result;
- gboolean use_reserved_slot = FALSE;
+ gboolean use_reserved_slot = TRUE;
BT_CHECK_PARAMETER(value, return);
BT_CHECK_ENABLED_ANY(return);
const bluetooth_scan_resp_data_t *value, int length)
{
int result;
- gboolean use_reserved_slot = FALSE;
+ gboolean use_reserved_slot = TRUE;
BT_CHECK_PARAMETER(value, return);
BT_CHECK_ENABLED_ANY(return);
}
}
-void _bt_convert_addr_string_to_type(unsigned char *addr,
- const char *address)
+void _bt_convert_addr_string_to_type(unsigned char *addr, const char *address)
{
int i;
char *ptr = NULL;
}
}
-void _bt_convert_addr_string_to_secure_string(char *addr,
- const char *address)
+void _bt_convert_addr_string_to_secure_string(char *addr, const char *address)
{
int len;
return;
}
-void _bt_convert_addr_type_to_string(char *address,
- unsigned char *addr)
+void _bt_convert_addr_type_to_string(char *address, unsigned char *addr)
{
ret_if(address == NULL);
ret_if(addr == NULL);
addr[3], addr[4], addr[5]);
}
+void _bt_convert_addr_type_to_secure_string(char *address, unsigned char *addr)
+{
+ ret_if(address == NULL);
+ ret_if(addr == NULL);
+
+ g_snprintf(address, BT_ADDRESS_STRING_SIZE,
+ "%2.2X:%2.2X:%2.2X:%2.2X:XX:XX",
+ addr[0], addr[1], addr[2], addr[3]);
+}
+
const char *_bt_convert_error_to_string(int error)
{
switch (error) {
static int latest_id = -1;
#define BT_RFCOMM_ID_MAX 245
static gboolean id_used[BT_RFCOMM_ID_MAX];
-GDBusNodeInfo *new_conn_node;
static const gchar rfcomm_agent_xml[] =
"<node name='/'>"
int _bt_register_new_conn(const char *path, bt_new_connection_cb cb)
{
GDBusConnection *gconn;
+ GDBusNodeInfo *node_info;
int id;
GError *error = NULL;
if (gconn == NULL)
return -1;
- if (new_conn_node == NULL)
- new_conn_node = _bt_get_gdbus_node(rfcomm_agent_xml);
-
- if (new_conn_node == NULL)
+ node_info = _bt_get_gdbus_node(rfcomm_agent_xml);
+ if (node_info == NULL)
return -1;
id = g_dbus_connection_register_object(gconn, path,
- new_conn_node->interfaces[0],
+ node_info->interfaces[0],
&method_table,
cb, NULL, &error);
+ g_dbus_node_info_unref(node_info);
if (id == 0) {
BT_ERR("Failed to register: %s", error->message);
g_error_free(error);
int _bt_register_new_conn_ex(const char *path, const char *bus_name, bt_new_connection_cb cb)
{
GDBusConnection *gconn;
+ GDBusNodeInfo *node_info;
int id;
GError *error = NULL;
if (gconn == NULL)
return -1;
- if (new_conn_node == NULL)
- new_conn_node = _bt_get_gdbus_node_ex(rfcomm_agent_xml, bus_name);
+ node_info = _bt_get_gdbus_node_ex(rfcomm_agent_xml, bus_name);
- if (new_conn_node == NULL)
+ if (node_info == NULL)
return -1;
id = g_dbus_connection_register_object(gconn, path,
- new_conn_node->interfaces[0],
+ node_info->interfaces[0],
&method_table,
cb, NULL, &error);
+ g_dbus_node_info_unref(node_info);
if (id == 0) {
BT_ERR("Failed to register: %s", error->message);
g_error_free(error);
proxy = g_dbus_proxy_new_sync(gconn, G_DBUS_PROXY_FLAGS_NONE, NULL,
BT_BLUEZ_NAME, object_path, BT_PROPERTIES_INTERFACE, NULL,
&err);
+
+ g_free(object_path);
+
retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
if (err) {
BT_ERR("DBus Error: [%s]", err->message);
proxy = g_dbus_proxy_new_sync(gconn, G_DBUS_PROXY_FLAGS_NONE, NULL,
BT_BLUEZ_NAME, object_path, BT_PROPERTIES_INTERFACE, NULL,
&err);
+
+ g_free(object_path);
+
retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
if (err) {
BT_ERR("DBus Error: [%s]", err->message);
return BLUETOOTH_ERROR_NONE;
}
+int _bt_disconnect_ext_profile(char *address, char *path)
+{
+ GDBusProxy *proxy;
+ char *object_path;
+
+ object_path = _bt_get_device_object_path(address);
+ if (object_path == NULL)
+ return BLUETOOTH_ERROR_INTERNAL;
+
+ proxy = __bt_gdbus_get_device_proxy(object_path);
+ g_free(object_path);
+ if (proxy == NULL) {
+ BT_ERR("Error while getting proxy");
+ return BLUETOOTH_ERROR_INTERNAL;
+ }
+
+ g_dbus_proxy_call(proxy, "DisconnectExtProfile",
+ g_variant_new("(o)", path),
+ G_DBUS_CALL_FLAGS_NONE,
+ DBUS_TIMEOUT, NULL, NULL, NULL);
+ BT_DBG("-");
+ return BLUETOOTH_ERROR_NONE;
+}
+
int _bt_get_adapter_path(GDBusConnection *conn, char *path)
{
GError *err = NULL;
}
+void _bt_convert_device_path_to_addr_type(const char *device_path,
+ unsigned char *addr)
+{
+ char *dev_addr;
+ char address[BT_ADDRESS_STRING_SIZE] = { 0 };
+ int i;
+ char *addr_ptr = address;
+ char *ptr = NULL;
+
+ ret_if(device_path == NULL);
+ ret_if(addr == NULL);
+
+ dev_addr = strstr(device_path, "dev_");
+ if (dev_addr != NULL) {
+ dev_addr += 4;
+ g_strlcpy(addr_ptr, dev_addr, BT_ADDRESS_STRING_SIZE);
+
+ for (i = 0; i < BT_ADDRESS_LENGTH_MAX; i++) {
+ addr[i] = strtol(addr_ptr, &ptr, 16);
+ if (ptr[0] != '\0') {
+ if (ptr[0] != '_')
+ return;
+
+ addr_ptr = ptr + 1;
+ }
+ }
+ }
+}
+
void _bt_convert_device_path_to_address(const char *device_path,
char *device_address)
{
static int obex_server_id;
static guint disable_timer_id;
static gboolean is_initialized;
-static GSList *sending_list = NULL;
-static GSList *server_list = NULL;
-static GSList *event_list = NULL;
-static int owner_sig_id = -1;
+static GSList *sending_list;
+static GSList *server_list;
+static GSList *event_list;
+static guint owner_sig_id;
void _bt_add_push_request_id(int request_id)
{
}
buffer = (char *) g_variant_get_data(byte_var);
memcpy(act_req.tds_data.data, buffer, act_req.tds_data.length);
+ g_variant_unref(byte_var);
_bt_convert_addr_string_to_type(act_req.rem_addr.addr, address);
buffer = (char *) g_variant_get_data(byte_var);
memcpy(ind_res.tds_data.data, buffer, ind_res.tds_data.length);
+ g_free(buffer);
_bt_convert_addr_string_to_type(ind_res.rem_addr.addr, address);
GDBusConnection *connection_type;
connection_type = _bt_gdbus_get_system_gconn();
- if (connection_type != NULL && owner_sig_id != -1) {
+ if (connection_type != NULL && owner_sig_id > 0) {
g_dbus_connection_signal_unsubscribe(connection_type,
owner_sig_id);
- owner_sig_id = -1;
+ owner_sig_id = 0;
}
}
GVariantIter *interface_iter = NULL;
char *interface_str = NULL;
bt_gatt_service_change_t change;
- char address[BT_ADDRESS_STRING_SIZE] = { 0 };
char secure_address[BT_ADDRESS_STRING_SIZE] = { 0 };
bt_user_info_t *user_info = NULL;
+ user_info = _bt_get_user_data(BT_COMMON);
+ if (user_info == NULL) {
+ BT_ERR("There is no registered common event callback");
+ return;
+ }
+
if (strcasecmp(signal_name, "GattServiceAdded") == 0) {
g_variant_get(parameters, "(&s)", &path);
- _bt_convert_device_path_to_address(path, address);
- _bt_convert_addr_string_to_type(change.device_addr.addr, address);
- _bt_convert_addr_string_to_secure_string(secure_address, address);
+ _bt_convert_device_path_to_addr_type(path, change.device_addr.addr);
+ _bt_convert_addr_type_to_secure_string(secure_address,
+ change.device_addr.addr);
if (_bluetooth_gatt_check_service_change_watcher_address(&change.device_addr)
== FALSE) {
BT_INFO("GATT Service [%s] added, but no watcher for %s",
- path, secure_address);
+ path, secure_address);
return;
} else
BT_INFO(" ### GATT Service added [%s] [%s]",
- path, secure_address);
+ path, secure_address);
change.svc_path = g_strdup(path);
change.change_type = BLUETOOTH_GATT_SERVICE_CHANGE_TYPE_ADD;
-
- user_info = _bt_get_user_data(BT_COMMON);
- if (user_info != NULL) {
- _bt_common_event_cb(
- BLUETOOTH_EVENT_GATT_CLIENT_SERVICE_CHANGED,
- BLUETOOTH_ERROR_NONE, &change,
- user_info->cb, user_info->user_data);
- }
-
+ _bt_common_event_cb(BLUETOOTH_EVENT_GATT_CLIENT_SERVICE_CHANGED,
+ BLUETOOTH_ERROR_NONE, &change,
+ user_info->cb, user_info->user_data);
g_free(change.svc_path);
} else if (strcasecmp(signal_name, "InterfacesRemoved") == 0) {
- g_variant_get(parameters, "(&oas)",
- &path, &interface_iter);
-
+ g_variant_get(parameters, "(&oas)", &path, &interface_iter);
if (!path) {
BT_ERR("Invalid adapter path");
+ g_variant_iter_free(interface_iter);
return;
}
- _bt_convert_device_path_to_address(path, address);
- _bt_convert_addr_string_to_type(change.device_addr.addr, address);
- _bt_convert_addr_string_to_secure_string(secure_address, address);
-
- if (_bluetooth_gatt_check_service_change_watcher_address(&change.device_addr)
- == FALSE) {
- BT_INFO("GATT Service [%s] removed, but no watcher for %s",
- path, secure_address);
+ _bt_convert_device_path_to_addr_type(path, change.device_addr.addr);
+ if (!_bluetooth_gatt_check_service_change_watcher_address(&change.device_addr)) {
+ g_variant_iter_free(interface_iter);
return;
}
- while (g_variant_iter_loop(interface_iter, "s", &interface_str)) {
- if (g_strcmp0(interface_str, GATT_SERV_INTERFACE) == 0) {
- change.svc_path = g_strdup(path);
- change.change_type = BLUETOOTH_GATT_SERVICE_CHANGE_TYPE_REMOVE;
-
- BT_INFO(" ### GATT Service removed [%s] [%s]",
- path, secure_address);
+ while (g_variant_iter_loop(interface_iter, "&s", &interface_str)) {
+ if (g_strcmp0(interface_str, GATT_SERV_INTERFACE) != 0)
+ continue;
- user_info = _bt_get_user_data(BT_COMMON);
- if (user_info != NULL) {
- _bt_common_event_cb(
- BLUETOOTH_EVENT_GATT_CLIENT_SERVICE_CHANGED,
- BLUETOOTH_ERROR_NONE, &change,
- user_info->cb, user_info->user_data);
- }
+ _bt_convert_addr_type_to_secure_string(secure_address,
+ change.device_addr.addr);
+ BT_INFO(" ### GATT Service removed [%s] [%s]",
+ path, secure_address);
- g_free(change.svc_path);
- break;
- }
+ change.svc_path = g_strdup(path);
+ change.change_type = BLUETOOTH_GATT_SERVICE_CHANGE_TYPE_REMOVE;
+ _bt_common_event_cb(
+ BLUETOOTH_EVENT_GATT_CLIENT_SERVICE_CHANGED,
+ BLUETOOTH_ERROR_NONE, &change,
+ user_info->cb, user_info->user_data);
+ g_free(change.svc_path);
+ break;
}
g_variant_iter_free(interface_iter);
}
int _bt_register_manager_subscribe_signal(gboolean subscribe)
{
GDBusConnection *g_conn;
- static int service_added_id = -1;
- static int interface_removed_id = -1;
+ static guint service_added_id = 0;
+ static guint interface_removed_id = 0;
g_conn = _bt_gdbus_get_system_gconn();
if (g_conn == NULL)
return BLUETOOTH_ERROR_INTERNAL;
if (subscribe == TRUE) {
- if (service_added_id == -1) {
+ if (service_added_id == 0) {
service_added_id = g_dbus_connection_signal_subscribe(g_conn,
NULL, GATT_SERV_INTERFACE,
"GattServiceAdded", NULL, NULL, 0,
__bt_manager_event_filter,
NULL, NULL);
}
- if (interface_removed_id == -1) {
+ if (interface_removed_id == 0) {
interface_removed_id = g_dbus_connection_signal_subscribe(g_conn,
NULL, BT_MANAGER_INTERFACE,
"InterfacesRemoved", NULL, NULL, 0,
NULL, NULL);
}
} else {
- if (service_added_id != -1) {
+ if (service_added_id > 0) {
g_dbus_connection_signal_unsubscribe(g_conn,
service_added_id);
- service_added_id = -1;
+ service_added_id = 0;
}
- if (interface_removed_id != -1) {
+ if (interface_removed_id > 0) {
g_dbus_connection_signal_unsubscribe(g_conn,
interface_removed_id);
- interface_removed_id = -1;
+ interface_removed_id = 0;
}
}
NULL, /* GDBusAuthObserver */
NULL,
&err);
+ g_free(address);
if (!g_conn) {
if (err) {
BT_ERR("Unable to connect to dbus: %s", err->message);
NULL, /* GDBusAuthObserver */
NULL,
&err);
-
+ g_free(address);
if (!local_system_gconn) {
BT_ERR("Unable to connect to dbus: %s", err->message);
g_clear_error(&err);
/* Register ObjectManager interface */
node_info = __bt_gatt_create_method_node_info(
manager_introspection_xml);
-
if (node_info == NULL) {
BT_ERR("failed to get node info");
goto failed;
&manager_interface_vtable,
NULL, NULL, &error);
}
-
+ g_dbus_node_info_unref(node_info);
if (manager_id == 0) {
BT_ERR("failed to register: %s", error->message);
g_error_free(error);
node_info = __bt_gatt_create_method_node_info(
service_introspection_xml);
-
if (node_info == NULL)
return BLUETOOTH_ERROR_INTERNAL;
node_info->interfaces[0],
&serv_interface_vtable,
NULL, NULL, &error);
+ g_dbus_node_info_unref(node_info);
if (object_id == 0) {
BT_ERR("failed to register: %s", error->message);
node_info = __bt_gatt_create_method_node_info(
characteristics_introspection_xml);
-
if (node_info == NULL)
return BLUETOOTH_ERROR_INTERNAL;
node_info->interfaces[0],
&char_interface_vtable,
NULL, NULL, &error);
+ g_dbus_node_info_unref(node_info);
if (object_id == 0) {
BT_ERR("failed to register: %s", error->message);
node_info = __bt_gatt_create_method_node_info(
descriptor_introspection_xml);
-
if (node_info == NULL) {
g_strfreev(line_argv);
g_free(serv_path);
node_info->interfaces[0],
&desc_interface_vtable,
NULL, NULL, &error);
+ g_dbus_node_info_unref(node_info);
if (object_id == 0) {
BT_ERR("failed to register: %s", error->message);
g_strfreev(line_argv);
g_variant_builder_unref(inner_builder);
g_variant_builder_unref(builder);
+ g_variant_builder_unref(builder2);
return BLUETOOTH_ERROR_NONE;
}
break;
}
+ case BT_HID_TRANS_GET_IDLE:{
+ BT_INFO("Get_IDLE");
+ data.type = HTYPE_TRANS_GET_IDLE;
+ data.param = PTYPE_DATA_RTYPE_INPUT;
+ data.buffer_size = len;
+ data.buffer = (char *) malloc(sizeof(char) * len);
+ if (data.buffer)
+ memcpy(data.buffer, buffer, len);
+ break;
+ }
+
+ case BT_HID_TRANS_SET_IDLE:{
+ BT_INFO("Set_IDLE");
+ data.type = HTYPE_TRANS_SET_IDLE;
+ data.param = PTYPE_DATA_RTYPE_INPUT;
+ data.buffer_size = len;
+ data.buffer = (char *) malloc(sizeof(char) * len);
+ if (data.buffer)
+ memcpy(data.buffer, buffer, len);
+ break;
+ }
+
default: {
BT_INFO("unsupported HIDP control message");
BT_ERR("Send Handshake Message");
bt_register_profile_info_t profile_info;
int result = BLUETOOTH_ERROR_NONE;
+ BT_CHECK_ENABLED(return);
+
if (_bt_check_privilege(BT_CHECK_PRIVILEGE, BT_HID_DEVICE_ACTIVATE)
== BLUETOOTH_ERROR_PERMISSION_DEINED) {
BT_ERR("Don't have a privilege to use this API");
BT_EXPORT_API int bluetooth_hid_device_deactivate(void)
{
+ BT_CHECK_ENABLED(return);
+
if (_bt_check_privilege(BT_CHECK_PRIVILEGE, BT_HID_DEVICE_DEACTIVATE)
== BLUETOOTH_ERROR_PERMISSION_DEINED) {
BT_ERR("Don't have a privilege to use this API");
BT_DBG("+");
BT_CHECK_PARAMETER(remote_addr, return);
+ BT_CHECK_ENABLED(return);
+
info = __find_hid_info_with_address(remote_addr);
if (info) {
BT_ERR("Connection Already Exists");
{
BT_CHECK_PARAMETER(remote_addr, return);
+ BT_CHECK_ENABLED(return);
+
if (_bt_check_privilege(BT_CHECK_PRIVILEGE, BT_HID_DEVICE_DISCONNECT)
== BLUETOOTH_ERROR_PERMISSION_DEINED) {
BT_ERR("Don't have a privilege to use this API");
{
int result;
struct reports output_report = { 0 };
- int bytes = 0;
+ int bytes = BLUETOOTH_ERROR_INTERNAL;
hid_connected_device_info_t *info = NULL;
info = __find_hid_info_with_address(remote_addr);
if (info == NULL) {
BT_DBG("Bytes Written %d", bytes);
break;
}
+
+ case HTYPE_TRANS_GET_IDLE: {
+ BT_DBG("Replying to Get_IDLE");
+ output_report.type = BT_HID_TRANS_DATA | BT_HID_DATA_RTYPE_OUTPUT;
+ output_report.rep_data[0] = data[0];
+ bytes = write(info->intr_fd, &output_report, 2);
+ BT_DBG("Bytes Written %d", bytes);
+ break;
+ }
+
+ case HTYPE_TRANS_SET_IDLE: {
+ BT_DBG("Reply to Set_IDLE");
+ output_report.type = BT_HID_TRANS_DATA | BT_HID_DATA_RTYPE_INPUT;
+ memcpy(output_report.rep_data, data, data_len);
+ bytes = write(info->ctrl_fd, &output_report,
+ sizeof(output_report));
+ BT_DBG("Bytes Written %d", bytes);
+ break;
+ }
+
default:
break;
}
close(conn_info->fd);
conn_info->disconnected = TRUE;
- _bt_disconnect_profile(conn_info->bt_addr, info->uuid,
- NULL, NULL);
-
+ _bt_disconnect_ext_profile(conn_info->bt_addr,
+ info->obj_path);
}
client = client->next;
object_id = _bt_register_new_conn(path, new_connection);
if (object_id < 0) {
__rfcomm_delete_id(id);
+ g_free(path);
return BLUETOOTH_ERROR_INTERNAL;
}
conn_info->disconnected = TRUE;
BT_INFO("conn_info %s", conn_info->bt_addr);
- _bt_disconnect_profile(conn_info->bt_addr, info->uuid, NULL, NULL);
+ _bt_disconnect_ext_profile(conn_info->bt_addr, info->obj_path);
if (info->idle_id == 0)
info->idle_id = g_idle_add(__rfcomm_client_disconnect, info);
close(fd);
_bt_convert_addr_type_to_string(addr_str, addr->addr);
- _bt_disconnect_profile(addr_str, info->uuid, NULL, NULL);
+ _bt_disconnect_ext_profile(addr_str, info->path);
return -1;
}
_bt_convert_addr_type_to_string(addr,
conn_info->addr.addr);
- _bt_disconnect_profile(addr, info->uuid, NULL, NULL);
+ _bt_disconnect_ext_profile(addr, info->path);
}
server = server->next;
_bt_convert_addr_type_to_string(address, conn->addr.addr);
BT_DBG("Address %s", address);
- _bt_disconnect_profile(address, info->uuid, NULL, NULL);
+ _bt_disconnect_ext_profile(address, info->path);
if (info->disconnect_idle_id == 0)
info->disconnect_idle_id = g_idle_add(
BT_CHECK_ENABLED_LE(return);
- retv_if(length > 0 && NULL == buf, BLUETOOTH_ERROR_INVALID_PARAM);
+ retv_if(NULL == buf, BLUETOOTH_ERROR_INVALID_PARAM);
+ retv_if(length == 0 || length > BLUETOOTH_TDS_DATA_LENGTH_MAX,
+ BLUETOOTH_ERROR_INVALID_PARAM);
tds_data.length = length;
memcpy(tds_data.data, buf, length);
node_info = __bt_telephony_create_method_node_info(
bt_telephony_introspection_xml);
-
if (node_info == NULL) {
BT_ERR("node_info NULL");
return BLUETOOTH_TELEPHONY_ERROR_INVALID_PARAM;
if (__bluetooth_telephony_register_object(TRUE, node_info) !=
BLUETOOTH_TELEPHONY_ERROR_NONE) {
BT_ERR("Registation of Method Failed");
+ g_dbus_node_info_unref(node_info);
return BLUETOOTH_TELEPHONY_ERROR_INTERNAL;
}
FN_END;
+ g_dbus_node_info_unref(node_info);
return BLUETOOTH_TELEPHONY_ERROR_NONE;
}
if (conn == NULL)
return -1;
- static int subscribe_adapter_id = -1;
+ static guint subscribe_adapter_id = 0;
+
if (subscribe == TRUE) {
- if (subscribe_adapter_id == -1) {
+ if (subscribe_adapter_id == 0) {
subscribe_adapter_id = g_dbus_connection_signal_subscribe(conn,
NULL, "org.freedesktop.DBus.ObjectManager",
"InterfacesAdded", NULL, NULL, 0,
}
return BLUETOOTH_TELEPHONY_ERROR_NONE;
} else {
- if (subscribe_adapter_id != -1) {
+ if (subscribe_adapter_id > 0) {
g_dbus_connection_signal_unsubscribe(conn,
subscribe_adapter_id);
- subscribe_adapter_id = -1;
+ subscribe_adapter_id = 0;
}
return BLUETOOTH_TELEPHONY_ERROR_NONE;
}
if (conn == NULL)
return -1;
- static int subscribe_event1_id = -1;
- static int subscribe_event2_id = -1;
- static int subscribe_event3_id = -1;
- static int subscribe_event4_id = -1;
- static int subscribe_event5_id = -1;
- static int subscribe_event6_id = -1;
+ static guint subscribe_event1_id = 0;
+ static guint subscribe_event2_id = 0;
+ static guint subscribe_event3_id = 0;
+ static guint subscribe_event4_id = 0;
+ static guint subscribe_event5_id = 0;
+ static guint subscribe_event6_id = 0;
+
if (subscribe == TRUE) {
- if (subscribe_event1_id == -1) {
+ if (subscribe_event1_id == 0) {
subscribe_event1_id = g_dbus_connection_signal_subscribe(conn,
NULL, BLUEZ_HEADSET_INTERFACE,
"PropertyChanged", NULL, NULL, 0,
__bluetooth_telephony_event_filter,
NULL, NULL);
}
- if (subscribe_event2_id == -1) {
+ if (subscribe_event2_id == 0) {
subscribe_event2_id = g_dbus_connection_signal_subscribe(conn,
NULL, HFP_AGENT_SERVICE,
HFP_NREC_STATUS_CHANGE, NULL, NULL, 0,
NULL, NULL);
}
- if (subscribe_event3_id == -1) {
+ if (subscribe_event3_id == 0) {
subscribe_event3_id = g_dbus_connection_signal_subscribe(conn,
NULL, HFP_AGENT_SERVICE,
HFP_ANSWER_CALL, NULL, NULL, 0,
__bluetooth_telephony_event_filter,
NULL, NULL);
}
- if (subscribe_event4_id == -1) {
+ if (subscribe_event4_id == 0) {
subscribe_event4_id = g_dbus_connection_signal_subscribe(conn,
NULL, HFP_AGENT_SERVICE,
HFP_REJECT_CALL, NULL, NULL, 0,
__bluetooth_telephony_event_filter,
NULL, NULL);
}
- if (subscribe_event5_id == -1) {
+ if (subscribe_event5_id == 0) {
subscribe_event5_id = g_dbus_connection_signal_subscribe(conn,
NULL, HFP_AGENT_SERVICE,
HFP_RELEASE_CALL, NULL, NULL, 0,
__bluetooth_telephony_event_filter,
NULL, NULL);
}
- if (subscribe_event6_id == -1) {
+ if (subscribe_event6_id == 0) {
subscribe_event6_id = g_dbus_connection_signal_subscribe(conn,
NULL, HFP_AGENT_SERVICE,
HFP_THREEWAY_CALL, NULL, NULL, 0,
return BLUETOOTH_TELEPHONY_ERROR_NONE;
} else {
- if (subscribe_event1_id != -1) {
+ if (subscribe_event1_id > 0) {
g_dbus_connection_signal_unsubscribe(conn,
subscribe_event1_id);
- subscribe_event1_id = -1;
+ subscribe_event1_id = 0;
}
- if (subscribe_event2_id != -1) {
+ if (subscribe_event2_id > 0) {
g_dbus_connection_signal_unsubscribe(conn,
subscribe_event2_id);
- subscribe_event2_id = -1;
+ subscribe_event2_id = 0;
}
- if (subscribe_event3_id != -1) {
+ if (subscribe_event3_id > 0) {
g_dbus_connection_signal_unsubscribe(conn,
subscribe_event3_id);
- subscribe_event3_id = -1;
+ subscribe_event3_id = 0;
}
- if (subscribe_event4_id != -1) {
+ if (subscribe_event4_id > 0) {
g_dbus_connection_signal_unsubscribe(conn,
subscribe_event4_id);
- subscribe_event4_id = -1;
+ subscribe_event4_id = 0;
}
- if (subscribe_event5_id != -1) {
+ if (subscribe_event5_id > 0) {
g_dbus_connection_signal_unsubscribe(conn,
subscribe_event5_id);
- subscribe_event5_id = -1;
+ subscribe_event5_id = 0;
}
- if (subscribe_event6_id != -1) {
+ if (subscribe_event6_id > 0) {
g_dbus_connection_signal_unsubscribe(conn,
subscribe_event6_id);
- subscribe_event6_id = -1;
+ subscribe_event6_id = 0;
}
return BLUETOOTH_TELEPHONY_ERROR_NONE;
}
GAsyncResult *res, gpointer user_data)
{
GError *error = NULL;
- GVariant *value;
+ GVariant *value = NULL;
value = g_dbus_proxy_call_finish(proxy, res, &error);
if (value == NULL) {
} else {
BT_ERR("SCo Start Failed");
}
+ g_object_unref(proxy);
+ return;
}
BT_DBG("sco_start_cb : -");
GAsyncResult *res, gpointer user_data)
{
GError *error = NULL;
- GVariant *value;
+ GVariant *value = NULL;
value = g_dbus_proxy_call_finish(proxy, res, &error);
if (value == NULL) {
} else {
BT_ERR("SCo close Failed");
}
+ g_object_unref(proxy);
+ return;
}
BT_DBG("sco_close_cb : -");
void _bt_divide_device_class(bluetooth_device_class_t *device_class,
unsigned int cod);
-void _bt_convert_addr_string_to_type(unsigned char *addr,
- const char *address);
+void _bt_convert_addr_string_to_type(unsigned char *addr, const char *address);
-void _bt_convert_addr_string_to_secure_string(char *addr,
- const char *address);
+void _bt_convert_addr_string_to_secure_string(char *addr, const char *address);
-void _bt_convert_addr_type_to_string(char *address,
- unsigned char *addr);
+void _bt_convert_addr_type_to_string(char *address, unsigned char *addr);
+
+void _bt_convert_addr_type_to_secure_string(char *address, unsigned char *addr);
const char *_bt_convert_error_to_string(int error);
gpointer func_data);
int _bt_disconnect_profile(char *address, char *uuid, void *cb,
gpointer func_data);
+int _bt_disconnect_ext_profile(char *address, char *path);
int _bt_cancel_discovers(char *address);
int _bt_discover_services(char *address, char *uuid, void *cb,
int _bt_get_uuid_specification_name(const char *uuid, char **name);
+void _bt_convert_device_path_to_addr_type(const char *device_path,
+ unsigned char *addr);
+
void _bt_convert_device_path_to_address(const char *device_path,
- char *device_address);
+ char *device_address);
#ifdef TIZEN_FEATURE_BT_RFCOMM_DIRECT
void _bt_rfcomm_server_free_all(void);
return TRUE;
}
+static gboolean __bt_core_terminate_cb(gpointer data)
+{
+ _bt_core_terminate();
+
+ return FALSE;
+}
+
gboolean _bt_core_disable_adapter(void)
{
int ret;
if (vconf_set_int(BT_OFF_DUE_TO_FLIGHT_MODE, 0) != 0)
BT_ERR("Set vconf failed");
+ g_idle_add((GSourceFunc)__bt_core_terminate_cb, NULL);
+
ret = _bt_disable_adapter();
if (ret < 0)
return FALSE;
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;
}
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;
char *http_security_obj_path = NULL;
static GMainLoop *main_loop;
-static int property_sub_id = -1;
-static int adapter_sub_id = -1;
+static guint property_sub_id;
+static guint adapter_sub_id;
static http_request_state req_state;
#ifdef HPS_GATT_DB
static GDBusConnection *conn;
static GDBusConnection *g_conn;
static guint g_owner_id = 0;
-GDBusNodeInfo *hps_node_info = NULL;
char *g_uri = NULL;
char *g_header = NULL;
static void _bt_hps_on_bus_acquired(GDBusConnection *connection, const gchar *name, gpointer user_data)
{
+ GDBusNodeInfo *node_info = NULL;
guint object_id;
GError *error = NULL;
g_conn = connection;
+ node_info = g_dbus_node_info_new_for_xml(hps_introspection_xml, &error);
+ if (!node_info) {
+ BT_ERR("Failed to install: %s", error->message);
+ g_clear_error(&error);
+ return;
+ }
+
object_id = g_dbus_connection_register_object(connection, BT_HPS_OBJECT_PATH,
- hps_node_info->interfaces[0],
+ node_info->interfaces[0],
&hps_method_table,
NULL, NULL, &error);
+ g_dbus_node_info_unref(node_info);
if (object_id == 0) {
BT_ERR("Failed to register method table: %s", error->message);
g_error_free(error);
- g_dbus_node_info_unref(hps_node_info);
}
return;
BT_DBG("");
g_object_unref(g_conn);
g_conn = NULL;
- g_dbus_node_info_unref(hps_node_info);
g_bus_unown_name(g_owner_id);
return;
int _bt_hps_register_interface(void)
{
- GError *error = NULL;
guint owner_id;
BT_DBG("");
- hps_node_info = g_dbus_node_info_new_for_xml(hps_introspection_xml, &error);
- if (!hps_node_info) {
- BT_ERR("Failed to install: %s", error->message);
- return BLUETOOTH_ERROR_INTERNAL;
- }
-
owner_id = g_bus_own_name(G_BUS_TYPE_SYSTEM,
BT_HPS_SERVICE_NAME,
G_BUS_NAME_OWNER_FLAGS_NONE,
g_object_unref(g_conn);
g_conn = NULL;
- g_dbus_node_info_unref(hps_node_info);
g_bus_unown_name(g_owner_id);
return;
if (tmp->data) {
struct hps_char_info *char_info = tmp->data;
if (!g_strcmp0(char_info->char_path, obj_path)) {
- gchar *str = NULL;
- if (offset > 0) {
- str = g_strdup(char_info->char_value);
- char_info->char_value = g_try_realloc(char_info->char_value, offset + value_length);
+ gchar *data = NULL;
+ if (char_info->char_value == NULL) {
+ char_info->char_value = g_malloc0(offset + value_length);
+ char_info->value_length = offset + value_length;
+ } else if (char_info->value_length >= offset + value_length) {
+ /* Just change from offset */
+ memcpy(&char_info->char_value[offset], value, value_length);
} else {
- char_info->char_value = g_try_realloc(char_info->char_value, value_length);
+ /* Values crossing pervious allocated limit realloc */
+ data = g_memdup(char_info->char_value, char_info->value_length);
+ char_info->char_value = g_try_realloc(char_info->char_value, offset + value_length);
+ memcpy(char_info->char_value, data, char_info->value_length);
+ memcpy(&char_info->char_value[offset], value, value_length);
+ char_info->value_length = offset + value_length;
+ g_free(data);
}
- if (char_info->char_value) {
- if (str) {
- memcpy(char_info->char_value, str, strlen(str));
- }
- if (offset > 0) {
- memcpy(&char_info->char_value[offset], value, value_length);
- char_info->value_length = offset + value_length;
- } else {
- memcpy(char_info->char_value, value, value_length);
- char_info->value_length = value_length;
- }
- hps_char_list = g_slist_insert_sorted(hps_char_list,
+ hps_char_list = g_slist_insert_sorted(hps_char_list,
char_info, char_info_cmp);
- }
- g_free(str);
return;
}
}
notify_read_info->offset_status = offset_status;
notify_read_info->https_status = https_status;
hps_notify_read_list = g_slist_insert_sorted(hps_notify_read_list,
- notify_read_info, notify_info_cmp);
+ notify_read_info, notify_info_cmp);
return;
}
}
hps_notify_read_list = g_slist_append(hps_notify_read_list, notify_read_info);
}
return;
- }
-
- /* Store Notification information */
- notify_read_info = g_new0(struct hps_notify_read_info, 1);
- if (notify_read_info) {
- notify_read_info->char_path = g_strdup(obj_path);
- notify_read_info->read_status = read_status;
- notify_read_info->offset_status = offset_status;
- notify_read_info->https_status = https_status;
- hps_notify_read_list = g_slist_append(hps_notify_read_list, notify_read_info);
+ } else {
+ /* Store Notification information */
+ notify_read_info = g_new0(struct hps_notify_read_info, 1);
+ if (notify_read_info) {
+ notify_read_info->char_path = g_strdup(obj_path);
+ notify_read_info->read_status = read_status;
+ notify_read_info->offset_status = offset_status;
+ notify_read_info->https_status = https_status;
+ hps_notify_read_list = g_slist_append(hps_notify_read_list, notify_read_info);
+ }
+ return;
}
}
void _bt_hps_deinit_event_receiver(void)
{
BT_DBG("");
- g_dbus_connection_signal_unsubscribe(conn, property_sub_id);
- g_dbus_connection_signal_unsubscribe(conn, adapter_sub_id);
+
+ if (conn == NULL)
+ return;
+
+ if (property_sub_id > 0) {
+ g_dbus_connection_signal_unsubscribe(conn, property_sub_id);
+ property_sub_id = 0;
+ }
+
+ if (adapter_sub_id) {
+ g_dbus_connection_signal_unsubscribe(conn, adapter_sub_id);
+ adapter_sub_id = 0;
+ }
+
conn = NULL;
+
return;
}
" </interface>"
"</node>";
-GDBusNodeInfo *node_info = NULL;
+static gboolean name_acquired = FALSE;
static char *current_sender_playing = NULL;
break;
}
case BT_LE_CONN_UPDATE: {
+ char *sender = NULL;
bluetooth_device_address_t local_address = { {0} };
bluetooth_le_connection_param_t parameters = {0};
+ sender = (char *)g_dbus_method_invocation_get_sender(context);
+
__bt_service_get_parameters(in_param1, &local_address,
sizeof(bluetooth_device_address_t));
__bt_service_get_parameters(in_param2, ¶meters,
sizeof(bluetooth_le_connection_param_t));
- result = _bt_le_conn_update(local_address.addr,
+ result = _bt_le_conn_update(sender,
+ local_address.addr,
parameters.interval_min,
parameters.interval_max,
parameters.latency,
break;
}
case BT_UPDATE_LE_CONNECTION_MODE: {
+ char *sender = NULL;
bluetooth_device_address_t remote_address = { { 0 } };
bluetooth_le_connection_param_t param = { 0 };
bluetooth_le_connection_mode_t mode = BLUETOOTH_LE_CONNECTION_MODE_BALANCED;
if (result != BLUETOOTH_ERROR_NONE)
break;
- result = _bt_le_conn_update(remote_address.addr,
+ sender = (char *)g_dbus_method_invocation_get_sender(context);
+
+ result = _bt_le_conn_update(sender,
+ remote_address.addr,
param.interval_min,
param.interval_max,
param.latency,
return 0;
}
+static void __bt_service_bus_acquired_handler(GDBusConnection *connection,
+ const gchar *name, gpointer user_data)
+{
+ GDBusNodeInfo *node_info = NULL;
+
+ BT_INFO("bus acquired");
+
+ ret_if(connection == NULL);
+
+ node_info = __bt_service_create_method_node_info(
+ bt_service_introspection_xml);
+ ret_if(node_info == NULL);
+
+ __bt_service_register_object(connection, node_info, TRUE);
+ g_dbus_node_info_unref(node_info);
+
+ bt_service_conn = connection;
+}
+
+static void __bt_service_name_acquired_handler(GDBusConnection *connection,
+ const gchar *name, gpointer user_data)
+{
+ BT_INFO("name acquired");
+ name_acquired = TRUE;
+}
+
+static void __bt_service_name_lost_handler(GDBusConnection *connection,
+ const gchar *name, gpointer user_data)
+{
+ BT_INFO("name lost");
+ name_acquired = FALSE;
+}
+
+gboolean _is_name_acquired(void)
+{
+ return name_acquired;
+}
+
int _bt_service_register(void)
{
GDBusConnection *conn;
GError *err = NULL;
- int result;
conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
+ bt_service_conn = conn;
owner_id = g_bus_own_name(G_BUS_TYPE_SYSTEM,
BT_SERVICE_NAME,
G_BUS_NAME_OWNER_FLAGS_NONE,
- NULL, NULL, NULL,
+ __bt_service_bus_acquired_handler,
+ __bt_service_name_acquired_handler,
+ __bt_service_name_lost_handler,
NULL, NULL);
BT_DBG("owner_id is [%d]", owner_id);
if (owner_id == 0)
goto fail;
- node_info = __bt_service_create_method_node_info(
- bt_service_introspection_xml);
-
- if (node_info == NULL)
- goto fail;
-
- result = __bt_service_register_object(conn, node_info, TRUE);
- g_dbus_node_info_unref(node_info);
- node_info = NULL;
-
- if (result != BLUETOOTH_ERROR_NONE)
- goto fail;
-
- bt_service_conn = conn;
-
return BLUETOOTH_ERROR_NONE;
fail:
g_object_unref(bt_service_conn);
bt_service_conn = NULL;
}
- if (node_info) {
- g_dbus_node_info_unref(node_info);
- node_info = NULL;
- }
if (owner_id > 0) {
g_bus_unown_name(owner_id);
owner_id = 0;
le_adv_slot = NULL;
}
-int _bt_service_adapter_le_init(void)
-{
- le_adv_slot = g_malloc0(sizeof(bt_adapter_le_adv_slot_t) * le_feature_info.adv_inst_max);
-
- return BLUETOOTH_ERROR_NONE;
-}
-
-void _bt_service_adapter_le_deinit(void)
-{
- __bt_free_le_adv_slot();
-}
-
gboolean _bt_update_le_feature_support(const char *item, const char *value)
{
if (item == NULL || value == NULL)
return FALSE;
+ if (!le_adv_slot)
+ _bt_service_adapter_le_init();
+
if (g_strcmp0(item, "adv_inst_max") == 0) {
int slot_num;
if (le_adv_slot == NULL)
return;
+ if (le_adv_slot[slot_id].hold_timer_id > 0) {
+ BT_INFO("Hold state adv is not unregistered");
+ return;
+ }
+
g_free(le_adv_slot[slot_id].sender);
le_adv_slot[slot_id].sender = NULL;
le_adv_slot[slot_id].adv_handle = 0;
if (le_adv_slot[slot_id].is_advertising == TRUE && enable == TRUE)
return BLUETOOTH_ERROR_IN_PROGRESS;
- if (le_adv_slot[slot_id].sender != NULL && le_adv_slot[slot_id].is_advertising == FALSE && enable == FALSE)
- return BLUETOOTH_ERROR_NOT_IN_OPERATION;
-
if (le_adv_slot[slot_id].hold_timer_id > 0) {
g_source_remove(le_adv_slot[slot_id].hold_timer_id);
le_adv_slot[slot_id].hold_timer_id = 0;
+ _bt_unregister_adv_slot_owner(slot_id);
}
+ if (le_adv_slot[slot_id].is_advertising == FALSE && enable == FALSE)
+ return BLUETOOTH_ERROR_NOT_IN_OPERATION;
+
proxy = _bt_get_adapter_proxy();
retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
if (le_adv_slot[slot_id].is_advertising == TRUE && enable == TRUE)
return BLUETOOTH_ERROR_IN_PROGRESS;
- if (le_adv_slot[slot_id].sender != NULL && le_adv_slot[slot_id].is_advertising == FALSE && enable == FALSE)
- return BLUETOOTH_ERROR_NOT_IN_OPERATION;
-
if (le_adv_slot[slot_id].hold_timer_id > 0) {
g_source_remove(le_adv_slot[slot_id].hold_timer_id);
le_adv_slot[slot_id].hold_timer_id = 0;
+ _bt_unregister_adv_slot_owner(slot_id);
}
+ if (le_adv_slot[slot_id].is_advertising == FALSE && enable == FALSE)
+ return BLUETOOTH_ERROR_NOT_IN_OPERATION;
+
proxy = _bt_get_adapter_proxy();
retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
if (enable == TRUE)
__bt_register_adv_slot_owner(sender, adv_handle, slot_id);
- else
- _bt_unregister_adv_slot_owner(slot_id);
le_adv_slot[slot_id].is_advertising = enable;
BT_INFO_C("### Set advertising [%d]", enable);
le_adv_slot[0].hold_timer_id = g_timeout_add(2000,
__bt_hold_current_advertising_timeout_cb, NULL);
} else {
- BT_ERR("It's NOT advertising");
+ BT_INFO("It's NOT advertising");
return BLUETOOTH_ERROR_NOT_IN_OPERATION;
}
scanner = __bt_find_scanner_from_list(sender);
if (scanner == NULL) {
scanner = g_malloc0(sizeof(bt_adapter_le_scanner_t));
- scanner->sender = strdup(sender);
+ scanner->sender = g_strdup(sender);
scanner_list = g_slist_append(scanner_list, scanner);
}
- filter_data = g_malloc0(sizeof(bluetooth_le_scan_filter_t));
- memcpy(filter_data, filter, sizeof(bluetooth_le_scan_filter_t));
- filter_data->slot_id = *slot_id;
- if (scanner)
+ if (scanner) {
+ filter_data = g_malloc0(sizeof(bluetooth_le_scan_filter_t));
+ memcpy(filter_data, filter, sizeof(bluetooth_le_scan_filter_t));
+ filter_data->slot_id = *slot_id;
+
scanner->filter_list = g_slist_append(scanner->filter_list, filter_data);
+ }
if (ret)
g_variant_unref(ret);
if (scanner == NULL) {
scanner = g_malloc0(sizeof(bt_adapter_le_scanner_t));
- scanner->sender = strdup(sender);
+ scanner->sender = g_strdup(sender);
scanner_list = g_slist_append(scanner_list, scanner);
}
}
}
+static void __bt_free_le_scanner(void)
+{
+ GSList *l;
+ bt_adapter_le_scanner_t *scanner;
+
+ for (l = scanner_list; l != NULL; l = g_slist_next(l)) {
+ scanner = l->data;
+ g_free(scanner->sender);
+ g_slist_free_full(scanner->filter_list, g_free);
+ g_free(scanner);
+ }
+
+ g_slist_free(scanner_list);
+ scanner_list = NULL;
+
+ scan_filter_enabled = FALSE;
+ is_le_scanning = FALSE;
+ is_le_set_scan_parameter = FALSE;
+}
+
void _bt_set_le_scan_status(gboolean mode)
{
is_le_scanning = mode;
return BLUETOOTH_ERROR_NONE;
}
+
+int _bt_service_adapter_le_init(void)
+{
+ le_adv_slot = g_malloc0(sizeof(bt_adapter_le_adv_slot_t) * le_feature_info.adv_inst_max);
+
+ return BLUETOOTH_ERROR_NONE;
+}
+
+void _bt_service_adapter_le_deinit(void)
+{
+ __bt_free_le_adv_slot();
+ __bt_free_le_scanner();
+}
GList *g_alarm_list;
} bt_service_alarm_mgr_t;
+#define BT_RECOVERY_MAX_COUNT 3
+
static bt_service_alarm_mgr_t alarm_mgr = {0, };
static gboolean is_discovering;
static GDBusProxy *core_proxy = NULL;
static guint timer_id = 0;
static guint le_timer_id = 0;
-static gboolean is_recovery_mode;
+static int recovery_cnt = BT_RECOVERY_MAX_COUNT;
+static guint recovery_timer = 0;
static uint status_reg_id;
#define BT_DISABLE_TIME 500 /* 500 ms */
+#define BT_RECOVERY_TIME_W 2000 /*2 sec*/
+#define BT_RECOVERY_TIME 5000 /*5 sec*/
+
static int alarm_cb(alarm_id_t alarm_id, void* user_param);
static void alarm_data_free(void *data);
char *phone_name = NULL;
char *ptr = NULL;
- if (node == NULL)
- return;
+ ret_if(node == NULL);
if (vconf_keynode_get_type(node) == VCONF_TYPE_STRING) {
phone_name = vconf_keynode_get_str(node);
(const char **)&ptr))
*ptr = '\0';
+ BT_INFO("device_name is changed to %s", phone_name);
_bt_set_local_name(phone_name);
+ } else {
+ BT_ERR("phone_name is NOT valid");
}
+ } else {
+ BT_ERR("vconf type is NOT string");
}
}
_bt_adapter_set_status(BT_DEACTIVATED);
_bt_set_discovery_status(FALSE);
- if (TIZEN_FEATURE_BT_USB_DONGLE ||
- _bt_adapter_get_le_status() != BT_LE_DEACTIVATED) {
- /* Send disabled event */
- _bt_send_event(BT_ADAPTER_EVENT, BLUETOOTH_EVENT_DISABLED,
- g_variant_new("(i)", result));
- }
-
BT_INFO("Adapter disabled");
}
/* Send disabled event */
_bt_send_event(BT_LE_ADAPTER_EVENT, BLUETOOTH_EVENT_LE_DISABLED,
- g_variant_new("(i)", result));
+ g_variant_new("(i)", result));
}
void *_bt_get_adapter_agent(void)
BT_DBG("bt_state: (%s)", bt_le_status);
}
+static gboolean __bt_adapter_recovery_cb(gpointer data)
+{
+ int ret = 0;
+
+ BT_DBG("+");
+
+ recovery_timer = 0;
+
+ _bt_service_initialize();
+
+ ret = _bt_enable_adapter_check_status();
+ if (ret == BLUETOOTH_ERROR_NONE) {
+ ret = _bt_enable_adapter();
+ if (ret < 0)
+ BT_ERR("_bt_enable_adapter() failed");
+
+ ret = _bt_enable_adapter_le();
+ if (ret < 0)
+ BT_ERR("_bt_enable_adapter_le() failed");
+ }
+
+ recovery_cnt--;
+
+ BT_DBG("-");
+
+ return FALSE;
+}
+
void _bt_handle_adapter_added(void)
{
BT_DBG("+");
}
*/
+ recovery_cnt = -1;
+
status = _bt_adapter_get_status();
le_status = _bt_adapter_get_le_status();
- BT_DBG("status : %d", status);
- BT_DBG("le_status : %d", le_status);
-
+ BT_INFO("status : %d", status);
+ BT_INFO("le_status : %d", le_status);
if (!TIZEN_FEATURE_BT_USB_DONGLE) {
adapter_agent = _bt_create_agent(BT_ADAPTER_AGENT_PATH, TRUE);
if (!adapter_agent) {
if (0 != ret)
ERR("vconf_ignore_key_changed failed\n");
-/* unregister all the services/servers/profiles registered on bluez-adapter
- once adapter is removed, reinitializing of the state-varaibles becomes
- a problem */
+ /* unregister all the services/servers/profiles registered on bluez-adapter
+ once adapter is removed, reinitializing of the state-varaibles becomes
+ a problem */
if (_bt_unregister_obex_server() != BLUETOOTH_ERROR_NONE)
BT_ERR("Fail to unregister obex server");
if (_bt_unregister_media_player() != BLUETOOTH_ERROR_NONE)
BT_ERR("Fail to unregister media player");
-/* Other unregister APIs should be placed here */
+ /* Other unregister APIs should be placed here */
if (!TIZEN_FEATURE_BT_USB_DONGLE) {
_bt_destroy_agent(adapter_agent);
adapter_agent = NULL;
- if (is_recovery_mode == TRUE) {
+ if (recovery_cnt > 0) {
/* Send disabled event */
_bt_set_disabled(BLUETOOTH_ERROR_NONE);
+ _bt_send_event(BT_ADAPTER_EVENT, BLUETOOTH_EVENT_DISABLED,
+ g_variant_new("(i)", BLUETOOTH_ERROR_NONE));
- /* Will recover BT by bt-core, so set the mode as activating */
- _bt_adapter_set_status(BT_ACTIVATING);
- is_recovery_mode = FALSE;
- } else {
- _bt_reliable_terminate_service(NULL);
+ if (recovery_timer > 0)
+ g_source_remove(recovery_timer);
+
+ if (TIZEN_PROFILE_WEARABLE) {
+ recovery_timer = g_timeout_add(BT_RECOVERY_TIME_W,
+ (GSourceFunc)__bt_adapter_recovery_cb, NULL);
+ } else {
+ recovery_timer = g_timeout_add(BT_RECOVERY_TIME,
+ (GSourceFunc)__bt_adapter_recovery_cb, NULL);
+ }
+
+ if (eventsystem_unregister_event(status_reg_id) != ES_R_OK)
+ BT_ERR("Fail to unregister system event");
+ return;
}
+
+ if (recovery_timer == 0)
+ _bt_reliable_terminate_service(NULL);
} else {
_bt_set_disabled(BLUETOOTH_ERROR_NONE);
+ _bt_send_event(BT_ADAPTER_EVENT, BLUETOOTH_EVENT_DISABLED,
+ g_variant_new("(i)", BLUETOOTH_ERROR_NONE));
}
if (eventsystem_unregister_event(status_reg_id) != ES_R_OK)
g_variant_unref(result);
_bt_set_disabled(BLUETOOTH_ERROR_TIMEOUT);
+ if (recovery_cnt > 0) {
+ BT_ERR("Try recovery again(remain:%d)", recovery_cnt);
+ if (recovery_timer > 0)
+ g_source_remove(recovery_timer);
+
+ if (TIZEN_PROFILE_WEARABLE) {
+ recovery_timer = g_timeout_add(BT_RECOVERY_TIME_W,
+ (GSourceFunc)__bt_adapter_recovery_cb, NULL);
+ } else {
+ recovery_timer = g_timeout_add(BT_RECOVERY_TIME,
+ (GSourceFunc)__bt_adapter_recovery_cb, NULL);
+ }
+
+ return FALSE;
+ }
+
if (!TIZEN_FEATURE_BT_USB_DONGLE)
_bt_terminate_service(NULL);
}
g_variant_unref(result);
- _bt_adapter_set_le_status(BT_LE_DEACTIVATED);
- _bt_set_le_disabled(BLUETOOTH_ERROR_TIMEOUT);
+ if (_bt_adapter_get_le_status() != BT_LE_DEACTIVATED)
+ _bt_set_le_disabled(BLUETOOTH_ERROR_TIMEOUT);
if (_bt_adapter_get_status() == BT_DEACTIVATED)
_bt_terminate_service(NULL);
return BLUETOOTH_ERROR_NONE;
}
+static gboolean __bt_set_powered(gboolean powered)
+{
+ GDBusProxy *proxy;
+ GError *error = NULL;
+ GVariant *result;
+
+ BT_DBG("");
+
+ proxy = _bt_get_adapter_properties_proxy();
+ retv_if(proxy == NULL, FALSE);
+
+ result = g_dbus_proxy_call_sync(proxy, "Set",
+ g_variant_new("(ssv)", BT_ADAPTER_INTERFACE, "Powered",
+ g_variant_new("b", powered)),
+ G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+ if (!result) {
+ if (error != NULL) {
+ BT_ERR("Failed to set powered property (Error: %s)",
+ error->message);
+ g_clear_error(&error);
+ } else {
+ BT_ERR("Failed to set powered property");
+ }
+ return FALSE;
+ }
+
+ BT_INFO("Set powered [%d]", powered);
+ g_variant_unref(result);
+ return TRUE;
+}
+
static gboolean __bt_disconnect_all(void)
{
int i;
{
BT_DBG("");
_bt_set_disabled(BLUETOOTH_ERROR_NONE);
+ _bt_send_event(BT_ADAPTER_EVENT, BLUETOOTH_EVENT_DISABLED,
+ g_variant_new("(i)", BLUETOOTH_ERROR_NONE));
return FALSE;
}
{
BT_DBG("+");
int ret;
+ bt_le_status_t le_status;
if (_bt_adapter_get_status() == BT_DEACTIVATING) {
BT_DBG("Disabling in progress");
g_source_remove(timer_id);
timer_id = 0;
}
-/* unregister all the services/servers/profiles registered on bluez-adapter
- once adapter is removed, reinitializing of the state-varaibles becomes
- a problem */
+
+ /* unregister all the services/servers/profiles registered on bluez-adapter
+ once adapter is removed, reinitializing of the state-varaibles becomes
+ a problem */
if (_bt_unregister_obex_server() != BLUETOOTH_ERROR_NONE)
BT_ERR("Fail to unregister obex server");
if (_bt_unregister_media_player() != BLUETOOTH_ERROR_NONE)
BT_ERR("Fail to unregister media player");
+ /* Other unregister APIs should be placed here */
+
+ le_status = _bt_adapter_get_le_status();
+ if (le_status == BT_LE_ACTIVATED && is_le_intended == TRUE) {
+ __bt_disconnect_all();
+ } else {
+ if (le_status == BT_LE_ACTIVATED)
+ _bt_set_le_disabled(BLUETOOTH_ERROR_NONE);
+
+ __bt_set_powered(FALSE);
+ }
-/* Other unregister APIs should be placed here */
- __bt_disconnect_all();
ret = _bt_disable_cb();
BT_DBG("-");
int _bt_recover_adapter(void)
{
BT_DBG("+");
- GDBusProxy *proxy;
- GVariant *result;
- GError *error = NULL;
if (_bt_adapter_get_status() == BT_DEACTIVATING) {
BT_DBG("Disabling in progress");
return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
}
- _bt_adapter_set_status(BT_DEACTIVATING);
-
- proxy = __bt_get_core_proxy();
- retv_if(!proxy, BLUETOOTH_ERROR_INTERNAL);
-
- result = g_dbus_proxy_call_sync(proxy,
- "RecoverAdapter",
- NULL,
- G_DBUS_CALL_FLAGS_NONE,
- -1,
- NULL,
- &error);
-
- if (!result) {
- if (error != NULL) {
- BT_ERR("Failed to RecoverAdapter (Error: %s)", error->message);
- g_clear_error(&error);
- } else
- BT_ERR("Failed to RecoverAdapter");
- return BLUETOOTH_ERROR_INTERNAL;
- }
-
- is_recovery_mode = TRUE;
+ recovery_cnt = BT_RECOVERY_MAX_COUNT;
- g_variant_unref(result);
- __bt_disconnect_all();
+ _bt_disable_adapter();
+ _bt_disable_adapter_le();
BT_DBG("-");
return BLUETOOTH_ERROR_NONE;
if (status == BT_DEACTIVATING || le_status == BT_LE_DEACTIVATING) {
BT_ERR("Disabling in progress");
+ _bt_set_le_intended_status(FALSE);
return BLUETOOTH_ERROR_DEVICE_BUSY;
}
}
check_req_info:
- req_info = _bt_get_request_info(func_data->req_id);
- if (req_info == NULL) {
- BT_ERR("req_info == NULL");
- goto done;
- }
-
if (g_error == NULL)
goto dbus_return;
/* Event will be sent by the event reciever */
dbus_return:
- if (req_info->context == NULL) {
- BT_DBG("req_info->context is NULL");
+ req_info = _bt_get_request_info(func_data->req_id);
+ if (req_info == NULL) {
+ BT_ERR("req_info == NULL");
+ goto done;
+ } else if (req_info->context == NULL) {
+ BT_ERR("req_info->context is NULL");
goto done;
}
node = g_list_next(node);
}
- if (!connected)
+ if (!connected) {
+ __bt_free_wait_data();
return BLUETOOTH_ERROR_NOT_CONNECTED;
+ }
BT_DBG("connected headset %s", connected_address);
goto fail;
}
BT_INFO("Connecting to service %s", uuid);
+ /* First Check if device is in connecting state if it than return error */
+ value = __bt_is_headset_connecting(type);
+ if (value != BLUETOOTH_ERROR_NONE) {
+ result = BLUETOOTH_ERROR_IN_PROGRESS;
+ goto fail;
+ }
value = __bt_is_headset_connected(type, request_id, address);
result = BLUETOOTH_ERROR_ALREADY_CONNECT;
goto fail;
} else if (value == BLUETOOTH_ERROR_NOT_CONNECTED) {
- value = __bt_is_headset_connecting(type);
- if (value != BLUETOOTH_ERROR_NONE) {
- result = BLUETOOTH_ERROR_IN_PROGRESS;
- goto fail;
- }
_bt_headset_set_local_connection(TRUE);
ret = _bt_connect_profile(address, uuid,
__bt_audio_request_cb, func_data);
gboolean auto_connect;
} bt_pending_le_conn_info_s;
+typedef struct {
+ char *address;
+ float interval_min;
+ float interval_max;
+ GSList *senders;
+} bt_connected_le_dev_t;
+
+typedef struct {
+ char *sender;
+ float interval_min;
+ float interval_max;
+ guint16 latency;
+ guint16 time_out;
+ float key;
+} bt_le_conn_param_t;
+
gboolean is_device_creating;
bt_funcion_data_t *bonding_info;
bt_funcion_data_t *searching_info;
bt_funcion_data_t *att_mtu_req_info;
+static GSList *le_connected_dev_list = NULL;
static GSList *pin_info_list = NULL;
static bt_pending_le_conn_info_s *pending_le_conn_info = NULL;
static guint pending_le_conn_timer_id = 0;
BT_CHECK_PARAMETER(bonding_info, return);
BT_CHECK_PARAMETER(bonding_info->addr, return);
+ is_device_creating = TRUE;
+
g_dbus_proxy_call(bonding_info->device_proxy, "Pair",
g_variant_new("(y)", bonding_info->conn_type),
G_DBUS_CALL_FLAGS_NONE,
g_dbus_method_invocation_return_value(req_info->context,
g_variant_new("(iv)", result, out_param1));
- g_variant_unref(out_param1);
-
_bt_delete_request_list(req_info->req_id);
done:
if (err)
static gboolean __bt_connect_le_timer_cb(gpointer user_data)
{
+ int ret;
+
BT_INFO("Try to initiate pending LE connection");
pending_le_conn_timer_id = 0;
- __bt_connect_le_device_internal(pending_le_conn_info->req_id,
- &pending_le_conn_info->bd_addr,
- pending_le_conn_info->auto_connect);
+ ret = __bt_connect_le_device_internal(pending_le_conn_info->req_id,
+ &pending_le_conn_info->bd_addr,
+ pending_le_conn_info->auto_connect);
+ if (ret != BLUETOOTH_ERROR_NONE) {
+ request_info_t *req_info = NULL;
+ GVariant *out_param1;
+
+ req_info = _bt_get_request_info(pending_le_conn_info->req_id);
+ if (req_info == NULL) {
+ BT_ERR("req_info is NULL");
+ goto done;
+ }
+
+ if (req_info->context == NULL) {
+ BT_ERR("req_info->context is NULL");
+ _bt_delete_request_list(req_info->req_id);
+ goto done;
+ }
+
+ out_param1 = g_variant_new_from_data((const GVariantType *)"ay",
+ &pending_le_conn_info->bd_addr,
+ sizeof(bluetooth_device_address_t), TRUE,
+ NULL, NULL);
+
+ g_dbus_method_invocation_return_value(req_info->context,
+ g_variant_new("(iv)", ret, out_param1));
+ }
+done:
g_free(pending_le_conn_info);
pending_le_conn_info = NULL;
g_timeout_add(1000, __bt_connect_le_timer_cb, NULL);
return BLUETOOTH_ERROR_NONE;
+ } else if (ret != BLUETOOTH_ERROR_NOT_IN_OPERATION) {
+ BT_ERR("Unable to hold advertising");
}
- BT_ERR("Unable to hold advertising");
-
return __bt_connect_le_device_internal(req_id, bd_addr, auto_connect);
}
return ret;
}
-int _bt_le_conn_update(unsigned char *device_address,
+static int __bt_le_set_conn_parameter(const char *address,
float interval_min, float interval_max,
guint16 latency, guint16 time_out)
{
- char address[BT_ADDRESS_STRING_SIZE] = { 0 };
gchar *device_path = NULL;
GError *error = NULL;
GDBusProxy *device_proxy = NULL;
GDBusConnection *conn;
GVariant *reply;
guint32 min, max, to;
- guint32 min_supervision_to;
int ret = BLUETOOTH_ERROR_NONE;
- BT_CHECK_PARAMETER(device_address, return);
+ BT_CHECK_PARAMETER(address, return);
BT_INFO("Min interval: %f, Max interval: %f, Latency: %u, Supervision timeout: %u",
interval_min, interval_max, latency, time_out);
- if (interval_min > interval_max ||
- interval_min < BT_LE_CONN_INTERVAL_MIN ||
- interval_max > BT_LE_CONN_INTERVAL_MAX) {
- ret = BLUETOOTH_ERROR_INVALID_PARAM;
- goto fail;
- }
-
- if (time_out < BT_LE_CONN_SUPER_TO_MIN ||
- time_out > BT_LE_CONN_SUPER_TO_MAX) {
- ret = BLUETOOTH_ERROR_INVALID_PARAM;
- goto fail;
- }
-
- if (latency > BT_LE_CONN_SLAVE_LATENCY_MAX) {
- ret = BLUETOOTH_ERROR_INVALID_PARAM;
- goto fail;
- }
-
- /*
- * The Supervision_Timeout in milliseconds shall be larger than
- * (1 + Conn_Latency) * Conn_Interval_Max * 2,
- * where Conn_Interval_Max is given in milliseconds.
- */
- min_supervision_to = (1 + latency) * interval_max * 2;
- if (time_out <= min_supervision_to) {
- ret = BLUETOOTH_ERROR_INVALID_PARAM;
- goto fail;
- }
-
- _bt_convert_addr_type_to_string(address, device_address);
-
- BT_DBG("Remote device address: %s", address);
-
- device_path = _bt_get_device_object_path(address);
+ device_path = _bt_get_device_object_path((char *)address);
if (device_path == NULL) {
BT_ERR("device_path NULL");
return ret;
}
+static void __bt_le_conn_param_free(void *data)
+{
+ bt_le_conn_param_t *param = (bt_le_conn_param_t *)data;
+
+ BT_DBG("%s", param->sender);
+ g_free(param->sender);
+ g_free(param);
+}
+
+static gint __bt_compare_le_conn_param_key(gpointer *a, gpointer *b)
+{
+ bt_le_conn_param_t *parama = (bt_le_conn_param_t *)a;
+ bt_le_conn_param_t *paramb = (bt_le_conn_param_t *)b;
+
+ return parama->key > paramb->key;
+}
+
+static bt_connected_le_dev_t *__bt_get_le_connected_dev_info(const char *address)
+{
+ GSList *l = NULL;
+ bt_connected_le_dev_t *dev;
+
+ if (!address)
+ return NULL;
+
+ for (l = le_connected_dev_list; l; l = g_slist_next(l)) {
+ dev = l->data;
+
+ if (g_strcmp0(dev->address, address) == 0)
+ return dev;
+ }
+ return NULL;
+}
+
+static bt_le_conn_param_t *__bt_get_le_conn_param_info(bt_connected_le_dev_t *dev, const char *sender)
+{
+ GSList *l = NULL;
+ bt_le_conn_param_t *param = NULL;
+
+ if (!dev || !sender)
+ return NULL;
+
+ for (l = dev->senders; l; l = g_slist_next(l)) {
+ param = l->data;
+ if (g_strcmp0(param->sender, sender) == 0)
+ return param;
+ }
+
+ return NULL;
+}
+
+int _bt_add_le_conn_param_info(const char *address, const char *sender,
+ float interval_min, float interval_max, guint16 latency, guint16 time_out)
+{
+ bt_connected_le_dev_t *dev = NULL;
+ bt_le_conn_param_t *param = NULL;
+ bt_le_conn_param_t *data = NULL;
+
+ if (!address || !sender)
+ return BLUETOOTH_ERROR_INVALID_PARAM;
+
+ dev = __bt_get_le_connected_dev_info(address);
+ if (!dev)
+ return BLUETOOTH_ERROR_INTERNAL;
+
+ param = __bt_get_le_conn_param_info(dev, sender);
+
+ data = g_malloc0(sizeof(bt_le_conn_param_t));
+ data->sender = g_strdup(sender);
+ data->interval_min = interval_min;
+ data->interval_max = interval_max;
+ data->latency = latency;
+ data->time_out = time_out;
+ data->key = interval_min + (interval_max - interval_min)/2;
+
+ if (param == NULL) {
+ BT_DBG("Add param %s %s %f %f", address, sender, interval_min, interval_max);
+ dev->senders = g_slist_append(dev->senders, data);
+ } else {
+ BT_DBG("Update param %s %s %f %f", address, sender, interval_min, interval_max);
+ dev->senders = g_slist_remove(dev->senders, param);
+ g_free(param->sender);
+ g_free(param);
+ dev->senders = g_slist_append(dev->senders, data);
+ }
+
+ /* Sorting. First element have the minimum interval */
+ dev->senders = g_slist_sort(dev->senders,
+ (GCompareFunc)__bt_compare_le_conn_param_key);
+
+ return BLUETOOTH_ERROR_NONE;
+}
+
+int _bt_remove_le_conn_param_info(const char *address, const char *sender, gboolean *is_removed)
+{
+ bt_connected_le_dev_t *dev = NULL;
+ bt_le_conn_param_t *param = NULL;
+
+ if (!address || !sender)
+ return BLUETOOTH_ERROR_INVALID_PARAM;
+
+ dev = __bt_get_le_connected_dev_info(address);
+ if (!dev)
+ return BLUETOOTH_ERROR_INTERNAL;
+
+ param = __bt_get_le_conn_param_info(dev, sender);
+ if (param) {
+ BT_DBG("Remove param %s %s ", address, sender);
+ dev->senders = g_slist_remove(dev->senders, param);
+ g_free(param->sender);
+ g_free(param);
+ *is_removed = TRUE;
+ } else
+ *is_removed = FALSE;
+
+ return BLUETOOTH_ERROR_NONE;
+}
+
+int _bt_remove_all_le_conn_param_info(const char *sender)
+{
+ GSList *l = NULL;
+ bt_connected_le_dev_t *dev = NULL;
+ bt_le_conn_param_t *param = NULL;
+ gboolean is_removed = FALSE;
+ char *sender_new = NULL;
+ unsigned char addr[BLUETOOTH_ADDRESS_LENGTH];
+ int ret = BLUETOOTH_ERROR_NONE;
+
+ if (!sender)
+ return BLUETOOTH_ERROR_INVALID_PARAM;
+
+ for (l = le_connected_dev_list; l; l = g_slist_next(l)) {
+ dev = l->data;
+ _bt_remove_le_conn_param_info(dev->address, sender, &is_removed);
+
+ if (is_removed) {
+ BT_INFO("Sender terminated. Update le conn interval [senders %d]",
+ g_slist_length(dev->senders));
+ if (g_slist_length(dev->senders) > 0) {
+ param = dev->senders->data;
+ BT_DBG("dev %f %f, param %f %f", dev->interval_min, dev->interval_max,
+ param->interval_min, param->interval_max);
+
+ if (dev->interval_min != param->interval_min ||
+ dev->interval_max != param->interval_max) {
+ sender_new = g_strdup(param->sender);
+
+ _bt_convert_addr_string_to_type(addr, dev->address);
+ ret = _bt_le_conn_update(sender_new, addr,
+ param->interval_min, param->interval_max,
+ param->latency, param->time_out);
+ g_free(sender_new);
+
+ if (ret != BLUETOOTH_ERROR_NONE)
+ BT_ERR("Unable to set le connection parameter");
+ }
+ } else {
+ BT_INFO("Set the default interval");
+
+ bluetooth_le_connection_param_t param = { 0 };
+ _bt_get_le_connection_parameter(
+ BLUETOOTH_LE_CONNECTION_MODE_LOW_POWER,
+ ¶m);
+
+ ret = __bt_le_set_conn_parameter(dev->address,
+ param.interval_min, param.interval_max,
+ param.latency, param.timeout);
+ if (ret == BLUETOOTH_ERROR_NONE) {
+ dev->interval_min = param.interval_min;
+ dev->interval_max = param.interval_max;
+ }
+ }
+ }
+ }
+
+ return ret;
+}
+
+void _bt_add_le_connected_dev_info(const char *address)
+{
+ bt_connected_le_dev_t *dev = NULL;
+
+ if (!address)
+ return;
+
+ dev = g_malloc0(sizeof(bt_connected_le_dev_t));
+ dev->address = g_strdup(address);
+
+ le_connected_dev_list = g_slist_append(le_connected_dev_list, dev);
+
+ return;
+}
+
+void _bt_remove_le_connected_dev_info(const char *address)
+{
+ bt_connected_le_dev_t *dev = NULL;
+
+ if (!address)
+ return;
+
+ dev = __bt_get_le_connected_dev_info(address);
+ if (!dev)
+ return;
+
+ g_slist_free_full(dev->senders, __bt_le_conn_param_free);
+ le_connected_dev_list = g_slist_remove(le_connected_dev_list, dev);
+ g_free(dev->address);
+ g_free(dev);
+
+ return;
+}
+
+int _bt_le_conn_update(const char *sender,
+ unsigned char *device_address,
+ float interval_min, float interval_max,
+ guint16 latency, guint16 time_out)
+{
+ char address[BT_ADDRESS_STRING_SIZE] = { 0 };
+ guint32 min_supervision_to;
+ bt_connected_le_dev_t *dev = NULL;
+ bt_le_conn_param_t *param = NULL;
+ gboolean is_removed = FALSE;
+ int ret = BLUETOOTH_ERROR_NONE;
+
+ BT_CHECK_PARAMETER(device_address, return);
+
+ BT_INFO("Sender %s, Min interval: %f, Max interval: %f, Latency: %u, Supervision timeout: %u",
+ sender, interval_min, interval_max, latency, time_out);
+
+ if (interval_min > interval_max ||
+ interval_min < BT_LE_CONN_INTERVAL_MIN ||
+ interval_max > BT_LE_CONN_INTERVAL_MAX) {
+ ret = BLUETOOTH_ERROR_INVALID_PARAM;
+ goto fail;
+ }
+
+ if (time_out < BT_LE_CONN_SUPER_TO_MIN ||
+ time_out > BT_LE_CONN_SUPER_TO_MAX) {
+ ret = BLUETOOTH_ERROR_INVALID_PARAM;
+ goto fail;
+ }
+
+ if (latency > BT_LE_CONN_SLAVE_LATENCY_MAX) {
+ ret = BLUETOOTH_ERROR_INVALID_PARAM;
+ goto fail;
+ }
+
+ /*
+ * The Supervision_Timeout in milliseconds shall be larger than
+ * (1 + Conn_Latency) * Conn_Interval_Max * 2,
+ * where Conn_Interval_Max is given in milliseconds.
+ */
+ min_supervision_to = (1 + latency) * interval_max * 2;
+ if (time_out <= min_supervision_to) {
+ ret = BLUETOOTH_ERROR_INVALID_PARAM;
+ goto fail;
+ }
+
+ _bt_convert_addr_type_to_string(address, device_address);
+ BT_DBG("Remote device address: %s", address);
+
+ _bt_add_le_conn_param_info(address, sender, interval_min, interval_max, 0, 2000);
+
+ dev = __bt_get_le_connected_dev_info(address);
+ if (dev == NULL) {
+ ret = BLUETOOTH_ERROR_NOT_CONNECTED;
+ goto fail;
+ }
+
+ if (g_slist_length(dev->senders) == 1)
+ goto update;
+ else {
+ param = dev->senders->data;
+
+ BT_DBG("dev %f, param %f, input %f", dev->interval_min, param->interval_min, interval_min);
+
+ if (dev->interval_min == param->interval_min && dev->interval_max == param->interval_max) {
+ BT_DBG("Skip due to same interval");
+ return ret;
+ }
+
+ interval_min = param->interval_min;
+ interval_max = param->interval_max;
+ }
+
+update:
+ ret = __bt_le_set_conn_parameter(address, interval_min, interval_max, latency, time_out);
+
+ if (ret != BLUETOOTH_ERROR_NONE) {
+ _bt_remove_le_conn_param_info(address, sender, &is_removed);
+ return ret;
+ }
+
+ dev->interval_min = interval_min;
+ dev->interval_max = interval_max;
+
+fail:
+ return ret;
+}
+
int _bt_set_pin_code(bluetooth_device_address_t *device_address,
bluetooth_device_pin_code_t *pin_code)
{
BT_DBG("-");
}
-static void __bt_device_remote_connected_properties(
- bt_remote_dev_info_t *remote_dev_info,
- char *address, gboolean connected)
-{
- int result = BLUETOOTH_ERROR_NONE;
- int i;
- GVariant *param = NULL;
- BT_DBG("+");
-
- if (remote_dev_info->uuid_count > 0) {
- for (i = 0; i < remote_dev_info->uuid_count; i++) {
- char *uuid = remote_dev_info->uuids[i];
- if (strcasecmp(uuid, HID_UUID) == 0) {
- int event = BLUETOOTH_EVENT_NONE;
-
- event = (connected == TRUE) ?
- BLUETOOTH_HID_CONNECTED :
- BLUETOOTH_HID_DISCONNECTED;
- param = g_variant_new("(is)", result,
- address);
- _bt_send_event(BT_HID_EVENT, event,
- param);
- break;
- }
- }
- }
-
- BT_DBG("-");
-}
-
gboolean __bt_handle_is_flight_mode_enabled(void)
{
int is_flight_mode = 0;
g_variant_get(val, "b", &discovering);
/* Send event to application */
BT_DBG("Discovering %d", discovering);
+ if (_bt_adapter_get_status() != BT_ACTIVATED)
+ return;
+
if (discovering == TRUE) {
_bt_set_discovery_status(TRUE);
param = g_variant_new("(i)", result);
gboolean le_discovering = FALSE;
g_variant_get(val, "b", &le_discovering);
+ BT_DBG("LEDiscovering %d", le_discovering);
+ if (_bt_adapter_get_status() != BT_ACTIVATED ||
+ _bt_adapter_get_le_status() != BT_LE_ACTIVATED)
+ return;
+
/* Send event to application */
if (le_discovering == TRUE) {
_bt_set_le_scan_status(TRUE);
char *property = NULL;
char *address;
GVariant *param = NULL;
- bt_remote_dev_info_t *remote_dev_info;
g_variant_iter_init(&value_iter, msg);
#ifdef TIZEN_FEATURE_BT_DPM
int desktop_state = DPM_BT_ERROR;
BT_DBG("connected: %d", connected);
BT_DBG("address: %s", address);
- remote_dev_info = _bt_get_remote_device_info_by_object_path(path);
-
- if (remote_dev_info != NULL) {
- __bt_device_remote_connected_properties(
- remote_dev_info, address,
- connected != BLUETOOTH_CONNECTED_LINK_NONE ?
- TRUE : FALSE);
- _bt_free_device_info(remote_dev_info);
- }
param = g_variant_new("(is)", result, address);
/* Send event to application */
_bt_send_event(BT_DEVICE_EVENT,
char *address;
GVariant *val = NULL;
GVariant *child = NULL;
- bt_remote_dev_info_t *remote_dev_info;
GVariant *param = NULL;
g_variant_iter_init(&value_iter, msg);
while ((child = g_variant_iter_next_value(&value_iter))) {
BT_DBG("connected: %d", connected);
BT_DBG("address: %s", address);
- remote_dev_info = _bt_get_remote_device_info(address);
-
- if (remote_dev_info != NULL) {
- __bt_device_remote_connected_properties(
- remote_dev_info, address, connected);
- _bt_free_device_info(remote_dev_info);
- }
param = g_variant_new("(is)", result, address);
/* Send event to application */
_bt_send_event(BT_AVRCP_EVENT,
!addr_type ? dev_name : secure_address);
g_free(dev_name);
+ if (addr_type)
+ _bt_add_le_connected_dev_info(address);
+
_bt_logging_connection(TRUE, addr_type);
param = g_variant_new("(isy)", result, address, addr_type);
/*Send event to application*/
_bt_headset_set_local_connection(FALSE);
_bt_logging_connection(FALSE, addr_type);
- if (!addr_type) {
+ if (addr_type)
+ _bt_remove_le_connected_dev_info(address);
+ else {
#ifdef TIZEN_BT_A2DP_SINK_AUTO_CONNECT
{
int bt_device_state = VCONFKEY_BT_DEVICE_NONE;
wait_list->address);
_bt_audio_connect(wait_list->req_id, wait_list->type,
&device_address, NULL);
- _bt_rel_wait_data();
} else if (event == BLUETOOTH_EVENT_AG_CONNECTED) {
/* Add data to the connected list */
_bt_add_headset_to_list(BT_AUDIO_HSP,
BT_INFO_C("### Bluetoothd is terminated");
if (_bt_adapter_get_status() != BT_DEACTIVATING &&
_bt_adapter_get_status() != BT_DEACTIVATED) {
- BT_INFO_C("### Recover it");
- _bt_recover_adapter();
+ BT_INFO_C("Turn Off Bluetooth");
+ _bt_set_le_disabled(BLUETOOTH_ERROR_NONE);
+ _bt_disable_cb();
}
_bt_handle_adapter_removed();
__bt_devices_list_free();
+ _bt_service_adapter_le_deinit();
}
_bt_obex_server_check_allocation(&value);
_bt_rfcomm_server_check_termination(name);
}
+ /* Reset connection interval */
+ _bt_remove_all_le_conn_param_info(name);
+
/* Stop advertising started by terminated process */
_bt_stop_advertising_by_terminated_process(name);
/* Stop LE Scan */
if (conn == NULL)
return -1;
- static int subs_interface_added_id = -1;
- static int subs_interface_removed_id = -1;
- static int subs_name_owner_id = -1;
- static int subs_property_id = -1;
- static int subs_adapter_id = -1;
- static int subs_gatt_id = -1;
+ static guint subs_interface_added_id;
+ static guint subs_interface_removed_id;
+ static guint subs_name_owner_id;
+ static guint subs_property_id;
+ static guint subs_adapter_id;
+ static guint subs_gatt_id;
if (subscribe) {
- if (subs_interface_added_id == -1) {
+ if (subs_interface_added_id == 0) {
subs_interface_added_id = g_dbus_connection_signal_subscribe(conn,
NULL, BT_MANAGER_INTERFACE,
BT_INTERFACES_ADDED, NULL, NULL, 0,
__bt_manager_event_filter,
NULL, NULL);
}
- if (subs_interface_removed_id == -1) {
+ if (subs_interface_removed_id == 0) {
subs_interface_removed_id = g_dbus_connection_signal_subscribe(conn,
NULL, BT_MANAGER_INTERFACE,
BT_INTERFACES_REMOVED, NULL, NULL, 0,
__bt_manager_event_filter,
NULL, NULL);
}
- if (subs_name_owner_id == -1) {
+ if (subs_name_owner_id == 0) {
subs_name_owner_id = g_dbus_connection_signal_subscribe(conn,
NULL, BT_FREEDESKTOP_INTERFACE,
BT_NAME_OWNER_CHANGED, NULL, NULL, 0,
__bt_manager_event_filter,
NULL, NULL);
}
- if (subs_property_id == -1) {
+ if (subs_property_id == 0) {
subs_property_id = g_dbus_connection_signal_subscribe(conn,
NULL, BT_PROPERTIES_INTERFACE,
BT_PROPERTIES_CHANGED, NULL, NULL, 0,
__bt_manager_event_filter,
NULL, NULL);
}
- if (subs_adapter_id == -1) {
+ if (subs_adapter_id == 0) {
subs_adapter_id = g_dbus_connection_signal_subscribe(conn,
NULL, BT_ADAPTER_INTERFACE,
NULL, NULL, NULL, 0,
__bt_manager_event_filter,
NULL, NULL);
}
- if (subs_gatt_id == -1) {
+ if (subs_gatt_id == 0) {
subs_gatt_id = g_dbus_connection_signal_subscribe(conn,
NULL, BT_GATT_CHAR_INTERFACE,
NULL, NULL, NULL, 0,
NULL, NULL);
}
} else {
- if (subs_interface_added_id != -1) {
+ if (subs_interface_added_id > 0) {
g_dbus_connection_signal_unsubscribe(conn,
subs_interface_added_id);
- subs_interface_added_id = -1;
+ subs_interface_added_id = 0;
}
- if (subs_interface_removed_id != -1) {
+ if (subs_interface_removed_id > 0) {
g_dbus_connection_signal_unsubscribe(conn,
subs_interface_removed_id);
- subs_interface_removed_id = -1;
+ subs_interface_removed_id = 0;
}
- if (subs_name_owner_id != -1) {
+ if (subs_name_owner_id > 0) {
g_dbus_connection_signal_unsubscribe(conn,
subs_name_owner_id);
- subs_name_owner_id = -1;
+ subs_name_owner_id = 0;
}
- if (subs_property_id != -1) {
+ if (subs_property_id > 0) {
g_dbus_connection_signal_unsubscribe(conn,
subs_property_id);
- subs_property_id = -1;
+ subs_property_id = 0;
}
- if (subs_adapter_id != -1) {
+ if (subs_adapter_id > 0) {
g_dbus_connection_signal_unsubscribe(conn, subs_adapter_id);
- subs_adapter_id = -1;
+ subs_adapter_id = 0;
}
- if (subs_gatt_id != -1) {
+ if (subs_gatt_id > 0) {
g_dbus_connection_signal_unsubscribe(conn, subs_gatt_id);
- subs_gatt_id = -1;
+ subs_gatt_id = 0;
}
}
return 0;
if (conn == NULL)
return -1;
- static int subs_device_id = -1;
+ static guint subs_device_id = 0;
if (subscribe) {
- if (subs_device_id == -1) {
+ if (subs_device_id == 0) {
subs_device_id = g_dbus_connection_signal_subscribe(conn,
NULL, BT_DEVICE_INTERFACE,
NULL, NULL, NULL, 0,
NULL, NULL);
}
} else {
- if (subs_device_id != -1) {
+ if (subs_device_id > 0) {
g_dbus_connection_signal_unsubscribe(conn,
subs_device_id);
- subs_device_id = -1;
+ subs_device_id = 0;
}
}
return 0;
if (conn == NULL)
return -1;
- static int subs_input_id = -1;
+ static int subs_input_id = 0;
if (subscribe) {
- if (subs_input_id == -1) {
+ if (subs_input_id == 0) {
subs_input_id = g_dbus_connection_signal_subscribe(conn,
NULL, BT_INPUT_INTERFACE,
NULL, NULL, NULL, 0,
NULL, NULL);
}
} else {
- if (subs_input_id != -1) {
+ if (subs_input_id > 0) {
g_dbus_connection_signal_unsubscribe(conn,
subs_input_id);
- subs_input_id = -1;
+ subs_input_id = 0;
}
}
return 0;
if (conn == NULL)
return -1;
- static int subs_serv_id = -1;
- static int subs_client_id = -1;
+ static guint subs_serv_id = 0;
+ static guint subs_client_id = 0;
if (subscribe) {
- if (subs_serv_id == -1) {
+ if (subs_serv_id == 0) {
subs_serv_id = g_dbus_connection_signal_subscribe(conn,
NULL, BT_NETWORK_SERVER_INTERFACE,
NULL, NULL, NULL, 0,
__bt_manager_event_filter,
NULL, NULL);
}
- if (subs_client_id == -1) {
+ if (subs_client_id == 0) {
subs_client_id = g_dbus_connection_signal_subscribe(conn,
NULL, BT_NETWORK_CLIENT_INTERFACE,
NULL, NULL, NULL, 0,
NULL, NULL);
}
} else {
- if (subs_serv_id != -1) {
+ if (subs_serv_id > 0) {
g_dbus_connection_signal_unsubscribe(conn,
subs_serv_id);
- subs_serv_id = -1;
+ subs_serv_id = 0;
}
- if (subs_client_id != -1) {
+ if (subs_client_id > 0) {
g_dbus_connection_signal_unsubscribe(conn,
subs_client_id);
- subs_client_id = -1;
+ subs_client_id = 0;
}
}
return 0;
if (conn == NULL)
return -1;
- static int subs_headset_id = -1;
- static int subs_sink_id = -1;
+ static guint subs_headset_id = 0;
+ static guint subs_sink_id = 0;
if (subscribe) {
- if (subs_headset_id == -1) {
+ if (subs_headset_id == 0) {
subs_headset_id = g_dbus_connection_signal_subscribe(conn,
NULL, BT_HEADSET_INTERFACE,
NULL, NULL, NULL, 0,
__bt_manager_event_filter,
NULL, NULL);
}
- if (subs_sink_id == -1) {
+ if (subs_sink_id == 0) {
subs_sink_id = g_dbus_connection_signal_subscribe(conn,
NULL, BT_SINK_INTERFACE,
NULL, NULL, NULL, 0,
NULL, NULL);
}
} else {
- if (subs_headset_id != -1) {
+ if (subs_headset_id > 0) {
g_dbus_connection_signal_unsubscribe(conn,
subs_headset_id);
- subs_headset_id = -1;
+ subs_headset_id = 0;
}
- if (subs_sink_id != -1) {
+ if (subs_sink_id > 0) {
g_dbus_connection_signal_unsubscribe(conn,
subs_sink_id);
- subs_sink_id = -1;
+ subs_sink_id = 0;
}
}
return 0;
if (conn == NULL)
return -1;
- static int subs_opp_server_interface_added_id = -1;
- static int subs_opp_server_interface_removed_id = -1;
- static int subs_opp_server_property_id = -1;
+ static guint subs_opp_server_interface_added_id = 0;
+ static guint subs_opp_server_interface_removed_id = 0;
+ static guint subs_opp_server_property_id = 0;
if (subscribe) {
- if (subs_opp_server_interface_added_id == -1) {
+ if (subs_opp_server_interface_added_id == 0) {
subs_opp_server_interface_added_id = g_dbus_connection_signal_subscribe(conn,
NULL, BT_MANAGER_INTERFACE,
BT_INTERFACES_ADDED, NULL, NULL, 0,
__bt_obexd_event_filter,
NULL, NULL);
}
- if (subs_opp_server_interface_removed_id == -1) {
+ if (subs_opp_server_interface_removed_id == 0) {
subs_opp_server_interface_removed_id = g_dbus_connection_signal_subscribe(conn,
NULL, BT_MANAGER_INTERFACE,
BT_INTERFACES_REMOVED, NULL, NULL, 0,
__bt_obexd_event_filter,
NULL, NULL);
}
- if (subs_opp_server_property_id == -1) {
+ if (subs_opp_server_property_id == 0) {
subs_opp_server_property_id = g_dbus_connection_signal_subscribe(conn,
NULL, BT_PROPERTIES_INTERFACE,
BT_PROPERTIES_CHANGED, NULL, NULL, 0,
NULL, NULL);
}
} else {
- if (subs_opp_server_interface_added_id != -1) {
+ if (subs_opp_server_interface_added_id > 0) {
g_dbus_connection_signal_unsubscribe(conn,
subs_opp_server_interface_added_id);
- subs_opp_server_interface_added_id = -1;
+ subs_opp_server_interface_added_id = 0;
}
- if (subs_opp_server_interface_removed_id != -1) {
+ if (subs_opp_server_interface_removed_id > 0) {
g_dbus_connection_signal_unsubscribe(conn,
subs_opp_server_interface_removed_id);
- subs_opp_server_interface_removed_id = -1;
+ subs_opp_server_interface_removed_id = 0;
}
- if (subs_opp_server_property_id != -1) {
+ if (subs_opp_server_property_id > 0) {
g_dbus_connection_signal_unsubscribe(conn,
subs_opp_server_property_id);
- subs_opp_server_property_id = -1;
+ subs_opp_server_property_id = 0;
}
}
return 0;
if (conn == NULL)
return -1;
- static int subs_opp_client_interface_added_id = -1;
- static int subs_opp_client_interface_removed_id = -1;
- static int subs_opp_client_property_id = -1;
+ static guint subs_opp_client_interface_added_id = 0;
+ static guint subs_opp_client_interface_removed_id = 0;
+ static guint subs_opp_client_property_id = 0;
if (subscribe) {
- if (subs_opp_client_interface_added_id == -1) {
+ if (subs_opp_client_interface_added_id == 0) {
subs_opp_client_interface_added_id = g_dbus_connection_signal_subscribe(conn,
NULL, BT_MANAGER_INTERFACE,
BT_INTERFACES_ADDED, NULL, NULL, 0,
__bt_opc_event_filter,
NULL, NULL);
}
- if (subs_opp_client_interface_removed_id == -1) {
+ if (subs_opp_client_interface_removed_id == 0) {
subs_opp_client_interface_removed_id = g_dbus_connection_signal_subscribe(conn,
NULL, BT_MANAGER_INTERFACE,
BT_INTERFACES_REMOVED, NULL, NULL, 0,
__bt_opc_event_filter,
NULL, NULL);
}
- if (subs_opp_client_property_id == -1) {
+ if (subs_opp_client_property_id == 0) {
subs_opp_client_property_id = g_dbus_connection_signal_subscribe(conn,
NULL, BT_PROPERTIES_INTERFACE,
BT_PROPERTIES_CHANGED, NULL, NULL, 0,
NULL, NULL);
}
} else {
- if (subs_opp_client_interface_added_id != -1) {
+ if (subs_opp_client_interface_added_id > 0) {
g_dbus_connection_signal_unsubscribe(conn,
subs_opp_client_interface_added_id);
- subs_opp_client_interface_added_id = -1;
+ subs_opp_client_interface_added_id = 0;
}
- if (subs_opp_client_interface_removed_id != -1) {
+ if (subs_opp_client_interface_removed_id > 0) {
g_dbus_connection_signal_unsubscribe(conn,
subs_opp_client_interface_removed_id);
- subs_opp_client_interface_removed_id = -1;
+ subs_opp_client_interface_removed_id = 0;
}
- if (subs_opp_client_property_id != -1) {
+ if (subs_opp_client_property_id > 0) {
g_dbus_connection_signal_unsubscribe(conn,
subs_opp_client_property_id);
- subs_opp_client_property_id = -1;
+ subs_opp_client_property_id = 0;
}
}
return 0;
if (conn == NULL)
return -1;
- static int subs_map_client_interface_added_id = -1;
- static int subs_map_client_interface_removed_id = -1;
- static int subs_map_client_property_id = -1;
+ static guint subs_map_client_interface_added_id = 0;
+ static guint subs_map_client_interface_removed_id = 0;
+ static guint subs_map_client_property_id = 0;
if (subscribe) {
- if (subs_map_client_interface_added_id == -1) {
+ if (subs_map_client_interface_added_id == 0) {
subs_map_client_interface_added_id = g_dbus_connection_signal_subscribe(conn,
NULL, BT_MANAGER_INTERFACE,
BT_INTERFACES_ADDED, NULL, NULL, 0,
__bt_map_event_filter,
NULL, NULL);
}
- if (subs_map_client_interface_removed_id == -1) {
+ if (subs_map_client_interface_removed_id == 0) {
subs_map_client_interface_removed_id = g_dbus_connection_signal_subscribe(conn,
NULL, BT_MANAGER_INTERFACE,
BT_INTERFACES_REMOVED, NULL, NULL, 0,
__bt_map_event_filter,
NULL, NULL);
}
- if (subs_map_client_property_id == -1) {
+ if (subs_map_client_property_id == 0) {
subs_map_client_property_id = g_dbus_connection_signal_subscribe(conn,
NULL, BT_PROPERTIES_INTERFACE,
BT_PROPERTIES_CHANGED, NULL, NULL, 0,
NULL, NULL);
}
} else {
- if (subs_map_client_interface_added_id != -1) {
+ if (subs_map_client_interface_added_id > 0) {
g_dbus_connection_signal_unsubscribe(conn,
subs_map_client_interface_added_id);
- subs_map_client_interface_added_id = -1;
+ subs_map_client_interface_added_id = 0;
}
- if (subs_map_client_interface_removed_id != -1) {
+ if (subs_map_client_interface_removed_id > 0) {
g_dbus_connection_signal_unsubscribe(conn,
subs_map_client_interface_removed_id);
- subs_map_client_interface_removed_id = -1;
+ subs_map_client_interface_removed_id = 0;
}
- if (subs_map_client_property_id != -1) {
+ if (subs_map_client_property_id > 0) {
g_dbus_connection_signal_unsubscribe(conn,
subs_map_client_property_id);
- subs_map_client_property_id = -1;
+ subs_map_client_property_id = 0;
}
}
return 0;
if (conn == NULL)
return -1;
- static int subs_a2dp_source_id = -1;
- static int subs_a2dp_sink_id = -1;
+ static guint subs_a2dp_source_id = 0;
+ static guint subs_a2dp_sink_id = 0;
if (subscribe) {
- if (subs_a2dp_source_id == -1) {
+ if (subs_a2dp_source_id == 0) {
subs_a2dp_source_id = g_dbus_connection_signal_subscribe(conn,
NULL, BT_A2DP_SOURCE_INTERFACE,
NULL, NULL, NULL, 0,
__bt_opc_event_filter,
NULL, NULL);
}
- if (subs_a2dp_sink_id == -1) {
+ if (subs_a2dp_sink_id == 0) {
subs_a2dp_sink_id = g_dbus_connection_signal_subscribe(conn,
NULL, BT_SINK_INTERFACE,
NULL, NULL, NULL, 0,
NULL, NULL);
}
} else {
- if (subs_a2dp_source_id != -1) {
+ if (subs_a2dp_source_id > 0) {
g_dbus_connection_signal_unsubscribe(conn,
subs_a2dp_source_id);
- subs_a2dp_source_id = -1;
+ subs_a2dp_source_id = 0;
}
- if (subs_a2dp_sink_id != -1) {
+ if (subs_a2dp_sink_id > 0) {
g_dbus_connection_signal_unsubscribe(conn,
subs_a2dp_sink_id);
- subs_a2dp_sink_id = -1;
+ subs_a2dp_sink_id = 0;
}
}
return 0;
if (conn == NULL)
return -1;
- static int subs_custom_id = -1;
+ static guint subs_custom_id = 0;
if (subscribe) {
- if (subs_custom_id == -1) {
+ if (subs_custom_id == 0) {
subs_custom_id = g_dbus_connection_signal_subscribe(conn,
NULL, BT_TDS_PROVIDER_INTERFACE,
NULL, NULL, NULL, 0,
NULL, NULL);
}
} else {
- if (subs_custom_id != -1) {
+ if (subs_custom_id > 0) {
g_dbus_connection_signal_unsubscribe(conn,
subs_custom_id);
- subs_custom_id = -1;
+ subs_custom_id = 0;
}
}
if (conn == NULL)
return -1;
- static int subs_source_id = -1;
+ static guint subs_source_id = 0;
if (subscribe) {
- if (subs_source_id == -1) {
+ if (subs_source_id == 0) {
subs_source_id = g_dbus_connection_signal_subscribe(conn,
NULL, BT_DUMP_SERVICE_INTERFACE,
BT_DUMP_SERVICE_SIGNAL, BT_DUMP_SERVICE_PATH, NULL, 0,
NULL, NULL);
}
} else {
- if (subs_source_id != -1) {
+ if (subs_source_id > 0) {
g_dbus_connection_signal_unsubscribe(conn,
subs_source_id);
- subs_source_id = -1;
+ subs_source_id = 0;
}
}
return 0;
int ps_mode_deactivation = 0;
#endif
+ if (_is_name_acquired() == FALSE) {
+ BT_ERR("dbus name is NOT acquired yet");
+ return TRUE;
+ }
+
status = _bt_adapter_get_status();
le_status = _bt_adapter_get_le_status();
BT_DBG("State: %d, LE State: %d", status, le_status);
if (vconf_get_int(BT_OFF_DUE_TO_TIMEOUT, &bt_off_due_to_timeout) != 0)
BT_ERR("Fail to get BT_OFF_DUE_TO_TIMEOUT");
+ if (bt_off_due_to_timeout) {
+ /* Set the vconf flag to 0 here, if BT need to be enabled
+ bt_off_due_to_timeout variable already hold the old value */
+
+ if (vconf_set_int(BT_OFF_DUE_TO_TIMEOUT, 0) != 0)
+ BT_ERR("Set vconf failed");
+ }
+
+
if ((bt_status != VCONFKEY_BT_STATUS_OFF || bt_off_due_to_timeout) &&
(status == BT_DEACTIVATED)) {
BT_DBG("Previous session was enabled.");
g_clear_error(&g_error);
}
result = BLUETOOTH_ERROR_INTERNAL;
+ } else {
+ g_variant_unref(reply);
}
- g_variant_unref(reply);
func_data = user_data;
if (func_data == NULL) {
g_clear_error(&g_error);
}
result = BLUETOOTH_ERROR_INTERNAL;
+ } else {
+ g_variant_unref(reply);
}
- g_variant_unref(reply);
func_data = user_data;
if (func_data == NULL) {
#define BT_SERVICE_NAME "org.projectx.bt"
#define BT_SERVICE_PATH "/org/projectx/bt_service"
+gboolean _is_name_acquired(void);
+
int _bt_service_register(void);
void _bt_service_unregister(void);
int _bt_disconnect_le_device(int req_id,
const bluetooth_device_address_t *bd_addr);
-int _bt_le_conn_update(unsigned char *device_address,
+void _bt_add_le_connected_dev_info(const char *address);
+void _bt_remove_le_connected_dev_info(const char *address);
+int _bt_remove_all_le_conn_param_info(const char *sender);
+
+int _bt_le_conn_update(const char *sender,
+ unsigned char *device_address,
float interval_min, float interval_max,
guint16 latency, guint16 time_out);
HTYPE_TRANS_GET_PROTOCOL,
HTYPE_TRANS_SET_PROTOCOL,
HTYPE_TRANS_DATA,
- HTYPE_TRANS_UNKNOWN
+ HTYPE_TRANS_UNKNOWN,
+ HTYPE_TRANS_GET_IDLE = 0xF0,
+ HTYPE_TRANS_SET_IDLE = 0xF1,
} bt_hid_header_type_t;
/**
} bt_gatt_indicate_confirm_t;
/**
+ * Structure for GATT response data
+ */
+typedef struct {
+ guint8 *value;
+ guint32 len;
+ gpointer user_data;
+} bt_gatt_resp_data_t;
+
+/**
* Structure to RSSI Signal Strength Alert
*/
ret = bluetooth_authorize_device(&device_address, FALSE);
if (ret < 0)
TC_PRT("%s failed with [0x%04x]", tc_table[23].tc_name, ret);
- break;
+ break;
}
case 25:
{
TC_PRT("service obj_path is %s", svc_obj_path);
+ g_free(service_uuid);
+
break;
}