[PATCH BlueZ 4/5] core: device: Add device_is_bonded_for_gatt

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Added the device_is_bonded_for_gatt function, which returns true if
the bonding state is true for the bearer over which the GATT db was
populated. For now, this only returns the LE state but added for
better layering, so that future changes to the internal logic can be
simply performed here to avoid regressions.

Change-Id: I6ebd16a1111aa38645a0a072536f4171d246b931
---
 src/device.c | 14 +++++++++++++-
 src/device.h |  1 +
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/src/device.c b/src/device.c
index 9cb5acb..2ef2b6a 100644
--- a/src/device.c
+++ b/src/device.c
@@ -506,8 +506,10 @@ static void gatt_client_cleanup(struct btd_device *device)
 	bt_gatt_client_unref(device->client);
 	device->client = NULL;
 
-	if (!device->le_state.bonded)
+	if (!device_is_bonded_for_gatt(device)) {
+		DBG("Device is not bonded, clearing client attribute cache");
 		gatt_db_clear(device->db);
+	}
 }
 
 static void attio_cleanup(struct btd_device *device)
@@ -638,6 +640,16 @@ bool device_is_bonded(struct btd_device *device, uint8_t bdaddr_type)
 	return state->bonded;
 }
 
+bool device_is_bonded_for_gatt(struct btd_device *device)
+{
+	/*
+	 * TODO: Once we properly support GATT over BR/EDR, we should remember
+	 * whether the GATT client  database was populated over LE or BR/EDR and
+	 * check the correct bonding state.
+	 */
+	return device->le_state.bonded;
+}
+
 gboolean device_is_trusted(struct btd_device *device)
 {
 	return device->trusted;
diff --git a/src/device.h b/src/device.h
index a7fefee..b4aead1 100644
--- a/src/device.h
+++ b/src/device.h
@@ -82,6 +82,7 @@ const char *device_get_path(const struct btd_device *device);
 gboolean device_is_temporary(struct btd_device *device);
 bool device_is_paired(struct btd_device *device, uint8_t bdaddr_type);
 bool device_is_bonded(struct btd_device *device, uint8_t bdaddr_type);
+bool device_is_bonded_for_gatt(struct btd_device *device);
 gboolean device_is_trusted(struct btd_device *device);
 void device_set_paired(struct btd_device *dev, uint8_t bdaddr_type);
 void device_set_unpaired(struct btd_device *dev, uint8_t bdaddr_type);
-- 
2.2.0.rc0.207.ga3a616c

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux