From: Santiago Carot-Nemesio <sancane@gmail.com>
To: linux-bluetooth@vger.kernel.org
Cc: Santiago Carot-Nemesio <sancane@gmail.com>
Subject: [PATCH 8/8] attrib-server: Add Gattrib in attrib_channel_detach function
Date: Tue, 27 Dec 2011 10:29:42 +0100 [thread overview]
Message-ID: <1324978182-5707-9-git-send-email-sancane@gmail.com> (raw)
In-Reply-To: <1324978182-5707-8-git-send-email-sancane@gmail.com>
---
src/attrib-server.c | 39 +++++++++++++++------------------------
src/attrib-server.h | 2 +-
src/device.c | 6 +++---
3 files changed, 19 insertions(+), 28 deletions(-)
diff --git a/src/attrib-server.c b/src/attrib-server.c
index 929a505..8cdb5b7 100644
--- a/src/attrib-server.c
+++ b/src/attrib-server.c
@@ -180,27 +180,6 @@ static struct gatt_adapter *find_gatt_adapter(const bdaddr_t *bdaddr)
return l->data;
}
-static struct gatt_adapter *get_default_gatt_adapter(void)
-{
- struct btd_adapter *adapter;
- GSList *l;
-
- adapter = manager_get_default_adapter();
- if (adapter == NULL) {
- error("Can't get default adapter");
- return NULL;
- }
-
- l = g_slist_find_custom(adapters, adapter, adapter_cmp);
- if (l == NULL) {
- error("Not GATT server initialized on adapter %s",
- adapter_get_path(adapter));
- return NULL;
- }
-
- return l->data;
-}
-
static sdp_record_t *server_record_new(uuid_t *uuid, uint16_t start, uint16_t end)
{
sdp_list_t *svclass_id, *apseq, *proto[2], *root, *aproto;
@@ -1080,15 +1059,27 @@ static gint channel_id_cmp(gconstpointer data, gconstpointer user_data)
return channel->id - id;
}
-gboolean attrib_channel_detach(guint id)
+gboolean attrib_channel_detach(GAttrib *attrib, guint id)
{
struct gatt_adapter *gadapter;
struct gatt_channel *channel;
+ GError *gerr = NULL;
+ GIOChannel *io;
+ bdaddr_t src;
GSList *l;
- DBG("Deprecated function");
+ io = g_attrib_get_channel(attrib);
+
+ bt_io_get(io, BT_IO_L2CAP, &gerr, BT_IO_OPT_SOURCE_BDADDR, &src,
+ BT_IO_OPT_INVALID);
+
+ if (gerr != NULL) {
+ error("bt_io_get: %s", gerr->message);
+ g_error_free(gerr);
+ return FALSE;
+ }
- gadapter = get_default_gatt_adapter();
+ gadapter = find_gatt_adapter(&src);
if (gadapter == NULL)
return FALSE;
diff --git a/src/attrib-server.h b/src/attrib-server.h
index dc08bfb..2c6f428 100644
--- a/src/attrib-server.h
+++ b/src/attrib-server.h
@@ -36,4 +36,4 @@ uint32_t attrib_create_sdp(struct btd_adapter *adapter, uint16_t handle,
const char *name);
void attrib_free_sdp(uint32_t sdp_handle);
guint attrib_channel_attach(GAttrib *attrib, gboolean out);
-gboolean attrib_channel_detach(guint id);
+gboolean attrib_channel_detach(GAttrib *attrib, guint id);
diff --git a/src/device.c b/src/device.c
index bb97089..5be3fc5 100644
--- a/src/device.c
+++ b/src/device.c
@@ -1725,7 +1725,7 @@ static void attrib_disconnected(gpointer user_data)
g_slist_foreach(device->attios, attio_disconnected, NULL);
- attrib_channel_detach(device->attachid);
+ attrib_channel_detach(device->attrib, device->attachid);
g_attrib_unref(device->attrib);
device->attrib = NULL;
@@ -1774,7 +1774,7 @@ static void primary_cb(GSList *services, guint8 status, gpointer user_data)
device_probe_drivers(device, uuids);
if (device->attios == NULL && device->attios_offline == NULL) {
- attrib_channel_detach(device->attachid);
+ attrib_channel_detach(device->attrib, device->attachid);
g_attrib_unref(device->attrib);
device->attrib = NULL;
} else
@@ -2869,7 +2869,7 @@ gboolean btd_device_remove_attio_callback(struct btd_device *device, guint id)
return TRUE;
if (device->attachid) {
- attrib_channel_detach(device->attachid);
+ attrib_channel_detach(device->attrib, device->attachid);
device->attachid = 0;
}
--
1.7.8.1
next prev parent reply other threads:[~2011-12-27 9:29 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-27 9:29 Multi-adapter GATT server support Santiago Carot-Nemesio
2011-12-27 9:29 ` [PATCH 1/8] attrib-server: Add blutooth adapter to attrib_db_find_avail function Santiago Carot-Nemesio
2011-12-27 9:29 ` [PATCH 2/8] attrib-server: Add bluetooth adapter in attrib_db_add Santiago Carot-Nemesio
2011-12-27 9:29 ` [PATCH 3/8] gatt-service: Add bluetooth adapter in gatt_service_add function Santiago Carot-Nemesio
2011-12-27 9:29 ` [PATCH 4/8] attrib-server: Add bluetooth adapter in attrib_db_update function Santiago Carot-Nemesio
2011-12-27 9:29 ` [PATCH 5/8] attrib-server: Add bluetooth adapter in attrib_gap_set function Santiago Carot-Nemesio
2011-12-27 9:29 ` [PATCH 6/8] attrib-server: Add bluetooth adapter in attrib_db_del Santiago Carot-Nemesio
2011-12-27 9:29 ` [PATCH 7/8] attrib-server: Add bluetooth adapter in attrib_create_sdp function Santiago Carot-Nemesio
2011-12-27 9:29 ` Santiago Carot-Nemesio [this message]
2011-12-27 14:46 ` Multi-adapter GATT server support Santiago Carot
-- strict thread matches above, loose matches on Subject: below --
2011-12-28 10:24 Multi-Adapter GATT server (finish) Santiago Carot-Nemesio
2011-12-28 10:24 ` [PATCH 1/8] attrib-server: Add blutooth adapter to attrib_db_find_avail function Santiago Carot-Nemesio
2011-12-28 10:24 ` [PATCH 2/8] attrib-server: Add bluetooth adapter in attrib_db_add Santiago Carot-Nemesio
2011-12-28 10:24 ` [PATCH 3/8] gatt-service: Add bluetooth adapter in gatt_service_add function Santiago Carot-Nemesio
2011-12-28 10:24 ` [PATCH 4/8] attrib-server: Add bluetooth adapter in attrib_db_update function Santiago Carot-Nemesio
2011-12-28 10:24 ` [PATCH 5/8] attrib-server: Add bluetooth adapter in attrib_gap_set function Santiago Carot-Nemesio
2011-12-28 10:24 ` [PATCH 6/8] attrib-server: Add bluetooth adapter in attrib_db_del Santiago Carot-Nemesio
2011-12-28 10:24 ` [PATCH 7/8] attrib-server: Add bluetooth adapter in attrib_create_sdp function Santiago Carot-Nemesio
2011-12-28 10:24 ` [PATCH 8/8] attrib-server: Add Gattrib in attrib_channel_detach function Santiago Carot-Nemesio
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1324978182-5707-9-git-send-email-sancane@gmail.com \
--to=sancane@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).