Received: by 2002:a05:7412:3290:b0:fa:6e18:a558 with SMTP id ev16csp162179rdb; Thu, 25 Jan 2024 11:08:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IGc23LSSDJ+lcgIYkQ7iCcmhtcrZHCsGE6T3+HQ/9vj8hIEjgMkejgWP0OCK2p0ZzaFWD+J X-Received: by 2002:a17:906:fb86:b0:a31:5ee4:6ce9 with SMTP id lr6-20020a170906fb8600b00a315ee46ce9mr30837ejb.98.1706209728142; Thu, 25 Jan 2024 11:08:48 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706209728; cv=pass; d=google.com; s=arc-20160816; b=GFuTv/pn1E1/0rbNAQbx4xc1sCQd4MOkb3Q4F5w19CYlkwO9cLNtKqXDrb6eMIeNPD 5ASxf4aIBlcZziX+pv+nHkj0J0ZHdYgEkt5EoS9giHJzxGjUVo/xGjrWdGyN0LVoVa+T 6/+OadOxSWzAYccQPhWXIuT+baendAZ75FvNuJB00y05E+jpIkbBvbSatmgru8wlpCUd gx9MVQD9zZSgZedM9RDQaAF9KbyFIlHDJEiWPQe4OzpdGbg4SaylFEkgvu/jYVp6+6PB lTpYnV3iLiU0Ejv6JqpWb3goZJ0U78iIg89uABGUhHbcg5uZbgVMJm1A/lhN1JfO12Xr /GsQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:to:from:dkim-signature; bh=meUGDeIcalaM4P8fGbRGXWv7LPQhd0f2PLUelUZtKCc=; fh=4lGQI6056MBa4/oovMyIYaKLn+Wz/24RGvUivMmQP8E=; b=zHNppGacdwvdGrBAMwqSruxZsQHm6cjdjLDcpFCUZHZGBmqjtVXwSypbnDJc65zk1V kKMjNuZjwuFuxfe4uFF+MRLCUOXRj7rXbbDTkzTWu80qt6rvAw+/D5i+37DOgFRDC+XZ 8ReRoPhmfYOtmqYGPNbBs7flpg9rZ5NNJk0w7f/P3hHwxjMong6HDoMOTH/pVhHRIfu5 Ijf1KC7MP1IhNd4GZr0KwNeoRqpkcfeBLgx3M2JHO6mv5t68Rb/UA+xZ5an5K2pMmfmd b8MMnRxIKwu9Z9p7aje9elEqf7rR1cT+UWlcSPZS+4bdwCj84NzHzv+AVYMP2AF0ZUaL sAXw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=myg7jpfg; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-bluetooth+bounces-1382-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-1382-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id l12-20020a170906a40c00b00a30fb91ac94si1158693ejz.63.2024.01.25.11.08.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 11:08:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-1382-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=myg7jpfg; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-bluetooth+bounces-1382-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-1382-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id E3B5F1F23925 for ; Thu, 25 Jan 2024 19:08:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4E3E313540C; Thu, 25 Jan 2024 19:08:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="myg7jpfg" X-Original-To: linux-bluetooth@vger.kernel.org Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5A5A51353F5 for ; Thu, 25 Jan 2024 19:08:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706209700; cv=none; b=Nl6/ewGSaitJEibbNVFBGf9z5YP24oiOumWA83QymURbEY8GF7dYco0GrquzswAiq2R8T0PYWkdXDGa64vod2lvBYqth7fURBopeKp49sDy7Z5hw1L2/zUdrWaA0ZEfeDjmPks98XhhK+tcIgjz+ngyvL5u08j0nBvd8wWZ30q8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706209700; c=relaxed/simple; bh=TR9FeCKfGpogbwWXGekAInfxeqoCMmoY+xr575x32gE=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=eXNoIoT8QECO0B4kz9bhI0R5pMefwrdTc7o8TVGlkbU6jgRpWr2SIHOek3o04rnEKlWPpvH20xSpvQCSGPuOr9/F0ixh1P3sCZTBPpXYk7nXZBQnr4Nbf0qtskSwMXMdzNOG/IkaQC2g6vaev+IlpLcwbtXVRF53CYNYU0KUA/Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=myg7jpfg; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1706209695; bh=TR9FeCKfGpogbwWXGekAInfxeqoCMmoY+xr575x32gE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=myg7jpfgsSeC8eWD9hb/H5AC73/jdYAAhaDkGGpnAJDTXnA/t4Nowad49kK4cX12f dTYq3rgBFkfL7bPOR0y89rG57lzFLkLp+PEmKqrQcV/Qh/DlT4H+zzI5u2HvVyoCny KIjdRWHS9IOy+FJSyhAMw96vgd4YpY7Koo8dFvMe1KP6sPuhCj8Ypx9/c6fSYeAjU9 b8+C7Ix+Ve3q5VseO7de7eCQjBJQsV+F+1HnyCI2R4CJoGhsWNjbsC/5yM/iQ5ncC6 AyDKJeog8Ld7A6dmenrqVIIAKBk0zbft8yR61BMLyQSD+rFcTlLUtYVZ6LOZMc2R2Z r/sNxbN002ItA== Received: from fdanis-XPS-13-9370.. (cola.collaboradmins.com [195.201.22.229]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: fdanis) by madrid.collaboradmins.com (Postfix) with ESMTPSA id ABC003782053 for ; Thu, 25 Jan 2024 19:08:15 +0000 (UTC) From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Danis?= To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ v3 5/5] btgatt-client: Add function to search all primary services Date: Thu, 25 Jan 2024 20:08:05 +0100 Message-Id: <20240125190805.1244787-6-frederic.danis@collabora.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240125190805.1244787-1-frederic.danis@collabora.com> References: <20240125190805.1244787-1-frederic.danis@collabora.com> Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit This is requested to pass PTS GATT/CL/GAD/BV-01-C test. --- tools/btgatt-client.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/tools/btgatt-client.c b/tools/btgatt-client.c index 04fd3ce0f..b47914da3 100644 --- a/tools/btgatt-client.c +++ b/tools/btgatt-client.c @@ -1354,13 +1354,6 @@ static void cmd_set_sign_key(struct client *cli, char *cmd_str) set_sign_key_usage(); } -static void search_service_usage(void) -{ - printf("Usage: search-service \n" - "e.g.:\n" - "\tsearch-service 1800\n"); -} - static void search_service_cb(bool success, uint8_t att_ecode, struct bt_gatt_result *result, void *user_data) @@ -1392,6 +1385,27 @@ static void search_service_cb(bool success, uint8_t att_ecode, PRLOG("\n"); } +static void cmd_search_all_primary_services(struct client *cli, char *cmd_str) +{ + if (!bt_gatt_client_is_ready(cli->gatt)) { + printf("GATT client not initialized\n"); + return; + } + + bt_gatt_discover_all_primary_services(bt_gatt_client_get_att(cli->gatt), + NULL, + search_service_cb, + NULL, + NULL); +} + +static void search_service_usage(void) +{ + printf("Usage: search-service \n" + "e.g.:\n" + "\tsearch-service 1800\n"); +} + static void cmd_search_service(struct client *cli, char *cmd_str) { char *argv[2]; @@ -1536,6 +1550,8 @@ static struct { "\tSet retry on security error by elevating security"}, { "set-sign-key", cmd_set_sign_key, "\tSet signing key for signed write command"}, + { "search-all-primary-services", cmd_search_all_primary_services, + "\tSearch all primary services"}, { "search-service", cmd_search_service, "\tSearch service"}, { "search-characteristics", cmd_search_characteristics, -- 2.34.1