return NULL;
}
+static rfcomm_info_t *__find_rfcomm_info_with_uuid(const char *uuid)
+{
+ GSList *l;
+
+ for (l = rfcomm_nodes; l != NULL; l = l->next) {
+ rfcomm_info_t *info = l->data;
+
+ if (g_strcmp0(info->uuid, uuid) == 0)
+ return info;
+ }
+
+ return NULL;
+}
+
gboolean _check_uuid_path(char *path, char *uuid)
{
rfcomm_info_t *info = NULL;
return info;
}
+static rfcomm_info_t *__register_method_2(const char *path,const char *bus_name)
+{
+ rfcomm_info_t *info;
+ int object_id;
+
+ object_id = _bt_register_new_conn_ex(path, bus_name, new_server_connection);
+ if (object_id < 0) {
+ return NULL;
+ }
+ info = g_new(rfcomm_info_t, 1);
+ info->object_id = (guint)object_id;
+ info->path = g_strdup(path);
+ info->id = -1;
+ info->fd = -1;
+
+ rfcomm_nodes = g_slist_append(rfcomm_nodes, info);
+
+ return info;
+}
+
void free_rfcomm_info(rfcomm_info_t *info)
{
bt_event_info_t *event_info;
#endif
}
+BT_EXPORT_API int bluetooth_rfcomm_create_socket_ex(const char *uuid, const char *bus_name, const char *path)
+{
+#ifdef RFCOMM_DIRECT
+ rfcomm_info_t *info;
+
+ BT_CHECK_ENABLED(return);
+ BT_CHECK_PARAMETER(path, return);
+ BT_INFO("PATH Provided %s", path);
+
+ if (_bt_check_privilege(BT_BLUEZ_SERVICE, BT_RFCOMM_CREATE_SOCKET_EX)
+ == BLUETOOTH_ERROR_PERMISSION_DEINED) {
+ BT_ERR("Don't have a privilege to use this API");
+ return BLUETOOTH_ERROR_PERMISSION_DEINED;
+ }
+
+ BT_INFO("<<<<<<<<< RFCOMM Create socket from app >>>>>>>>>");
+ info = __register_method_2(path, bus_name);
+ if (info == NULL)
+ return BLUETOOTH_ERROR_IN_PROGRESS;
+ info->uuid = g_strdup(uuid);
+ info->disconnect_idle_id = 0;
+
+ return BLUETOOTH_ERROR_NONE;
+#else
+ return BLUETOOTH_ERROR_NOT_SUPPORT;
+#endif
+}
+
+
BT_EXPORT_API int bluetooth_rfcomm_remove_socket(int socket_fd)
{
#ifdef RFCOMM_DIRECT
#endif
}
+BT_EXPORT_API int bluetooth_rfcomm_remove_socket_ex(const char *uuid)
+{
+#ifdef RFCOMM_DIRECT
+ rfcomm_info_t *info;
+
+ BT_CHECK_ENABLED(return);
+
+ if (_bt_check_privilege(BT_BLUEZ_SERVICE, BT_RFCOMM_REMOVE_SOCKET)
+ == BLUETOOTH_ERROR_PERMISSION_DEINED) {
+ BT_ERR("Don't have a privilege to use this API");
+ return BLUETOOTH_ERROR_PERMISSION_DEINED;
+ }
+
+ BT_INFO("<<<<<<<<< RFCOMM Remove socket request from app, uuid=[%s] >>>>>>>>>>>", uuid);
+
+ info = __find_rfcomm_info_with_uuid(uuid);
+ if (info == NULL)
+ return BLUETOOTH_ERROR_INVALID_PARAM;
+
+ _bt_unregister_osp_server_in_agent(BT_RFCOMM_SERVER, info->uuid);
+ _bt_unregister_profile(info->path);
+
+ rfcomm_nodes = g_slist_remove(rfcomm_nodes, info);
+ free_rfcomm_info(info);
+
+ return BLUETOOTH_ERROR_NONE;
+#else
+ return BLUETOOTH_ERROR_NOT_SUPPORT;
+#endif
+}
+
BT_EXPORT_API int bluetooth_rfcomm_server_disconnect(int socket_fd)
{
#ifdef RFCOMM_DIRECT
BT_DBG("Address %s", address);
_bt_disconnect_profile(address, info->uuid, NULL,NULL);
- info->disconnect_idle_id = g_idle_add(__rfcomm_server_disconnect, info);
+ info->disconnect_idle_id = g_idle_add((GSourceFunc)
+ __rfcomm_server_disconnect, info);
BT_DBG("-");
return BLUETOOTH_ERROR_NONE;
return available;
}
-BT_EXPORT_API int bluetooth_rfcomm_server_is_connected(bluetooth_device_address_t *device_address, gboolean *connected)
+BT_EXPORT_API int bluetooth_rfcomm_server_is_connected(const bluetooth_device_address_t *device_address, gboolean *connected)
{
GSList *l;
rfcomm_info_t *info;
BT_CHECK_PARAMETER(device_address, return);
BT_CHECK_PARAMETER(connected, return);
- _bt_convert_addr_type_to_string(input_addr, device_address->addr);
+ _bt_convert_addr_type_to_string(input_addr, (unsigned char *)device_address->addr);
*connected = FALSE;
profile_info.role = NULL;
profile_info.service = info->uuid;
profile_info.uuid = info->uuid;
+
BT_INFO("uuid %s", profile_info.uuid);
result = _bt_register_profile(&profile_info, TRUE);
#endif
}
+BT_EXPORT_API int bluetooth_rfcomm_listen_and_accept_ex(const char *uuid, int max_pending_connection, const char *bus_name, const char *path)
+{
+#ifdef RFCOMM_DIRECT
+ rfcomm_info_t *info;
+
+ BT_CHECK_ENABLED(return);
+
+ BT_INFO("<<<<<<<<< RFCOMM Listen & accept from app >>>>>>>>>>>");
+
+ info = __find_rfcomm_info_with_uuid(uuid);
+ if (info == NULL)
+ return BLUETOOTH_ERROR_INVALID_PARAM;
+
+ bt_register_profile_info_t profile_info;
+ int result;
+
+ profile_info.authentication = TRUE;
+ profile_info.authorization = TRUE;
+ profile_info.obj_path = info->path;
+ profile_info.role = NULL;
+ profile_info.service = info->uuid;
+ profile_info.uuid = info->uuid;
+
+ BT_INFO("uuid %s", profile_info.uuid);
+ result = _bt_register_profile_ex(&profile_info, TRUE, bus_name, path);
+
+ return result;
+#else
+ return BLUETOOTH_ERROR_NOT_SUPPORT;
+#endif
+}
+
BT_EXPORT_API int bluetooth_rfcomm_listen(int socket_fd, int max_pending_connection)
{
#ifdef RFCOMM_DIRECT