From cb6db2386bd2f27cc52b30ed65af095db1eb2e5b Mon Sep 17 00:00:00 2001 From: Claudio Takahasi Date: Wed, 20 Jun 2012 14:27:46 -0300 Subject: [PATCH] gatttool: Use GAttrib buffer This patch replaces the static local buffer by the GAttrib internal buffer to store temporarly the output ATT PDU. --- attrib/gatttool.c | 6 ++++-- attrib/interactive.c | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/attrib/gatttool.c b/attrib/gatttool.c index c70b1d653..1f23522dc 100644 --- a/attrib/gatttool.c +++ b/attrib/gatttool.c @@ -75,8 +75,9 @@ struct characteristic_data { static void events_handler(const uint8_t *pdu, uint16_t len, gpointer user_data) { GAttrib *attrib = user_data; - uint8_t opdu[ATT_MAX_MTU]; + uint8_t *opdu; uint16_t handle, i, olen = 0; + int plen; handle = att_get_u16(&pdu[1]); @@ -100,7 +101,8 @@ static void events_handler(const uint8_t *pdu, uint16_t len, gpointer user_data) if (pdu[0] == ATT_OP_HANDLE_NOTIFY) return; - olen = enc_confirmation(opdu, sizeof(opdu)); + opdu = g_attrib_get_buffer(attrib, &plen); + olen = enc_confirmation(opdu, plen); if (olen > 0) g_attrib_send(attrib, 0, opdu[0], opdu, olen, NULL, NULL, NULL); diff --git a/attrib/interactive.c b/attrib/interactive.c index 1cdbfefc9..365779850 100644 --- a/attrib/interactive.c +++ b/attrib/interactive.c @@ -101,8 +101,9 @@ static void set_state(enum state st) static void events_handler(const uint8_t *pdu, uint16_t len, gpointer user_data) { - uint8_t opdu[ATT_MAX_MTU]; + uint8_t *opdu; uint16_t handle, i, olen; + int plen; handle = att_get_u16(&pdu[1]); @@ -128,7 +129,8 @@ static void events_handler(const uint8_t *pdu, uint16_t len, gpointer user_data) if (pdu[0] == ATT_OP_HANDLE_NOTIFY) return; - olen = enc_confirmation(opdu, sizeof(opdu)); + opdu = g_attrib_get_buffer(attrib, &plen); + olen = enc_confirmation(opdu, plen); if (olen > 0) g_attrib_send(attrib, 0, opdu[0], opdu, olen, NULL, NULL, NULL); -- 2.47.3