client: Add MTU and UpdateMTU implementation
PATCH 3/3 client: Add MTU and UpdateMTU implementation
Add MTU in GDBusPropertyTable and UpdateMTU in GDBusMethodTable for Characteristic.
--- client/gatt.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
client/gatt.c +26 -0
@@ -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) },
Signature · 1 line
2.14.1.690.gbb1197296e-goog
PATCH 1/3 doc/gatt-api: Add UpdateMTU and MTU
Add updateMTU in gatt method to get att mtu value in server side. Add MTU property in gatt property.
--- doc/gatt-api.txt | 11 +++++++++++ 1 file changed, 11 insertions(+)
doc/gatt-api.txt +11 -0
@@ -169,6 +169,13 @@ Methods array{byte} ReadValue(dict options) Possible Errors: org.bluez.Error.Failed + void UpdateMTU() [optional] (Server only) + + This method doesn't expect a reply so it is just + MTU value update in user space at server side. + + Possible Errors: org.bluez.Error.Failed + Properties string UUID [read-only] 128-bit characteristic UUID.
@@ -225,6 +232,10 @@ Properties string UUID [read-only] "secure-read" (Server only) "secure-write" (Server only) + uint16_t MTU [read-only, optional] + + ATT MTU value + Characteristic Descriptors hierarchy ====================================
Signature · 1 line
2.14.1.690.gbb1197296e-goog
Re: [PATCH BlueZ 1/3] doc/gatt-api: Add UpdateMTU and MTU
Hi, Luiz
In order to implement packet fragmentation/assembly in upper layer application, may we get ATT MTU extraction API in peripheral/server side? Basic idea is to get ATT mtu after MTU exchange complete and write comes in. This patch is the draft implementation.
Thanks
Best wishes
Yunhan
Quoted 38 lines · Yunhan Wang
Add updateMTU in gatt method to get att mtu value in server side. Add MTU property in gatt property.
--- doc/gatt-api.txt | 11 +++++++++++ 1 file changed, 11 insertions(+)doc/gatt-api.txt +11
-1@@ -169,6 +169,13 @@ Methods array{byte} ReadValue(dict options) Possible Errors: org.bluez.Error.Failed + void UpdateMTU() [optional] (Server only) + + This method doesn't expect a reply so it is just + MTU value update in user space at server side. + + Possible Errors: org.bluez.Error.Failed + Properties string UUID [read-only] 128-bit characteristic UUID.@@ -225,6 +232,10 @@ Properties string UUID [read-only] "secure-read" (Server only) "secure-write" (Server only) + uint16_t MTU [read-only, optional] + + ATT MTU value + Characteristic Descriptors hierarchy ==================================== --2.14.1.690.gbb1197296e-goog
Luiz Augusto von Dentz
maintainerRe: [PATCH BlueZ 1/3] doc/gatt-api: Add UpdateMTU and MTU
Hi Yunhan,
Quoted 6 lines · Yunhan Wang
Hi, Luiz
In order to implement packet fragmentation/assembly in upper layer application, may we get ATT MTU extraction API in peripheral/server side? Basic idea is to get ATT mtu after MTU exchange complete and write comes in. This patch is the draft implementation.
Im implementing AcquireWrite and AcquireNotify for server as well, that should address GATT services that want to emulate serial port or other protocol on top of it, like mesh.
Quoted 43 lines
Thanks
Best wishes
YunhanQuoted 38 lines · Yunhan Wang
Add updateMTU in gatt method to get att mtu value in server side. Add MTU property in gatt property.
--- doc/gatt-api.txt | 11 +++++++++++ 1 file changed, 11 insertions(+)doc/gatt-api.txt +11
-1@@ -169,6 +169,13 @@ Methods array{byte} ReadValue(dict options) Possible Errors: org.bluez.Error.Failed + void UpdateMTU() [optional] (Server only) + + This method doesn't expect a reply so it is just + MTU value update in user space at server side. + + Possible Errors: org.bluez.Error.Failed + Properties string UUID [read-only] 128-bit characteristic UUID.@@ -225,6 +232,10 @@ Properties string UUID [read-only] "secure-read" (Server only) "secure-write" (Server only) + uint16_t MTU [read-only, optional] + + ATT MTU value + Characteristic Descriptors hierarchy ==================================== --2.14.1.690.gbb1197296e-goog
Signature · 1 line
Luiz Augusto von Dentz
A message that is not in the archive (sent off-list or not yet received): CALvjcs9HB7E2=Rmm7LxPHwzEFbF4az+G2=T=XzgnH4JZ6fSN_Q@mail.gmail.com
Luiz Augusto von Dentz
maintainerRe: [PATCH BlueZ 1/3] doc/gatt-api: Add UpdateMTU and MTU
Hi Yunhan,
Quoted 4 lines · Yunhan Wang
Hi Luiz
Sounds great! Could you describe a little bit more about the idea that use AcquireWrite and AcquireNotify and get MTU in GATT service side?
No top-posting in the list, please reply inline.
It is pretty similar to Acquire* for clients but adding a few options to the server like MTU and Device, the key difference is that the app can provide any type of fd instead of pipe for each device that has requested it.
Quoted 71 lines
Thank you.
Best wishes
YunhanQuoted 64 lines · On Thu, Sep 14, 2017 at 23:21 Luiz Augusto von Dentz <[email protected]>…
Hi Yunhan,
Quoted 6 lines · Yunhan Wang
Hi, Luiz
In order to implement packet fragmentation/assembly in upper layer application, may we get ATT MTU extraction API in peripheral/server side? Basic idea is to get ATT mtu after MTU exchange complete and write comes in. This patch is the draft implementation.
Im implementing AcquireWrite and AcquireNotify for server as well, that should address GATT services that want to emulate serial port or other protocol on top of it, like mesh
Quoted 42 lines
Thanks
Best wishes
YunhanQuoted 37 lines · Yunhan Wang
Add updateMTU in gatt method to get att mtu value in server side. Add MTU property in gatt property.
--- doc/gatt-api.txt | 11 +++++++++++ 1 file changed, 11 insertions(+)doc/gatt-api.txt +3
-0@@ -169,6 +169,13 @@ Methods array{byte} ReadValue(dict options) Possible Errors: org.bluez.Error.Failed + void UpdateMTU() [optional] (Server only) + + This method doesn't expect a reply so it isjust
doc/gatt-api.txt +8
-0+ MTU value update in user space at server side. + + Possible Errors: org.bluez.Error.Failed + Properties string UUID [read-only] 128-bit characteristic UUID.@@ -225,6 +232,10 @@ Properties string UUID [read-only] "secure-read" (Server only) "secure-write" (Server only) + uint16_t MTU [read-only, optional] + + ATT MTU value + Characteristic Descriptors hierarchy ====================================Quoted 3 lines
Quoted 3 lines
--
2.14.1.690.gbb1197296e-goog--
Luiz Augusto von Dentz
Signature · 1 line
Luiz Augusto von Dentz
PATCH 2/3 gatt: Do UpdateMTU when write comes in
In reply to Yunhan WangAdd mtu in external_chrc strcutre, and call UpdateMTU when MTU exchange complete and write comes in
--- src/gatt-database.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
src/gatt-database.c +12 -0
@@ -122,6 +122,7 @@ struct external_chrc {struct queue *pending_reads;struct queue *pending_writes;unsigned int ntfy_cnt; +uint16_t mtu; };struct external_desc {
@@ -1678,6 +1679,12 @@ static struct pending_op *send_read(struct btd_device *device,return NULL ; } +static void update_mtu_setup_cb (DBusMessageIter *iter,void *user_data) +{ +struct external_chrc *chrc = user_data; +dbus_message_iter_append_basic (iter,DBUS_TYPE_UINT16 , &chrc->mtu); +} +static void write_setup_cb (DBusMessageIter *iter,void *user_data) {struct pending_op *op = user_data;
@@ -2090,12 +2097,17 @@ static void chrc_write_cb(struct gatt_db_attribute *attrib,struct external_chrc *chrc = user_data;struct btd_device *device;struct queue *queue; +uint16_t mtu;if (chrc->attrib != attrib) {error ("Write callback called with incorrect attribute" ); goto fail; } + mtu =bt_att_get_mtu (att); + chrc->mtu = mtu; +g_dbus_proxy_method_call (chrc->proxy,"UpdateMTU" , update_mtu_setup_cb,NULL , user_data,NULL ); + device =att_get_device (att);if (!device) {error ("Unable to find device object" );
Signature · 1 line
2.14.1.690.gbb1197296e-goog