return le_dev_info;
}
-static bluetooth_ibeacon_device_info_t *__bt_get_ibeacon_device_info_in_message(GVariant *parameters, int *ret)
-{
- bluetooth_ibeacon_device_info_t *ibeacon_dev_info = NULL;
- const char *address = NULL;
- short addr_type = 0;
- int company_id = 0;
- int ibeacon_type = 0;
- int major_id = 0;
- int minor_id = 0;
- int measured_power = 0;
- const char *uuid = NULL;
- int result = BLUETOOTH_ERROR_NONE;
-
- g_variant_get(parameters, "(i&snnn&snnn)", &result, &address,
- &addr_type, &company_id, &ibeacon_type, &uuid, &major_id, &minor_id, &measured_power);
- ibeacon_dev_info = g_malloc0(sizeof(bluetooth_ibeacon_device_info_t));
- if (ibeacon_dev_info == NULL) {
- result = BLUETOOTH_ERROR_MEMORY_ALLOCATION;
- goto done;
- }
-
- _bt_convert_addr_string_to_type(ibeacon_dev_info->device_address.addr, address);
- ibeacon_dev_info->addr_type = addr_type;
- ibeacon_dev_info->company_id = company_id;
- ibeacon_dev_info->ibeacon_type = ibeacon_type;
- ibeacon_dev_info->major_id = major_id;
- ibeacon_dev_info->minor_id = minor_id;
- ibeacon_dev_info->measured_power = measured_power;
- ibeacon_dev_info->uuid_len = strlen(uuid);
- memcpy(ibeacon_dev_info->uuid, uuid, ibeacon_dev_info->uuid_len);
-done:
-
- *ret = result;
-
- return ibeacon_dev_info;
-}
-
gboolean __bt_reliable_disable_cb(gpointer user_data)
{
BT_DBG("+");
}
g_free(le_device_info);
- } else if (strcasecmp(signal_name, BT_IBEACON_DEVICE_FOUND) == 0) {
- bluetooth_ibeacon_device_info_t *ibeacon_device_info;
- BT_DBG("BT_IBEACON_DEVICE_FOUND");
- ibeacon_device_info = __bt_get_ibeacon_device_info_in_message(parameters,
- &result);
- ret_if(ibeacon_device_info == NULL);
-
- _bt_common_event_cb(BLUETOOTH_EVENT_REMOTE_IBEACON_DEVICE_FOUND,
- result, ibeacon_device_info,
- event_info->cb, event_info->user_data);
-
- g_free(ibeacon_device_info);
}
}
BT_DBG("-");
}
+void _bt_rfcomm_client_disconnect_all(void)
+{
+ GSList *client;
+ GSList *conn;
+
+ BT_INFO_C("### Disconnect all RFCOMM client connections");
+
+ for (client = rfcomm_clients; client; ) {
+ rfcomm_cb_data_t *info = client->data;
+
+ for (conn = info->rfcomm_conns; conn; conn = conn->next) {
+ rfcomm_conn_info_t *conn_info = conn->data;
+
+ if (conn_info == NULL)
+ continue;
+
+ if (conn_info->watch_id == 0 || conn_info->disconnected)
+ continue;
+
+ close(conn_info->fd);
+ conn_info->disconnected = TRUE;
+
+ _bt_disconnect_profile(conn_info->bt_addr, info->uuid,
+ NULL,NULL);
+
+ }
+
+ client = client->next;
+ __rfcomm_client_disconnect(info);
+ }
+
+ return;
+}
#endif
int new_connection(const char *path, int fd, bluetooth_device_address_t *addr)
rfcomm_cb_data_t *info;
GIOChannel *data_io;
rfcomm_conn_info_t *conn_info = NULL;
- BT_DBG("%s %d", path, fd);
char address[BT_ADDRESS_STRING_SIZE];
+
+ BT_INFO("%s %d", path, fd);
+
_bt_convert_addr_type_to_string(address,
(unsigned char *)addr);
+
info = __find_rfcomm_info_from_path(path);
- if (info == NULL)
+ if (info == NULL) {
+ BT_ERR("rfcomm info is NULL");
return -1;
- conn_info = __get_conn_info_from_address(info, address);
+ }
+ conn_info = __get_conn_info_from_address(info, address);
if (conn_info == NULL) {
- BT_ERR("Device Address %s not found in connection list", address);
+ BT_ERR("connection info is NULL");
return -1;
}
+
conn_info->fd = fd;
- BT_DBG("connection info fd %d", conn_info->fd);
+
data_io = g_io_channel_unix_new(fd);
+
g_io_channel_set_encoding(data_io, NULL, NULL);
g_io_channel_set_flags(data_io, G_IO_FLAG_NONBLOCK, NULL);
+
conn_info->watch_id = g_io_add_watch(data_io,
G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
__client_data_received_cb, info);
BT_INFO("conn_info %s", conn_info->bt_addr);
_bt_disconnect_profile(conn_info->bt_addr, info->uuid, NULL, NULL);
- /*
- * ToDo : If idle_id is not zero, it means disconnect request is
- * going on. Such a case, in-progress error should be returned.
- */
if (info->idle_id == 0)
info->idle_id = g_idle_add(__rfcomm_client_disconnect, info);
if (info == NULL)
return -1;
+#ifdef TIZEN_DPM_ENABLE
+ if (_bt_check_dpm(BT_DPM_SPP, NULL) == BT_DPM_RESTRICTED) {
+ char addr_str[20];
+
+ BT_ERR("Not allow to use SPP profile");
+
+ close(fd);
+ _bt_convert_addr_type_to_string(addr_str, addr->addr);
+ _bt_disconnect_profile(addr_str, info->uuid, NULL,NULL);
+
+ return -1;
+ }
+#endif
+
conn = g_new0(rfcomm_conn_t, 1);
conn->fd = fd;
memcpy(&conn->addr, addr, sizeof(bluetooth_device_address_t));
g_free(info);
}
-void _bt_rfcomm_server_free_all()
+void _bt_rfcomm_server_free_all(void)
{
BT_DBG("Free all the servers");
g_slist_free_full(rfcomm_nodes, (GDestroyNotify)free_rfcomm_info);
rfcomm_nodes = NULL;
}
+
+void _bt_rfcomm_server_disconnect_all(void)
+{
+ GSList *server;
+ GSList *conn;
+ char addr[20];
+
+ BT_INFO("### Disconnect all RFCOMM server connections");
+
+ for (server = rfcomm_nodes; server; ) {
+ rfcomm_info_t *info = server->data;
+
+ for (conn = info->rfcomm_conns; conn; conn = conn->next) {
+ rfcomm_conn_t *conn_info = conn->data;
+
+ if (conn_info == NULL)
+ continue;
+
+ if (conn_info->watch_id == 0 || conn_info->disconnected)
+ continue;
+
+ close(conn_info->fd);
+ conn_info->disconnected = TRUE;
+
+ _bt_convert_addr_type_to_string(addr,
+ conn_info->addr.addr);
+ _bt_disconnect_profile(addr, info->uuid, NULL,NULL);
+ }
+
+ server = server->next;
+ __rfcomm_server_disconnect(info);
+ }
+
+ return;
+}
#endif
BT_EXPORT_API int bluetooth_rfcomm_create_socket(const char *uuid)
char *device_address);
#ifdef RFCOMM_DIRECT
-void _bt_rfcomm_server_free_all();
+void _bt_rfcomm_server_free_all(void);
+
+void _bt_rfcomm_server_disconnect_all(void);
+
+void _bt_rfcomm_client_disconnect_all(void);
gboolean _check_uuid_path(char *path, char *uuid);
#endif
void _bluetooth_hid_free_hid_info(void);
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
}
}
-void _bt_send_ibeacon_scan_result_event(const bt_remote_ibeacon_dev_info_t *ibeacon_dev_info)
-{
- int result = BLUETOOTH_ERROR_NONE;
- GSList *l;
- GVariant *param;
- bt_adapter_le_scanner_t *scanner = NULL;
-
- ret_if(ibeacon_dev_info == NULL);
- BT_DBG("_bt_send_ibeacon_scan_result_event");
-
- for (l = scanner_list; l != NULL; l = g_slist_next(l)) {
- scanner = l->data;
- if (scanner->is_scanning == FALSE)
- continue;
-
- param = g_variant_new("(isnnnsnnn)",
- result,
- ibeacon_dev_info->address,
- ibeacon_dev_info->addr_type,
- ibeacon_dev_info->company_id,
- ibeacon_dev_info->ibeacon_type,
- ibeacon_dev_info->uuid,
- ibeacon_dev_info->major_id,
- ibeacon_dev_info->minor_id,
- ibeacon_dev_info->measured_power);
-
- _bt_send_event(BT_LE_ADAPTER_EVENT, BLUETOOTH_EVENT_REMOTE_IBEACON_DEVICE_FOUND, param);
- }
-}
-
int _bt_add_white_list(bluetooth_device_address_t *device_address, bluetooth_device_address_type_t address_type)
{
GDBusProxy *proxy;
return BLUETOOTH_ERROR_NONE;
}
+int _bt_disconnect_all(char *address)
+{
+ int ret = BLUETOOTH_ERROR_NONE;
+ char *object_path;
+ GDBusProxy *proxy;
+ GDBusConnection *conn;
+ GVariant *result = NULL;
+ GError *err = NULL;
+
+ BT_DBG("");
+ conn = _bt_gdbus_get_system_gconn();
+ retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
+
+ object_path = _bt_get_device_object_path(address);
+ retv_if(object_path == NULL, BLUETOOTH_ERROR_INTERNAL);
+
+ proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
+ NULL, BT_BLUEZ_NAME,
+ object_path, BT_DEVICE_INTERFACE, NULL, NULL);
+ g_free(object_path);
+ retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
+
+ result = g_dbus_proxy_call_sync(proxy, "Disconnect",
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1, NULL,
+ &err);
+
+ if (err != NULL) {
+ BT_ERR("Dbus Call Error:[%s]", err->message);
+ g_error_free(err);
+ ret = BLUETOOTH_ERROR_INTERNAL;
+ }
+
+ g_object_unref(proxy);
+ if (result)
+ g_variant_unref(result);
+
+ return ret;
+}
+
int _bt_disconnect_profile(char *address, char *uuid,
void *cb, gpointer func_data)
{
event,
param);
g_free(address);
- } else if (strcasecmp(member, "iBeaconReport") == 0) {
- bt_remote_ibeacon_dev_info_t *ibeacon_dev_info = NULL;
-
- ret_if(_bt_is_le_scanning() == FALSE);
-
- ibeacon_dev_info = g_malloc0(sizeof(bt_remote_ibeacon_dev_info_t));
- if (ibeacon_dev_info == NULL)
- return;
-
- g_variant_get(msg, "(syuusuuy)", &ibeacon_dev_info->address,
- &ibeacon_dev_info->addr_type,
- &ibeacon_dev_info->company_id,
- &ibeacon_dev_info->ibeacon_type,
- &ibeacon_dev_info->uuid,
- &ibeacon_dev_info->major_id,
- &ibeacon_dev_info->minor_id,
- &ibeacon_dev_info->measured_power);
- _bt_send_ibeacon_scan_result_event(ibeacon_dev_info);
- g_free(ibeacon_dev_info);
}
}
case BLUETOOTH_EVENT_LE_DATA_LENGTH_CHANGED:
signal = BT_LE_DATA_LENGTH_CHANGED;
break;
- case BLUETOOTH_EVENT_REMOTE_IBEACON_DEVICE_FOUND:
- signal = BT_IBEACON_DEVICE_FOUND;
- break;
case BLUETOOTH_EVENT_PXP_PROPERTY_CHANGED:
signal = BT_PXP_PROPERTY_CHANGED;
break;
g_variant_builder_add(builder, "y", agent_info.auth_info->contact_auth_info[i]);
param = g_variant_new("(isssstii(ay))", result,
+ transfer_info->device_name,
transfer_info->filename,
transfer_info->type,
- transfer_info->device_name,
transfer_info->address,
transfer_info->file_size,
transfer_info->transfer_id,
void _bt_send_scan_result_event(const bt_remote_le_dev_info_t *le_dev_info, const bt_le_adv_info_t *adv_info);
-void _bt_send_ibeacon_scan_result_event(const bt_remote_ibeacon_dev_info_t *ibeacon_dev_info);
-
int _bt_add_white_list(bluetooth_device_address_t *device_address, bluetooth_device_address_type_t address_type);
int _bt_remove_white_list(bluetooth_device_address_t *device_address, bluetooth_device_address_type_t address_type);
} bt_remote_le_dev_info_t;
typedef struct {
- char *address;
- int addr_type;
- int rssi;
- int adv_type;
- int company_id;
- int ibeacon_type;
- int major_id;
- int minor_id;
- int measured_power;
- char *uuid;
-} bt_remote_ibeacon_dev_info_t;
-
-typedef struct {
int rssi;
int class;
char *address;
int _bt_connect_profile(char *address, char *uuid,
void *cb, gpointer func_data);
+int _bt_disconnect_all(char *address);
+
int _bt_disconnect_profile(char *address, char *uuid,
void *cb, gpointer func_data);
BLUETOOTH_EVENT_LE_DISCOVERY_STARTED, /**< Bluetooth event LE discovery started */
BLUETOOTH_EVENT_LE_DISCOVERY_FINISHED, /**< Bluetooth event LE discovery finished */
BLUETOOTH_EVENT_REMOTE_LE_DEVICE_FOUND, /**< Bluetooth event remote deice found (LE dev) */
- BLUETOOTH_EVENT_REMOTE_IBEACON_DEVICE_FOUND, /**< Bluetooth event remote ibeacon device found (iBeacon LE dev) */
BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED,/**< Bluetooth event remote device name updated*/
BLUETOOTH_EVENT_BONDING_FINISHED, /**< Bluetooth event bonding completed */
BLUETOOTH_EVENT_BONDED_DEVICE_REMOVED, /**< Bluetooth event bonding removed */
} bluetooth_le_device_info_t;
typedef struct {
- bluetooth_device_address_t device_address; /**< device address */
- int addr_type; /**< address type*/
- int rssi; /**< received strength signal*/
- int adv_type;
- int company_id; /** <Company ID> */
- int ibeacon_type; /** <iBeacon type> */
- int major_id; /** <Major ID> */
- int minor_id; /** <Minor ID> */
- int measured_power; /** <Measured Power value for proximity> */
- int uuid_len; /** <uuid string len> */
- char uuid[BLUETOOTH_UUID_STRING_MAX]; /** <customr/specific UUID> */
-} bluetooth_ibeacon_device_info_t;
-
-typedef struct {
int slot_id;
bluetooth_le_scan_filter_feature_t added_features; /**< added features */
bluetooth_device_address_t device_address; /**< device address */
#define BT_IPSP_CONNECTED "IpspConnected"
#define BT_IPSP_DISCONNECTED "IpspDisconnected"
#define BT_LE_DATA_LENGTH_CHANGED "LEDataLengthChanged"
-#define BT_IBEACON_DEVICE_FOUND "iBeaconDeviceFound"
#define BT_PXP_PROPERTY_CHANGED "PxpValueChanged"
#ifdef __cplusplus