From 0986ba25f3e2b92697ef6e99871fbf39c3bd1c6f Mon Sep 17 00:00:00 2001 From: Arman Uguray Date: Fri, 27 Feb 2015 19:41:14 -0800 Subject: [PATCH] shared/gatt: Return ATT id for exchange MTU bt_gatt_exchange_mtu now returns the underlying ATT protocol id so that the upper layer can cancel the operation if needed. --- src/shared/gatt-helpers.c | 13 ++++++------- src/shared/gatt-helpers.h | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/shared/gatt-helpers.c b/src/shared/gatt-helpers.c index 2d07a8399..bad20d9f1 100644 --- a/src/shared/gatt-helpers.c +++ b/src/shared/gatt-helpers.c @@ -535,13 +535,14 @@ done: op->callback(success, att_ecode, op->user_data); } -bool bt_gatt_exchange_mtu(struct bt_att *att, uint16_t client_rx_mtu, +unsigned int bt_gatt_exchange_mtu(struct bt_att *att, uint16_t client_rx_mtu, bt_gatt_result_callback_t callback, void *user_data, bt_gatt_destroy_func_t destroy) { struct mtu_op *op; uint8_t pdu[2]; + unsigned int id; if (!att || !client_rx_mtu) return false; @@ -558,14 +559,12 @@ bool bt_gatt_exchange_mtu(struct bt_att *att, uint16_t client_rx_mtu, put_le16(client_rx_mtu, pdu); - if (!bt_att_send(att, BT_ATT_OP_MTU_REQ, pdu, sizeof(pdu), - mtu_cb, op, - destroy_mtu_op)) { + id = bt_att_send(att, BT_ATT_OP_MTU_REQ, pdu, sizeof(pdu), mtu_cb, op, + destroy_mtu_op); + if (!id) free(op); - return false; - } - return true; + return id; } static inline int get_uuid_len(const bt_uuid_t *uuid) diff --git a/src/shared/gatt-helpers.h b/src/shared/gatt-helpers.h index 0217e82a8..cf920751c 100644 --- a/src/shared/gatt-helpers.h +++ b/src/shared/gatt-helpers.h @@ -65,7 +65,7 @@ typedef void (*bt_gatt_discovery_callback_t)(bool success, uint8_t att_ecode, struct bt_gatt_result *result, void *user_data); -bool bt_gatt_exchange_mtu(struct bt_att *att, uint16_t client_rx_mtu, +unsigned int bt_gatt_exchange_mtu(struct bt_att *att, uint16_t client_rx_mtu, bt_gatt_result_callback_t callback, void *user_data, bt_gatt_destroy_func_t destroy); -- 2.47.3