All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ 1/3] attrib: Fix not honoring MTU
@ 2015-03-13  8:54 Luiz Augusto von Dentz
  2015-03-13  8:54 ` [PATCH BlueZ 2/3] core/device: Fix not handling notification Luiz Augusto von Dentz
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Luiz Augusto von Dentz @ 2015-03-13  8:54 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

If MTU has changed, by bt_gatt_client for example, the code should be
able to figure it out without waiting g_attrib_set_mtu to be called.
---
 attrib/gattrib.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index 514fc8f..2011359 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -429,9 +429,24 @@ guint g_attrib_register(GAttrib *attrib, guint8 opcode, guint16 handle,
 
 uint8_t *g_attrib_get_buffer(GAttrib *attrib, size_t *len)
 {
+	uint16_t mtu;
+
 	if (!attrib || !len)
 		return NULL;
 
+	mtu = bt_att_get_mtu(attrib->att);
+
+	/*
+	 * Clients of this expect a buffer to use.
+	 *
+	 * Pdu encoding in shared/att verifies if whole buffer fits the mtu,
+	 * thus we should set the buflen also when mtu is reduced. But we
+	 * need to reallocate the buffer only if mtu is larger.
+	 */
+	if (mtu > attrib->buflen)
+		attrib->buf = g_realloc(attrib->buf, mtu);
+
+	attrib->buflen = mtu;
 	*len = attrib->buflen;
 	return attrib->buf;
 }
-- 
2.1.0


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

* [PATCH BlueZ 2/3] core/device: Fix not handling notification
  2015-03-13  8:54 [PATCH BlueZ 1/3] attrib: Fix not honoring MTU Luiz Augusto von Dentz
@ 2015-03-13  8:54 ` Luiz Augusto von Dentz
  2015-03-13  8:54 ` [PATCH BlueZ 3/3] core/device: Remove call to g_attrib_set_mtu Luiz Augusto von Dentz
  2015-03-15  7:05 ` [PATCH BlueZ 1/3] attrib: Fix not honoring MTU Luiz Augusto von Dentz
  2 siblings, 0 replies; 4+ messages in thread
From: Luiz Augusto von Dentz @ 2015-03-13  8:54 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

attio callbacks needs to be triggered as soon as possible once connected
otherwise profiles such as HoG may miss notification that are sent while
bt_gatt_client is doing MTU exchange.
---
 src/device.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/device.c b/src/device.c
index 831efea..0dc8c86 100644
--- a/src/device.c
+++ b/src/device.c
@@ -3984,8 +3984,6 @@ static void gatt_client_ready_cb(bool success, uint8_t att_ecode,
 
 	device_accept_gatt_profiles(device);
 
-	g_slist_foreach(device->attios, attio_connected, device->attrib);
-
 	btd_gatt_client_ready(device->client_dbus);
 }
 
@@ -4007,6 +4005,9 @@ static void gatt_client_init(struct btd_device *device)
 		return;
 	}
 
+	/* Notify attio so it can react to notifications */
+	g_slist_foreach(device->attios, attio_connected, device->attrib);
+
 	if (!bt_gatt_client_set_ready_handler(device->client,
 							gatt_client_ready_cb,
 							device, NULL)) {
-- 
2.1.0


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

* [PATCH BlueZ 3/3] core/device: Remove call to g_attrib_set_mtu
  2015-03-13  8:54 [PATCH BlueZ 1/3] attrib: Fix not honoring MTU Luiz Augusto von Dentz
  2015-03-13  8:54 ` [PATCH BlueZ 2/3] core/device: Fix not handling notification Luiz Augusto von Dentz
@ 2015-03-13  8:54 ` Luiz Augusto von Dentz
  2015-03-15  7:05 ` [PATCH BlueZ 1/3] attrib: Fix not honoring MTU Luiz Augusto von Dentz
  2 siblings, 0 replies; 4+ messages in thread
From: Luiz Augusto von Dentz @ 2015-03-13  8:54 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

The call to g_attrib_set_mtu is no longer needed since
g_attrib_get_buffer has learned to check bt_att MTU.
---
 src/device.c | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/src/device.c b/src/device.c
index 0dc8c86..97c0523 100644
--- a/src/device.c
+++ b/src/device.c
@@ -3975,11 +3975,6 @@ static void gatt_client_ready_cb(bool success, uint8_t att_ecode,
 		return;
 	}
 
-	device->att_mtu = bt_att_get_mtu(device->att);
-	g_attrib_set_mtu(device->attrib, device->att_mtu);
-
-	DBG("MTU: %u", device->att_mtu);
-
 	register_gatt_services(device);
 
 	device_accept_gatt_profiles(device);
-- 
2.1.0


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

* Re: [PATCH BlueZ 1/3] attrib: Fix not honoring MTU
  2015-03-13  8:54 [PATCH BlueZ 1/3] attrib: Fix not honoring MTU Luiz Augusto von Dentz
  2015-03-13  8:54 ` [PATCH BlueZ 2/3] core/device: Fix not handling notification Luiz Augusto von Dentz
  2015-03-13  8:54 ` [PATCH BlueZ 3/3] core/device: Remove call to g_attrib_set_mtu Luiz Augusto von Dentz
@ 2015-03-15  7:05 ` Luiz Augusto von Dentz
  2 siblings, 0 replies; 4+ messages in thread
From: Luiz Augusto von Dentz @ 2015-03-15  7:05 UTC (permalink / raw)
  To: linux-bluetooth

Hi,

On Fri, Mar 13, 2015 at 10:54 AM, Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>
> If MTU has changed, by bt_gatt_client for example, the code should be
> able to figure it out without waiting g_attrib_set_mtu to be called.
> ---
>  attrib/gattrib.c | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
>
> diff --git a/attrib/gattrib.c b/attrib/gattrib.c
> index 514fc8f..2011359 100644
> --- a/attrib/gattrib.c
> +++ b/attrib/gattrib.c
> @@ -429,9 +429,24 @@ guint g_attrib_register(GAttrib *attrib, guint8 opcode, guint16 handle,
>
>  uint8_t *g_attrib_get_buffer(GAttrib *attrib, size_t *len)
>  {
> +       uint16_t mtu;
> +
>         if (!attrib || !len)
>                 return NULL;
>
> +       mtu = bt_att_get_mtu(attrib->att);
> +
> +       /*
> +        * Clients of this expect a buffer to use.
> +        *
> +        * Pdu encoding in shared/att verifies if whole buffer fits the mtu,
> +        * thus we should set the buflen also when mtu is reduced. But we
> +        * need to reallocate the buffer only if mtu is larger.
> +        */
> +       if (mtu > attrib->buflen)
> +               attrib->buf = g_realloc(attrib->buf, mtu);
> +
> +       attrib->buflen = mtu;
>         *len = attrib->buflen;
>         return attrib->buf;
>  }
> --
> 2.1.0

Applied.


-- 
Luiz Augusto von Dentz

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

end of thread, other threads:[~2015-03-15  7:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-13  8:54 [PATCH BlueZ 1/3] attrib: Fix not honoring MTU Luiz Augusto von Dentz
2015-03-13  8:54 ` [PATCH BlueZ 2/3] core/device: Fix not handling notification Luiz Augusto von Dentz
2015-03-13  8:54 ` [PATCH BlueZ 3/3] core/device: Remove call to g_attrib_set_mtu Luiz Augusto von Dentz
2015-03-15  7:05 ` [PATCH BlueZ 1/3] attrib: Fix not honoring MTU Luiz Augusto von Dentz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.