linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Santiago Carot-Nemesio <sancane@gmail.com>
To: linux-bluetooth@vger.kernel.org
Cc: Santiago Carot-Nemesio <sancane@gmail.com>
Subject: [PATCH 4/8] attrib-server: Add bluetooth adapter in attrib_db_update function
Date: Tue, 27 Dec 2011 10:29:38 +0100	[thread overview]
Message-ID: <1324978182-5707-5-git-send-email-sancane@gmail.com> (raw)
In-Reply-To: <1324978182-5707-4-git-send-email-sancane@gmail.com>

---
 plugins/gatt-example.c |    3 ++-
 src/attrib-server.c    |   17 ++++++++++-------
 src/attrib-server.h    |    3 ++-
 time/server.c          |    6 ++++--
 4 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/plugins/gatt-example.c b/plugins/gatt-example.c
index 27d3d13..332c190 100644
--- a/plugins/gatt-example.c
+++ b/plugins/gatt-example.c
@@ -97,7 +97,8 @@ static uint8_t battery_state_read(struct attribute *a, gpointer user_data)
 	uint8_t value;
 
 	value = 0x04;
-	attrib_db_update(a->handle, NULL, &value, sizeof(value), NULL);
+	/* FIXME: Provide the adapter in next function */
+	attrib_db_update(NULL, a->handle, NULL, &value, sizeof(value), NULL);
 
 	return 0;
 }
diff --git a/src/attrib-server.c b/src/attrib-server.c
index cdf54ee..d163cb9 100644
--- a/src/attrib-server.c
+++ b/src/attrib-server.c
@@ -844,7 +844,8 @@ static uint16_t write_value(struct gatt_channel *channel, uint16_t handle,
 
 	if (bt_uuid_cmp(&ccc_uuid, &a->uuid) != 0) {
 
-		attrib_db_update(handle, NULL, value, vlen, NULL);
+		attrib_db_update(channel->gadapter->adapter, handle, NULL,
+							value, vlen, NULL);
 
 		if (a->write_cb) {
 			status = a->write_cb(a, a->cb_user_data);
@@ -1330,7 +1331,8 @@ struct attribute *attrib_db_add(struct btd_adapter *adapter, uint16_t handle,
 								value, len);
 }
 
-int attrib_db_update(uint16_t handle, bt_uuid_t *uuid, const uint8_t *value,
+int attrib_db_update(struct btd_adapter *adapter, uint16_t handle,
+					bt_uuid_t *uuid, const uint8_t *value,
 					int len, struct attribute **attr)
 {
 	struct gatt_adapter *gadapter;
@@ -1338,12 +1340,12 @@ int attrib_db_update(uint16_t handle, bt_uuid_t *uuid, const uint8_t *value,
 	GSList *l;
 	guint h = handle;
 
-	DBG("Deprecated function!");
-
-	gadapter = get_default_gatt_adapter();
-	if (gadapter == NULL)
+	l = g_slist_find_custom(adapters, adapter, adapter_cmp);
+	if (l == NULL)
 		return -ENOENT;
 
+	gadapter = l->data;
+
 	DBG("handle=0x%04x", handle);
 
 	l = g_slist_find_custom(gadapter->database, GUINT_TO_POINTER(h),
@@ -1416,5 +1418,6 @@ int attrib_gap_set(uint16_t uuid, const uint8_t *value, int len)
 		return -ENOSYS;
 	}
 
-	return attrib_db_update(handle, NULL, value, len, NULL);
+	/* FIXME: Provide the adapter in next function */
+	return attrib_db_update(NULL, handle, NULL, value, len, NULL);
 }
diff --git a/src/attrib-server.h b/src/attrib-server.h
index ac1c388..1265bd1 100644
--- a/src/attrib-server.h
+++ b/src/attrib-server.h
@@ -26,7 +26,8 @@ uint16_t attrib_db_find_avail(struct btd_adapter *adapter, uint16_t nitems);
 struct attribute *attrib_db_add(struct btd_adapter *adapter, uint16_t handle,
 				bt_uuid_t *uuid, int read_reqs, int write_reqs,
 				const uint8_t *value, int len);
-int attrib_db_update(uint16_t handle, bt_uuid_t *uuid, const uint8_t *value,
+int attrib_db_update(struct btd_adapter *adapter, uint16_t handle,
+					bt_uuid_t *uuid, const uint8_t *value,
 					int len, struct attribute **attr);
 int attrib_db_del(uint16_t handle);
 int attrib_gap_set(uint16_t uuid, const uint8_t *value, int len);
diff --git a/time/server.c b/time/server.c
index 839b33a..4ed9cf2 100644
--- a/time/server.c
+++ b/time/server.c
@@ -85,7 +85,8 @@ static uint8_t current_time_read(struct attribute *a, gpointer user_data)
 	if (encode_current_time(value) < 0)
 		return ATT_ECODE_IO;
 
-	attrib_db_update(a->handle, NULL, value, sizeof(value), NULL);
+	/* FIXME: Provide the adapter in next function */
+	attrib_db_update(NULL, a->handle, NULL, value, sizeof(value), NULL);
 
 	return 0;
 }
@@ -106,7 +107,8 @@ static uint8_t local_time_info_read(struct attribute *a, gpointer user_data)
 	 * format (offset from UTC in number of 15 minutes increments). */
 	value[1] = (uint8_t) (-1 * timezone / (60 * 15));
 
-	attrib_db_update(a->handle, NULL, value, sizeof(value), NULL);
+	/* FIXME: Provide the adapter in next function */
+	attrib_db_update(NULL, a->handle, NULL, value, sizeof(value), NULL);
 
 	return 0;
 }
-- 
1.7.8.1


  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       ` Santiago Carot-Nemesio [this message]
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               ` [PATCH 8/8] attrib-server: Add Gattrib in attrib_channel_detach function Santiago Carot-Nemesio
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

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-5-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).