diff --git a/android/gatt.c b/android/gatt.c
index 0bd206b..a05b764 100644
--- a/android/gatt.c
+++ b/android/gatt.c
goto done;
}
+ if (!queue_isempty(dev->services)) {
+ info("gatt: Services already cached");
+ gatt_status = GATT_SUCCESS;
+ goto done;
+ }
+
/* There might be multiply services with same uuid. Therefore make sure
* each primary service one has unique instance_id
*/
{
struct discover_char_data *data = user_data;
- cache_all_srvc_chars(characteristics, data->service->chars);
+ if (queue_isempty(data->service->chars))
+ cache_all_srvc_chars(characteristics, data->service->chars);
send_client_char_notify(queue_peek_head(data->service->chars),
data->conn_id, data->service);
if (status)
error("gatt: Discover all char descriptors failed: %s",
att_ecode2str(status));
- else
+ else if (queue_isempty(data->ch->descriptors))
cache_all_descr(pdu, len, data->ch->descriptors);
descr = queue_peek_head(data->ch->descriptors);