gatt: Omit MTU if not connected
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Mon, 29 Nov 2021 17:59:42 +0000 (09:59 -0800)
committerAyush Garg <ayush.garg@samsung.com>
Fri, 11 Mar 2022 13:38:38 +0000 (19:08 +0530)
If not connected there is no reason to expose the MTU as that only
valid while connected.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
src/gatt-client.c

index 750570c..0759b09 100644 (file)
@@ -946,6 +946,14 @@ static gboolean characteristic_get_mtu(const GDBusPropertyTable *property,
        return TRUE;
 }
 
+static gboolean characteristic_mtu_exists(const GDBusPropertyTable *property,
+                                                               void *data)
+{
+       struct characteristic *chrc = data;
+
+       return chrc->service->client->gatt ? TRUE : FALSE;
+}
+
 static void write_characteristic_cb(struct gatt_db_attribute *attr, int err,
                                                                void *user_data)
 {
@@ -1879,7 +1887,7 @@ static const GDBusPropertyTable characteristic_properties[] = {
                                characteristic_write_acquired_exists },
        { "NotifyAcquired", "b", characteristic_get_notify_acquired, NULL,
                                characteristic_notify_acquired_exists },
-       { "MTU", "q", characteristic_get_mtu, NULL, NULL },
+       { "MTU", "q", characteristic_get_mtu, NULL, characteristic_mtu_exists },
 #ifdef TIZEN_FEATURE_BLUEZ_MODIFY
        { "Descriptors", "ao", characteristic_get_descriptors },
 #endif