Skip to content

Commit 02d980a

Browse files
MariuszSkamranashif
authored andcommitted
bluetooth: gatt: Add GAP Central Address Resolution characteristic
This adds Central Address Resolution characteristic that is required to check by peer if it's about to send directed advertisements where initiator address is set to RPA. Zephyr supports the Address Resolution, so the characteristic value is hard-coded. Please check Core 5.0 Vol 3 Part C 12.4 CENTRAL ADDRESS RESOLUTION Related PTS test case: GAP/CONN/ACEP/BV-03-C Signed-off-by: Mariusz Skamra <[email protected]>
1 parent 0312483 commit 02d980a

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

subsys/bluetooth/host/gatt.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,18 @@ static ssize_t read_appearance(struct bt_conn *conn,
100100
sizeof(appearance));
101101
}
102102

103+
#if defined(CONFIG_BT_CENTRAL) && defined(CONFIG_BT_PRIVACY)
104+
static ssize_t read_central_addr_res(struct bt_conn *conn,
105+
const struct bt_gatt_attr *attr, void *buf,
106+
u16_t len, u16_t offset)
107+
{
108+
u8_t central_addr_res = BT_GATT_CENTRAL_ADDR_RES_SUPP;
109+
110+
return bt_gatt_attr_read(conn, attr, buf, len, offset,
111+
&central_addr_res, sizeof(central_addr_res));
112+
}
113+
#endif /* CONFIG_BT_CENTRAL && CONFIG_BT_PRIVACY */
114+
103115
static struct bt_gatt_attr gap_attrs[] = {
104116
BT_GATT_PRIMARY_SERVICE(BT_UUID_GAP),
105117
#if defined(CONFIG_BT_DEVICE_NAME_GATT_WRITABLE)
@@ -114,6 +126,11 @@ static struct bt_gatt_attr gap_attrs[] = {
114126
#endif /* CONFIG_BT_DEVICE_NAME_GATT_WRITABLE */
115127
BT_GATT_CHARACTERISTIC(BT_UUID_GAP_APPEARANCE, BT_GATT_CHRC_READ,
116128
BT_GATT_PERM_READ, read_appearance, NULL, NULL),
129+
#if defined(CONFIG_BT_CENTRAL) && defined(CONFIG_BT_PRIVACY)
130+
BT_GATT_CHARACTERISTIC(BT_UUID_CENTRAL_ADDR_RES,
131+
BT_GATT_CHRC_READ, BT_GATT_PERM_READ,
132+
read_central_addr_res, NULL, NULL),
133+
#endif /* CONFIG_BT_CENTRAL && CONFIG_BT_PRIVACY */
117134
};
118135

119136
static struct bt_gatt_service gap_svc = BT_GATT_SERVICE(gap_attrs);

subsys/bluetooth/host/gatt_internal.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
* SPDX-License-Identifier: Apache-2.0
99
*/
1010

11+
#define BT_GATT_CENTRAL_ADDR_RES_NOT_SUPP 0
12+
#define BT_GATT_CENTRAL_ADDR_RES_SUPP 1
13+
1114
void bt_gatt_init(void);
1215
void bt_gatt_connected(struct bt_conn *conn);
1316
void bt_gatt_disconnected(struct bt_conn *conn);

0 commit comments

Comments
 (0)