From 022b6a3c695ecccc54e20432caff3668bd28d4c5 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Thu, 6 Mar 2008 14:03:45 +0000 Subject: Add skeleton for GLib helpers --- common/glib-helper.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 common/glib-helper.h (limited to 'common/glib-helper.h') diff --git a/common/glib-helper.h b/common/glib-helper.h new file mode 100644 index 00000000..71377516 --- /dev/null +++ b/common/glib-helper.h @@ -0,0 +1,22 @@ +/* + * + * BlueZ - Bluetooth protocol stack for Linux + * + * Copyright (C) 2004-2008 Marcel Holtmann + * + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ -- cgit From 6eab5e203d793fbeea8a488a315a62ab2e69417e Mon Sep 17 00:00:00 2001 From: Claudio Takahasi Date: Thu, 6 Mar 2008 21:58:13 +0000 Subject: added bt_discover_services function --- common/glib-helper.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'common/glib-helper.h') diff --git a/common/glib-helper.h b/common/glib-helper.h index 71377516..7426a6ad 100644 --- a/common/glib-helper.h +++ b/common/glib-helper.h @@ -20,3 +20,9 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ + +typedef void (*bt_callback_t) (gpointer user_data, sdp_list_t *recs, int err); +typedef void (*bt_destroy_t) (gpointer user_data); + +int bt_discover_services(const bdaddr_t *src, const bdaddr_t *dst, + bt_callback_t cb, void *user_data, bt_destroy_t destroy); -- cgit From ea00a446dbacead62040dd2bd7e663774c205c04 Mon Sep 17 00:00:00 2001 From: Claudio Takahasi Date: Mon, 10 Mar 2008 14:20:50 +0000 Subject: added new function to convert uuid to string(uuid128) --- common/glib-helper.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'common/glib-helper.h') diff --git a/common/glib-helper.h b/common/glib-helper.h index 7426a6ad..e64eccca 100644 --- a/common/glib-helper.h +++ b/common/glib-helper.h @@ -26,3 +26,5 @@ typedef void (*bt_destroy_t) (gpointer user_data); int bt_discover_services(const bdaddr_t *src, const bdaddr_t *dst, bt_callback_t cb, void *user_data, bt_destroy_t destroy); + +gchar *bt_uuid2string(uuid_t *uuid); -- cgit From b583273d911d67eb202f3f367f18d4460913ad41 Mon Sep 17 00:00:00 2001 From: Claudio Takahasi Date: Mon, 10 Mar 2008 20:01:52 +0000 Subject: added list2string function --- common/glib-helper.h | 1 + 1 file changed, 1 insertion(+) (limited to 'common/glib-helper.h') diff --git a/common/glib-helper.h b/common/glib-helper.h index e64eccca..7cfdc5dc 100644 --- a/common/glib-helper.h +++ b/common/glib-helper.h @@ -28,3 +28,4 @@ int bt_discover_services(const bdaddr_t *src, const bdaddr_t *dst, bt_callback_t cb, void *user_data, bt_destroy_t destroy); gchar *bt_uuid2string(uuid_t *uuid); +gchar *bt_list2string(GSList *list); -- cgit From 2c52650872bdeede320c4192bc0ac06c029f2732 Mon Sep 17 00:00:00 2001 From: Claudio Takahasi Date: Tue, 11 Mar 2008 19:29:12 +0000 Subject: added bt_string2list function --- common/glib-helper.h | 1 + 1 file changed, 1 insertion(+) (limited to 'common/glib-helper.h') diff --git a/common/glib-helper.h b/common/glib-helper.h index 7cfdc5dc..ed724af6 100644 --- a/common/glib-helper.h +++ b/common/glib-helper.h @@ -29,3 +29,4 @@ int bt_discover_services(const bdaddr_t *src, const bdaddr_t *dst, gchar *bt_uuid2string(uuid_t *uuid); gchar *bt_list2string(GSList *list); +GSList *bt_string2list(const gchar *str); -- cgit From ec96a4be11db022bd8d2b403beb7ca245c5d1ebc Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Fri, 18 Apr 2008 17:41:06 +0000 Subject: Introduce bt_search_service and bt_rfcomm_connect. --- common/glib-helper.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'common/glib-helper.h') diff --git a/common/glib-helper.h b/common/glib-helper.h index ed724af6..a6939fd1 100644 --- a/common/glib-helper.h +++ b/common/glib-helper.h @@ -21,12 +21,21 @@ * */ +typedef void (*bt_io_callback_t) (GIOChannel *io, int err, gpointer user_data); typedef void (*bt_callback_t) (gpointer user_data, sdp_list_t *recs, int err); typedef void (*bt_destroy_t) (gpointer user_data); int bt_discover_services(const bdaddr_t *src, const bdaddr_t *dst, bt_callback_t cb, void *user_data, bt_destroy_t destroy); +int bt_search_service(const bdaddr_t *src, const bdaddr_t *dst, + uuid_t uuid, bt_callback_t cb, void *user_data, + bt_destroy_t destroy); + gchar *bt_uuid2string(uuid_t *uuid); gchar *bt_list2string(GSList *list); GSList *bt_string2list(const gchar *str); + +int bt_rfcomm_connect(const bdaddr_t *src, const bdaddr_t *dst, + sdp_record_t *record, bt_io_callback_t cb, + void *user_data); -- cgit From 56eba24d02bc70648c9f7da5a13ded03bccf8a2f Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Tue, 22 Apr 2008 14:50:37 +0000 Subject: Introduce bt_l2cap_connect. --- common/glib-helper.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'common/glib-helper.h') diff --git a/common/glib-helper.h b/common/glib-helper.h index a6939fd1..d356290f 100644 --- a/common/glib-helper.h +++ b/common/glib-helper.h @@ -39,3 +39,5 @@ GSList *bt_string2list(const gchar *str); int bt_rfcomm_connect(const bdaddr_t *src, const bdaddr_t *dst, sdp_record_t *record, bt_io_callback_t cb, void *user_data); +int bt_l2cap_connect(const bdaddr_t *src, const bdaddr_t *dst, + uint16_t psm, bt_io_callback_t cb, void *user_data); -- cgit From 5b9b4989612f0bee7d7b5574e78e760090bd2b7d Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Wed, 23 Apr 2008 20:19:04 +0000 Subject: Make bt_rfcomm_connect to take a channel instead of record and export bt_sco_connect. --- common/glib-helper.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'common/glib-helper.h') diff --git a/common/glib-helper.h b/common/glib-helper.h index d356290f..b51122ad 100644 --- a/common/glib-helper.h +++ b/common/glib-helper.h @@ -37,7 +37,8 @@ gchar *bt_list2string(GSList *list); GSList *bt_string2list(const gchar *str); int bt_rfcomm_connect(const bdaddr_t *src, const bdaddr_t *dst, - sdp_record_t *record, bt_io_callback_t cb, - void *user_data); + uint8_t channel, bt_io_callback_t cb, void *user_data); int bt_l2cap_connect(const bdaddr_t *src, const bdaddr_t *dst, uint16_t psm, bt_io_callback_t cb, void *user_data); +int bt_sco_connect(const bdaddr_t *src, const bdaddr_t *dst, + bt_io_callback_t cb, void *user_data); -- cgit From 3a2024530dd736ece6f8b59db53bd8f67a755361 Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Thu, 24 Apr 2008 14:56:40 +0000 Subject: Close socket on bind failure, fix callback user_data to be the last parameter and pass uuid refence. --- common/glib-helper.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'common/glib-helper.h') diff --git a/common/glib-helper.h b/common/glib-helper.h index b51122ad..6d191640 100644 --- a/common/glib-helper.h +++ b/common/glib-helper.h @@ -22,14 +22,14 @@ */ typedef void (*bt_io_callback_t) (GIOChannel *io, int err, gpointer user_data); -typedef void (*bt_callback_t) (gpointer user_data, sdp_list_t *recs, int err); +typedef void (*bt_callback_t) (sdp_list_t *recs, int err, gpointer user_data); typedef void (*bt_destroy_t) (gpointer user_data); int bt_discover_services(const bdaddr_t *src, const bdaddr_t *dst, bt_callback_t cb, void *user_data, bt_destroy_t destroy); int bt_search_service(const bdaddr_t *src, const bdaddr_t *dst, - uuid_t uuid, bt_callback_t cb, void *user_data, + uuid_t *uuid, bt_callback_t cb, void *user_data, bt_destroy_t destroy); gchar *bt_uuid2string(uuid_t *uuid); -- cgit From f85b9560ece47c94ec82466cba9c44da715591d9 Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Wed, 7 May 2008 18:39:36 +0000 Subject: Make bt_l2cap_connect to take mtu as paramter. --- common/glib-helper.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'common/glib-helper.h') diff --git a/common/glib-helper.h b/common/glib-helper.h index 6d191640..97f51b11 100644 --- a/common/glib-helper.h +++ b/common/glib-helper.h @@ -39,6 +39,7 @@ GSList *bt_string2list(const gchar *str); int bt_rfcomm_connect(const bdaddr_t *src, const bdaddr_t *dst, uint8_t channel, bt_io_callback_t cb, void *user_data); int bt_l2cap_connect(const bdaddr_t *src, const bdaddr_t *dst, - uint16_t psm, bt_io_callback_t cb, void *user_data); + uint16_t psm, uint16_t mtu, bt_io_callback_t cb, + void *user_data); int bt_sco_connect(const bdaddr_t *src, const bdaddr_t *dst, bt_io_callback_t cb, void *user_data); -- cgit From 4d39e4d2ea552e2d4ad36c085700f513e10be7e0 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Thu, 8 May 2008 18:47:21 +0000 Subject: Move set_nonblocking() to the GLib helpers for now --- common/glib-helper.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'common/glib-helper.h') diff --git a/common/glib-helper.h b/common/glib-helper.h index 97f51b11..7a312005 100644 --- a/common/glib-helper.h +++ b/common/glib-helper.h @@ -21,6 +21,8 @@ * */ +int set_nonblocking(int fd); + typedef void (*bt_io_callback_t) (GIOChannel *io, int err, gpointer user_data); typedef void (*bt_callback_t) (sdp_list_t *recs, int err, gpointer user_data); typedef void (*bt_destroy_t) (gpointer user_data); -- cgit From eac653286a4619a0b28614cdde1506997e5d6023 Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Mon, 12 May 2008 21:21:47 +0000 Subject: introduce bt_rfcomm_listen. --- common/glib-helper.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'common/glib-helper.h') diff --git a/common/glib-helper.h b/common/glib-helper.h index 7a312005..71ed67b8 100644 --- a/common/glib-helper.h +++ b/common/glib-helper.h @@ -38,6 +38,8 @@ gchar *bt_uuid2string(uuid_t *uuid); gchar *bt_list2string(GSList *list); GSList *bt_string2list(const gchar *str); +GIOChannel *bt_rfcomm_listen(const bdaddr_t *src, uint8_t channel, + uint32_t flags, bt_io_callback_t cb, void *user_data); int bt_rfcomm_connect(const bdaddr_t *src, const bdaddr_t *dst, uint8_t channel, bt_io_callback_t cb, void *user_data); int bt_l2cap_connect(const bdaddr_t *src, const bdaddr_t *dst, -- cgit From efeeab95ad87e827c2a801186754df868b598242 Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Tue, 13 May 2008 18:18:02 +0000 Subject: Introduce bt_l2cap_listen. --- common/glib-helper.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'common/glib-helper.h') diff --git a/common/glib-helper.h b/common/glib-helper.h index 71ed67b8..ddc57d4b 100644 --- a/common/glib-helper.h +++ b/common/glib-helper.h @@ -42,6 +42,9 @@ GIOChannel *bt_rfcomm_listen(const bdaddr_t *src, uint8_t channel, uint32_t flags, bt_io_callback_t cb, void *user_data); int bt_rfcomm_connect(const bdaddr_t *src, const bdaddr_t *dst, uint8_t channel, bt_io_callback_t cb, void *user_data); + +GIOChannel *bt_l2cap_listen(const bdaddr_t *src, uint16_t psm, uint16_t mtu, + uint32_t flags, bt_io_callback_t cb, void *user_data); int bt_l2cap_connect(const bdaddr_t *src, const bdaddr_t *dst, uint16_t psm, uint16_t mtu, bt_io_callback_t cb, void *user_data); -- cgit From 0094809955895c974fbe95f2d3ed13f420a6a6ed Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Wed, 14 May 2008 22:16:16 +0000 Subject: Make bt_io_callback_t to take both source and destination. --- common/glib-helper.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'common/glib-helper.h') diff --git a/common/glib-helper.h b/common/glib-helper.h index ddc57d4b..1db329ca 100644 --- a/common/glib-helper.h +++ b/common/glib-helper.h @@ -23,7 +23,8 @@ int set_nonblocking(int fd); -typedef void (*bt_io_callback_t) (GIOChannel *io, int err, gpointer user_data); +typedef void (*bt_io_callback_t) (GIOChannel *io, int err, const bdaddr_t *src, + const bdaddr_t *dst, gpointer user_data); typedef void (*bt_callback_t) (sdp_list_t *recs, int err, gpointer user_data); typedef void (*bt_destroy_t) (gpointer user_data); -- cgit From 497dd72d04902511120a03b0f66333642426be47 Mon Sep 17 00:00:00 2001 From: Cidorvan Leite Date: Thu, 15 May 2008 13:17:42 +0000 Subject: Added function for convert string to uuid128 --- common/glib-helper.h | 1 + 1 file changed, 1 insertion(+) (limited to 'common/glib-helper.h') diff --git a/common/glib-helper.h b/common/glib-helper.h index 1db329ca..23a04046 100644 --- a/common/glib-helper.h +++ b/common/glib-helper.h @@ -36,6 +36,7 @@ int bt_search_service(const bdaddr_t *src, const bdaddr_t *dst, bt_destroy_t destroy); gchar *bt_uuid2string(uuid_t *uuid); +int bt_string2uuid(uuid_t *uuid, const char *string); gchar *bt_list2string(GSList *list); GSList *bt_string2list(const gchar *str); -- cgit From 3cb3d3d7e4aa089dd5840980c8846927631757f6 Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Fri, 16 May 2008 22:25:51 +0000 Subject: Introduce bt_rfcomm_listen_allocate. --- common/glib-helper.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'common/glib-helper.h') diff --git a/common/glib-helper.h b/common/glib-helper.h index 23a04046..8d346b49 100644 --- a/common/glib-helper.h +++ b/common/glib-helper.h @@ -42,6 +42,8 @@ GSList *bt_string2list(const gchar *str); GIOChannel *bt_rfcomm_listen(const bdaddr_t *src, uint8_t channel, uint32_t flags, bt_io_callback_t cb, void *user_data); +GIOChannel *bt_rfcomm_listen_allocate(const bdaddr_t *src, uint8_t *channel, + uint32_t flags, bt_io_callback_t cb, void *user_data); int bt_rfcomm_connect(const bdaddr_t *src, const bdaddr_t *dst, uint8_t channel, bt_io_callback_t cb, void *user_data); -- cgit From 95fda45987df20c6603b1c5a068fe46fccf55b6e Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Fri, 30 May 2008 07:51:44 +0000 Subject: Add initial implementation of BtIO API. --- common/glib-helper.h | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'common/glib-helper.h') diff --git a/common/glib-helper.h b/common/glib-helper.h index 8d346b49..458d5c88 100644 --- a/common/glib-helper.h +++ b/common/glib-helper.h @@ -54,3 +54,40 @@ int bt_l2cap_connect(const bdaddr_t *src, const bdaddr_t *dst, void *user_data); int bt_sco_connect(const bdaddr_t *src, const bdaddr_t *dst, bt_io_callback_t cb, void *user_data); + +/* Experiemental bt_io API */ + +typedef struct bt_io BtIO; + +typedef enum { + BT_L2CAP, + BT_RFCOMM, + BT_SCO +} BtIOTransport; + +typedef enum { + BT_IO_SUCCESS, + BT_IO_FAILED +} BtIOError; + +typedef void (*BtIOFunc) (BtIO *io, BtIOError err, GIOChannel *chan, + gpointer user_data); + +BtIO *bt_io_create(BtIOTransport type, gpointer user_data, GDestroyNotify notify); +BtIO *bt_io_ref(BtIO *io); +void bt_io_unref(BtIO *io); +gboolean bt_io_set_source(BtIO *io, const char *address); +const char *bt_io_get_source(BtIO *io); +gboolean bt_io_set_destination(BtIO *io, const char *address); +const char *bt_io_get_destination(BtIO *io); +gboolean bt_io_set_flags(BtIO *io, guint32 flags); +guint32 bt_io_get_flags(BtIO *io); +gboolean bt_io_set_channel(BtIO *io, guint8 channel); +guint8 bt_io_get_channel(BtIO *io); +gboolean bt_io_set_psm(BtIO *io, guint16 psm); +guint16 bt_io_get_psm(BtIO *io); +gboolean bt_io_set_mtu(BtIO *io, guint16 mtu); +guint16 bt_io_get_mtu(BtIO *io); +BtIOError bt_io_connect(BtIO *io, const char *uuid, BtIOFunc func); +BtIOError bt_io_listen(BtIO *io, const char *uuid, BtIOFunc func); +BtIOError bt_io_shutdown(BtIO *io); -- cgit From 3232edc9af22131032cef987479d081b90fa4f81 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Fri, 30 May 2008 08:57:22 +0000 Subject: Rename the transport types with proper BT_IO prefix --- common/glib-helper.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'common/glib-helper.h') diff --git a/common/glib-helper.h b/common/glib-helper.h index 458d5c88..0919fe97 100644 --- a/common/glib-helper.h +++ b/common/glib-helper.h @@ -60,14 +60,15 @@ int bt_sco_connect(const bdaddr_t *src, const bdaddr_t *dst, typedef struct bt_io BtIO; typedef enum { - BT_L2CAP, - BT_RFCOMM, - BT_SCO + BT_IO_AUTO, + BT_IO_L2CAP, + BT_IO_RFCOMM, + BT_IO_SCO, } BtIOTransport; typedef enum { BT_IO_SUCCESS, - BT_IO_FAILED + BT_IO_FAILED, } BtIOError; typedef void (*BtIOFunc) (BtIO *io, BtIOError err, GIOChannel *chan, -- cgit From 19b4c8b0e51a20a1b95ede34b092ebc56e1183ae Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Mon, 16 Jun 2008 14:26:54 +0000 Subject: Allow to cancel a service discovery --- common/glib-helper.h | 1 + 1 file changed, 1 insertion(+) (limited to 'common/glib-helper.h') diff --git a/common/glib-helper.h b/common/glib-helper.h index 0919fe97..6c9b89b0 100644 --- a/common/glib-helper.h +++ b/common/glib-helper.h @@ -34,6 +34,7 @@ int bt_discover_services(const bdaddr_t *src, const bdaddr_t *dst, int bt_search_service(const bdaddr_t *src, const bdaddr_t *dst, uuid_t *uuid, bt_callback_t cb, void *user_data, bt_destroy_t destroy); +void bt_cancel_discovery(const bdaddr_t *src, const bdaddr_t *dst); gchar *bt_uuid2string(uuid_t *uuid); int bt_string2uuid(uuid_t *uuid, const char *string); -- cgit From 289e29c6c4a073569c7e7aa3c8fc51ed5c46993f Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Mon, 16 Jun 2008 16:56:38 +0000 Subject: Fix bt_cancel_discovery to only succeed when there is a discover to cancel. --- common/glib-helper.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'common/glib-helper.h') diff --git a/common/glib-helper.h b/common/glib-helper.h index 6c9b89b0..8bb6b284 100644 --- a/common/glib-helper.h +++ b/common/glib-helper.h @@ -34,7 +34,7 @@ int bt_discover_services(const bdaddr_t *src, const bdaddr_t *dst, int bt_search_service(const bdaddr_t *src, const bdaddr_t *dst, uuid_t *uuid, bt_callback_t cb, void *user_data, bt_destroy_t destroy); -void bt_cancel_discovery(const bdaddr_t *src, const bdaddr_t *dst); +int bt_cancel_discovery(const bdaddr_t *src, const bdaddr_t *dst); gchar *bt_uuid2string(uuid_t *uuid); int bt_string2uuid(uuid_t *uuid, const char *string); -- cgit From 3005856580174bb25cd0510115bed9499b1f1bdc Mon Sep 17 00:00:00 2001 From: Claudio Takahasi Date: Mon, 30 Jun 2008 14:05:38 +0000 Subject: Accept friendly names for discover services --- common/glib-helper.h | 1 + 1 file changed, 1 insertion(+) (limited to 'common/glib-helper.h') diff --git a/common/glib-helper.h b/common/glib-helper.h index 8bb6b284..6b188f7f 100644 --- a/common/glib-helper.h +++ b/common/glib-helper.h @@ -37,6 +37,7 @@ int bt_search_service(const bdaddr_t *src, const bdaddr_t *dst, int bt_cancel_discovery(const bdaddr_t *src, const bdaddr_t *dst); gchar *bt_uuid2string(uuid_t *uuid); +uint16_t bt_string2class(const char *string); int bt_string2uuid(uuid_t *uuid, const char *string); gchar *bt_list2string(GSList *list); GSList *bt_string2list(const gchar *str); -- cgit