gatt: Add implementation of GattCharacteristic1.MTU
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Tue, 28 Sep 2021 22:45:05 +0000 (15:45 -0700)
committerAyush Garg <ayush.garg@samsung.com>
Fri, 11 Mar 2022 13:38:37 +0000 (19:08 +0530)
This implements MTU property in GattCharacteristic1 interface.

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

index b810a90b38f7233fa492e30be14c30c475146496..64227e233aeda92321a2e60cf15329eb3dc427c6 100644 (file)
@@ -929,6 +929,25 @@ characteristic_notify_acquired_exists(const GDBusPropertyTable *property,
        return (chrc->props & BT_GATT_CHRC_PROP_NOTIFY);
 }
 
+static gboolean characteristic_get_mtu(const GDBusPropertyTable *property,
+                                      DBusMessageIter *iter, void *data)
+{
+       struct characteristic *chrc = data;
+       struct bt_gatt_client *gatt = chrc->service->client->gatt;
+       struct bt_att *att;
+       uint16_t mtu;
+
+       att = bt_gatt_client_get_att(gatt);
+       if (!att)
+               return FALSE;
+
+       mtu = bt_att_get_mtu(att);
+
+       dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT16, &mtu);
+
+       return TRUE;
+}
+
 static void write_characteristic_cb(struct gatt_db_attribute *attr, int err,
                                                                void *user_data)
 {
@@ -1862,6 +1881,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 },
 #ifdef TIZEN_FEATURE_BLUEZ_MODIFY
        { "Descriptors", "ao", characteristic_get_descriptors },
 #endif