1 /** @file
2 * @brief Internal API for Generic Attribute Profile handling.
3 */
4
5 /*
6 * Copyright (c) 2015-2016 Intel Corporation
7 *
8 * SPDX-License-Identifier: Apache-2.0
9 */
10
11 #define BT_GATT_CENTRAL_ADDR_RES_NOT_SUPP 0
12 #define BT_GATT_CENTRAL_ADDR_RES_SUPP 1
13
14 #define BT_GATT_PERM_READ_MASK (BT_GATT_PERM_READ | \
15 BT_GATT_PERM_READ_ENCRYPT | \
16 BT_GATT_PERM_READ_AUTHEN | \
17 BT_GATT_PERM_READ_LESC)
18 #define BT_GATT_PERM_WRITE_MASK (BT_GATT_PERM_WRITE | \
19 BT_GATT_PERM_WRITE_ENCRYPT | \
20 BT_GATT_PERM_WRITE_AUTHEN | \
21 BT_GATT_PERM_WRITE_LESC)
22 #define BT_GATT_PERM_ENCRYPT_MASK (BT_GATT_PERM_READ_ENCRYPT | \
23 BT_GATT_PERM_WRITE_ENCRYPT)
24 #define BT_GATT_PERM_AUTHEN_MASK (BT_GATT_PERM_READ_AUTHEN | \
25 BT_GATT_PERM_WRITE_AUTHEN)
26 #define BT_GATT_PERM_LESC_MASK (BT_GATT_PERM_READ_LESC | \
27 BT_GATT_PERM_WRITE_LESC)
28 #define BT_GATT_PERM_READ_ENCRYPT_MASK (BT_GATT_PERM_READ_ENCRYPT | \
29 BT_GATT_PERM_READ_AUTHEN | \
30 BT_GATT_PERM_READ_LESC)
31
32 void bt_gatt_init(void);
33 void bt_gatt_connected(struct bt_conn *conn);
34 void bt_gatt_att_max_mtu_changed(struct bt_conn *conn, uint16_t tx, uint16_t rx);
35 void bt_gatt_encrypt_change(struct bt_conn *conn);
36 void bt_gatt_disconnected(struct bt_conn *conn);
37
38 bool bt_gatt_change_aware(struct bt_conn *conn, bool req);
39
40 int bt_gatt_store_ccc(uint8_t id, const bt_addr_le_t *addr);
41
42 int bt_gatt_clear(uint8_t id, const bt_addr_le_t *addr);
43
44 #if defined(CONFIG_BT_GATT_CLIENT)
45 void bt_gatt_notification(struct bt_conn *conn, uint16_t handle,
46 const void *data, uint16_t length);
47
48 void bt_gatt_mult_notification(struct bt_conn *conn, const void *data,
49 uint16_t length);
50 #else
bt_gatt_notification(struct bt_conn * conn,uint16_t handle,const void * data,uint16_t length)51 static inline void bt_gatt_notification(struct bt_conn *conn, uint16_t handle,
52 const void *data, uint16_t length)
53 {
54 }
55
bt_gatt_mult_notification(struct bt_conn * conn,const void * data,uint16_t length)56 static inline void bt_gatt_mult_notification(struct bt_conn *conn,
57 const void *data, uint16_t length)
58 {
59 }
60 #endif /* CONFIG_BT_GATT_CLIENT */
61
62 struct bt_gatt_attr;
63
64 /* Check attribute permission */
65 uint8_t bt_gatt_check_perm(struct bt_conn *conn, const struct bt_gatt_attr *attr,
66 uint16_t mask);
67