From: Santiago Carot-Nemesio <sancane@gmail.com>
To: linux-bluetooth@vger.kernel.org
Cc: Santiago Carot-Nemesio <sancane@gmail.com>
Subject: [PATCH 3/8] gatt-service: Add bluetooth adapter in gatt_service_add function
Date: Wed, 28 Dec 2011 11:24:45 +0100 [thread overview]
Message-ID: <1325067890-6953-4-git-send-email-sancane@gmail.com> (raw)
In-Reply-To: <1325067890-6953-3-git-send-email-sancane@gmail.com>
---
attrib/gatt-service.c | 31 +++++++++++++------------------
attrib/gatt-service.h | 3 ++-
plugins/gatt-example.c | 7 ++++---
time/server.c | 3 ++-
4 files changed, 21 insertions(+), 23 deletions(-)
diff --git a/attrib/gatt-service.c b/attrib/gatt-service.c
index 73230f2..3bfa565 100644
--- a/attrib/gatt-service.c
+++ b/attrib/gatt-service.c
@@ -151,7 +151,8 @@ static gint find_callback(gconstpointer a, gconstpointer b)
return cb->event - event;
}
-static gboolean add_characteristic(uint16_t *handle, struct gatt_info *info)
+static gboolean add_characteristic(struct btd_adapter *adapter,
+ uint16_t *handle, struct gatt_info *info)
{
int read_reqs, write_reqs;
uint16_t h = *handle;
@@ -197,14 +198,12 @@ static gboolean add_characteristic(uint16_t *handle, struct gatt_info *info)
atval[0] = info->props;
att_put_u16(h + 1, &atval[1]);
att_put_u16(info->uuid.value.u16, &atval[3]);
- /* FIXME: Provide the adapter in next function */
- attrib_db_add(NULL, h++, &bt_uuid, ATT_NONE, ATT_NOT_PERMITTED, atval,
- sizeof(atval));
+ attrib_db_add(adapter, h++, &bt_uuid, ATT_NONE, ATT_NOT_PERMITTED,
+ atval, sizeof(atval));
/* characteristic value */
- /* FIXME: Provide the adapter in next function */
- a = attrib_db_add(NULL, h++, &info->uuid, read_reqs, write_reqs, NULL,
- 0);
+ a = attrib_db_add(adapter, h++, &info->uuid, read_reqs, write_reqs,
+ NULL, 0);
for (l = info->callbacks; l != NULL; l = l->next) {
struct attrib_cb *cb = l->data;
@@ -228,8 +227,7 @@ static gboolean add_characteristic(uint16_t *handle, struct gatt_info *info)
bt_uuid16_create(&bt_uuid, GATT_CLIENT_CHARAC_CFG_UUID);
cfg_val[0] = 0x00;
cfg_val[1] = 0x00;
- /* FIXME: Provide the adapter in next function */
- a = attrib_db_add(NULL, h++, &bt_uuid, ATT_NONE,
+ a = attrib_db_add(adapter, h++, &bt_uuid, ATT_NONE,
ATT_AUTHENTICATION, cfg_val, sizeof(cfg_val));
if (info->ccc_handle != NULL)
@@ -249,7 +247,8 @@ static void free_gatt_info(void *data)
g_free(info);
}
-gboolean gatt_service_add(uint16_t uuid, uint16_t svc_uuid, gatt_option opt1, ...)
+gboolean gatt_service_add(struct btd_adapter *adapter, uint16_t uuid,
+ uint16_t svc_uuid, gatt_option opt1, ...)
{
uint16_t start_handle, h;
unsigned int size;
@@ -266,9 +265,7 @@ gboolean gatt_service_add(uint16_t uuid, uint16_t svc_uuid, gatt_option opt1, ..
size += info->num_attrs;
}
va_end(args);
-
- /* FIXME: Provide the adapter in next function */
- start_handle = attrib_db_find_avail(NULL, size);
+ start_handle = attrib_db_find_avail(adapter, size);
if (start_handle == 0) {
error("Not enough free handles to register service");
g_slist_free_full(chrs, free_gatt_info);
@@ -282,15 +279,13 @@ gboolean gatt_service_add(uint16_t uuid, uint16_t svc_uuid, gatt_option opt1, ..
h = start_handle;
bt_uuid16_create(&bt_uuid, uuid);
att_put_u16(svc_uuid, &atval[0]);
- /* FIXME: Provide the adapter in next function */
- attrib_db_add(NULL, h++, &bt_uuid, ATT_NONE, ATT_NOT_PERMITTED, atval,
- sizeof(atval));
-
+ attrib_db_add(adapter, h++, &bt_uuid, ATT_NONE, ATT_NOT_PERMITTED,
+ atval, sizeof(atval));
for (l = chrs; l != NULL; l = l->next) {
struct gatt_info *info = l->data;
DBG("New characteristic: handle 0x%04x", h);
- if (!add_characteristic(&h, info)) {
+ if (!add_characteristic(adapter, &h, info)) {
g_slist_free_full(chrs, free_gatt_info);
return FALSE;
}
diff --git a/attrib/gatt-service.h b/attrib/gatt-service.h
index 95064c0..7af2d3e 100644
--- a/attrib/gatt-service.h
+++ b/attrib/gatt-service.h
@@ -47,4 +47,5 @@ typedef enum {
ATTRIB_WRITE,
} attrib_event_t;
-gboolean gatt_service_add(uint16_t uuid, uint16_t svc_uuid, gatt_option opt1, ...);
+gboolean gatt_service_add(struct btd_adapter *adapter, uint16_t uuid,
+ uint16_t svc_uuid, gatt_option opt1, ...);
diff --git a/plugins/gatt-example.c b/plugins/gatt-example.c
index f3f2b3a..27d3d13 100644
--- a/plugins/gatt-example.c
+++ b/plugins/gatt-example.c
@@ -102,9 +102,10 @@ static uint8_t battery_state_read(struct attribute *a, gpointer user_data)
return 0;
}
-static gboolean register_battery_service(void)
+static gboolean register_battery_service(struct btd_adapter *adapter)
{
- return gatt_service_add(GATT_PRIM_SVC_UUID, BATTERY_STATE_SVC_UUID,
+ return gatt_service_add(adapter, GATT_PRIM_SVC_UUID,
+ BATTERY_STATE_SVC_UUID,
/* battery state characteristic */
GATT_OPT_CHR_UUID, BATTERY_STATE_UUID,
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_READ |
@@ -509,7 +510,7 @@ static int gatt_example_adapter_probe(struct btd_adapter *adapter)
gadapter = g_new0(struct gatt_example_adapter, 1);
gadapter->adapter = btd_adapter_ref(adapter);
- if (!register_battery_service()) {
+ if (!register_battery_service(adapter)) {
DBG("Battery service could not be registered");
gatt_example_adapter_free(gadapter);
return -EIO;
diff --git a/time/server.c b/time/server.c
index 5636cca..839b33a 100644
--- a/time/server.c
+++ b/time/server.c
@@ -114,7 +114,8 @@ static uint8_t local_time_info_read(struct attribute *a, gpointer user_data)
static void register_current_time_service(void)
{
/* Current Time service */
- gatt_service_add(GATT_PRIM_SVC_UUID, CURRENT_TIME_SVC_UUID,
+ /* FIXME: Provide the adapter in next function */
+ gatt_service_add(NULL, GATT_PRIM_SVC_UUID, CURRENT_TIME_SVC_UUID,
/* CT Time characteristic */
GATT_OPT_CHR_UUID, CT_TIME_CHR_UUID,
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_READ |
--
1.7.8.1
next prev parent reply other threads:[~2011-12-28 10:24 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Santiago Carot-Nemesio [this message]
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
2011-12-30 11:03 ` Multi-Adapter GATT server (finish) Johan Hedberg
-- strict thread matches above, loose matches on Subject: below --
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
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=1325067890-6953-4-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).