diff mbox series

[BlueZ,2/5] gatt: Add implementation of GattCharacteristic1.MTU

Message ID 20210928235447.3077055-2-luiz.dentz@gmail.com (mailing list archive)
State Accepted
Delegated to: Brian Gix
Headers show
Series [BlueZ,1/5] gatt-api: Add MTU property to GattCharacteristic1 | expand

Checks

Context Check Description
tedd_an/checkpatch success Checkpatch PASS
tedd_an/gitlint success Gitlint PASS

Commit Message

Luiz Augusto von Dentz Sept. 28, 2021, 11:54 p.m. UTC
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This implements MTU property in GattCharacteristic1 interface.
---
 src/gatt-client.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
diff mbox series

Patch

diff --git a/src/gatt-client.c b/src/gatt-client.c
index 6bed77793..5b10cbfa0 100644
--- a/src/gatt-client.c
+++ b/src/gatt-client.c
@@ -873,6 +873,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)
 {
@@ -1646,6 +1665,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 },
 	{ }
 };