Bluetooth: Add support for disabling GATT client support
Binary size reduction of sample peripheral app: 45940 -> 45772 Change-Id: Ia8c463c9642a2928c2cb2ec48d9e9c4eeef20fe7 Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
This commit is contained in:
parent
9c2ad108b8
commit
9ecbd34f89
8 changed files with 43 additions and 9 deletions
|
@ -68,6 +68,11 @@ config BLUETOOTH_SIGNING
|
||||||
This option enables data signing which is used for transferring
|
This option enables data signing which is used for transferring
|
||||||
authenticated data in an unencrypted connection.
|
authenticated data in an unencrypted connection.
|
||||||
|
|
||||||
|
config BLUETOOTH_GATT_CLIENT
|
||||||
|
bool
|
||||||
|
prompt "GATT client support"
|
||||||
|
default n
|
||||||
|
|
||||||
config BLUETOOTH_MAX_CONN
|
config BLUETOOTH_MAX_CONN
|
||||||
int
|
int
|
||||||
prompt "Maximum number of simultaneous connections"
|
prompt "Maximum number of simultaneous connections"
|
||||||
|
|
|
@ -1586,6 +1586,7 @@ void bt_att_init(void)
|
||||||
#endif /* CONFIG_BLUETOOTH_SMP */
|
#endif /* CONFIG_BLUETOOTH_SMP */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(CONFIG_BLUETOOTH_GATT_CLIENT)
|
||||||
uint16_t bt_att_get_mtu(struct bt_conn *conn)
|
uint16_t bt_att_get_mtu(struct bt_conn *conn)
|
||||||
{
|
{
|
||||||
struct bt_att *att = conn->att;
|
struct bt_att *att = conn->att;
|
||||||
|
@ -1654,3 +1655,4 @@ void bt_att_cancel(struct bt_conn *conn)
|
||||||
|
|
||||||
att_req_destroy(&att->req);
|
att_req_destroy(&att->req);
|
||||||
}
|
}
|
||||||
|
#endif /* CONFIG_BLUETOOTH_GATT_CLIENT */
|
||||||
|
|
|
@ -62,7 +62,9 @@
|
||||||
static const struct bt_gatt_attr *db = NULL;
|
static const struct bt_gatt_attr *db = NULL;
|
||||||
static size_t attr_count = 0;
|
static size_t attr_count = 0;
|
||||||
|
|
||||||
|
#if defined(CONFIG_BLUETOOTH_GATT_CLIENT)
|
||||||
static struct bt_gatt_subscribe_params *subscriptions;
|
static struct bt_gatt_subscribe_params *subscriptions;
|
||||||
|
#endif /* CONFIG_BLUETOOTH_GATT_CLIENT */
|
||||||
|
|
||||||
void bt_gatt_register(const struct bt_gatt_attr *attrs, size_t count)
|
void bt_gatt_register(const struct bt_gatt_attr *attrs, size_t count)
|
||||||
{
|
{
|
||||||
|
@ -418,6 +420,7 @@ void bt_gatt_connected(struct bt_conn *conn)
|
||||||
bt_gatt_foreach_attr(0x0001, 0xffff, connected_cb, conn);
|
bt_gatt_foreach_attr(0x0001, 0xffff, connected_cb, conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(CONFIG_BLUETOOTH_GATT_CLIENT)
|
||||||
void bt_gatt_notification(struct bt_conn *conn, uint16_t handle,
|
void bt_gatt_notification(struct bt_conn *conn, uint16_t handle,
|
||||||
const void *data, uint16_t length)
|
const void *data, uint16_t length)
|
||||||
{
|
{
|
||||||
|
@ -431,6 +434,7 @@ void bt_gatt_notification(struct bt_conn *conn, uint16_t handle,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif /* CONFIG_BLUETOOTH_GATT_CLIENT */
|
||||||
|
|
||||||
static uint8_t disconnected_cb(const struct bt_gatt_attr *attr, void *user_data)
|
static uint8_t disconnected_cb(const struct bt_gatt_attr *attr, void *user_data)
|
||||||
{
|
{
|
||||||
|
@ -477,6 +481,7 @@ static uint8_t disconnected_cb(const struct bt_gatt_attr *attr, void *user_data)
|
||||||
return BT_GATT_ITER_CONTINUE;
|
return BT_GATT_ITER_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(CONFIG_BLUETOOTH_GATT_CLIENT)
|
||||||
static void gatt_subscription_remove(struct bt_gatt_subscribe_params *prev,
|
static void gatt_subscription_remove(struct bt_gatt_subscribe_params *prev,
|
||||||
struct bt_gatt_subscribe_params *params)
|
struct bt_gatt_subscribe_params *params)
|
||||||
{
|
{
|
||||||
|
@ -491,18 +496,10 @@ static void gatt_subscription_remove(struct bt_gatt_subscribe_params *prev,
|
||||||
params->destroy(params);
|
params->destroy(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
void bt_gatt_disconnected(struct bt_conn *conn)
|
static void remove_subscribtions(struct bt_conn *conn)
|
||||||
{
|
{
|
||||||
struct bt_gatt_subscribe_params *params, *prev;
|
struct bt_gatt_subscribe_params *params, *prev;
|
||||||
|
|
||||||
BT_DBG("conn %p\n", conn);
|
|
||||||
bt_gatt_foreach_attr(0x0001, 0xffff, disconnected_cb, conn);
|
|
||||||
|
|
||||||
/* If paired don't remove subscriptions */
|
|
||||||
if (bt_keys_find_addr(&conn->dst)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Lookup existing subscriptions */
|
/* Lookup existing subscriptions */
|
||||||
for (params = subscriptions, prev = NULL; params;
|
for (params = subscriptions, prev = NULL; params;
|
||||||
prev = params, params = params->_next) {
|
prev = params, params = params->_next) {
|
||||||
|
@ -514,7 +511,24 @@ void bt_gatt_disconnected(struct bt_conn *conn)
|
||||||
gatt_subscription_remove(prev, params);
|
gatt_subscription_remove(prev, params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif /* CONFIG_BLUETOOTH_GATT_CLIENT */
|
||||||
|
|
||||||
|
void bt_gatt_disconnected(struct bt_conn *conn)
|
||||||
|
{
|
||||||
|
BT_DBG("conn %p\n", conn);
|
||||||
|
bt_gatt_foreach_attr(0x0001, 0xffff, disconnected_cb, conn);
|
||||||
|
|
||||||
|
#if defined(CONFIG_BLUETOOTH_GATT_CLIENT)
|
||||||
|
/* If paired don't remove subscriptions */
|
||||||
|
if (bt_keys_find_addr(&conn->dst)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
remove_subscribtions(conn);
|
||||||
|
#endif /* CONFIG_BLUETOOTH_GATT_CLIENT */
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(CONFIG_BLUETOOTH_GATT_CLIENT)
|
||||||
static void gatt_mtu_rsp(struct bt_conn *conn, uint8_t err, const void *pdu,
|
static void gatt_mtu_rsp(struct bt_conn *conn, uint8_t err, const void *pdu,
|
||||||
uint16_t length, void *user_data)
|
uint16_t length, void *user_data)
|
||||||
{
|
{
|
||||||
|
@ -1457,3 +1471,4 @@ int bt_gatt_read_multiple(struct bt_conn *conn, const uint16_t *handles,
|
||||||
|
|
||||||
return gatt_send(conn, buf, att_read_rsp, func, NULL);
|
return gatt_send(conn, buf, att_read_rsp, func, NULL);
|
||||||
}
|
}
|
||||||
|
#endif /* CONFIG_BLUETOOTH_GATT_CLIENT */
|
||||||
|
|
|
@ -34,5 +34,13 @@
|
||||||
|
|
||||||
void bt_gatt_connected(struct bt_conn *conn);
|
void bt_gatt_connected(struct bt_conn *conn);
|
||||||
void bt_gatt_disconnected(struct bt_conn *conn);
|
void bt_gatt_disconnected(struct bt_conn *conn);
|
||||||
|
|
||||||
|
#if defined(CONFIG_BLUETOOTH_GATT_CLIENT)
|
||||||
void bt_gatt_notification(struct bt_conn *conn, uint16_t handle,
|
void bt_gatt_notification(struct bt_conn *conn, uint16_t handle,
|
||||||
const void *data, uint16_t length);
|
const void *data, uint16_t length);
|
||||||
|
#else
|
||||||
|
static inline void bt_gatt_notification(struct bt_conn *conn, uint16_t handle,
|
||||||
|
const void *data, uint16_t length)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
#endif /* CONFIG_BLUETOOTH_GATT_CLIENT */
|
||||||
|
|
|
@ -4,3 +4,4 @@ CONFIG_BLUETOOTH_UART=y
|
||||||
CONFIG_BLUETOOTH_DEBUG=y
|
CONFIG_BLUETOOTH_DEBUG=y
|
||||||
CONFIG_BLUETOOTH_CENTRAL=y
|
CONFIG_BLUETOOTH_CENTRAL=y
|
||||||
CONFIG_BLUETOOTH_SMP=y
|
CONFIG_BLUETOOTH_SMP=y
|
||||||
|
CONFIG_BLUETOOTH_GATT_CLIENT=y
|
||||||
|
|
|
@ -8,3 +8,4 @@ CONFIG_BLUETOOTH_CENTRAL=y
|
||||||
CONFIG_BLUETOOTH_PERIPHERAL=y
|
CONFIG_BLUETOOTH_PERIPHERAL=y
|
||||||
CONFIG_BLUETOOTH_SMP=y
|
CONFIG_BLUETOOTH_SMP=y
|
||||||
CONFIG_BLUETOOTH_SIGNING=y
|
CONFIG_BLUETOOTH_SIGNING=y
|
||||||
|
CONFIG_BLUETOOTH_GATT_CLIENT=y
|
||||||
|
|
|
@ -8,5 +8,6 @@ CONFIG_BLUETOOTH_CENTRAL=y
|
||||||
CONFIG_BLUETOOTH_PERIPHERAL=y
|
CONFIG_BLUETOOTH_PERIPHERAL=y
|
||||||
CONFIG_BLUETOOTH_SMP=y
|
CONFIG_BLUETOOTH_SMP=y
|
||||||
CONFIG_BLUETOOTH_SIGNING=y
|
CONFIG_BLUETOOTH_SIGNING=y
|
||||||
|
CONFIG_BLUETOOTH_GATT_CLIENT=y
|
||||||
CONFIG_TINYCRYPT=y
|
CONFIG_TINYCRYPT=y
|
||||||
CONFIG_TINYCRYPT_AES=y
|
CONFIG_TINYCRYPT_AES=y
|
||||||
|
|
|
@ -7,6 +7,7 @@ CONFIG_BLUETOOTH_CENTRAL=y
|
||||||
CONFIG_BLUETOOTH_PERIPHERAL=y
|
CONFIG_BLUETOOTH_PERIPHERAL=y
|
||||||
CONFIG_BLUETOOTH_SMP=y
|
CONFIG_BLUETOOTH_SMP=y
|
||||||
CONFIG_BLUETOOTH_SIGNING=y
|
CONFIG_BLUETOOTH_SIGNING=y
|
||||||
|
CONFIG_BLUETOOTH_GATT_CLIENT=y
|
||||||
CONFIG_BLUETOOTH_DEBUG=y
|
CONFIG_BLUETOOTH_DEBUG=y
|
||||||
CONFIG_BLUETOOTH_DEBUG_HCI_CORE=y
|
CONFIG_BLUETOOTH_DEBUG_HCI_CORE=y
|
||||||
CONFIG_BLUETOOTH_DEBUG_BUF=y
|
CONFIG_BLUETOOTH_DEBUG_BUF=y
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue