Some internal capis are defined.
The capis shouldn't be shown to the upper app.
Therefore, remove them.
Change-Id: If93984aef4eb80ebaeb93eb0e47bfaf5d9382bea
Signed-off-by: Wu Zheng <wu.zheng@intel.com>
#define ADDRESS_LEN 20
static char pushing_address[ADDRESS_LEN];
+typedef enum {
+ BT_OPP_TRANSFER_UNKNOWN = 0x0,
+ BT_OPP_TRANSFER_QUEUED,
+ BT_OPP_TRANSFER_ACTIVE,
+ BT_OPP_TRANSFER_COMPLETED,
+ BT_OPP_TRANSFER_CANCELED,
+ BT_OPP_TRANSFER_ERROR,
+} bt_opp_transfer_state_e;
+
+typedef void (*bt_opp_server_push_file_requested_cb)(
+ const char *remote_address,
+ const char *name,
+ uint64_t size,
+ void *user_data);
+
+typedef void (*bt_opp_transfer_state_cb)(
+ int transfer_id,
+ bt_opp_transfer_state_e state,
+ const char *name,
+ uint64_t size,
+ unsigned char percent,
+ void *user_data);
+
+typedef enum {
+ BT_OPP_PUSH_ACCETPED = 0,
+ BT_OPP_PUSH_RETRY,
+ BT_OPP_PUSH_FAILED,
+ BT_OPP_PUSH_REFUSED,
+ BT_OPP_PUSH_TIMEOUT,
+ BT_OPP_PUSH_NO_SERVICE
+} push_state_e;
+
+typedef void (*bt_opp_client_push_responded_new_cb)(
+ const char *remote_address,
+ push_state_e state,
+ void *user_data);
+
static struct {
char *root_folder;
char *pending_name;
static gboolean received_data(GIOChannel *channel, GIOCondition con,
gpointer user_data);
+typedef void (*bt_spp_new_connection_cb)(
+ const char *uuid,
+ const char *device_name,
+ int fd,
+ void *user_data);
+
+struct spp_channel {
+ GIOChannel *channel;
+ guint io_watch;
+ gchar *remote_address;
+ gint io_shutdown;
+};
+
+struct spp_context {
+ int fd;
+ gchar *uuid;
+ gchar *spp_path;
+ GIOChannel *channel;
+ GList *chan_list;
+ bt_spp_new_connection_cb new_connection;
+ void *new_connection_data;
+
+ int max_pending;
+ void *requestion;
+ gboolean is_accept;
+ bt_socket_role_e role;
+};
+
+typedef void (*bt_spp_connection_requested_cb) (
+ const char *uuid,
+ const char *remote_address,
+ bt_req_t *requestion,
+ void *user_data);
+
+static int bt_spp_create_rfcomm(
+ const char *uuid,
+ bt_spp_new_connection_cb new_connection_cb,
+ void *user_data);
+
+static int bt_spp_destroy_rfcomm(const char *uuid);
+
+static int bt_spp_connect_rfcomm(
+ const char *remote_address,
+ const char *service_uuid);
+
+static int bt_spp_disconnect_rfcomm(
+ const char *remote_address,
+ const char *service_uuid);
+
+static int bt_spp_accept(bt_req_t *requestion);
+
+static int bt_spp_reject(bt_req_t *requestion);
+
+typedef void (*bt_spp_connection_requested_cb) (
+ const char *uuid,
+ const char *remote_address,
+ bt_req_t *requestion,
+ void *user_data);
+
+typedef struct {
+ int socket_fd; /**< The socket fd */
+ int data_size; /**< The length of the received data */
+ char *data; /**< The received data */
+} bt_spp_received_data;
+
+typedef void (*bt_spp_data_received_cb)(bt_spp_received_data *data,
+ void *user_data);
+
+static int bt_spp_set_data_received_cb(
+ bt_spp_data_received_cb callback,
+ void *user_data);
+
+static int bt_spp_unset_data_received_cb(void);
+
struct device_connect_cb_node {
bt_device_gatt_state_changed_cb cb;
void *user_data;
return BT_SUCCESS;
}
-struct spp_channel {
- GIOChannel *channel;
- guint io_watch;
- gchar *remote_address;
- gint io_shutdown;
-};
-
-struct spp_context {
- int fd;
- gchar *uuid;
- gchar *spp_path;
- GIOChannel *channel;
- GList *chan_list;
- bt_spp_new_connection_cb new_connection;
- void *new_connection_data;
-
- int max_pending;
- void *requestion;
- gboolean is_accept;
- bt_socket_role_e role;
-};
-
GList *spp_ctx_list;
static GDBusNodeInfo *profile_xml_data;
return path;
}
-int bt_spp_create_rfcomm(const char *uuid,
+static int bt_spp_create_rfcomm(const char *uuid,
bt_spp_new_connection_cb new_connection_cb,
void *user_data)
{
return BT_SUCCESS;
}
-int bt_spp_destroy_rfcomm(const char *uuid)
+static int bt_spp_destroy_rfcomm(const char *uuid)
{
struct spp_context *spp_ctx;
struct spp_channel *spp_chan;
return BT_SUCCESS;
}
-int bt_spp_connect_rfcomm(const char *remote_address,
+static int bt_spp_connect_rfcomm(const char *remote_address,
const char *service_uuid)
{
bluez_device_t *device;
return BT_SUCCESS;
}
-int bt_spp_disconnect_rfcomm(const char *remote_address,
+static int bt_spp_disconnect_rfcomm(const char *remote_address,
const char *service_uuid)
{
bluez_device_t *device;
return BT_SUCCESS;
}
-int bt_spp_accept(bt_req_t *requestion)
+static int bt_spp_accept(bt_req_t *requestion)
{
GDBusMethodInvocation *invocation = requestion;
return BT_SUCCESS;
}
-int bt_spp_reject(bt_req_t *requestion)
+static int bt_spp_reject(bt_req_t *requestion)
{
GDBusMethodInvocation *invocation = requestion;
return BT_SUCCESS;
}
-int bt_spp_set_connection_requested_cb(bt_spp_connection_requested_cb callback,
- void *user_data)
-{
- struct spp_connection_requested_cb_node *node_data;
-
- if (callback == NULL)
- return BT_ERROR_INVALID_PARAMETER;
-
- if (spp_connection_requested_node) {
- DBG("spp connection requested callback already set.");
- return BT_ERROR_ALREADY_DONE;
- }
-
- node_data = g_new0(struct spp_connection_requested_cb_node, 1);
- if (node_data == NULL) {
- ERROR("no memory");
- return BT_ERROR_OUT_OF_MEMORY;
- }
-
- node_data->cb = callback;
- node_data->user_data = user_data;
-
- spp_connection_requested_node = node_data;
-
- return BT_SUCCESS;
-}
-
-int bt_spp_unset_connection_requested_cb(void)
-{
- DBG("");
-
- if (initialized == false)
- return BT_ERROR_NOT_INITIALIZED;
-
- if (default_adapter == NULL)
- return BT_ERROR_ADAPTER_NOT_FOUND;
-
- if (!spp_connection_requested_node)
- return BT_SUCCESS;
-
- g_free(spp_connection_requested_node);
- spp_connection_requested_node = NULL;
-
- return BT_SUCCESS;
-}
-
-int bt_spp_send_data(int fd, const char *data, int length)
+static int bt_spp_send_data(int fd, const char *data, int length)
{
struct spp_context *spp_ctx;
gsize written = 0, count = 0;
return BT_SUCCESS;
}
-int bt_spp_set_data_received_cb(bt_spp_data_received_cb callback,
+static int bt_spp_set_data_received_cb(bt_spp_data_received_cb callback,
void *user_data)
{
struct spp_data_received_cb_node *node_data;
return BT_SUCCESS;
}
-int bt_spp_unset_data_received_cb(void)
+static int bt_spp_unset_data_received_cb(void)
{
DBG("");
**/
int bt_opp_client_cancel_push(void);
-/* New OPP API*/
-int bt_opp_init(void);
-
-int bt_opp_deinit(void);
-
-typedef void (*bt_opp_server_push_file_requested_cb)(
- const char *remote_address,
- const char *name,
- uint64_t size,
- void *user_data);
-
-int bt_opp_register_server(
- const char *dir,
- bt_opp_server_push_file_requested_cb push_requested_cb,
- void *user_data);
-
-int bt_opp_unregister_server(void);
-
-typedef enum
-{
- BT_OPP_TRANSFER_UNKNOWN = 0x0,
- BT_OPP_TRANSFER_QUEUED,
- BT_OPP_TRANSFER_ACTIVE,
- BT_OPP_TRANSFER_COMPLETED,
- BT_OPP_TRANSFER_CANCELED,
- BT_OPP_TRANSFER_ERROR,
-} bt_opp_transfer_state_e;
-
-typedef void (*bt_opp_transfer_state_cb)(
- int transfer_id,
- bt_opp_transfer_state_e state,
- const char *name,
- uint64_t size,
- unsigned char percent,
- void *user_data);
-
-int bt_opp_server_accept_request(
- const char *name,
- bt_opp_transfer_state_cb cb,
- void *user_data,
- int *transfer_id);
-
-int bt_opp_server_reject_request(void);
-
-int bt_opp_server_set_directroy(const char *dir);
-
-typedef enum {
- BT_OPP_PUSH_ACCETPED = 0,
- BT_OPP_PUSH_RETRY,
- BT_OPP_PUSH_FAILED,
- BT_OPP_PUSH_REFUSED,
- BT_OPP_PUSH_TIMEOUT,
- BT_OPP_PUSH_NO_SERVICE
-} push_state_e;
-
-typedef void (*bt_opp_client_push_responded_new_cb)(
- const char *remote_address,
- push_state_e state,
- void *user_data);
-
-int bt_opp_client_push_file(
- const char *name,
- const char *remote_address,
- bt_opp_client_push_responded_new_cb responded_cb,
- void *responded_data,
- bt_opp_transfer_state_cb transfer_state_cb,
- void *transfer_data);
-
-int bt_opp_set_transfers_state_cb(
- bt_opp_transfer_state_cb cb,
- void *user_data);
-
-void bt_opp_clear_transfers_state_cb(void);
-
-int bt_opp_transfer_get_source_addres(
- int transfer_id,
- const char **source_address);
-
-int bt_opp_transfer_get_target_addres(
- int transfer_id,
- const char **target_address);
-
-int bt_opp_transfer_is_server(
- int transfer_id,
- bool *is_server);
-
-int bt_opp_transfer_cancel(
- int transfer_id);
-
/**
* @ingroup CAPI_NETWORK_BLUETOOTH_PAN_NAP_MODULE
* @brief Called when the connection state is changed.
int bt_device_disconnect_le(bt_device_gatt_state_changed_cb callback,
const char *address);
-/* SPP */
-typedef void (*bt_spp_new_connection_cb)(
- const char *uuid,
- const char *device_name,
- int fd,
- void *user_data);
-
-int bt_spp_create_rfcomm(
- const char *uuid,
- bt_spp_new_connection_cb new_connection_cb,
- void *user_data);
-
-int bt_spp_destroy_rfcomm(
- const char *uuid);
-
-int bt_spp_connect_rfcomm(
- const char *remote_address,
- const char *service_uuid);
-
-int bt_spp_disconnect_rfcomm(
- const char *remote_address,
- const char *service_uuid);
-
-int bt_spp_accept(bt_req_t *requestion);
-
-int bt_spp_reject(bt_req_t *requestion);
-
-typedef void (*bt_spp_connection_requested_cb) (
- const char *uuid,
- const char *remote_address,
- bt_req_t *requestion,
- void *user_data);
-
-int bt_spp_set_connection_requested_cb(
- bt_spp_connection_requested_cb callback,
- void *user_data);
-
-int bt_spp_unset_connection_requested_cb(void);
-
-int bt_spp_send_data(
- int fd,
- const char *data,
- int length);
-
-typedef struct
-{
- int socket_fd; /**< The socket fd */
- int data_size; /**< The length of the received data */
- char *data; /**< The received data */
-} bt_spp_received_data;
-
-typedef void (*bt_spp_data_received_cb)(
- bt_spp_received_data *data,
- void *user_data);
-
-int bt_spp_set_data_received_cb(
- bt_spp_data_received_cb callback,
- void *user_data);
-
-int bt_spp_unset_data_received_cb(void);
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
return ret;
}
-static void transfer_state_cb(int transfer_id,
- bt_opp_transfer_state_e state,
- const char *file, guint64 size,
- unsigned char percent, void *user_data)
-{
- printf("\n\ttransfer %d state %d\n\t", transfer_id, state);
- printf("\n\t%s size %ju transfered %d\n\t", file, size, percent);
-}
-
-static void server_push_requested_cb(const char *remote_address,
- const char *file, guint64 size,
- void *user_data)
-{
- int id;
-
- printf("\n\t%s push %s size %ju\n\t", remote_address, file, size);
- printf("\n\tAccept it...\n\t");
-
- bt_opp_server_accept_request(NULL, NULL, NULL, &id);
-
- printf("\n\ttransfer %d accepted\n", id);
-}
-
-static int register_opp_server(const char *p1, const char *p2)
-{
- bt_opp_init();
- bt_opp_register_server("/tmp", server_push_requested_cb, NULL);
- return 0;
-}
-
-static int opp_watch(const char *p1, const char *p2)
-{
- if (!g_strcmp0(p1, "on"))
- bt_opp_set_transfers_state_cb(transfer_state_cb, NULL);
- else if (!g_strcmp0(p1, "off"))
- bt_opp_clear_transfers_state_cb();
- else
- ERROR("Unknown parameter %s", (char *) p1);
-
- return 0;
-}
-
-static void push_responded_cb(
- const char *remote_address,
- push_state_e state,
- void *user_data)
-{
- printf("\n\t %s connection state %d\n", remote_address, state);
-}
-
-
-static int opp_send(const char *p1, const char *p2)
-{
- bt_opp_client_push_file(p1, p2, push_responded_cb, NULL,
- transfer_state_cb, NULL);
- return 0;
-}
-
-static int init_opp(const char *p1, const char *p2)
-{
- bt_opp_init();
-
- return 0;
-}
-
-static int deinit_opp(const char *p1, const char *p2)
-{
- bt_opp_deinit();
-
- return 0;
-}
-
static void print_bonded_device_info(bt_device_info_s *device_info)
{
int len;
return 0;
}
-static void new_connection(const char *uuid, const char *device_name,
- int fd, void *user_data)
-{
- DBG("%s %s comming connect with %d", device_name, uuid, fd);
-}
-
-static int spp_create(const char *p1, const char *p2)
-{
- int ret;
-
- if (p1 == NULL) {
- ERROR("spp create must give the UUID");
- return 0;
- }
-
- ret = bt_spp_create_rfcomm(p1, new_connection, NULL);
- if (ret != BT_SUCCESS)
- DBG("spp create failed");
-
- return 0;
-}
-
-static int spp_destroy(const char *p1, const char *p2)
-{
- int ret;
-
- if (p1 == NULL) {
- ERROR("spp create must give the UUID");
- return 0;
- }
-
- ret = bt_spp_destroy_rfcomm(p1);
- if (ret != BT_SUCCESS)
- DBG("destroy spp failed");
-
- return 0;
-}
-
-static void spp_authorize_cb(const char *uuid, const char *device_name,
- bt_req_t *requestion, void *user_data)
-{
- const gchar *confirm_info, *p1, *p2;
- gchar input_value[32] = { 0 };
-
- DBG("\n\t%s %s requset connect, Please input(Y/N):\n",
- device_name, uuid);
-
- if (fgets(input_value, 32, stdin) == NULL) {
- ERROR("fgets error.");
- return;
- }
-
- split_input(input_value, &confirm_info, &p1, &p2);
-
- if (g_ascii_strncasecmp(confirm_info, "y", 1))
- bt_spp_reject(requestion);
- else
- bt_spp_accept(requestion);
-}
-
-static int spp_set_authorize_cb(const char *p1, const char *p2)
-{
- int ret;
-
- ret = bt_spp_set_connection_requested_cb(spp_authorize_cb, NULL);
- if (ret != BT_SUCCESS)
- DBG("spp set connection requested callback failed");
-
- return 0;
-}
-
-static void spp_data_received(bt_spp_received_data *data, void *user_data)
-{
- DBG("received data from %d %s", data->socket_fd, data->data);
-}
-
-static int spp_set_data_receive_cb(const char *p1, const char *p2)
-{
- int ret;
-
- ret = bt_spp_set_data_received_cb(spp_data_received, NULL);
- if (ret != BT_SUCCESS)
- DBG("set spp data received callback failed");
-
- return 0;
-}
-
-static int spp_connect(const char *p1, const char *p2)
-{
- int ret;
-
- if (p1 == NULL) {
- ERROR("spp connect must give the device address");
- return 0;
- }
-
- if (p2 == NULL) {
- ERROR("spp connect must give the UUID");
- return 0;
- }
-
- ret = bt_spp_connect_rfcomm(p1, p2);
- if (ret != BT_SUCCESS)
- DBG("spp connect failed");
-
- return 0;
-}
-
-static int spp_disconnect(const char *p1, const char *p2)
-{
- int ret;
-
- if (p1 == NULL) {
- ERROR("spp disconnect must give the device address");
- return 0;
- }
-
- if (p2 == NULL) {
- ERROR("spp disconnect must give the UUID");
- return 0;
- }
-
- ret = bt_spp_disconnect_rfcomm(p1, p2);
- if (ret != BT_SUCCESS)
- DBG("disconnect spp failed");
-
- return 0;
-}
-
-static int spp_send(const char *p1, const char *p2)
-{
- int ret, fd;
-
- fd = g_ascii_strtoll(p1, NULL, 10);
- if (fd < 0) {
- DBG("invalid fd %d", fd);
- return 0;
- }
-
- ret = bt_spp_send_data(fd, p2, strlen(p2));
- if (ret != BT_SUCCESS)
- DBG("spp send failed");
-
- return 0;
-}
-
static void panu_connected_changed(int result, bool connected,
const char *remote_address,
bt_panu_service_type_e type,
{"opp_client_cancel_push", opp_client_cancel_push,
"Usage: opp_client_cancel_push\n\topp client cancel"},
- {"init_opp", init_opp,
- "Usage: init_opp\n\tinitialize obex_lib"},
-
- {"deinit_opp", deinit_opp,
- "Usage: deinit_opp\n\tdeinitialize obex_lib"},
-
- {"register_opp_server", register_opp_server,
- "Usage: register_opp_server\n\tregister opp server"},
-
- {"opp_send", opp_send,
- "Usage: opp_send file_name destination\n\tpush file"},
-
- {"opp_watch", opp_watch,
- "Usage: opp_watch on/off\n\ton/off opp_watch"},
-
{"socket_create", socket_create,
"Usage: socket_create 00001101-0000-1000-8000-00805f9b34fb\n\tcreate socket with uuid"},
{"socket_unset_connection_requested_cb", socket_unset_connection_requested_cb,
"Usage: socket_unset_connection_requested_cb\n\tunset socket connection requested callback"},
- {"spp_create", spp_create,
- "Usage: spp_create 00001101-0000-1000-8000-00805f9b34fb\n\tcreate spp with uuid"},
-
- {"spp_destroy", spp_destroy,
- "Usage: spp_destroy\n\tdestory spp"},
-
- {"spp_set_authorize_cb", spp_set_authorize_cb,
- "Usage: spp_set_authorize_cb\n\tset spp authorize callback, accept/reject"},
-
- {"spp_set_data_receive_cb", spp_set_data_receive_cb,
- "Usage: spp_set_data_receive_cb\n\tset spp data recieved callback"},
-
- {"spp_connect", spp_connect,
- "Usage: spp_connect 70:F9:27:64:DF:65 00001101-0000-1000-8000-00805f9b34fb\n\tconnect spp"},
-
- {"spp_disconnect", spp_disconnect,
- "Usage: spp_disconnect 70:F9:27:64:DF:65 00001101-0000-1000-8000-00805f9b34fb\n\tdisconnect spp"},
-
- {"spp_send", spp_send,
- "Usage: spp_send fd 'data'\n\tsend spp data to fd"},
-
{"panu_set_state_changed", panu_set_state_changed,
"Usage: panu_set_state_changed\n\tset panu state changed callback"},
{"hdp_set_data_rec_cb", hdp_set_data_received_cb,
"Usage: hdp_set_data_rec_cb\n\tset hdp data rec cb"},
- {"hdo_unset_connect_cb", hdp_unset_connection_state_changed_cb,
+ {"hdp_unset_connect_cb", hdp_unset_connection_state_changed_cb,
"Usage: hdp_unset_connect_cb\n\tunset hdp conn cb"},
{"hdp_unset_data_rec_cb", hdp_unset_data_received_cb,