shared/gatt-client: Fix not removing services that had disappeared
[Problem] There are duplicated services in gatt client database.
[Cause & Measure] When GATT service discovery happens and there are no
services in the middle of discovery range, the services in that range
are not removed. This causes a local application recognize that the
services exist. But those are actually removed in remote side so
the local application malfunction happens.
[Checking Method] Connect device to iOS. It happens rarely but it makes
the issue happen with below procedures.
1. Connect two bluez devices via BLE
2. Make pair
3. Register any service in one side (A)
4. Disconnect BLE
5. Unregister the service and register it again on side A
6. Make a connection again
7. Check the side A's services on side B
This patch comes from below commit of upstream.
commit
6b34bdd967a639c2d219b5d83f0a20637c56e68e
Author: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Date: Wed May 24 13:22:01 2017 +0300
If a service cannot be found in the middle of the database the current
logic don't clear its range leaving it still active which cause upper
layer to believe its attributes are still available.
In order to fix the code now loads existing services into the pending
list and remove the services left at the end of the discovery:
src/device.c:gatt_debug() Primary services found: 2
src/device.c:gatt_debug() start: 0x0001, end: 0x0005, uuid:
00001800-0000-1000-8000-
00805f9b34fb
src/device.c:gatt_debug() start: 0x0100, end: 0x0104, uuid:
0000180a-0000-1000-8000-
00805f9b34fb
src/device.c:gatt_debug() Secondary service discovery failed. ATT ECODE: 0x0a
src/device.c:gatt_debug() Characteristics found: 2
src/device.c:gatt_debug() start: 0x0101, end: 0x0102, value: 0x0102, props: 0x02, uuid:
00002a24-0000-1
src/device.c:gatt_debug() start: 0x0103, end: 0x0104, value: 0x0104, props: 0x02, uuid:
00002a29-0000-1
src/device.c:gatt_debug() service disappeared: start 0x0006 end 0x000a
src/device.c:gatt_service_removed() start: 0x0006, end: 0x000a
Change-Id: I8ef0b3c3feaadaa61d280f494532ab26ceecec2e
Signed-off-by: Seungyoun Ju <sy39.ju@samsung.com>
Signed-off-by: DoHyun Pyun <dh79.pyun@samsung.com>