Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp1413616rwo; Wed, 2 Aug 2023 13:45:36 -0700 (PDT) X-Google-Smtp-Source: APBJJlHk4RMkk/wiBk5TRe0kH2gZ7c7hFYxIsNTRMFMpwvxVPOVcWE3FIaLCG1bVChYU/QI5vbqR X-Received: by 2002:a05:6808:2a4e:b0:3a7:4fff:6481 with SMTP id fa14-20020a0568082a4e00b003a74fff6481mr4872541oib.49.1691009135787; Wed, 02 Aug 2023 13:45:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691009135; cv=none; d=google.com; s=arc-20160816; b=veft36sUjUSQGjQCCkcrCKbxVYQ9Ry5c2bidmF1kDcVSwqU1xRCTBa9tUyWiaW2N5+ BCOy83YxFTiXh0CPX6NOhg30VNBoCN/KHlk5E2kmJ2hrWX9t0hZXjRhuoJ+xglJIAJQD b1z1ie/j+jVF14+cq3QnzWqAXqqIaBUpiLh2rTMVUhTOmv2hv0FXp7JG8qm2YAGA3Cqj RWjiqr1ssKBfvY5nhPLqATIkVKYBZ9RDZ3W8HKbc+7VBCG8LlHLeCm61qQGoqy+VhF+j GBnkls8uuivzuEILcjmmTGZSRbnoHGcfGdNnD5sK1WMJu0yl3NAs2eA0Z8rp0uvyYEYa NmTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:to:from:dkim-signature; bh=CpcQF2DQCIMnKy3lACKGfyzR8y138lcXemdIuDv/JJQ=; fh=V2LL5OuZUBGeSu6TXDWykcThOoazTGUpkln19rrO2KM=; b=Ij0UUlalCNbo8fA37Fm106cdclH8DN7weEOQgSA9uWdoLwRB6D/469V3AfNC+lbadq zqsMwhgOQ2j3oIjWOO4rRIMOid2cbauvun9D65dTKe1pNSpQN1eLW44dpJwES7qyqN5b 77ETl/6zzRVRN2oQjYGVVTXSeSR1qdhOyn2yu46MgZwKcg9ggG6i6LGxv5i+8JKUzykb ADVDPJ59G/4aveTW0SaBPLfHhehlWEY92JnnRnoJV4NRSl5nyw74iMLfaxYfYeIBi36h mLAJhyQl+1T2GNXGPo70FYOP3ins2yPNMlH6affVjSOdpuyPaEkH5vOhIi/2nyRasrvm 8Y+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=ds6uIqFh; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a73-20020a63904c000000b0055ae20ada77si8349651pge.591.2023.08.02.13.45.09; Wed, 02 Aug 2023 13:45:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=ds6uIqFh; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229713AbjHBUPt (ORCPT + 99 others); Wed, 2 Aug 2023 16:15:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231561AbjHBUPp (ORCPT ); Wed, 2 Aug 2023 16:15:45 -0400 Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7079A26A1 for ; Wed, 2 Aug 2023 13:15:42 -0700 (PDT) Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-686b91c2744so171215b3a.0 for ; Wed, 02 Aug 2023 13:15:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691007341; x=1691612141; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=CpcQF2DQCIMnKy3lACKGfyzR8y138lcXemdIuDv/JJQ=; b=ds6uIqFhKoY/sbXNMYceE/y3SmFMbMpkYpFFyVt/UmTNMrxhQXS2fQ5MwvAF9/USeQ wrS8xjwSyF1LIyzn0wdPx6Kc4mQJZCa5S2MrnPTjcfDneeHLgkHYXO5K8jVi+VqO8Q/b ZeGZ5K09+xx4bXCv0cd+4UtULk5xCXSfwrnSHh1uomrfn8znwm87TX3V4nGOn6iahI3n Ze11dqP5F+RT+3ygtauOXUvWNDtHcajeN7PxPr+x8RIo2Pp4amcSghMK6w3pVqnAGNan v1Y6abmdUqvF2N+N8RnSoMdrbPiPJGhNH+XxT8QvXFs2nuHYeRoGZjB1KpL7nN109mVE udOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691007341; x=1691612141; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=CpcQF2DQCIMnKy3lACKGfyzR8y138lcXemdIuDv/JJQ=; b=fFVpG+dcuBChTtf98TfEJLHFS7nB5AadJXLVdPwtAJx8uXOuKjDRQOfqnmig/0TQ01 Pr5XNEBLxzT5QG+8BTtSywu/cGmznnc7zE2eZNvh68TZIECSLe6vKnXjmLFSAium5uPp RnywpbiWrsL4If3AIqSdbiaHWDTjEgxFz82zotvBVzALM7lA7Mb3tiG7TbsTLoBcgBIk g270GplzD9Mmt8jS488vaxZHMUv2/UmkjNy/ZxGBms4DnvNFl8QG2E46hUNsFGqfnb1P PammZpb8SzYtsNGOwZATYET5pwDqS7M3Ky+PXLQ9mKDdMpJJz2RYors8nbCEDDewSXcb lQTg== X-Gm-Message-State: ABy/qLaGqq0WO4GrVyjVowE8D/KLye89m/a/Olyz3T04rDWIU8ptEuWs zWptV+xBRdaHEMGkzVCDiAdt/yQFswE= X-Received: by 2002:a17:902:968e:b0:1b1:9218:6bf3 with SMTP id n14-20020a170902968e00b001b192186bf3mr14924521plp.37.1691007340901; Wed, 02 Aug 2023 13:15:40 -0700 (PDT) Received: from lvondent-mobl4.. (c-71-236-201-58.hsd1.or.comcast.net. [71.236.201.58]) by smtp.gmail.com with ESMTPSA id u9-20020a17090341c900b001b9da8b4eb7sm12800586ple.35.2023.08.02.13.15.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 13:15:39 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [BlueZ RFC] profile: Add probe_on_discover flag Date: Wed, 2 Aug 2023 13:15:38 -0700 Message-ID: <20230802201538.584029-1-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz This adds probe_on_discover flag which indicates if profile needs to be probed when the remote_uuid is discovered and changes device logic to attempt to probe driver when a new UUID is discovered and probe_on_discover is set. --- src/device.c | 22 +++++++++++++++++----- src/profile.h | 5 +++++ 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/device.c b/src/device.c index b43ced8b5c91..19ae03f7d98a 100644 --- a/src/device.c +++ b/src/device.c @@ -2156,7 +2156,7 @@ done: void device_add_eir_uuids(struct btd_device *dev, GSList *uuids) { GSList *l; - bool added = false; + GSList *added = NULL; if (dev->bredr_state.svc_resolved || dev->le_state.svc_resolved) return; @@ -2165,13 +2165,11 @@ void device_add_eir_uuids(struct btd_device *dev, GSList *uuids) const char *str = l->data; if (g_slist_find_custom(dev->eir_uuids, str, bt_uuid_strcmp)) continue; - added = true; + added = g_slist_append(added, (void *)str); dev->eir_uuids = g_slist_append(dev->eir_uuids, g_strdup(str)); } - if (added) - g_dbus_emit_property_changed(dbus_conn, dev->path, - DEVICE_INTERFACE, "UUIDs"); + device_probe_profiles(dev, added); } static void add_manufacturer_data(void *data, void *user_data) @@ -2201,6 +2199,7 @@ static void add_service_data(void *data, void *user_data) struct eir_sd *sd = data; struct btd_device *dev = user_data; bt_uuid_t uuid; + GSList *l; if (bt_string_to_uuid(&uuid, sd->uuid) < 0) return; @@ -2208,6 +2207,10 @@ static void add_service_data(void *data, void *user_data) if (!bt_ad_add_service_data(dev->ad, &uuid, sd->data, sd->data_len)) return; + l = g_slist_append(NULL, sd->uuid); + device_add_eir_uuids(dev, l); + g_slist_free(l); + g_dbus_emit_property_changed(dbus_conn, dev->path, DEVICE_INTERFACE, "ServiceData"); } @@ -3930,6 +3933,12 @@ static bool device_match_profile(struct btd_device *device, if (profile->remote_uuid == NULL) return false; + /* Don't match if device was just discovered (not connected) and the + * profile don't have probe_on_discover flag set. + */ + if (!btd_device_is_connected(device) && !profile->probe_on_discover) + return false; + if (g_slist_find_custom(uuids, profile->remote_uuid, bt_uuid_strcmp) == NULL) return false; @@ -4884,6 +4893,9 @@ void device_probe_profiles(struct btd_device *device, GSList *uuids) struct probe_data d = { device, uuids }; char addr[18]; + if (!uuids) + return; + ba2str(&device->bdaddr, addr); if (device->blocked) { diff --git a/src/profile.h b/src/profile.h index 6871f2f0d7d8..cfc50058812d 100644 --- a/src/profile.h +++ b/src/profile.h @@ -33,6 +33,11 @@ struct btd_profile { */ bool experimental; + /* Indicates the profile needs to be probed when the remote_uuid is + * discovered. + */ + bool probe_on_discover; + int (*device_probe) (struct btd_service *service); void (*device_remove) (struct btd_service *service); -- 2.41.0