diff options
author | Injun Yang <injun.yang@samsung.com> | 2017-01-17 17:12:57 +0900 |
---|---|---|
committer | Injun Yang <injun.yang@samsung.com> | 2017-01-17 17:12:57 +0900 |
commit | 7ab660598efe700238d36711a744f66429d4ef72 (patch) | |
tree | 7e6507b040dace0d69ac2aac7eda82a628539afd /src | |
parent | d3ee3d5b5653c6d71a34f93dfcb8dd46946ecd21 (diff) | |
download | bluez-7ab660598efe700238d36711a744f66429d4ef72.tar.gz bluez-7ab660598efe700238d36711a744f66429d4ef72.tar.bz2 bluez-7ab660598efe700238d36711a744f66429d4ef72.zip |
Invoke MTU changed callback
[Model] All
[BinType] AP
[Customer] OPEN
[Issue#] N/A
[Request] Internal
[Occurence Version] N/A
[Problem] When remote device request mtu exchange,
mtu changed callback is not invoked on responder
[Cause & Measure] Invoke mtu changed callback
[Checking Method] Request mtu exchange on remote device
[Team] Basic Connection
[Developer] Injun Yang
[Solution company] Samsung
[Change Type] Specification change
Change-Id: Ib9ee0e2c67043cb0384fed59bfc6a2e3e6b467e6
Signed-off-by: Injun Yang <injun.yang@samsung.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/device.c | 23 | ||||
-rw-r--r-- | src/shared/gatt-client.c | 2 | ||||
-rw-r--r-- | src/shared/gatt-server.c | 33 | ||||
-rw-r--r-- | src/shared/gatt-server.h | 11 |
4 files changed, 66 insertions, 3 deletions
diff --git a/src/device.c b/src/device.c index 618d5bbf..73ae618c 100644 --- a/src/device.c +++ b/src/device.c @@ -6355,6 +6355,20 @@ done: attio_cleanup(device); } +#ifdef TIZEN_FEATURE_BLUEZ_MODIFY +static void att_mtu_changed(uint16_t mtu, void *user_data) +{ + struct btd_device *device = user_data; + + DBG("att mtu changed %d", mtu); + + g_dbus_emit_signal(dbus_conn, device->path, + DEVICE_INTERFACE, "AttMtuChanged", + DBUS_TYPE_UINT16, &mtu, + DBUS_TYPE_INVALID); +} +#endif + static void register_gatt_services(struct btd_device *device) { struct browse_req *req = device->browse; @@ -6503,6 +6517,15 @@ static void gatt_server_init(struct btd_device *device, struct gatt_db *db) error("Failed to initialize bt_gatt_server"); bt_gatt_server_set_debug(device->server, gatt_debug, NULL, NULL); + +#ifdef TIZEN_FEATURE_BLUEZ_MODIFY + if (!bt_gatt_server_set_mtu_changed(device->server, + att_mtu_changed, + device, NULL)) { + DBG("Failed to set mtu changed handler"); + return; + } +#endif } static bool local_counter(uint32_t *sign_cnt, void *user_data) diff --git a/src/shared/gatt-client.c b/src/shared/gatt-client.c index 3c6d7a8a..9f4e075f 100644 --- a/src/shared/gatt-client.c +++ b/src/shared/gatt-client.c @@ -1181,7 +1181,7 @@ static void exchange_mtu_cb(bool success, uint8_t att_ecode, void *user_data) } util_debug(client->debug_callback, client->debug_data, - "MTU exchange complete, with MTU: %u", + "att client MTU exchange complete, with MTU: %u", bt_att_get_mtu(client->att)); discover: diff --git a/src/shared/gatt-server.c b/src/shared/gatt-server.c index e9786455..53c60f3d 100644 --- a/src/shared/gatt-server.c +++ b/src/shared/gatt-server.c @@ -110,6 +110,12 @@ struct bt_gatt_server { bt_gatt_server_debug_func_t debug_callback; bt_gatt_server_destroy_func_t debug_destroy; void *debug_data; + +#ifdef TIZEN_FEATURE_BLUEZ_MODIFY + bt_gatt_server_mtu_changed_callback_t mtu_chngd_callback; + bt_gatt_server_destroy_func_t mtu_chngd_destroy; + void *mtu_chngd_data; +#endif }; static void bt_gatt_server_free(struct bt_gatt_server *server) @@ -1304,7 +1310,7 @@ static void exchange_mtu_cb(uint8_t opcode, const void *pdu, } client_rx_mtu = get_le16(pdu); -#ifndef __TIZEN_PACTH__ +#ifndef TIZEN_FEATURE_BLUEZ_MODIFY final_mtu = MAX(MIN(client_rx_mtu, server->mtu), BT_ATT_DEFAULT_LE_MTU); /* Respond with the server MTU */ @@ -1326,10 +1332,13 @@ static void exchange_mtu_cb(uint8_t opcode, const void *pdu, put_le16(server->mtu, rsp_pdu); bt_att_send(server->att, BT_ATT_OP_MTU_RSP, rsp_pdu, 2, NULL, NULL, NULL); + + if (server->mtu_chngd_callback) + server->mtu_chngd_callback(final_mtu, server->mtu_chngd_data); #endif util_debug(server->debug_callback, server->debug_data, - "MTU exchange complete, with MTU: %u", final_mtu); + "att server MTU exchange complete, with MTU: %u", final_mtu); } static bool gatt_server_register_att_handlers(struct bt_gatt_server *server) @@ -1581,3 +1590,23 @@ bool bt_gatt_server_send_indication(struct bt_gatt_server *server, return result; } + +#ifdef TIZEN_FEATURE_BLUEZ_MODIFY +bool bt_gatt_server_set_mtu_changed(struct bt_gatt_server *server, + bt_gatt_server_mtu_changed_callback_t callback, + void *user_data, + bt_gatt_server_destroy_func_t destroy) +{ + if (!server) + return false; + + if (server->mtu_chngd_destroy) + server->mtu_chngd_destroy(server->mtu_chngd_data); + + server->mtu_chngd_callback = callback; + server->mtu_chngd_destroy = destroy; + server->mtu_chngd_data = user_data; + + return true; +} +#endif diff --git a/src/shared/gatt-server.h b/src/shared/gatt-server.h index 0e480e1b..c61eabe8 100644 --- a/src/shared/gatt-server.h +++ b/src/shared/gatt-server.h @@ -50,3 +50,14 @@ bool bt_gatt_server_send_indication(struct bt_gatt_server *server, bt_gatt_server_conf_func_t callback, void *user_data, bt_gatt_server_destroy_func_t destroy); + +#ifdef TIZEN_FEATURE_BLUEZ_MODIFY +typedef void (*bt_gatt_server_mtu_changed_callback_t)(uint16_t mtu, + void *user_data); + +bool bt_gatt_server_set_mtu_changed(struct bt_gatt_server *server, + bt_gatt_server_mtu_changed_callback_t callback, + void *user_data, + bt_gatt_server_destroy_func_t destroy); + +#endif |