Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH BlueZ 3/3] client: Add MTU and UpdateMTU implementation
@ 2017-09-14 23:47 Yunhan Wang
  2017-09-14 23:47 ` [PATCH BlueZ 2/3] gatt: Do UpdateMTU when write comes in Yunhan Wang
  2017-09-14 23:47 ` [PATCH BlueZ 1/3] doc/gatt-api: Add UpdateMTU and MTU Yunhan Wang
  0 siblings, 2 replies; 6+ messages in thread
From: Yunhan Wang @ 2017-09-14 23:47 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Yunhan Wang

Add MTU in GDBusPropertyTable and UpdateMTU in GDBusMethodTable for Characteristic.
---
 client/gatt.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/client/gatt.c b/client/gatt.c
index 753038303..22cb5679d 100644
--- a/client/gatt.c
+++ b/client/gatt.c
@@ -98,6 +98,8 @@ static GDBusProxy *notify_proxy;
 static struct io *notify_io;
 static uint16_t notify_mtu;
 
+static uint16_t att_mtu = 300;
+
 static void print_service(struct service *service, const char *description)
 {
 	const char *text;
@@ -1273,6 +1275,15 @@ static gboolean chrc_get_value(const GDBusPropertyTable *property,
 	return TRUE;
 }
 
+static gboolean chrc_get_mtu(const GDBusPropertyTable *property,
+							   DBusMessageIter *iter, void *data)
+{
+	struct chrc *chrc = data;
+	const char * msg = NULL;
+	dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT16, att_mtu);
+	return TRUE;
+}
+
 static gboolean chrc_get_notifying(const GDBusPropertyTable *property,
 					DBusMessageIter *iter, void *data)
 {
@@ -1308,6 +1319,7 @@ static const GDBusPropertyTable chrc_properties[] = {
 	{ "UUID", "s", chrc_get_uuid, NULL, NULL },
 	{ "Service", "o", chrc_get_service, NULL, NULL },
 	{ "Value", "ay", chrc_get_value, NULL, NULL },
+	{ "MTU", "q", chrc_get_mtu, NULL, NULL },
 	{ "Notifying", "b", chrc_get_notifying, NULL, NULL },
 	{ "Flags", "as", chrc_get_flags, NULL, NULL },
 	{ }
@@ -1415,6 +1427,18 @@ static DBusMessage *chrc_confirm(DBusConnection *conn, DBusMessage *msg,
 	return dbus_message_new_method_return(msg);
 }
 
+static DBusMessage *chrc_update_mtu(DBusConnection *conn, DBusMessage *msg,
+								 void *user_data)
+{
+	struct chrc *chrc = user_data;
+	DBusMessageIter iter;
+	dbus_message_iter_init(msg, &iter);
+
+	dbus_message_iter_get_basic(&iter, &att_mtu);
+
+	return dbus_message_new_method_return(msg);
+}
+
 static const GDBusMethodTable chrc_methods[] = {
 	{ GDBUS_ASYNC_METHOD("ReadValue", GDBUS_ARGS({ "options", "a{sv}" }),
 					GDBUS_ARGS({ "value", "ay" }),
@@ -1422,6 +1446,8 @@ static const GDBusMethodTable chrc_methods[] = {
 	{ GDBUS_ASYNC_METHOD("WriteValue", GDBUS_ARGS({ "value", "ay" },
 						{ "options", "a{sv}" }),
 					NULL, chrc_write_value) },
+	{ GDBUS_ASYNC_METHOD("UpdateMTU", GDBUS_ARGS({ "value", "q" }),
+					NULL, chrc_update_mtu) },
 	{ GDBUS_ASYNC_METHOD("StartNotify", NULL, NULL, chrc_start_notify) },
 	{ GDBUS_METHOD("StopNotify", NULL, NULL, chrc_stop_notify) },
 	{ GDBUS_METHOD("Confirm", NULL, NULL, chrc_confirm) },
-- 
2.14.1.690.gbb1197296e-goog


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-09-15  7:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-14 23:47 [PATCH BlueZ 3/3] client: Add MTU and UpdateMTU implementation Yunhan Wang
2017-09-14 23:47 ` [PATCH BlueZ 2/3] gatt: Do UpdateMTU when write comes in Yunhan Wang
2017-09-14 23:47 ` [PATCH BlueZ 1/3] doc/gatt-api: Add UpdateMTU and MTU Yunhan Wang
2017-09-14 23:52   ` Yunhan Wang
2017-09-15  6:21     ` Luiz Augusto von Dentz
     [not found]       ` <CALvjcs9HB7E2=Rmm7LxPHwzEFbF4az+G2=T=XzgnH4JZ6fSN_Q@mail.gmail.com>
2017-09-15  7:36         ` Luiz Augusto von Dentz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox