From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH v2] gatt: Add support for Central Address Resolution characteristic
Date: Wed, 28 Jul 2021 13:48:00 -0700 [thread overview]
Message-ID: <20210728204800.2205665-1-luiz.dentz@gmail.com> (raw)
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds Central Address Resolution characteristic so peripherals can
use directed advertising using RPA as initiator address.
---
lib/uuid.h | 1 +
src/gatt-database.c | 33 +++++++++++++++++++++++++--------
2 files changed, 26 insertions(+), 8 deletions(-)
diff --git a/lib/uuid.h b/lib/uuid.h
index 1a4029b68..6236752a1 100644
--- a/lib/uuid.h
+++ b/lib/uuid.h
@@ -116,6 +116,7 @@ extern "C" {
#define GATT_CHARAC_SOFTWARE_REVISION_STRING 0x2A28
#define GATT_CHARAC_MANUFACTURER_NAME_STRING 0x2A29
#define GATT_CHARAC_PNP_ID 0x2A50
+#define GATT_CHARAC_CAR 0x2AA6
/* GATT Characteristic Descriptors */
#define GATT_CHARAC_EXT_PROPER_UUID 0x2900
diff --git a/src/gatt-database.c b/src/gatt-database.c
index 8cf60c597..99c95f2d6 100644
--- a/src/gatt-database.c
+++ b/src/gatt-database.c
@@ -699,6 +699,18 @@ static void gap_appearance_read_cb(struct gatt_db_attribute *attrib,
gatt_db_attribute_read_result(attrib, id, error, value, len);
}
+static void gap_car_read_cb(struct gatt_db_attribute *attrib,
+ unsigned int id, uint16_t offset,
+ uint8_t opcode, struct bt_att *att,
+ void *user_data)
+{
+ uint8_t value = 0x01;
+
+ DBG("GAP Central Address Resolution read request\n");
+
+ gatt_db_attribute_read_result(attrib, id, 0, &value, sizeof(value));
+}
+
static sdp_record_t *record_new(uuid_t *uuid, uint16_t start, uint16_t end)
{
sdp_list_t *svclass_id, *apseq, *proto[2], *root, *aproto;
@@ -820,7 +832,7 @@ static void populate_gap_service(struct btd_gatt_database *database)
/* Add the GAP service */
bt_uuid16_create(&uuid, UUID_GAP);
- service = gatt_db_add_service(database->db, &uuid, true, 5);
+ service = gatt_db_add_service(database->db, &uuid, true, 7);
/*
* Device Name characteristic.
@@ -842,6 +854,17 @@ static void populate_gap_service(struct btd_gatt_database *database)
NULL, database);
gatt_db_attribute_set_fixed_length(attrib, 2);
+ /*
+ * Central Address Resolution characteristic.
+ */
+ bt_uuid16_create(&uuid, GATT_CHARAC_CAR);
+ attrib = gatt_db_service_add_characteristic(service, &uuid,
+ BT_ATT_PERM_READ,
+ BT_GATT_CHRC_PROP_READ,
+ gap_car_read_cb,
+ NULL, database);
+ gatt_db_attribute_set_fixed_length(attrib, 1);
+
gatt_db_service_set_active(service, true);
database_add_record(database, service);
@@ -3853,13 +3876,7 @@ void btd_gatt_database_restore_svc_chng_ccc(struct btd_gatt_database *database)
*/
btd_adapter_for_each_device(database->adapter, restore_state, database);
- /* This needs to be updated (probably to 0x0001) if we ever change
- * core services
- *
- * TODO we could also store this info (along with CCC value) and be able
- * to send 0x0001-0xffff only once per device.
- */
- put_le16(0x000a, value);
+ put_le16(0x0001, value);
put_le16(0xffff, value + 2);
send_notification_to_devices(database, handle, value, sizeof(value),
--
2.31.1
next reply other threads:[~2021-07-28 20:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-28 20:48 Luiz Augusto von Dentz [this message]
2021-07-28 21:35 ` [v2] gatt: Add support for Central Address Resolution characteristic bluez.test.bot
2021-07-29 21:20 ` Luiz Augusto von Dentz
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=20210728204800.2205665-1-luiz.dentz@gmail.com \
--to=luiz.dentz@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.