From 66881873e32ca3653644bb0453eb8545575506ea Mon Sep 17 00:00:00 2001 From: Milanka Ringwald Date: Tue, 15 Jun 2021 17:11:32 +0200 Subject: [PATCH] gatt-service/device_information_service_client: prevent calling query twice --- .../gatt-service/device_information_service_client.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/ble/gatt-service/device_information_service_client.c b/src/ble/gatt-service/device_information_service_client.c index c9e38410f..0df9423d9 100644 --- a/src/ble/gatt-service/device_information_service_client.c +++ b/src/ble/gatt-service/device_information_service_client.c @@ -456,15 +456,18 @@ static void handle_gatt_client_event(uint8_t packet_type, uint16_t channel, uint uint8_t device_information_service_client_query(hci_con_handle_t con_handle, btstack_packet_handler_t packet_handler){ btstack_assert(packet_handler != NULL); - device_information_service_client_t * client = device_information_service_client_get_client(); + device_information_service_client_t * client = device_information_service_get_client_for_con_handle(con_handle); - if (client->state != DEVICE_INFORMATION_SERVICE_CLIENT_STATE_IDLE){ - return GATT_CLIENT_IN_WRONG_STATE; - } + if (client != NULL){ + return ERROR_CODE_COMMAND_DISALLOWED; + } + client = device_information_service_client_get_client(); + client->con_handle = con_handle; client->client_handler = packet_handler; client->state = DEVICE_INFORMATION_SERVICE_CLIENT_STATE_W2_QUERY_SERVICE; + device_information_service_run_for_client(client); return ERROR_CODE_SUCCESS; }