From: "Dirk-Jan C. Binnema" <djcb.bulk@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH] attrib/gatt_service_add: support 128-bit uuids for characteristics
Date: Tue, 23 Jul 2013 16:47:23 +0300 [thread overview]
Message-ID: <1374587243-30452-1-git-send-email-djcb.bulk@gmail.com> (raw)
From: "Dirk-Jan C. Binnema" <djcb.bulk@gmail.com>
Add GATT_OPT_CHR_BT_UUID_T, which does what GATT_OPT_CHR_UUID does, but
instead takes a bt_uuid_t*, so 128-bit uuids are supported as well.
GATT_OPT_CHR_UUID is kept around for backward compatibility.
Signed-off-by: Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
---
attrib/gatt-service.c | 19 ++++++++++++-------
attrib/gatt-service.h | 1 +
2 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/attrib/gatt-service.c b/attrib/gatt-service.c
index 4b02d39..bc17778 100644
--- a/attrib/gatt-service.c
+++ b/attrib/gatt-service.c
@@ -73,6 +73,11 @@ static GSList *parse_opts(gatt_option opt1, va_list args)
/* characteristic declaration and value */
info->num_attrs += 2;
break;
+ case GATT_OPT_CHR_BT_UUID_T:
+ memcpy(&info->uuid, va_arg(args, bt_uuid_t *), sizeof(bt_uuid_t));
+ /* characteristic declaration and value */
+ info->num_attrs += 2;
+ break;
case GATT_OPT_CHR_PROPS:
info->props = va_arg(args, int);
@@ -108,7 +113,7 @@ static GSList *parse_opts(gatt_option opt1, va_list args)
}
opt = va_arg(args, gatt_option);
- if (opt == GATT_OPT_CHR_UUID) {
+ if (opt == GATT_OPT_CHR_UUID || opt == GATT_OPT_CHR_BT_UUID_T) {
info = g_new0(struct gatt_info, 1);
l = g_slist_append(l, info);
}
@@ -177,16 +182,16 @@ static int find_callback(gconstpointer a, gconstpointer b)
}
static gboolean add_characteristic(struct btd_adapter *adapter,
- uint16_t *handle, struct gatt_info *info)
+ uint16_t *handle, struct gatt_info *info)
{
int read_req, write_req;
uint16_t h = *handle;
struct attribute *a;
bt_uuid_t bt_uuid;
- uint8_t atval[5];
+ uint8_t atval[131];
GSList *l;
- if (!info->uuid.value.u16 || !info->props) {
+ if ((!info->uuid.value.u16 && info->uuid.type != BT_UUID128) || !info->props) {
error("Characteristic UUID or properties are missing");
return FALSE;
}
@@ -222,9 +227,9 @@ static gboolean add_characteristic(struct btd_adapter *adapter,
bt_uuid16_create(&bt_uuid, GATT_CHARAC_UUID);
atval[0] = info->props;
att_put_u16(h + 1, &atval[1]);
- att_put_u16(info->uuid.value.u16, &atval[3]);
+ att_put_uuid(info->uuid, &atval[3]);
if (attrib_db_add(adapter, h++, &bt_uuid, ATT_NONE, ATT_NOT_PERMITTED,
- atval, sizeof(atval)) == NULL)
+ atval, 3 + info->uuid.type/8) == NULL)
return FALSE;
/* characteristic value */
@@ -341,7 +346,7 @@ gboolean gatt_service_add(struct btd_adapter *adapter, uint16_t uuid,
}
g_assert(size < USHRT_MAX);
- g_assert(h - start_handle == (uint16_t) size);
+ g_assert((uint16_t)(h - start_handle) == (uint16_t) size);
g_slist_free_full(chrs, free_gatt_info);
return TRUE;
diff --git a/attrib/gatt-service.h b/attrib/gatt-service.h
index b810e2e..5c3e15d 100644
--- a/attrib/gatt-service.h
+++ b/attrib/gatt-service.h
@@ -25,6 +25,7 @@
typedef enum {
GATT_OPT_INVALID = 0,
GATT_OPT_CHR_UUID,
+ GATT_OPT_CHR_BT_UUID_T,
GATT_OPT_CHR_PROPS,
GATT_OPT_CHR_VALUE_CB,
GATT_OPT_CHR_AUTHENTICATION,
--
1.8.3.2
next reply other threads:[~2013-07-23 13:47 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-23 13:47 Dirk-Jan C. Binnema [this message]
2013-07-24 4:57 ` [PATCH] attrib/gatt_service_add: support 128-bit uuids for characteristics Johan Hedberg
2013-07-24 7:25 ` Dirk-Jan C. Binnema
2013-07-24 7:32 ` Dirk-Jan C. Binnema
2013-07-24 10:55 ` Anderson Lizardo
2013-07-24 16:43 ` Dirk-Jan C. Binnema
2013-07-24 17:03 ` Johan Hedberg
2013-07-24 17:51 ` [PATCH 1/2] Add support for 128-bit UUIDs " Dirk-Jan C. Binnema
2013-07-24 17:51 ` [PATCH 2/2] Use GATT_OPT_CHR_UUID for bt_uuid_t*, GATT_OPT_CHR_UUID16 for uint16 chrs Dirk-Jan C. Binnema
2013-07-24 17:38 ` [PATCH] attrib/gatt_service_add: support 128-bit uuids for characteristics Anderson Lizardo
2013-07-24 18:04 ` Dirk-Jan C. Binnema
2013-07-25 4:35 ` [PATCH 1/3] gatt-service: fix assertion in gatt_service_add for 128-bit uuids Dirk-Jan C. Binnema
2013-07-25 4:35 ` [PATCH 2/3] gatt_service_add: add support for 128-bit uuids for characteristics Dirk-Jan C. Binnema
2013-07-25 4:35 ` [PATCH 3/3] Use GATT_OPT_CHR_UUID for bt_uuid_t*, GATT_OPT_CHR_UUID16 for uint16 chrs Dirk-Jan C. Binnema
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=1374587243-30452-1-git-send-email-djcb.bulk@gmail.com \
--to=djcb.bulk@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.