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 <mariusz.skamra@codecoup.pl>
This commit is contained in:
Mariusz Skamra 2018-09-07 15:16:33 +02:00 committed by Anas Nashif
commit 02d980add3
2 changed files with 20 additions and 0 deletions

View file

@ -100,6 +100,18 @@ static ssize_t read_appearance(struct bt_conn *conn,
sizeof(appearance));
}
#if defined(CONFIG_BT_CENTRAL) && defined(CONFIG_BT_PRIVACY)
static ssize_t read_central_addr_res(struct bt_conn *conn,
const struct bt_gatt_attr *attr, void *buf,
u16_t len, u16_t offset)
{
u8_t central_addr_res = BT_GATT_CENTRAL_ADDR_RES_SUPP;
return bt_gatt_attr_read(conn, attr, buf, len, offset,
&central_addr_res, sizeof(central_addr_res));
}
#endif /* CONFIG_BT_CENTRAL && CONFIG_BT_PRIVACY */
static struct bt_gatt_attr gap_attrs[] = {
BT_GATT_PRIMARY_SERVICE(BT_UUID_GAP),
#if defined(CONFIG_BT_DEVICE_NAME_GATT_WRITABLE)
@ -114,6 +126,11 @@ static struct bt_gatt_attr gap_attrs[] = {
#endif /* CONFIG_BT_DEVICE_NAME_GATT_WRITABLE */
BT_GATT_CHARACTERISTIC(BT_UUID_GAP_APPEARANCE, BT_GATT_CHRC_READ,
BT_GATT_PERM_READ, read_appearance, NULL, NULL),
#if defined(CONFIG_BT_CENTRAL) && defined(CONFIG_BT_PRIVACY)
BT_GATT_CHARACTERISTIC(BT_UUID_CENTRAL_ADDR_RES,
BT_GATT_CHRC_READ, BT_GATT_PERM_READ,
read_central_addr_res, NULL, NULL),
#endif /* CONFIG_BT_CENTRAL && CONFIG_BT_PRIVACY */
};
static struct bt_gatt_service gap_svc = BT_GATT_SERVICE(gap_attrs);

View file

@ -8,6 +8,9 @@
* SPDX-License-Identifier: Apache-2.0
*/
#define BT_GATT_CENTRAL_ADDR_RES_NOT_SUPP 0
#define BT_GATT_CENTRAL_ADDR_RES_SUPP 1
void bt_gatt_init(void);
void bt_gatt_connected(struct bt_conn *conn);
void bt_gatt_disconnected(struct bt_conn *conn);