Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1617264ybk; Thu, 21 May 2020 11:01:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzisIp2NruC/21qE0g2u05DdDNL0VwKUeWIOgA4C/wYC3Mqqbx4bBuNKt3iRc9lGs2hfsON X-Received: by 2002:a17:906:1f8b:: with SMTP id t11mr4709529ejr.201.1590084115455; Thu, 21 May 2020 11:01:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590084115; cv=none; d=google.com; s=arc-20160816; b=HAeCde+PINtUn+KNpUAhTla3WgXRhZpGb7w0xonO7WBBekCdqjuJJI/SiUHOgtksTl 2u+WQ0TMXya/EHG6ThXp13erNRsVKOfUy4wlC7L5at34UoCoTvrVojDc8LzwKgt8h5kC EFFHEzDLcIco/5/Q4blXHkYXKawPxPvZ1Nww9pi9kGqm0n+WzjbBrA6O3j5FTfkXRK73 tq6PpzU0fkMKss+iY98TNMR/LNEpW6Rn1W0wgPMlzyRXQ7+hpcSLIx1wvwMIZ6vafNX7 p1JH/mJY71XqR5zUA64fo9alLqKlI1P1aLBzrHIojnLzWZMqE7shnelt9/5hbJJG3r8G 7M4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=MFO+E2oPIKbUN1g/6GJpK5+R9fJDP4WX5hJngZf8lr4=; b=X7ldAvvsQIT4tiCDDpOPVQigh5YN6KJfG53M1hhUGowgUsdCPKQs6iI/sA7v9OwMSe 9HScKOOROu1d49knKOElcjr73tAhRX9Mt3ieooRHbNuxyGhoN/kNHszyUTfGc7x9eEWN KnuD4vviaRCdKbixNuCVZDjelap73YHwSB7EprGrBrJXpHVTAnp8c3FiDHYGCETxhr5M jEeuWTYSinGm1pbvZa4DAmM1YF41183fU+wc4KpRrHNaddLXf5YjUzsXxwpV0AZ8HXV7 guDWtQl/xNB8Iglpb+iKNp2xqc6nUhtB7MRCI0wR2GJt3bJ7O20uKCEKaVtw6pKZh5Dp zeUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=P4TQsLj1; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id re19si3570429ejb.56.2020.05.21.11.01.29; Thu, 21 May 2020 11:01:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=P4TQsLj1; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729183AbgEUSBX (ORCPT + 99 others); Thu, 21 May 2020 14:01:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728888AbgEUSBX (ORCPT ); Thu, 21 May 2020 14:01:23 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3997C061A0E for ; Thu, 21 May 2020 11:01:22 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id a13so3141945pls.8 for ; Thu, 21 May 2020 11:01:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id; bh=MFO+E2oPIKbUN1g/6GJpK5+R9fJDP4WX5hJngZf8lr4=; b=P4TQsLj135jzfjxhtahY1DB3XLGHr3C8lrmyWCh7QkvdL4d++UF0DJr3tzlhHznGId gdPPqX3/K8VFNVJsOVX9uOMfR6J8X2BIDjVdXDDGItkkBJxiBJMIE9O/+bmGUhhhFje9 7YQ7NDW+6DAxS8F2l0f0Bl9exHUtqiZUgLBd0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=MFO+E2oPIKbUN1g/6GJpK5+R9fJDP4WX5hJngZf8lr4=; b=dRe8bb1HC17IEl1VkJ8hwkuzx4/JCU23rLNO0uo5VcUh1icnSrXWZSKlkHLdojz0hz GkenWyL50YBT65tlqNn7LdYT1x6nssyqKLRfACe8Eh3DxrvbVrovyo6sG6p6sHmlrre2 SaU7RC4m8WW4JokHylNOutbFoXrwbY3tamUXtmb7u/J/7qt7Y4BENil1pWhHTVjx8bvU KS/MhlaiNb9EiEd1lec5wGs5huqo8bDtGGuF6+0CX2Txo+NUPQbTqe6nXje4t/Iuaqv0 YGjLSf4efsIjpB1HrB9E0BLRYKaL+MeIuKMessm1xZvO0yQCwR4Vz46Ihdmfh4AmluI3 sXAQ== X-Gm-Message-State: AOAM5328naDDJrTNLIQI9+IJfTpBZOrmDdJKQOiR+qQDAjrdyIp27Z2Z rEMEhfy2ZC9ihOaaKJtB9MGyfBWyQOw= X-Received: by 2002:a17:902:7281:: with SMTP id d1mr11172693pll.78.1590084081233; Thu, 21 May 2020 11:01:21 -0700 (PDT) Received: from localhost.localdomain (c-73-231-41-185.hsd1.ca.comcast.net. [73.231.41.185]) by smtp.googlemail.com with ESMTPSA id h4sm4845975pfo.3.2020.05.21.11.01.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 May 2020 11:01:20 -0700 (PDT) From: Sonny Sasaka To: linux-bluetooth@vger.kernel.org Cc: Eric Caruso Subject: [PATCH v3 1/3] device: Add device type property Date: Thu, 21 May 2020 11:00:59 -0700 Message-Id: <20200521180101.8223-1-sonnysasaka@chromium.org> X-Mailer: git-send-email 2.17.1 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Eric Caruso This allows us to gather information about whether a device supports BR/EDR, BLE, or both. It appears as DBus Property "Types" on the org.bluez.Device1 interface. --- src/device.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/device.c b/src/device.c index 7b0eb256e..2b5a7f2e8 100644 --- a/src/device.c +++ b/src/device.c @@ -745,6 +745,32 @@ static gboolean property_get_address_type(const GDBusPropertyTable *property, return TRUE; } +static gboolean dev_property_get_types(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *data) +{ + struct btd_device *device = data; + const char *type; + + DBusMessageIter array; + + dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, + DBUS_TYPE_BYTE_AS_STRING, &array); + + if (device->bredr) { + type = "bredr"; + dbus_message_iter_append_basic(&array, DBUS_TYPE_STRING, &type); + } + + if (device->le) { + type = "le"; + dbus_message_iter_append_basic(&array, DBUS_TYPE_STRING, &type); + } + + dbus_message_iter_close_container(iter, &array); + + return TRUE; +} + static gboolean dev_property_get_name(const GDBusPropertyTable *property, DBusMessageIter *iter, void *data) { @@ -2759,6 +2785,7 @@ static const GDBusMethodTable device_methods[] = { static const GDBusPropertyTable device_properties[] = { { "Address", "s", dev_property_get_address }, { "AddressType", "s", property_get_address_type }, + { "Types", "as", dev_property_get_types, NULL, NULL }, { "Name", "s", dev_property_get_name, NULL, dev_property_exists_name }, { "Alias", "s", dev_property_get_alias, dev_property_set_alias }, { "Class", "u", dev_property_get_class, NULL, -- 2.17.1