From 9a0689a77082a4edba1397f7bf22a2d7b6c96e5e Mon Sep 17 00:00:00 2001 From: "matthias.ringwald@gmail.com" Date: Sun, 11 May 2014 20:52:34 +0000 Subject: [PATCH] don't reset gatt_client context every command --- src/daemon.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/daemon.c b/src/daemon.c index 92e36f8b2..236dabe89 100644 --- a/src/daemon.c +++ b/src/daemon.c @@ -166,10 +166,11 @@ typedef struct gatt_client_helper { static gatt_client_t * daemon_provide_gatt_client_context_for_handle(uint16_t handle){ gatt_client_t *context; context = get_gatt_client_context_for_handle(handle); - if (!context){ - context = (gatt_client_t*)malloc(sizeof(gatt_client_t) + sizeof(gatt_client_helper_t) + ATT_MAX_LONG_ATTRIBUTE_SIZE); - } + if (context) return context; + + context = (gatt_client_t*)malloc(sizeof(gatt_client_t) + sizeof(gatt_client_helper_t) + ATT_MAX_LONG_ATTRIBUTE_SIZE); if (!context) return NULL; + gatt_client_start(context, handle); return context; } @@ -599,7 +600,6 @@ static int btstack_command_handler(connection_t *connection, uint8_t *packet, ui daemon_gatt_deserialize_characteristic(packet, 5, &characteristic); data_length = READ_BT_16(packet, 5 + CHARACTERISTIC_LENGTH); data = daemon_get_data_buffer(context); - hci_dump_log("GATT_WRITE_VALUE_OF_CHARACTERISTIC handle %x, len %u\n", characteristic.value_handle, data_length); memcpy(data, &packet[7 + CHARACTERISTIC_LENGTH], data_length); gatt_client_write_value_of_characteristic(context, characteristic.value_handle, data_length, data); break;