shared/gatt-client: Fix discovery of discontinuous database 54/204954/1
authorAndrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
Thu, 22 Mar 2018 15:21:00 +0000 (16:21 +0100)
committerAmit Purwar <amit.purwar@samsung.com>
Fri, 26 Apr 2019 10:53:40 +0000 (16:23 +0530)
commitf58c46a963a941dcb432ffa17c5d2ec5f2333e7a
tree478701d6338700112098735cff3a910e393e0837
parentdf27ec0614e2c264ce3b485604f579661fe803fb
shared/gatt-client: Fix discovery of discontinuous database

If local cache of peer's database has gaps where new services appear
after reconnection, GATT client will attempt to discover all included
services and characteristics definitions between starting handle of
first service and end handle of last service. This means the result
will contain also attributes which are already present in active
services in local database and thus attempting to add them again will
fail.

To fix this, instead of discovering whole range we'll only discover
ranges for missing services - starting with included services then
characteristics. To optimize this process we'll merge ranges of
adjacent services and any empty spaces in between - the result is
basically set of ranges without any known service. In most cases this
works the same or very similar to current implementation.

This issue can sometimes be observed with iOS devices as ANCS and CTS
services may not be available all the time.

Change-Id: I2b73f0204f2e3cb7177b97799182f608156138ef
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
src/shared/gatt-client.c