{
int value = VCONFKEY_BT_STATUS_OFF;
+#if 0
#ifndef TIZEN_TEST_EMUL
int ret;
if (ret != BLUETOOTH_ERROR_NONE)
return BLUETOOTH_ADAPTER_DISABLED;
#endif
+#endif
/* check VCONFKEY_BT_STATUS */
if (vconf_get_int(VCONFKEY_BT_STATUS, &value) != 0) {
int manufacturer_data_len = 0;
GVariant *manufacturer_var = NULL;
const char *manufacturer_data = NULL;
+ int vid;
+ int pid;
- g_variant_get(parameters, "(isunsbub@asn@ay)", &result, &address,
- &dev_class, &rssi, &name, &paired,
- &connected, &trust, &string_var, &manufacturer_data_len, &manufacturer_var);
+ g_variant_get(parameters, "(isunsbub@asn@ayii)", &result, &address,
+ &dev_class, &rssi, &name, &paired, &connected, &trust,
+ &string_var, &manufacturer_data_len, &manufacturer_var, &vid, &pid);
if (string_var == NULL) {
BT_ERR("invalid parameters in signal");
dev_info->paired = paired;
dev_info->connected = connected;
dev_info->trust = trust;
+ dev_info->vid = vid;
+ dev_info->pid = pid;
g_strlcpy(dev_info->device_name.name, name,
BLUETOOTH_DEVICE_NAME_LENGTH_MAX + 1);
fd = g_io_channel_unix_get_fd(chan);
if (cond & (G_IO_NVAL | G_IO_HUP | G_IO_ERR)) {
BT_ERR_C("RFComm Client disconnected: %d", fd);
- goto error;
+ goto fail;
}
buffer = g_malloc0(BT_RFCOMM_BUFFER_LEN + 1);
__is_error_by_disconnect(err)) {
BT_ERR("cond : %d", cond);
g_error_free(err);
- goto error;
+ goto fail;
}
g_error_free(err);
}
return TRUE;
}
+ if (len == 0) {
+ BT_ERR("Length is zero, remote end hang up");
+ goto fail;
+ }
+
BT_DBG("fd: %d, len: %d, buffer: %s", fd, len, buffer);
event_info = _bt_event_get_cb_data(BT_RFCOMM_CLIENT_EVENT);
g_free(buffer);
return TRUE;
-error:
+fail:
conn_info = __find_rfcomm_conn_info_with_fd(fd);
if (conn_info) {
__bt_rfcomm_client_disconnected(conn_info);
if (cond & (G_IO_NVAL | G_IO_HUP | G_IO_ERR)) {
BT_ERR_C("RFComm Server disconnected: %d", client_info->sock_fd);
- goto err;
+ goto fail;
}
buffer = g_malloc0(BT_RFCOMM_BUFFER_LEN + 1);
!g_strcmp0(err->message, "Connection reset by peer")) {
BT_ERR("cond : %d", cond);
g_error_free(err);
- goto err;
+ goto fail;
}
g_error_free(err);
}
if (len == 0) {
BT_ERR("Length is zero, remote end hang up");
- goto err;
+ goto fail;
}
event_info = _bt_event_get_cb_data(BT_RFCOMM_SERVER_EVENT);
return TRUE;
-err:
+fail:
BT_ERR("Failure occured, remove client connection");
server_info->conn_list = g_slist_remove(
server_info->conn_list, client_info);
return BLUETOOTH_ERROR_INTERNAL;
}
- __bt_post_oal_init();
return BLUETOOTH_ERROR_NONE;
}
result = adapter_get_version();
if (result != OAL_STATUS_SUCCESS) {
- BT_ERR("adapter_get_address failed: %d", result);
+ BT_ERR("adapter_get_version failed: %d", result);
result = BLUETOOTH_ERROR_INTERNAL;
} else
result = BLUETOOTH_ERROR_NONE;
BT_DBG("+");
result = adapter_set_connectable(connectable);
if (result != OAL_STATUS_SUCCESS) {
- BT_ERR("adapter_get_address failed: %d", result);
+ BT_ERR("adapter_set_connectable failed: %d", result);
result = BLUETOOTH_ERROR_INTERNAL;
} else
result = BLUETOOTH_ERROR_NONE;
static void __bt_post_oal_init(void)
{
int ret;
+ int status = VCONFKEY_BT_STATUS_OFF;
BT_DBG("OAL initialized, Init profiles..");
ret = __bt_init_profiles();
if (ret != BLUETOOTH_ERROR_NONE)
BT_ERR("Bluetooth profile init error: %d", ret);
+ if (vconf_get_int(VCONFKEY_BT_STATUS, &status) != 0) {
+ BT_ERR("Fail to get the enabled value");
+ }
+
+ /* Update Bluetooth Status to OFF */
+ if (vconf_set_int(VCONFKEY_BT_STATUS, VCONFKEY_BT_STATUS_OFF) != 0)
+ BT_ERR("Set vconf failed\n");
+
+ if (status & VCONFKEY_BT_STATUS_ON) {
+ ret = _bt_enable_adapter();
+ if (ret != BLUETOOTH_ERROR_NONE)
+ BT_ERR("_bt_enable_adapter failed with error: %d", ret);
+ }
+
return;
}
ret = vconf_get_int(VCONFKEY_SYSMAN_POWER_OFF_STATUS, &power_off_status);
BT_DBG("ret : %d, power_off_status : %d", ret, power_off_status);
+ /* Update Bluetooth Status to notify other modules */
+ if (vconf_set_int(VCONFKEY_BT_STATUS, VCONFKEY_BT_STATUS_OFF) != 0)
+ BT_ERR("Set vconf failed\n");
+
/* TODO:Add timer function to handle any further post processing */
g_idle_add((GSourceFunc)__bt_adapter_post_set_disabled, NULL);
static GDBusConnection *bt_service_conn;
static guint owner_id = 0;
static guint owner_sig_id = 0;
-cynara *p_cynara;
-cynara_configuration *conf;
+
+static cynara *p_cynara;
+static cynara_configuration *conf;
static const gchar bt_service_introspection_xml[] =
"<node name='/org/projectx/bt_service'>"
out_param1 = g_array_new(FALSE, FALSE, sizeof(gchar));
sender = g_dbus_method_invocation_get_sender(invocation);
-
if (service_type == BT_CORE_SERVICE) {
BT_DBG("No need to check privilege from bt-core");
} else if (__bt_service_check_privilege(service_function,
g_variant_unref(param3);
g_variant_unref(param4);
g_variant_unref(param5);
-// g_free(sender);
FN_END;
return;
fail:
g_variant_unref(param3);
g_variant_unref(param4);
g_variant_unref(param5);
-// g_free(sender);
}
FN_END;
result, sender, function_name, NULL);
} else {
g_array_append_vals(*out_param1, &socket_fd, sizeof(int));
- g_free(sender);
}
break;
}
channel_type, data_type, sender, app_id);
if (result != BLUETOOTH_ERROR_NONE) {
g_array_append_vals(*out_param1, &app_id, sizeof(app_id));
- g_free(sender);
g_free(app_id);
} else {
_bt_save_invocation_context(context, result, sender,
sscanf(app_handle, "health_app_%d", app_id);
result = _bt_hdp_app_unregister(*app_id);
if (result != BLUETOOTH_ERROR_NONE) {
- //g_array_append_vals(*out_param1, app_handle, (strlen(app_handle) + 1));
g_free(app_id);
} else {
sender = (char*)g_dbus_method_invocation_get_sender(context);
return 0;
}
-void _bt_copy_remote_dev(bt_remote_dev_info_t * dev_info, remote_device_t * oal_device)
+void _bt_copy_remote_dev(bt_remote_dev_info_t *dev_info, remote_device_t *oal_device)
{
int i;
BT_INFO("+");
BT_DBG("[%s]", dev_info->uuids[i]);
}
+ dev_info->vid = (unsigned short)oal_device->vid;
+ BT_INFO("VID [0x%.4X]", dev_info->vid);
+ dev_info->pid = (unsigned short)oal_device->pid;
+ BT_INFO("PID [0x%.4X]", dev_info->pid);
+ dev_info->device_type = (int)oal_device->type;
+ BT_INFO("device_type [0x%.4X]", dev_info->device_type);
+
BT_INFO("-");
}
} else {
dev->manufacturer_data.data_len = 0;
}
+
+ dev->vid = rem_dev->vid;
+ dev->pid = rem_dev->pid;
BT_DBG("-");
}
BT_DBG("+");
- if (!address)
- return NULL;
+ retv_if(NULL == address, NULL);
/* Get method invocation context */
for (l = _bt_get_invocation_list(); l != NULL; l = g_slist_next(l)) {
return req_info;
}
+ BT_DBG("-");
return NULL;
}
#include "bt-service-common.h"
#include "bt-service-event-receiver.h"
+typedef struct {
+ int type;
+ void *data;
+} bt_service_oal_event_data_t;
+
_bt_service_event_handler_callback adapter_cb;
_bt_service_event_handler_callback device_cb;
_bt_service_event_handler_callback hid_cb;
}
}
-void _bt_service_oal_event_receiver(int event_type, gpointer event_data, gsize len)
+static gboolean __bt_handle_oal_events(gpointer data)
{
- BT_INFO("event_type: [%d], data size: [%d]", event_type, len);
+ bt_service_oal_event_data_t *oal_event = data;
+ int event_type = oal_event->type;
+ gpointer event_data = oal_event->data;
switch (event_type) {
case OAL_EVENT_ADAPTER_ENABLED:
case OAL_EVENT_DEVICE_AUTHORIZE_REQUEST:
case OAL_EVENT_DEVICE_TRUSTED:
case OAL_EVENT_DEVICE_UNTRUSTED:
+ case OAL_EVENT_DEVICE_NAME:
if (device_cb)
device_cb(event_type, event_data);
break;
socket_cb(event_type, event_data);
break;
case OAL_EVENT_AUDIO_CONNECTING:
- case OAL_EVENT_AUDIO_DISCONNECTING:
- case OAL_EVENT_AUDIO_CONNECTED:
- case OAL_EVENT_AUDIO_DISCONNECTED:
- case OAL_EVENT_AUDIO_STOPPED:
- case OAL_EVENT_AUDIO_STARTED:
- if (a2dp_source_cb)
- a2dp_source_cb(event_type,event_data);
+ case OAL_EVENT_AUDIO_DISCONNECTING:
+ case OAL_EVENT_AUDIO_CONNECTED:
+ case OAL_EVENT_AUDIO_DISCONNECTED:
+ case OAL_EVENT_AUDIO_STOPPED:
+ case OAL_EVENT_AUDIO_STARTED:
+ if (a2dp_source_cb)
+ a2dp_source_cb(event_type,event_data);
break;
case OAL_EVENT_A2DP_SINK_DISCONNECTED:
case OAL_EVENT_A2DP_SINK_CONNECTED:
BT_ERR("Unhandled Event: %d", event_type);
break;
}
+
+ if (oal_event->data)
+ g_free(oal_event->data);
+ g_free(oal_event);
+ return FALSE;
}
+
+void _bt_service_oal_event_receiver(int event_type, gpointer event_data, gsize len)
+{
+ bt_service_oal_event_data_t *oal_event = g_new0(bt_service_oal_event_data_t, 1);
+
+ BT_INFO("event_type: [%d], data size: [%d]", event_type, len);
+
+ oal_event->type = event_type;
+ if (event_data)
+ oal_event->data = g_memdup(event_data, len);
+
+ g_idle_add(__bt_handle_oal_events, oal_event);
+}
\ No newline at end of file
if (!trigger_bond_info->dev_info ||
!trigger_bond_info->dev_info->name ||
!trigger_bond_info->dev_info->address ||
- !trigger_bond_info->dev_info->uuid_count == 0) {
+ trigger_bond_info->dev_info->uuid_count == 0) {
BT_INFO("Complete data is not present, Assigning rem_info");
+ g_free(trigger_bond_info->dev_info);
trigger_bond_info->dev_info = rem_info;
}
}
remote_dev_info->manufacturer_data, remote_dev_info->manufacturer_data_len,
TRUE, NULL, NULL);
- param = g_variant_new("(isunsbub@asn@ay)",
+ param = g_variant_new("(isunsbub@asn@ayii)",
BLUETOOTH_ERROR_NONE,
remote_dev_info->address,
remote_dev_info->class,
remote_dev_info->trust,
uuids,
remote_dev_info->manufacturer_data_len,
- manufacturer_data);
+ manufacturer_data,
+ remote_dev_info->vid,
+ remote_dev_info->pid);
/* Send the event to application */
_bt_send_event(BT_ADAPTER_EVENT,
BLUETOOTH_EVENT_SERVICE_SEARCHED,
int i;
BT_DBG("+");
+ if (trigger_bond_info && _bt_compare_adddress(trigger_bond_info->dev_addr,
+ (bluetooth_device_address_t *)&uuid_list->address) == TRUE) {
+ bluetooth_device_address_t *dev_addr = trigger_bond_info->dev_addr;
+
+ BT_DBG("Bonding dev addr has matched");
+ /* Bonding ongoing, Query device properties again */
+ if (BLUETOOTH_ERROR_NONE ==
+ _bt_device_get_bonded_device_info(dev_addr))
+ BT_DBG("_bt_device_get_bonded_device_info success");
+ else
+ BT_ERR("_bt_device_get_bonded_device_info failed");
+ }
+
if (service_search_info == NULL) {
/* Send reply */
BT_DBG("searching_info == NULL");
remote_dev_info->manufacturer_data, remote_dev_info->manufacturer_data_len,
TRUE, NULL, NULL);
- param = g_variant_new("(isunsbub@asn@ay)",
+ param = g_variant_new("(isunsbub@asn@ayii)",
BLUETOOTH_ERROR_NONE,
remote_dev_info->address,
remote_dev_info->class,
remote_dev_info->trust,
uuids,
remote_dev_info->manufacturer_data_len,
- manufacturer_data);
+ manufacturer_data,
+ remote_dev_info->vid,
+ remote_dev_info->pid);
/* Send the event to application */
_bt_send_event(BT_ADAPTER_EVENT,
BLUETOOTH_EVENT_BONDING_FINISHED,
__bt_device_trusted_callback(FALSE, (event_dev_trust_t*)event_data);
break;
}
+ case OAL_EVENT_DEVICE_NAME: {
+ remote_device_t *rem_dev = event_data;
+ gchar address[BT_ADDRESS_STR_LEN];
+
+ _bt_convert_addr_type_to_string(address, rem_dev->address.addr);
+ BT_INFO("Remote Device name Received");
+ BT_INFO("Name: %s, Address: %s", rem_dev->name, address);
+ break;
+ }
default:
BT_INFO("Unhandled event..");
}
dev_info->manufacturer_data_len,
TRUE,
NULL, NULL);
- param = g_variant_new("(isunsbub@asn@ay)", result,
+ param = g_variant_new("(isunsbub@asn@ayii)", result,
dev_info->address,
dev_info->class,
dev_info->rssi,
dev_info->trust,
uuids,
dev_info->manufacturer_data_len,
- manufacturer_data);
+ manufacturer_data,
+ dev_info->vid,
+ dev_info->pid);
_bt_send_event(BT_ADAPTER_EVENT,
BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND,
#include "bt-request-handler.h"
#include "bt-service-util.h"
#include "bt-service-event.h"
-#include "bt-service-hidhost.h"
#include "bt-service-common.h"
+#include "bt-service-hidhost.h"
#include "bt-service-event-receiver.h"
#include "oal-event.h"
#include "oal-device-mgr.h"
static GList *g_connected_list;
-static invocation_info_t* __bt_get_request_info(int service_function, char *address)
+bt_remote_dev_info_t *_bt_hid_get_device_info(const char *address)
{
- GSList *l;
- invocation_info_t *req_info = NULL;
-
- BT_DBG("+");
+ GList *node;
- retv_if(NULL == address, FALSE);
+ node = g_list_first(g_connected_list);
+ while (node != NULL) {
+ bt_connected_hid_dev_info_t *hid_dev_info = node->data;
- /* Get method invocation context */
- for (l = _bt_get_invocation_list(); l != NULL; l = g_slist_next(l)) {
- req_info = l->data;
- if (req_info == NULL || req_info->service_function != service_function)
+ if (g_strcmp0(hid_dev_info->address, address) != 0) {
+ node = g_list_next(node);
continue;
+ }
- if (!strncasecmp((char *)req_info->user_data, address, BT_ADDRESS_STRING_SIZE))
- return req_info;
+ BT_DBG("Address match \n");
+ return hid_dev_info->dev_info;
}
+ BT_DBG("");
return NULL;
}
_bt_convert_addr_type_to_string(address, event->address.addr);
/* Reply to async request for HID connect, if any */
- req_info = __bt_get_request_info(BT_HID_CONNECT, address);
+ req_info = _bt_get_request_info_data(BT_HID_CONNECT, address);
if (NULL != req_info) {
out_param = g_array_new(FALSE, FALSE, sizeof(gchar));
g_array_append_vals(out_param, &device_address,
_bt_convert_addr_type_to_string(address, event->address.addr);
BT_INFO("HID device [%s] disconnected", address);
- req_info = __bt_get_request_info(BT_HID_DISCONNECT, address);
+ req_info = _bt_get_request_info_data(BT_HID_DISCONNECT, address);
if (NULL == req_info) {
BT_DBG("BT_HID_DISCONNECT request not found");
- req_info = __bt_get_request_info(BT_HID_CONNECT, address);
+ req_info = _bt_get_request_info_data(BT_HID_CONNECT, address);
if (NULL == req_info) {
BT_DBG("BT_HID_CONNECT request also not found");
__bt_handle_hid_disconnection(address);
/*
* HID_DISCONNECTED event is received in response to hid_connect,
* Set result as BLUETOOTH_ERROR_INTERNAL
- * */
+ */
result = BLUETOOTH_ERROR_INTERNAL;
}
}
}
/* Register HID event handler */
- _bt_service_register_event_handler_callback(BT_HID_MODULE, __bt_hid_event_handler);
+ _bt_service_register_event_handler_callback(
+ BT_HID_MODULE, __bt_hid_event_handler);
+
return BLUETOOTH_ERROR_NONE;
}
#if 0 /* Should match with bt_dev_info_t in bluetooth-api.h */
bt_remote_le_dev_info_t le_dev_info;
#endif
+ int vid;
+ int pid;
+ int device_type;
} bt_remote_dev_info_t;
/* RFCOMM client /server will use this structure*/
extern "C" {
#endif
- int _bt_hidhost_initialize(void);
- void _bt_hidhost_deinitialize(void);
- int _bt_hid_connect(bluetooth_device_address_t *device_address);
- int _bt_hid_disconnect(bluetooth_device_address_t *device_address);
+int _bt_hidhost_initialize(void);
+void _bt_hidhost_deinitialize(void);
+int _bt_hid_connect(bluetooth_device_address_t *device_address);
+int _bt_hid_disconnect(bluetooth_device_address_t *device_address);
+
+bt_remote_dev_info_t *_bt_hid_get_device_info(const char *address);
#ifdef __cplusplus
}
gboolean trust; /**< trust flag */
gboolean is_alias_set; /** is device alias set flag**/
bluetooth_manufacturer_data_t manufacturer_data; /**< manafacturer specific class */
+ int vid;
+ int pid;
} bluetooth_device_info_t;
/**