diff options
author | Jakub Tyszkowski <jakub.tyszkowski@tieto.com> | 2015-02-10 11:04:31 +0100 |
---|---|---|
committer | Szymon Janc <szymon.janc@tieto.com> | 2015-02-11 12:29:00 +0100 |
commit | b5a78bf6d3c88657acf1d28c8453c539e0236a7b (patch) | |
tree | ec1d421cd1985436c070e326a2e2bd9e46089b6b /android/gatt.c | |
parent | 5647336bba71c9e974b87ea02d1e122b491a4b3d (diff) | |
download | bluez-b5a78bf6d3c88657acf1d28c8453c539e0236a7b.tar.gz |
android/gatt: Fix not confirming notifications and indications
In Lollipop, server app notifications needs to be confirmed just like
indications. We had those confirmations missing thus server apps
would stop indicating/notifying after first indication/notification
is send.
Diffstat (limited to 'android/gatt.c')
-rw-r--r-- | android/gatt.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/android/gatt.c b/android/gatt.c index 7f8f99f88..8e58e41c3 100644 --- a/android/gatt.c +++ b/android/gatt.c @@ -5523,6 +5523,18 @@ failed: HAL_OP_GATT_SERVER_DELETE_SERVICE, status); } +static void indication_confirmation_cb(guint8 status, const guint8 *pdu, + guint16 len, gpointer user_data) +{ + struct hal_ev_gatt_server_indication_sent ev; + + ev.status = status; + ev.conn_id = PTR_TO_UINT(user_data); + + ipc_send_notif(hal_ipc, HAL_SERVICE_ID_GATT, + HAL_EV_GATT_SERVER_INDICATION_SENT, sizeof(ev), &ev); +} + static void handle_server_send_indication(const void *buf, uint16_t len) { const struct hal_cmd_gatt_server_send_indication *cmd = buf; @@ -5545,11 +5557,10 @@ static void handle_server_send_indication(const void *buf, uint16_t len) pdu = g_attrib_get_buffer(conn->device->attrib, &mtu); if (cmd->confirm) { - /* TODO: Add data to track confirmation for this request */ length = enc_indication(cmd->attribute_handle, (uint8_t *) cmd->value, cmd->len, pdu, mtu); - confirmation_cb = ignore_confirmation_cb; + confirmation_cb = indication_confirmation_cb; } else { length = enc_notification(cmd->attribute_handle, (uint8_t *) cmd->value, @@ -5561,10 +5572,15 @@ static void handle_server_send_indication(const void *buf, uint16_t len) status = HAL_STATUS_FAILED; } else { g_attrib_send(conn->device->attrib, 0, pdu, length, - confirmation_cb, NULL, NULL); + confirmation_cb, UINT_TO_PTR(conn->id), NULL); status = HAL_STATUS_SUCCESS; } + /* Here we confirm failed indications and all notifications */ + if (status || !confirmation_cb) + indication_confirmation_cb(status, NULL, 0, + UINT_TO_PTR(conn->id)); + reply: ipc_send_rsp(hal_ipc, HAL_SERVICE_ID_GATT, HAL_OP_GATT_SERVER_SEND_INDICATION, status); |